code stringlengths 114 1.05M | path stringlengths 3 312 | quality_prob float64 0.5 0.99 | learning_prob float64 0.2 1 | filename stringlengths 3 168 | kind stringclasses 1
value |
|---|---|---|---|---|---|
package pac
import (
"bytes"
"gopkg.in/jcmturner/gokrb5.v6/iana/chksumtype"
"gopkg.in/jcmturner/rpc.v1/mstypes"
)
/*
https://msdn.microsoft.com/en-us/library/cc237955.aspx
The Key Usage Value MUST be KERB_NON_KERB_CKSUM_SALT (17) [MS-KILE] (section 3.1.5.9).
Server Signature (SignatureType = 0x00000006)
https:/... | pac/signature_data.go | 0.719285 | 0.481576 | signature_data.go | starcoder |
package core
import (
"fmt"
"reflect"
)
// Convert and apply args to arbitrary function fn
func Cumin(fn interface{}, args []interface{}) ([]interface{}, error) {
reciever := reflect.TypeOf(fn)
var ret []interface{}
if reciever.Kind() != reflect.Func {
return ret, fmt.Errorf("Handler is not a function!")
}
... | cumin.go | 0.625667 | 0.512815 | cumin.go | starcoder |
package query
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"sort"
"strings"
"github.com/Jeffail/gabs/v2"
jsonschema "github.com/xeipuuv/gojsonschema"
)
var _ = registerSimpleMethod(
NewMethodSpec(
"all",
"Checks each element of an array against a query and returns true if all elements passed. An erro... | internal/bloblang/query/methods_structured.go | 0.625438 | 0.446253 | methods_structured.go | starcoder |
package buffer
import (
"sync/atomic"
"time"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
)
//------------------------------------------------------------------------------
func init(... | lib/buffer/none.go | 0.608827 | 0.477371 | none.go | starcoder |
package output
import (
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/internal/service/redis"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/output/writer"
"github.com/Jeffail/benthos/v3/lib/types"
)
//-------... | lib/output/redis_streams.go | 0.669853 | 0.430506 | redis_streams.go | starcoder |
package geoindex
import (
"fmt"
)
type CountIndex struct {
index *geoIndex
currentPosition map[string]Point
}
type CountPoint struct {
*GeoPoint
Count interface{}
}
func (p *CountPoint) String() string {
return fmt.Sprintf("%f %f %d", p.Lat(), p.Lon(), p.Count)
}
// NewCountIndex creates an index w... | hotelReservation/vendor/github.com/hailocab/go-geoindex/count-index.go | 0.816443 | 0.589332 | count-index.go | starcoder |
package analysis
import (
"go/ast"
"go/types"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/inspect"
"golang.org/x/tools/go/ast/inspector"
"golang.org/x/tools/go/types/typeutil"
)
// funcLookup allows the performant lookup of function and method declarations in the current package by ... | analysis/function_lookup.go | 0.681515 | 0.44077 | function_lookup.go | starcoder |
// Package stats provides support for recording telemetry statistics.
// It acts as a coordination point between things that want to record stats,
// and things that want to aggregate and report stats.
package stats
import (
"context"
"github.com/fhs/acme-lsp/internal/golang_org_x_tools/telemetry/unit"
)
// Int64... | internal/golang_org_x_tools/telemetry/stats/stats.go | 0.827515 | 0.537406 | stats.go | starcoder |
package rxgo
import "context"
type (
operatorOptions struct {
stop func()
resetIterable func(Iterable)
}
// Comparator defines a func that returns an int:
// - 0 if two elements are equals
// - A negative value if the first argument is less than the second
// - A positive value if the first argume... | types.go | 0.665954 | 0.42054 | types.go | starcoder |
package flattree
import "errors"
// Range type is an inclusive tree range that is in the form of [start, finish]
type Range []uint64
// FullRoots returns a list of all the full roots (subtrees where all nodes have either 2 or 0 children) `<` index.
// For example `fullRoots(8)` returns `[3]` since the subtree rooted... | flattree.go | 0.872266 | 0.719728 | flattree.go | starcoder |
package solver
import (
"bufio"
"fmt"
"io"
"strconv"
"strings"
)
// ParseSlice parse a slice of slice of lits and returns the equivalent problem.
// The argument is supposed to be a well-formed CNF.
func ParseSlice(cnf [][]int) *Problem {
var pb Problem
pb.parseSlice(cnf)
return &pb
}
// ParseSliceNb parse a... | solver/parser.go | 0.650578 | 0.478285 | parser.go | starcoder |
package geometry
import (
"github.com/schidstorm/engine/gls"
"github.com/schidstorm/engine/math32"
"math"
)
// NewTorus creates a torus geometry with the specified revolution radius, tube radius,
// number of radial segments, number of tubular segments, and arc length angle in radians.
// TODO instead of 'arc' ha... | geometry/torus.go | 0.51562 | 0.492981 | torus.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// WorkbookChartLegend
type WorkbookChartLegend struct {
Entity
// Represents the formatting of a chart legend, which includes fill and font formatting. R... | models/workbook_chart_legend.go | 0.752468 | 0.473292 | workbook_chart_legend.go | starcoder |
// This package implements a basic LISP interpretor for embedding in a go program for scripting.
// This file implements data elements.
package golisp
import (
"errors"
"fmt"
"strings"
"unsafe"
)
const (
ConsCellType = iota
AlistType
AlistCellType
IntegerType
FloatType
BooleanType
StringType
SymbolType
... | data.go | 0.763484 | 0.524029 | data.go | starcoder |
package drawing
// Liner receive segment definition
type Liner interface {
// LineTo Draw a line from the current position to the point (x, y)
LineTo(x, y float64)
}
// Flattener receive segment definition
type Flattener interface {
// MoveTo Start a New line from the point (x, y)
MoveTo(x, y float64)
// LineTo ... | vendor/github.com/wcharczuk/go-chart/v2/drawing/flattener.go | 0.633864 | 0.609059 | flattener.go | starcoder |
package nets
import (
"fmt"
"math"
"math/rand"
"time"
"github.com/qvantel/nerd/api/types"
"github.com/qvantel/nerd/internal/config"
"github.com/qvantel/nerd/internal/logger"
"github.com/qvantel/nerd/internal/series/pointstores"
)
// Chromosome represents a neural network configuration
type Chromosome struct ... | internal/nets/evolution.go | 0.716615 | 0.451145 | evolution.go | starcoder |
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
)
type GraphVertex interface {
fmt.Stringer
}
type SimpleVertex string
func (v SimpleVertex) String() string {
return string(v)
}
type TagVertex Tag
func (v TagVertex) String() string {
return fmt.Sprintf("tag_%d", int(v))
}
type NodeSourceVertex Node
... | deps/vbmap/graph.go | 0.663669 | 0.519338 | graph.go | starcoder |
package main
import ()
/* Objectives
- Playing with values
- Bytes
- Integers
- Strings
- Booleans
- Arrays
- Maps
- Data type and Storage
*/
/* Values
- literal - 1, true, "text"
- computed - 1 + 4
*/
/* Everything is a Number
- Everything typed into a computer is a character
- Every character is represen... | series_4/go_004_values_bits_numbers.go | 0.628521 | 0.427337 | go_004_values_bits_numbers.go | starcoder |
package iter
import "math"
// FloatRange represets a range of float64
type FloatRange struct {
Start, End, Step float64
}
// FloatIterator iterates over a FloatRange
type FloatIterator struct {
*IdxIterator
FloatRange
}
// Iter creates a new FloatIterator from a FloatRange
func (r FloatRange) Iter() (*FloatItera... | iter/float.go | 0.843927 | 0.574693 | float.go | starcoder |
package autobatch
import (
ds "github.com/ipfs/go-datastore"
dsq "github.com/ipfs/go-datastore/query"
)
// Datastore implements a go-datatsore.
type Datastore struct {
child ds.Batching
// TODO: discuss making ds.Batch implement the full ds.Datastore interface
buffer map[ds.Key][]byte
maxBufferEntrie... | autobatch/autobatch.go | 0.572962 | 0.470797 | autobatch.go | starcoder |
package cqlnls
// Node is an element block that contains the data and has pointers to other
// Nodes that it's connected
type Node struct {
Value interface{}
Next, Previous *Node
}
// CircularLinkedList provides the interface for Nodes to connect
// add and remove nodes from the structure
type CircularLink... | cqlnls.go | 0.734786 | 0.408749 | cqlnls.go | starcoder |
package common
import (
"encoding/json"
"regexp"
"strings"
)
// Statistics provide a type and method receivers for marshalling and
// un-marshalling statistics, as JSON, for components across the network.
type Statistics map[string]interface{}
// NewStatistics return a new instance of stat structure initialized ... | secondary/common/stats.go | 0.692954 | 0.400691 | stats.go | starcoder |
package ring
import (
"math"
"math/big"
)
// NewFloat creates a new big.Float element with "logPrecision" bits of precision
func NewFloat(x float64, logPrecision int) (y *big.Float) {
y = new(big.Float)
y.SetPrec(uint(logPrecision)) // decimal precision
y.SetFloat64(x)
return
}
// Cos implements the arbitrary ... | ring/complex128.go | 0.760428 | 0.444866 | complex128.go | starcoder |
// Package compare provides functions for comparing types by value.
package compare
import (
"reflect"
"strconv"
)
// Comparable defines the interface for a comparable type.
type Comparable interface {
Int64() int64
}
func getValues(a, b interface{}) (int64, int64) {
var (
left, right int64
av = re... | main.go | 0.850313 | 0.561996 | main.go | starcoder |
package jgl
import (
// "fmt"
"math"
"github.com/Stymphalian/go.math/lmath"
"github.com/go-gl/gl/v3.3-compatibility/gl"
)
type Sphere struct {
Pos lmath.Vec3
Radius float64
LightFlag bool
Mat Material
radius_vec lmath.Vec3
vertices []lmath.Vec3
}
func NewSphere(radius float64) *Sphere {
out ... | jgl/sphere.go | 0.636579 | 0.48377 | sphere.go | starcoder |
package types
// CapabilityStore defines an ephemeral in-memory object capability store.
type CapabilityStore struct {
revMemStore map[string]*Capability
fwdMemStore map[string]string
}
func NewCapabilityStore() CapabilityStore {
return CapabilityStore{
revMemStore: make(map[string]*Capability),
fwdMemStore: m... | x/capability/types/store.go | 0.81309 | 0.556159 | store.go | starcoder |
package sort
import "math"
/* CountingSort
suppose all elements in an array are in a relative small range 0~k, then we can use counting sort to sort the array in O(n+k)
steps:
1. define counting array[k+1] : ca[k+1] example: [0, 0, 0]
2. scan all elements in input array, set: ca[input[i]]++ example: [1, ... | Algorithm-go/sort/linearsort.go | 0.524151 | 0.569134 | linearsort.go | starcoder |
package local_days
import (
"fmt"
"log"
"time"
)
// NewTimeZoneBasedLocalTimeConverter returns a ToLocalTimeConverter that internally uses the timezone data from the timezone with the given zoneName (e.g. "Europe/Berlin"). It requires the tzdata to be available on the system and will panic if this is not the case.... | local_days/local_days.go | 0.83025 | 0.648146 | local_days.go | starcoder |
package main
import (
"errors"
"math"
"math/rand"
blt "bearlibterminal"
)
const (
// Values to catch errors.
WrongIndexValue = -1
)
func RoundFloatToInt(x float64) int {
/* Function RoundFloatToInt takes one float64 number,
rounds it to nearest 1.0, then returns it as a integer. */
return int(math.Round... | utilities_math.go | 0.695648 | 0.422922 | utilities_math.go | starcoder |
package types
import (
"bytes"
"fmt"
"sort"
"github.com/spacemeshos/ed25519"
"github.com/spacemeshos/go-spacemesh/codec"
"github.com/spacemeshos/go-spacemesh/log"
"github.com/spacemeshos/go-spacemesh/signing"
)
const (
// ProposalIDSize in bytes.
// FIXME(dshulyak) why do we cast to hash32 when returning b... | common/types/proposal.go | 0.555918 | 0.414543 | proposal.go | starcoder |
package goment
import (
"math"
)
// Get is a string getter using the supplied units. Returns 0 if unsupported property.
func (g *Goment) Get(units string) int {
switch units {
case "y", "year", "years":
return g.Year()
case "M", "month", "months":
return g.Month()
case "D", "date", "dates":
return g.Date()... | get_set.go | 0.834373 | 0.569583 | get_set.go | starcoder |
package mincut
import (
"math/rand"
)
// Graph represents a graph, where map[head]map[tail]edge_count
type Graph map[int]map[int]int
// Edge represents an edge between vertex a and vertex b.
type Edge struct{ a, b int }
// WithEdges first converts the slice of Edges into Graph, and call WithGraph with it.
func Wit... | mincut/mincut.go | 0.730001 | 0.480418 | mincut.go | starcoder |
package should
import "github.com/smartystreets/assertions"
var (
AlmostEqual = assertions.ShouldAlmostEqual
BeBetween = assertions.ShouldBeBetween
BeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual
BeBlank = assertions.ShouldBeBlank
BeChronological = asserti... | vendor/github.com/smartystreets/assertions/should/should.go | 0.632276 | 0.609582 | should.go | starcoder |
package iso20022
// Set of elements used to provide information specific to the individual direct debit transaction(s) included in the message.
type DirectDebitTransactionInformation9 struct {
// Set of elements used to reference a payment instruction.
PaymentIdentification *PaymentIdentification1 `xml:"PmtId"`
/... | DirectDebitTransactionInformation9.go | 0.767429 | 0.558026 | DirectDebitTransactionInformation9.go | starcoder |
package continuous
import (
gsl "github.com/jtejido/ggsl"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Assymetric Laplace distribution
// https://en.wikipedia.org/wiki/Asymmetric_Laplace_distribution
type AssymetricLaplace struct {
baseContinuousWithSource
location, scale, ... | dist/continuous/assymetric_laplace.go | 0.775987 | 0.474692 | assymetric_laplace.go | starcoder |
package migrator
import (
"bytes"
"database/sql"
"fmt"
"math"
"reflect"
)
// BatchedInsert takes an array of SQL data rows and creates a series of
// batched inserts to insert the data into an existing sql.Tx (transaction)
// object.
func BatchedInsert(tx *sql.Tx, table string, data []SQLUntypedRow, size int, pa... | batched_queries.go | 0.624408 | 0.510802 | batched_queries.go | starcoder |
package xxhash
const (
prime32x1 uint32 = 2654435761
prime32x2 uint32 = 2246822519
prime32x3 uint32 = 3266489917
prime32x4 uint32 = 668265263
prime32x5 uint32 = 374761393
prime64x1 uint64 = 11400714785074694791
prime64x2 uint64 = 14029467366897019727
prime64x3 uint64 = 1609587929392839161
prime64... | vendor/github.com/elastic/beats/vendor/github.com/OneOfOne/xxhash/xxhash.go | 0.659515 | 0.424889 | xxhash.go | starcoder |
package testdata
import (
"errors"
"fmt"
"io"
)
func HelloWorld() string {
_ = len("hello")
return "Hello, World!"
} // total complexity = 0
func SimpleCond(n int) string { // want "cognitive complexity 1 of func SimpleCond is high \\(> 0\\)"
if n == 100 { // +1
return "a hundred"
}
return "others"
} // t... | testdata/src/a/a.go | 0.744192 | 0.483039 | a.go | starcoder |
package timing
import (
"fmt"
"time"
)
// Span is a pair of times, representing the start and end of a process.
type Span struct {
// Start is the start time of the timespan.
Start time.Time `json:"start,omitempty"`
// End is the end time of the timespan.
End time.Time `json:"end,omitempty"`
}
// SpanFromInst... | internal/timing/span.go | 0.829181 | 0.504394 | span.go | starcoder |
package metrics_metadata
// Metadata for an individual result of the metrics metadata query
type Metric struct {
// Name of the metric that has the retrieved metadata
Name string `json:"name,omitempty"`
// Description of the metric that has the retrieved metadata. You can use up to 1024 UTF-8 characters.
Descripti... | metrics_metadata/model_metric.go | 0.877451 | 0.462898 | model_metric.go | starcoder |
package zgeo
import (
"image"
"math"
)
type Rect struct {
Pos Pos `json:"pos"`
Size Size `json:"size"`
}
func RectMake(x0, y0, x1, y1 float64) Rect {
r := Rect{}
r.Pos.X = x0
r.Pos.Y = y0
r.Size.W = x1 - x0
r.Size.H = y1 - y0
return r
}
func RectFromXYWH(x, y, w, h float64) Rect {
return Rect{Pos{x, y}... | zgeo/rect.go | 0.79158 | 0.579579 | rect.go | starcoder |
package lexing
import (
"sort"
"strings"
"github.com/efritz/gostgres/internal/syntax/tokens"
)
type tokenSequenceReplacement struct {
pattern []tokens.TokenType
replacement tokens.TokenType
}
var tokenSequenceReplacements = []tokenSequenceReplacement{
{[]tokens.TokenType{tokens.TokenTypeNot, tokens.TokenT... | internal/syntax/lexing/lex.go | 0.599251 | 0.520679 | lex.go | starcoder |
package api
import (
"net/url"
"strconv"
"github.com/nexucis/grafana-go-client/api/types"
"github.com/nexucis/grafana-go-client/grafanahttp"
)
type QueryParamAnnotation struct {
grafanahttp.QueryInterface
// epoch datetime in milliseconds. Optional.
From int64
// epoch datetime in milliseconds. Optional.
T... | api/query.go | 0.741861 | 0.490053 | query.go | starcoder |
package layer
import tf "github.com/galeone/tensorflow/tensorflow/go"
type LNormalization struct {
axis float64
dtype DataType
inputs []Layer
mean interface{}
name string
shape tf.Shape
trainable bool
variance interface{}
layerWeights []*tf.Tensor
}
func No... | layer/Normalization.go | 0.752468 | 0.412589 | Normalization.go | starcoder |
package definitions
type (
// System is the main node, obiously
System struct {
// SystemType may be Solitary or Multiple
SystemType string `valid:"alpha,lowercase,in(solitary|multiple)"`
NumberOfStars int `valid:"numeric"`
// CompanionOrbits lists the number of Orbits
CompanionOrbits OrbitData
// ... | src/definitions/system.go | 0.737631 | 0.634925 | system.go | starcoder |
package parser
import (
"fmt"
"github.com/authzed/spicedb/pkg/schemadsl/dslshape"
"github.com/authzed/spicedb/pkg/schemadsl/input"
"github.com/authzed/spicedb/pkg/schemadsl/lexer"
)
// Parse parses the given Schema DSL source into a parse tree.
func Parse(builder NodeBuilder, source input.InputSource, input stri... | pkg/schemadsl/parser/parser.go | 0.743634 | 0.547948 | parser.go | starcoder |
package v1alpha1
import (
v1alpha1 "github.com/openebs/maya/pkg/apis/openebs.io/kubeassert/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// KubeAssertLister helps list KubeAsserts.
type KubeAssertLister interface {
// List lists all KubeAsserts ... | pkg/client/generated/openebs.io/kubeassert/v1alpha1/lister/kubeassert/v1alpha1/kubeassert.go | 0.65368 | 0.429908 | kubeassert.go | starcoder |
package multiplication
import (
"math"
"strconv"
)
// Karatsuba returns the product of a and b, which should be positive integers
// represented as strings (e.g. 123 as "123").
func Karatsuba(a string, b string) string {
evenPad(&a, &b)
a = padToPowerOfTwo(a)
b = padToPowerOfTwo(b)
return unpad(karatsuba(a, b))... | multiplication/multiplication.go | 0.813868 | 0.519156 | multiplication.go | starcoder |
package parseip4
import (
"fmt"
)
// Octets represents all 4 octets of an address, in as single unsigned integer.
// To produce a sensible Octets value, see OctsList.Pack().
type Octets uint32
// OctsList is a (presumed) len()=4 list of 8-bit unsigned integer values, or
// octets.
type OctsList []uint8
// Addr rep... | parseip4/parseip4.go | 0.756358 | 0.419648 | parseip4.go | starcoder |
package telegraf
import (
"fmt"
"strconv"
"strings"
"time"
)
var (
// Escapes the various parts of the influxdb line protocal
measurementEscaper = strings.NewReplacer(`,`, `\,`, ` `, `\ `)
keyEscaper = strings.NewReplacer(`,`, `\,`, ` `, `\ `, `=`, `\=`)
tagValueEscaper = keyEscaper
)
// Measureme... | measurement.go | 0.840979 | 0.524456 | measurement.go | starcoder |
package graph
// Vertex represents a single node in a graph.
type Vertex struct {
// Value in our implementation is just an integer for readability
Value int
// Graph allows us to make sure the vertices are in the same graph
Graph *Graph
// Neighbors stores edges between two vertices
Neighbors []*Vertex
}
// Ge... | data-structures/graph/graph.go | 0.877306 | 0.745028 | graph.go | starcoder |
package gofa
// Ephemeride
/*
Epv00 Earth position and velocity, heliocentric and barycentric, with
respect to the Barycentric Celestial Reference System.
Given:
date1,date2 float64 TDB date (Note 1)
Returned:
pvh [2][3]float64 heliocentric Earth position/velocity
pvb [2][3]f... | ephem.go | 0.765681 | 0.646899 | ephem.go | starcoder |
package pkg
import "fmt"
type Fraction = float64
type Weight = float64
type Probability = float64
// Distribution describes a distribution of values.
type Distribution interface {
GetValue() DistributionValues
IsSingleValue() bool
}
// DistributionValues describe a set of fraction over weight.
// For example, Dis... | pkg/distribution.go | 0.820757 | 0.444324 | distribution.go | starcoder |
package internal
import (
"sort"
)
// A kd-Tree with k=3 dimensions and payload.
// Inspired by https://en.wikipedia.org/wiki/K-d_tree
// Pointerless idea came up by itself ;)
type KDTree3P []Point3DPayload
// Builds a pointerless k-dimensional tree with k=3 from the points by resorting the array.
// Function ... | internal/kdtree3p.go | 0.622115 | 0.493775 | kdtree3p.go | starcoder |
package main
import (
"crypto"
"crypto/ecdsa"
"crypto/elliptic"
"encoding/asn1"
"errors"
"fmt"
"log"
"math/big"
"github.com/miekg/pkcs11"
)
var stringToCurve = map[string]*elliptic.CurveParams{
elliptic.P224().Params().Name: elliptic.P224().Params(),
elliptic.P256().Params().Name: elliptic.P256().Params()... | scripts/letsencrypt/boulder/cmd/gen-key/ecdsa.go | 0.554109 | 0.450239 | ecdsa.go | starcoder |
package la
import "github.com/cpmech/gosl/chk"
// --------------------------------------------------------------------------------------------------
// matrix-matrix ------------------------------------------------------------------------------------
// ---------------------------------------------------------------... | la/sparse_blas.go | 0.747524 | 0.47926 | sparse_blas.go | starcoder |
package util
import (
"math/rand"
)
const (
maxLevel = 16 // Should be enough for 2^16 elements
probability = 0.25 // It's the best practice value (Based on Time and Space)
// Higher level, smaller probability
// Just modify the probability factor P to reduce additional space
)
type slNode struct {
score ... | warekv/util/skiplist.go | 0.642208 | 0.440289 | skiplist.go | starcoder |
package tree
import (
"context"
"github.com/itzamna314/battlesnake/game"
)
// expandWorker listens to the tree's expand channel
// It checks each next node to see if its our new best, and
// adds all of its children to the weight channel
func (t *Tree) expandWorker(ctx context.Context) {
for {
select {
case <... | tree/expand.go | 0.541166 | 0.41745 | expand.go | starcoder |
package html
import (
"strings"
"github.com/golangee/dom"
gt "github.com/golangee/gotrino"
)
func Div(e ...gt.Renderable) gt.Node {
return gt.Element("div", e...)
}
func IFrame(e ...gt.Renderable) gt.Node {
return gt.Element("iframe", e...)
}
func Hr(e ...gt.Renderable) gt.Node {
return gt.Element("hr", e..... | html.go | 0.578924 | 0.415136 | html.go | starcoder |
package fauxgl
import "math"
type Shader interface {
Vertex(Vertex) Vertex
Fragment(Vertex) Color
}
// SolidColorShader renders with a single, solid color.
type SolidColorShader struct {
Matrix Matrix
Color Color
}
func NewSolidColorShader(matrix Matrix, color Color) *SolidColorShader {
return &SolidColorShad... | shader.go | 0.888837 | 0.485356 | shader.go | starcoder |
package geography
import (
"database/sql/driver"
"encoding/binary"
"errors"
"strconv"
"github.com/go-courier/geography/encoding/mvt"
"github.com/go-courier/geography/encoding/wkb"
"github.com/go-courier/geography/encoding/wkt"
)
type MultiPolygon []Polygon
func (mp MultiPolygon) ToGeom() Geom {
return mp
}
... | geom_multi_polygon.go | 0.630002 | 0.402157 | geom_multi_polygon.go | starcoder |
package ioutil
/*
// A Path is a slice of names.
type Path []string
// Parent returns the parent path segments. The parent of the empty element is nil.
func (p Path) Parent() Path {
if len(p) == 0 {
return nil
}
return p[0 : len(p)-1]
}
// IsEmpty returns true, if no path segments are present
func (p Path) IsE... | path.go | 0.816882 | 0.464051 | path.go | starcoder |
package image
import (
"bytes"
"fmt"
"github.com/google/gapid/core/data/endian"
"github.com/google/gapid/core/math/sint"
"github.com/google/gapid/core/os/device"
)
type rgbaF32 struct {
r, g, b, a float32
}
// resizeRGBA_F32 returns a RGBA_F32 image resized from srcW x srcH to dstW x dstH.
// The algorithm u... | core/image/rgba_f32.go | 0.692226 | 0.471345 | rgba_f32.go | starcoder |
package pointers
import (
"sync/atomic"
"unsafe"
)
// - MARK: Atomics section.
// CASSliceSlot is a function that performs a CAS operation
// on a given slice slot by performing pointer arithmitic
// to find slot address. `addr` is a pointer to slice,
// `data` is a pointer to old value to be compared,
// `target`... | pointers/pointers.go | 0.739799 | 0.562477 | pointers.go | starcoder |
package main
import (
"regexp"
"strconv"
"strings"
)
const armyRegex = `^(.*):$`
const groupRegex = `^(\d+) units each with (\d+) hit points (?:\((.*)\) )?with an attack that does (\d+) (\w+) damage at initiative (\d+)$`
func atoi(str string) int {
i, err := strconv.Atoi(str)
if err != nil {
panic(err)
}
re... | 2018/day24/old/data.go | 0.722821 | 0.654305 | data.go | starcoder |
package fp
// ExistsIntPtr checks if given item exists in the list
func ExistsIntPtr(num *int, list []*int) bool {
for _, v := range list {
if v == num {
return true
}
}
return false
}
// ExistsInt64Ptr checks if given item exists in the list
func ExistsInt64Ptr(num *int64, list []*int64) bool {
for _, v :... | fp/existsptr.go | 0.527073 | 0.400779 | existsptr.go | starcoder |
package neuralNetwork
import (
"fmt"
"math"
"gonum.org/v1/gonum/mat"
)
type activationStruct struct{}
// ActivationFunctions WIP
type ActivationFunctions interface {
Func(z, h *mat.Dense)
Grad(z, h, grad *mat.Dense)
}
type identityActivation struct{ activationStruct }
func (identityActivation) Func(z, h *mat.... | neural_network/activation.go | 0.705278 | 0.500732 | activation.go | starcoder |
package map180
import (
"bytes"
"fmt"
)
const (
svgPointQuery = `with p as (
select st_transScale(st_transform(st_setsrid(st_makepoint($1, $2), 4326), 3857), $3, $4, $5, $6) as pt
)
select round(ST_X(pt)), round(ST_Y(pt)*-1) from p`
)
type Marker struct {
longitude, latitude float64
drawSVG ... | vendor/github.com/GeoNet/kit/map180/marker.go | 0.688468 | 0.416559 | marker.go | starcoder |
package aliensim
import (
"bufio"
"fmt"
"io"
"strings"
)
// WorldMap contains all of the data structures relevant to mapping out our
// simulated world.
type WorldMap struct {
cityNames []string // The names of the cities in the order read from the input.
cities map[string]*City // A map of the c... | pkg/aliensim/worldmap.go | 0.589126 | 0.471588 | worldmap.go | starcoder |
package rel
type FunctionNode struct {
Expressions []Visitable
Alias *SqlLiteralNode
Distinct bool
BaseVisitable
}
type SumNode FunctionNode
type MaxNode FunctionNode
type MinNode FunctionNode
type AvgNode FunctionNode
func Sum(attr *AttributeNode) *SumNode {
return &SumNode{Expressions: []Visitable{at... | function_node.go | 0.754192 | 0.463201 | function_node.go | starcoder |
package object
// Bitmap3D describes how a bitmap object should be represented in 3D world.
type Bitmap3D uint16
const (
bitmap3DBitmapNumberLowMask uint16 = 0x03FF
bitmap3DBitmapNumberHighMask uint16 = 0x8000
bitmap3DBitmapNumberMask = bitmap3DBitmapNumberLowMask | bitmap3DBitmapNumberHighMask
bitmap... | ss1/content/object/Bitmap3D.go | 0.893629 | 0.638018 | Bitmap3D.go | starcoder |
package avl
import (
"errors"
"fmt"
"math"
ds "github.com/DavidCai1993/datastructures.go"
)
// Errors used by this package
var (
ErrEmptyTree = errors.New("avl: empty tree")
)
// Tree represents an AVL (Adelson, Velski & Landis) tree.
type Tree struct {
root *node
}
type node struct {
val ds.Comparable
... | avl-tree/avl.go | 0.845815 | 0.435781 | avl.go | starcoder |
package integration
// CloneAST creates a deep clone of the input.
func CloneAST(in AST) AST {
if in == nil {
return nil
}
switch in := in.(type) {
case BasicType:
return in
case Bytes:
return CloneBytes(in)
case InterfaceContainer:
return CloneInterfaceContainer(in)
case InterfaceSlice:
return Clone... | go/tools/asthelpergen/integration/clone.go | 0.644225 | 0.482429 | clone.go | starcoder |
package runtime
import (
"math"
"github.com/brettbuddin/shaden/dsp"
"github.com/brettbuddin/shaden/lisp"
)
func hzFn(sampleRate int) func(lisp.List) (interface{}, error) {
return func(args lisp.List) (interface{}, error) {
if err := lisp.CheckArityEqual(args, 1); err != nil {
return nil, err
}
switch v ... | runtime/value.go | 0.524395 | 0.41117 | value.go | starcoder |
package cism
/*
HistoryRecord represents a past state change and the event that caused it.
*/
type HistoryRecord struct {
State State // state that was transitioned to
Event Event // event that triggered the state change
}
/*
Machine is a state machine driven by a state transition table. All state
transitions are ... | machine.go | 0.665628 | 0.585338 | machine.go | starcoder |
package image
import (
"image"
"image/color"
"golang.org/x/image/draw"
)
const (
// skips image interpolation
ScaleSkip = -1
// initial image interpolation algorithm
ScaleOld = 0
// nearest neighbour interpolation
ScaleNearestNeighbour = 1
// bilinear interpolation
ScaleBilinear = 2
)
func Resize(scaleTy... | pkg/emulator/libretro/image/scale.go | 0.574514 | 0.483466 | scale.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_kmeans
#include <capi/kmeans.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type KmeansOptionalParam struct {
Algorithm string
AllowEmptyClusters bool
InPlace bool
InitialCentroids *mat.Dense
KillE... | kmeans.go | 0.685529 | 0.409368 | kmeans.go | starcoder |
package garkov
import (
"math/rand"
"time"
"github.com/mickuehl/garkov/dictionary"
)
// WordCount the number of occurences of a word from the word vector
type WordCount struct {
Idx int
Count int
}
// WordChain is the main structure of the model. It represents a prefix and all its suffixes.
type WordChain st... | markov.go | 0.572723 | 0.564459 | markov.go | starcoder |
package barcode
import (
"fmt"
"image"
"image/color"
"github.com/LLKennedy/imagetemplate/v3/render"
"golang.org/x/tools/godoc/vfs"
)
// Component implements the Component interface for images.
type Component struct {
/*
NamedPropertiesMap maps user/application variables to properties of the component.
This... | components/barcode/barcode.go | 0.734215 | 0.427755 | barcode.go | starcoder |
package curve1174
import (
"github.com/dterei/gotsc"
"math"
"math/rand"
"sort"
"time"
)
const testsNumber = 1 + percentilesNumber + 1
const enoughMeasurements = 10000
const percentilesNumber = 100
type timer struct {
startCount uint64
endCount uint64
}
func (t *timer) Start() {
t.startCount = gotsc.BenchS... | fixture.go | 0.526586 | 0.407864 | fixture.go | starcoder |
package rules
import (
"gonum.org/v1/gonum/mat"
"github.com/pkg/errors"
)
func createVarList(variables []VariableFieldName, varCache map[VariableFieldName]VariableValuePair) ([]float64, error) {
var variableVect []float64
for _, v := range variables {
if val, varOk := varCache[v]; varOk {
variableVect = ap... | internal/common/rules/basicruleevaluator.go | 0.600774 | 0.465387 | basicruleevaluator.go | starcoder |
package sky
import (
"log"
"github.com/chewxy/math32"
"github.com/go-gl/gl/v3.3-core/gl"
"github.com/go-gl/mathgl/mgl32"
"github.com/benanders/mineral/camera"
"github.com/benanders/mineral/math"
"github.com/benanders/mineral/render"
"github.com/benanders/mineral/world"
)
// The temperature throughout the wo... | sky/sky.go | 0.738103 | 0.441974 | sky.go | starcoder |
package def
import (
"math/rand"
"math"
"fmt"
)
const (
Pit = iota
Normal = iota
)
type Point struct {
PosX int
PosY int
}
type Perception struct {
Smell bool
Breeze bool
Shine bool
Shock bool
Scream bool
}
type Square struct {
terrain int
hasGold bool
hasWump bool
hasHunter bo... | def/world.go | 0.564939 | 0.454533 | world.go | starcoder |
package tcp
// https://github.com/aws/aws-sdk-go/blob/master/aws/convert_types.go
// String returns a pointer to the string value passed in.
func String(v string) *string {
return &v
}
// StringValue returns the value of the string pointer passed in or
// "" if the pointer is nil.
func StringValue(v *string) string... | tcp/convert_types.go | 0.852429 | 0.445771 | convert_types.go | starcoder |
// Package image provides a mockable wrapper for image.
package image
import (
image "image"
color "image/color"
io "io"
)
var _ Interface = &Impl{}
var _ = image.Decode
type Interface interface {
Decode(r io.Reader) (image.Image, string, error)
DecodeConfig(r io.Reader) (image.Config, string, error)
NewAlpha... | image/image.go | 0.841696 | 0.485295 | image.go | starcoder |
package prtree
import (
"github.com/tidwall/geoindex/child"
"github.com/tidwall/ptree"
"github.com/tidwall/rtree"
)
// PRTree is a tree for storing points and rects
type PRTree struct {
ptree *ptree.PTree
rtree *rtree.RTree
}
// New returns a new PRTree
func New(min, max [2]float64) *PRTree {
tr := new(PRTree... | prtree.go | 0.646795 | 0.443299 | prtree.go | starcoder |
package msgraph
// RatingFranceMoviesType undocumented
type RatingFranceMoviesType string
const (
// RatingFranceMoviesTypeVAllAllowed undocumented
RatingFranceMoviesTypeVAllAllowed RatingFranceMoviesType = "AllAllowed"
// RatingFranceMoviesTypeVAllBlocked undocumented
RatingFranceMoviesTypeVAllBlocked RatingFra... | v1.0/RatingFranceMoviesTypeEnum.go | 0.583678 | 0.441432 | RatingFranceMoviesTypeEnum.go | starcoder |
package geometry
import (
"bufio"
"errors"
"io/ioutil"
"math/rand"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
"github.com/gonum/matrix/mat64"
"github.com/google/uuid"
)
// PointCloud Represents an array of vectors
type PointCloud struct {
Vectors []*mat64.Vector
boxKNNSize *mat64.Vector
k ... | pointcloud3.go | 0.654122 | 0.429489 | pointcloud3.go | starcoder |
package models
import (
"fmt"
)
// TimePoint contains a relative time, the numbers of events of interest and censoring events occured at that time.
type TimePoint struct {
Time int64
Events Events
}
// Events contains the number of events of interest and censoring events occurring at the same relative time.
typ... | pkg/datasource/models/survival_query_time_points.go | 0.708313 | 0.526891 | survival_query_time_points.go | starcoder |
package main
import (
"sort"
)
// HuffmanTree is a codification of a Huffman tree. We arbitrary decide that we interpret the left tree as bit 1 and
// the right tree as bit 0. In the right part of the tree we store the values for the level, i.e. the nearer to the
// root on the right side, the higher the frequency o... | Greedy Algorithms/Huffman/go/huffman.go | 0.805632 | 0.721461 | huffman.go | starcoder |
package sampler
import (
"math"
)
const (
// 2^64 - 1
maxTraceID = ^uint64(0)
maxTraceIDFloat = float64(maxTraceID)
// Good number for Knuth hashing (large, prime, fit in int64 for languages without uint64)
samplerHasher = uint64(1111111111111111111)
)
// SampleByRate tells if a trace (from its ID) with ... | pkg/trace/sampler/score.go | 0.846578 | 0.463019 | score.go | starcoder |
package main
import (
"code.google.com/p/gomatrix/matrix"
"fmt"
"math"
)
func sign(s float64) float64 {
if s > 0 {
return 1
} else if s < 0 {
return -1
}
return 0
}
func unitVector(n int) *matrix.DenseMatrix {
vec := matrix.Zeros(n, 1)
vec.Set(0, 0, 1)
return v... | Task/QR-decomposition/Go/qr-decomposition.go | 0.758153 | 0.680655 | qr-decomposition.go | starcoder |
func getLength(array) {
"""
Get the length of an array like object.
INPUT <= array object
OUTPUT => integer array length
"""
count = 0
for _ in array {
count += 1
return count
func getMiddleOfLengthInsert(length) {
"""
Get the position for inserting an item in the midd... | shift_array/shift_array.go | 0.773388 | 0.788013 | shift_array.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_logistic_regression
#include <capi/logistic_regression.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type LogisticRegressionOptionalParam struct {
BatchSize int
DecisionBoundary float64
InputModel *logist... | logistic_regression.go | 0.667364 | 0.51013 | logistic_regression.go | starcoder |
package view
import (
"fmt"
"github.com/protolambda/ztyp/codec"
. "github.com/protolambda/ztyp/tree"
)
type ComplexVectorTypeDef struct {
ElemType TypeDef
VectorLength uint64
ComplexTypeBase
}
func ComplexVectorType(elemType TypeDef, length uint64) *ComplexVectorTypeDef {
minSize := uint64(0)
maxSize := ... | view/complex_vector.go | 0.549399 | 0.554712 | complex_vector.go | starcoder |
package axmlParser
type Listener interface {
StartDocument()
/**
* Receive notification of the end of a document.
*/
EndDocument()
/**
* Begin the scope of a prefix-URI Namespace mapping.
*
* @param prefix
* the Namespace prefix being declared. An empty string is used
* for th... | listener.go | 0.698227 | 0.487002 | listener.go | starcoder |
package types
import (
"encoding/json"
"math/big"
"math/rand"
)
func newIntegerFromString(s string) (*big.Int, bool) {
return new(big.Int).SetString(s, 0)
}
func equal(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) == 0 }
func gt(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) == 1 }
func lt(i *big.Int, i2... | types/int.go | 0.744749 | 0.425784 | int.go | starcoder |
package volumes
import (
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
"github.com/mitchellh/mapstructure"
)
// Volume contains all the information associated with an OpenStack Volume.
type Volume struct {
// Instances onto which the volume is attached.
Attachments []map[strin... | vendor/github.com/rackspace/gophercloud/openstack/blockstorage/v2/volumes/results.go | 0.752013 | 0.411643 | results.go | starcoder |
package chrono
import (
"fmt"
"strconv"
"time"
)
// Constants for calculating time in microsecond resolution.
const (
secondsPerDay = 86400
microsPerSecond = 1000000
microsPerNano = 1000
)
// Time is interpreted and stored at a microsecond-level resolution. This
// enables times ranging from January 1, 000... | chrono/time.go | 0.741206 | 0.45175 | time.go | starcoder |
package expression
import (
"fmt"
"github.com/dolthub/go-mysql-server/sql"
)
// Literal represents a literal expression (string, number, bool, ...).
type Literal struct {
value interface{}
fieldType sql.Type
}
var _ sql.Expression = &Literal{}
// NewLiteral creates a new Literal expression.
func NewLitera... | sql/expression/literal.go | 0.560253 | 0.443359 | literal.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.