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 signature import ( "bytes" "crypto/ecdsa" "crypto/elliptic" "crypto/hmac" "errors" "hash" "math/big" ) var ( // Used in RFC6979 implementation when testing the nonce for correctness one = big.NewInt(1) // oneInitializer is used to fill a byte slice with byte 0x01. It is provided // here to avoid ...
crypto/signature/rft6979.go
0.757615
0.413359
rft6979.go
starcoder
package main import ( "github.com/wdevore/RangerGo/api" "github.com/wdevore/RangerGo/engine/geometry" "github.com/wdevore/RangerGo/engine/misc" "github.com/wdevore/RangerGo/engine/nodes" "github.com/wdevore/RangerGo/engine/rendering" ) // TriangleNode is a basic triangle type TriangleNode struct { nodes.Node ...
examples/physics/intermediate/sensors/triangle_node.go
0.749179
0.415136
triangle_node.go
starcoder
package colorgrad import ( "math" "github.com/lucasb-eyer/go-colorful" ) // Algorithms adapted from: https://github.com/d3/d3-scale-chromatic const deg2rad = math.Pi / 180 const pi1_3 = math.Pi / 3 const pi2_3 = math.Pi * 2 / 3 // Sinebow type sinebowGradient struct{} func Sinebow() Gradient { return Gradient...
preset_fn.go
0.774498
0.63689
preset_fn.go
starcoder
package geobuf_raw import ( "github.com/murphy214/pbf" "math" "reflect" ) var powerfactor = math.Pow(10.0, 7.0) // encodes a var int for 32 bit number func EncodeVarint32(x uint32) []byte { var buf [4]byte var n int for n = 0; x > 127; n++ { buf[n] = 0x80 | uint8(x&0x7F) x >>= 7 } buf[n] = uint8(x) n++ ...
geobuf_raw/write_primitives.go
0.553023
0.483892
write_primitives.go
starcoder
package rotate import ( "math" "math/rand" "github.com/paulwrubel/photolum/config/geometry" "github.com/paulwrubel/photolum/config/geometry/primitive" "github.com/paulwrubel/photolum/config/geometry/primitive/aabb" "github.com/paulwrubel/photolum/config/shading/material" ) // RotationX is a primiti...
config/geometry/primitive/transform/rotate/rotatex.go
0.82748
0.408454
rotatex.go
starcoder
package finnhub import ( "encoding/json" ) // EconomicData struct for EconomicData type EconomicData struct { // Array of economic data for requested code. Data *[]EconomicDataInfo `json:"data,omitempty"` // Finnhub economic code Code *string `json:"code,omitempty"` } // NewEconomicData instantiates a new Econ...
model_economic_data.go
0.72952
0.439086
model_economic_data.go
starcoder
package dfl import ( "fmt" "reflect" "strings" ) // Set is a Node representing a set of values, which can be either a Literal or Attribute. type Set struct { Nodes []Node } // Len returns the length of the underlying array. func (s Set) Len() int { return len(s.Nodes) } func (s Set) Dfl(quotes []string, prett...
pkg/dfl/Set.go
0.698844
0.410047
Set.go
starcoder
package collections import "fmt" // Note: We very deliberately didn't call this type a List // because we don't want users of the library making the // mistake of using it as a general purpose sequence. // The right type for a general purpose sequence is Vector // A immutable stack implemented as a singly linked lis...
stack.go
0.799286
0.530601
stack.go
starcoder
// nolint: lll package containeranalysis import ( "context" "reflect" "github.com/pulumi/pulumi/sdk/go/pulumi" ) type NoteAttestationAuthority struct { Hint NoteAttestationAuthorityHint `pulumi:"hint"` } type NoteAttestationAuthorityInput interface { pulumi.Input ToNoteAttestationAuthorityOutput() NoteAttes...
sdk/go/gcp/containeranalysis/pulumiTypes.go
0.525612
0.461684
pulumiTypes.go
starcoder
package tic_tac_toe import "math" type TicTacToe struct { rows []int cols []int diagonal int antiDiagonal int } func New(n int) *TicTacToe { t := new(TicTacToe) t.rows = make([]int, n) t.cols = make([]int, n) return t } func (t *TicTacToe) Move(row, col int, player int) int { currentPlayer := -1 if playe...
golang/tic_tac_toe/tic_tac_toe.go
0.618896
0.45647
tic_tac_toe.go
starcoder
package helper import ( "fmt" "strings" utilerrors "github.com/gardener/gardener/pkg/utils/errors" machinev1alpha1 "github.com/gardener/machine-controller-manager/pkg/apis/machine/v1alpha1" "github.com/hashicorp/go-multierror" ) const ( nameLabel = "name" // MachineSetKind is the kind of the owner reference...
vendor/github.com/gardener/gardener/extensions/pkg/controller/worker/helper/helper.go
0.721351
0.422981
helper.go
starcoder
package judgment import ( "fmt" "sort" ) // MajorityJudgment is one of the deliberators ; it implements DeliberatorInterface. type MajorityJudgment struct { favorContestation bool // strategy for evenness of judgments ; defaults to true } // Deliberate is part of the DeliberatorInterface func (mj *MajorityJudgmen...
judgment/majorityjudgment.go
0.575349
0.412471
majorityjudgment.go
starcoder
package types import ( "fmt" "time" "github.com/tendermint/go-amino" sdk "github.com/okex/exchain/libs/cosmos-sdk/types" ) type ( // Commission defines a commission parameters for a given validator Commission struct { CommissionRates `json:"commission_rates" yaml:"commission_rates"` UpdateTime time.T...
x/staking/types/commission.go
0.707
0.44571
commission.go
starcoder
package main import ( "github.com/grant/spamorham/data" "math" "sort" "math/rand" ) type Tree struct { Leaf bool Prediction Prediction FeatureIndex int Threshold float64 Left *Tree Right *Tree } type Prediction map[string]float64 type Data []data.Point type SortedData struct { ...
tree/tree.go
0.682362
0.575707
tree.go
starcoder
package actions import ( "github.com/LindsayBradford/crem/internal/pkg/model/action" "github.com/LindsayBradford/crem/internal/pkg/model/planningunit" ) const GullyRestorationType action.ManagementActionType = "GullyRestoration" func NewGullyRestoration() *GullyRestoration { return new(GullyRestoration).WithType...
internal/pkg/model/models/catchment/actions/GullyRestoration.go
0.761982
0.569224
GullyRestoration.go
starcoder
package library import ( "github.com/ethereum/go-ethereum/common" "github.com/whoerau/go-uniswap-core/factory" "math/big" ) func Quote(amountA, reserveA, reserveB *big.Int) (amountB *big.Int) { amountB = new(big.Int).Div(new(big.Int).Mul(amountA, reserveB), reserveA) return amountB } func GetAmountOut(amountIn,...
utils/library/uniswapv2library.go
0.621311
0.462594
uniswapv2library.go
starcoder
package interpolate import ( "fmt" "math" "sort" ) type xy struct{ x, y []float64 } func (s *xy) Len() int { return len(s.x) } func (s *xy) Less(i, j int) bool { return s.x[i] < s.x[j] } func (s *xy) Swap(i, j int) { s.x[i], s.x[j] = s.x[j], s.x[i] s.y[i], s.y[j] = s.y[j], s.y[i] } func (s *xy) XY(i i...
interpolate/interpolate.go
0.533884
0.45302
interpolate.go
starcoder
package main import ( "fmt" "math" "github.com/jackytck/projecteuler/tools" ) func add(a, b float64) float64 { return a + b } func minus(a, b float64) float64 { return a - b } func mul(a, b float64) float64 { return a * b } func div(a, b float64) float64 { if b == 0 { return math.MaxInt64 } return a / ...
93/main.go
0.741768
0.52756
main.go
starcoder
package sexp import ( "go/types" "magic_pkg/emacs/lisp" "xtypes" ) func (atom Bool) Type() types.Type { return xtypes.TypBool } func (atom Int) Type() types.Type { return xtypes.TypInt } func (atom Float) Type() types.Type { return xtypes.TypFloat64 } func (atom Str) Type() types.Type { return xtypes.TypS...
src/sexp/type.go
0.609175
0.609001
type.go
starcoder
package iso20022 // Extract of trade data for an investment fund order. type FundOrderData5 struct { // Account information of the individual order instruction for which the status is given. InvestmentAccountDetails *InvestmentAccount58 `xml:"InvstmtAcctDtls,omitempty"` // Financial instrument information of the ...
FundOrderData5.go
0.803405
0.627951
FundOrderData5.go
starcoder
package cov import ( "errors" "fmt" "golang.org/x/tools/cover" "sort" ) // MergeProfiles merges two coverage profiles. // The profiles are expected to be similar - that is, from multiple invocations of a // single binary, or multiple binaries using the same codebase. // In particular, any source files with the sa...
gopherage/pkg/cov/merge.go
0.780579
0.425963
merge.go
starcoder
package estack import( "image" "image/color" "math" "github.com/skypies/util/histogram" ) // The output color should have 16 bits per color channel type CombinerFunc func(Stack, int,int, []ExposureValue, []color.Color) (color.Color, error) var( Hists = []histogram.Histogram{ histogram.Histogram{NumBuckets:25...
pkg/estack/combiners.go
0.510741
0.461988
combiners.go
starcoder
package unum import ( "math" ) // Vec2{1, 1} func Vec2_One() Vec2 { return Vec2{1, 1} } // Vec2{1, 0} func Vec2_Right() Vec2 { return Vec2{1, 0} } // Vec2{0, 1} func Vec2_Up() Vec2 { return Vec2{0, 1} } // Vec2{0, 0} func Vec2_Zero() Vec2 { return Vec2{0, 0} } func Vec2_Lerp(from, t...
util/num/vec2.go
0.761095
0.519582
vec2.go
starcoder
package gotrader import ( "errors" "github.com/sirupsen/logrus" ) // Option represents trading session functional option type Option func(p *sessionParameters) // Instruments is the functional option to define the instruments to trade func Instruments(instruments []string) Option { return func(p *sessionParamete...
session.go
0.68721
0.423458
session.go
starcoder
package algebra import ( "fmt" "math" ) type Vector2 struct { X MnFloat Y MnFloat } var ( ZeroVector2 = Vector2{0.0, 0.0} ) func (v Vector2) Dump() Vector2 { fmt.Println(fmt.Sprintf("X = %f, Y = %f", v.X, v.Y)) return v } // Calculates the dot product between two vectors. func (v Vector2) Dot(other Vector2)...
algebra/vector2.go
0.870088
0.676283
vector2.go
starcoder
package solver import ( "errors" "github.com/Spi1y/tsp-solver/solver/matrix" "github.com/Spi1y/tsp-solver/solver/tasks" ) // Solver is an object used to encapulate internal state of // the algorithm type Solver struct { DistanceMatrix matrix.Matrix bestSolution []int bestSolutionDistance int queue t...
solver/solver.go
0.810216
0.548674
solver.go
starcoder
package api import ( "net/url" "time" ) // Modified version from https://github.com/codedellemc/libstorage as an example. // This is a minimal definition. Ultimately, this will be the simplest and // most concise definition that consolidates the goodness from muliple // service management drivers. // Service defi...
api/provider.go
0.636692
0.417509
provider.go
starcoder
// This is an example of using composition and interfaces. // This is something we want to do in Go. // This pattern does provide a good design principle in a Go program. // We will group common types by their behavior and not by their state. // What brilliant about Go is that it doesn't have to be configured ahead o...
go/design/grouping_types_2.go
0.578686
0.494934
grouping_types_2.go
starcoder
package matrix import ( "fmt" "strings" sh "github.com/leonhfr/aoc/shared" ) type Matrix [][]int type Coordinates struct { I, J int } type Direction int const ( Clockwise Direction = iota CounterClockwise ) func NewMatrix(m, n int) Matrix { matrix := make(Matrix, m) for i := 0; i < n; i++ { matrix[i] =...
shared/matrix/lib.go
0.616012
0.41324
lib.go
starcoder
package main type Number struct { value int index int } func mergeSort(array, sorted []Number, left, right int) { if left >= right { return } middle := (left + right) >> 1 mergeSort(array, sorted, left, middle) mergeSort(array, sorted, middle+1, right) leftStart, rightStart := left, middle+1 for position ...
1-two-sum.go
0.639849
0.499268
1-two-sum.go
starcoder
package cal import "time" // Holidays (official and traditional) in Denmark // Reference https://da.wikipedia.org/wiki/Helligdag#Danske_helligdage var ( DKNytaarsdag = NewYear DKSkaertorsdag = NewHolidayFunc(calculateSkaertorsdag) DKLangfredag = GoodFriday DKPaaskedag = New...
vendor/github.com/rickar/cal/holiday_defs_dk.go
0.663451
0.468122
holiday_defs_dk.go
starcoder
package primitive import ( "math" "math/rand" ) type Material interface { Bounce(input Ray, hit Hit, rnd *rand.Rand) (bool, Ray) Color() Color } type Lambertian struct { Attenuation Color } func (l Lambertian) Color() Color { return l.Attenuation } func (l Lambertian) Bounce(input Ray, hit Hit, rnd *rand.Ran...
primitive/material.go
0.832713
0.443118
material.go
starcoder
package moira import ( "bytes" "math" "time" ) // BytesScanner allows to scan for subslices separated by separator type BytesScanner struct { source []byte index int separator byte emitEmptySlice bool } //HasNext checks if next subslice available or not func (it *BytesScanner) HasNext() ...
helpers.go
0.75101
0.418103
helpers.go
starcoder
package solutions type Sudoku struct { board [][]byte rows [90]bool columns [90]bool squares [230]bool solved bool } func solveSudoku(board [][]byte) { s := createBoard(board) for i := 0; i < 9; i++ { for j := 0; j < 9; j++ { if s.board[i][j] == '.' { s...
solutions/37.go
0.678753
0.500305
37.go
starcoder
package rawmdns type ( // RecordType is the type of a Resource Record; see RFC 1035 RecordType uint16 // RecordClass is the class of a Resource Record, e.g. "1" for INET; see RFC 1035 RecordClass uint16 // An OpCode is the operation being performed in a given DNS Message, usually // (always?) 0 i.e. "standard qu...
constants.go
0.66888
0.522629
constants.go
starcoder
package circuit import "github.com/heustis/tsp-solver-go/model" // ClonableCircuit is a Circuit variant where the circuit may be cloned with each update, depending on the implementation, // so that each clone represents a different branch of solving the circuit. type ClonableCircuit interface { model.Deletable // ...
circuit/clonable.go
0.903889
0.713107
clonable.go
starcoder
package game import ( "errors" "fmt" "strconv" "strings" ) // BiddingRound round is a collection of bids. type BiddingRound interface { // IsDone returns true if the bidding is complete (4 bids). IsDone() bool // placeBid makes a bid for the player in playerPos position. Bid validation must be performed befor...
server/pkg/game/bidding.go
0.665519
0.492371
bidding.go
starcoder
package parser // SourceExpressionTo is a record of an expression, along with its start and end positions. type SourceExpressionTo struct { Source Expression Target Range } // NewSourceMap creates a new lookup to map templ source code to items in the // parsed template. func NewSourceMap() *SourceMap { return &Sou...
parser/v2/sourcemap.go
0.782496
0.525125
sourcemap.go
starcoder
package chebyshev_iteration import ( "github.com/mitsuse/matrix-go" "math" "github.com/mitsuse/matrix-go/dense" "sync" ) var n int // Matrix dimension var h float64 // Step size var eps float64 // Precision var iterationCount int = 512 // Number of iterations var x_k matrix.Matrix // Matrix х var gamma1 floa...
chebyshev_iteration/chebyshev_iteration.go
0.689828
0.505005
chebyshev_iteration.go
starcoder
package executables // deriveTuplePackable returns a function, which returns the input values. // Since tuples are not first class citizens in Go, this is a way to fake it, because functions that return tuples are first class citizens. func deriveTuplePackable(v0 *packable, v1 error) func() (*packable, error) { retu...
internal/executables/derived.gen.go
0.785514
0.554953
derived.gen.go
starcoder
package hector import ( "math" "strconv" ) func Sigmoid(x float64)(y float64) { y = 1 / (1 + math.Exp(-1 * x)) return y } func UnSigmoid(x float64) float64 { x = x * 0.99 + 0.01 y := math.Log(x / (1 - x)) return y } func Signum(x float64) float64 { ret := 0.0 if x > 0{ ret = 1.0 } else if(x < 0) { ret...
math_util.go
0.704058
0.405802
math_util.go
starcoder
package raftify import ( "time" ) // toBootstrap initiates the transition into the bootstrap mode. In this mode, nodes wait for // the expected number of nodes specified in the expect field of the raftify.json to go online // and start all nodes of the cluster at the same time. func (n *Node) toBootstrap() { n.logg...
bootstrap.go
0.504394
0.437042
bootstrap.go
starcoder
package main func divides(p int, q int) bool { return p%q == 0 } func prime(p int) bool { i := 1 divisions := 0 for i <= p { if divides(p, i) { divisions++ } i++ } return divisions == 2 } func main() { i := 2 for i <= 100 { if prime(i) { println(i, "prime") } else { println(i, "composite") ...
test/t12.go
0.552057
0.469703
t12.go
starcoder
package container import ( "fmt" "reflect" "strings" "github.com/pspaces/gospace/function" ) // Tuple contains a set of fields, where fields can be any primitive or type. // A tuple is used to store information which is placed in a tuple space. type Tuple struct { Flds []interface{} `bson:"fields" json:"fields"...
container/tuple.go
0.737347
0.491517
tuple.go
starcoder
package cmd import ( "io/ioutil" "os" "strings" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/emc-advanced-dev/pkg/errors" "github.com/solo-io/unik/pkg/client" unikos "github.com/solo-io/unik/pkg/os" ) var data string var size int var volumeType string var rawVolume bool const ( VolTyp...
cmd/create-volume.go
0.592667
0.415907
create-volume.go
starcoder
package gp import ( "strconv" "math" "hector/core" ) type GaussianProcessParameters struct { Dim int64 Theta float64 } type GaussianProcess struct { Params GaussianProcessParameters CovarianceFunc CovFunc CovMatrix *core.Matrix TargetValues *core.Vector InvCovTarget *core.Vect...
gp/gaussian_process.go
0.762689
0.530115
gaussian_process.go
starcoder
package hex import ( "fmt" "github.com/RdecKa/0xAI/common/astarsearch" ) // Cells in a rectangular grid that are neighbours in a hexagonal grid // DO NOT MIX THE ORDER var neighbours = [6][]int{ []int{0, -1}, []int{1, -1}, []int{1, 0}, []int{0, 1}, []int{-1, 1}, []int{-1, 0}, } // Cells in a rectangular gri...
common/game/hex/astarsearch.go
0.700178
0.452173
astarsearch.go
starcoder
package main import ( "fmt" "math" "github.com/dyedgreen/comp-phys/pkg/signal" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/plotutil" "gonum.org/v1/plot/vg" ) // Range over which we plot const start = -10 const stop = 10 // Functions given in assignment func g(t float64) float64 { ret...
assignment/q-4/main.go
0.778228
0.445469
main.go
starcoder
package compose import "time" // CountRetryF composes a Func with retry capabilities. The error function has // access to the current retry count in its first parameter, which is useful // e.g when we are implementing a delay mechanism. func CountRetryF(retryCount uint) func(func(uint, interface{}) (interface{}, erro...
compose/retry.go
0.77081
0.409634
retry.go
starcoder
package hex import ( "bufio" "fmt" "log" "os" "strings" ) // This file provides functions for pattern matching in hex grids. Grids must be // represented as lists of integers, where one integer represents one row, and // each two bits in an integer represent one column. Patterns must be // represented as 2D slic...
common/game/hex/patmat.go
0.699973
0.433502
patmat.go
starcoder
package futil import ( "io/ioutil" "regexp" "github.com/phR0ze/n/pkg/sys" "github.com/pkg/errors" ) // ExtractString reads the filepath data then compiles the given regular // expression exp and applies it to the data and returns the results. // Match will be empty if no matches were found. Use (?m) to have ^ $ ...
pkg/futil/extract.go
0.555194
0.494629
extract.go
starcoder
package imagex import ( "bytes" "encoding/base64" "github.com/maxfish/go-libs/pkg/geom" "image" "image/draw" _ "image/jpeg" "image/png" ) func NewRGBAImagesFromAreas(img image.Image, areas []geom.Rect, skipEmptyAreas bool) []*image.RGBA { images := make([]*image.RGBA, 0, len(areas)) for _, area := range are...
pkg/imagex/image.go
0.72086
0.567697
image.go
starcoder
package selector import ( "fmt" "io" "strings" "unicode" ) // TokenT represents the type of lexer tokens type TokenT int type Token struct { Type TokenT Value string } const ( // start represents the starting state start TokenT = iota // endOfStringToken represents the end of the input string endOfStrin...
backend/selector/lexer.go
0.598547
0.414425
lexer.go
starcoder
package geomfn import ( "github.com/cockroachdb/cockroach/pkg/geo" "github.com/cockroachdb/errors" "github.com/twpayne/go-geom" ) // RemoveRepeatedPoints returns the geometry with repeated points removed. func RemoveRepeatedPoints(g geo.Geometry, tolerance float64) (geo.Geometry, error) { t, err := g.AsGeomT() ...
pkg/geo/geomfn/remove_repeated_points.go
0.75985
0.545588
remove_repeated_points.go
starcoder
package f64utils import ( "github.com/nlpodyssey/spago/pkg/global" "gonum.org/v1/gonum/floats" "math" "strconv" "strings" ) func EqualApprox(a, b float64) bool { return floats.EqualWithinAbsOrRel(a, b, 1.0e-06, 1.0e-06) } func Copy(in []float64) []float64 { out := make([]float64, len(in)) copy(out, in) ret...
pkg/mat/f64utils/utils.go
0.750461
0.413477
utils.go
starcoder
package main import ( rl "github.com/gen2brain/raylib-go/raylib" ) func Normalize(c complex64) float64 { x := float64(real(c)) y := float64(imag(c)) return x*x + y*y } func mandelbrotPixel(pos rl.Vector2, xdim float32, ydim float32, maxIter int) rl.Color { c := complex(pos.Y, pos.X) c = c * complex(2.4/ydim, 0...
main.go
0.663669
0.496826
main.go
starcoder
package raytracer import "math" type Tuple struct { X float64 Y float64 Z float64 W float64 } type TupleType int const Eps = 1e-5 const ( VectorType TupleType = iota PointType ) func (t *Tuple) Type() TupleType { if AlmostEqual(t.W, 1.0, Eps) { return PointType } else { return VectorType } } func (t *T...
raytracer/tuples.go
0.854779
0.666877
tuples.go
starcoder
package colorquant import ( "image" "image/color" "math" "image/draw" ) // Dither is a two dimensional slice for storing different dithering methods. type Dither struct { Filter [][]float32 } // NoDither is used to call the default quantize method without applying dithering. var NoDither Quantizer = Dither{} /...
ditherer.go
0.754553
0.550607
ditherer.go
starcoder
package math import ( "math" "runtime" "github.com/entropyx/tools" ) // Mean function func Mean(x []float64) float64 { out := 0.00 n := len(x) for i := 0; i < n; i++ { out = out + x[i] } out = out / float64(n) return out } // Sd standart desviation function func Sd(x []float64) float64 { mu := Mean(x) ...
math.go
0.667039
0.416263
math.go
starcoder
package mock import ( "github.com/corestoreio/pkg/storage/null" "github.com/corestoreio/pkg/store" ) // NewServiceEuroOZ creates a fully initialized store.Service with 3 websites, // 4 groups and 7 stores used for testing. Panics on error. Website 1 contains // Europe and website 2 contains Australia/New Zealand. ...
store/mock/service.go
0.57093
0.42471
service.go
starcoder
package state import ( "github.com/zarbchain/zarb-go/block" "github.com/zarbchain/zarb-go/crypto" "github.com/zarbchain/zarb-go/errors" "github.com/zarbchain/zarb-go/vote" ) func (st *state) validateBlock(block block.Block) error { if err := block.SanityCheck(); err != nil { return err } if !block.Header()....
state/validation.go
0.540681
0.408159
validation.go
starcoder
package types import ( "github.com/antihax/optional" "time" ) type CreateScheduledViewDefinition struct { // The query that defines the data to be included in the scheduled view. Query string `json:"query"` // Name of the index for the scheduled view. IndexName string `json:"indexName"` // Start timestamp in U...
service/cip/types/scheduled_view_types.go
0.801509
0.491761
scheduled_view_types.go
starcoder
package oracle import ( "bytes" "math/rand" ) // ECBOracle2 encrypts using ECB with a fixed unknown key, a fixed plaintext // suffix and a variable plaintext prefix. // The goal is to decrypt that plaintext suffix. type ECBOracle2 struct { o *ECBOracle prefix []byte } // NewECBOracle2 creates an ECBOracle w...
oracle/ecb2.go
0.760917
0.477067
ecb2.go
starcoder
package timequeue type semaphore struct { buffered bool signal internalSignal ch chan internalSignal processedSignals map[internalSignal]bool actions map[internalSignal]func() broadcasts map[internalSignal][]*semaphore } func newSemaphore(buf int) *semaphore { buf...
semaphore.go
0.668556
0.482734
semaphore.go
starcoder
package dotmatrix import ( "image" "image/color" "io" ) // Braille epresents an 8 dot braille pattern in x,y coordinates space. Eg: // +----------+ // |(0,0)(1,0)| // |(0,1)(1,1)| // |(0,2)(1,2)| // |(0,3)(1,3)| // +----------+ type Braille [2][4]int // Rune maps each point in braille to a dot identif...
braille.go
0.68742
0.413063
braille.go
starcoder
package network import ( "testing" "github.com/klokare/evo" ) var ( ForwardXor = evo.Substrate{ Nodes: []evo.Node{ {Position: evo.Position{Layer: 0.0, X: 0.0}, Neuron: evo.Input, Activation: evo.Direct}, {Position: evo.Position{Layer: 0.0, X: 1.0}, Neuron: evo.Input, Activation: evo.Direct}, {Position:...
xor.go
0.501465
0.624236
xor.go
starcoder
package graph import ( "errors" "github.com/skydive-project/skydive/common" ) // MemoryBackendNode a memory backend node type MemoryBackendNode struct { *Node edges map[Identifier]*MemoryBackendEdge } // MemoryBackendEdge a memory backend edge type MemoryBackendEdge struct { *Edge } // MemoryBackend describes...
topology/graph/memory.go
0.728265
0.427456
memory.go
starcoder
package wad import ( "math/big" "strings" "github.com/robert-zaremba/errstack" ) var oneCoinF = big.NewFloat(1e18) var oneCoin *big.Int // OneGwei is a constant equal to 1 billion (1e9) var OneGwei *big.Int type numberType int const ( anyNumber numberType = iota negative notNegative positive ) func init(...
go-lib/ethereum/wad/number.go
0.650467
0.428054
number.go
starcoder
package mqclient // SubscriptionInitialPosition is the type of a subscription initial position type SubscriptionInitialPosition int const ( // SubscriptionPositionLatest is latest position which means the start consuming position will be the last message SubscriptionPositionLatest SubscriptionInitialPosition = iot...
internal/util/mqclient/consumer.go
0.635901
0.409634
consumer.go
starcoder
package battleship import "io" /* Board represents the game board. It allows one to print the board out to any io.Writer. A board should be printed as the following: # A New board should look like this: A B C D E F G H I J K L M N O P ╭─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─╮ 1│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ┼─┼─┼...
battleship/main.go
0.592077
0.97372
main.go
starcoder
package dither import ( "image" "image/color" "image/color/palette" "image/draw" ) // RGBAVec is container for single pixel values. // Values are stored as int64 to prevent underflow and overflow. type RGBAVec struct { // TODO: int32 or int would be probably enough R int64 G int64 B int64 A int64 } // Color...
dither/dither.go
0.512693
0.500427
dither.go
starcoder
package cmd import ( "bytes" "fmt" "io" "os" "github.com/spf13/cobra" ) // language=markdown var cliReferenceHeader = `--- layout: default title: Command (CLI) Reference description: lakeFS comes with its own native CLI client. Here you can see the complete command reference. parent: Reference nav_order: 3 has_...
cmd/lakectl/cmd/docs.go
0.624637
0.451387
docs.go
starcoder
package binaryheap // Comparator returns true if, and only if, 'a' has a higher priority than 'b'; // that is, 'a' should be retrieved from the heap before 'b'. type Comparator[T any] func(a, b T) bool type BinaryHeap[T any] struct { heap []T cmp Comparator[T] } // The default capacity of the slice that contains ...
binaryheap.go
0.899558
0.572364
binaryheap.go
starcoder
package input import ( "github.com/Jeffail/benthos/v3/lib/input/reader" "github.com/Jeffail/benthos/v3/lib/log" "github.com/Jeffail/benthos/v3/lib/metrics" "github.com/Jeffail/benthos/v3/lib/types" "github.com/Jeffail/benthos/v3/lib/x/docs" ) //-------------------------------------------------------------------...
lib/input/zmq4.go
0.64131
0.593315
zmq4.go
starcoder
package lexer import ( "strings" ) type typename map[string]string //OperatorAttributes wraps the precedance and Associativity of a operator type OperatorAttributes struct { Precedance int Associativity string } //IsLitteral checks if a given token is a litteral type func IsLitteral(token Token) bool { litte...
lexer/types.go
0.722037
0.475057
types.go
starcoder
package iso20022 // Provides information on the status of a trade. type TradeData7 struct { // Identification of the present message assigned by the party issuing the message. This identification must be unique amongst all messages of same type sent by the same party. MessageIdentification *Max35Text `xml:"MsgId"` ...
TradeData7.go
0.790247
0.447581
TradeData7.go
starcoder
package logger // Possible states of a given key type KeyState uint8 const ( Released KeyState = 0x00 Pressed KeyState = 0x01 ) // Keys recognized and returned by the logger type Key uint8 const ( _Nil Key = iota Backspace Tab Return Esc Space PageUp PageDown End Home ...
logger/logger.go
0.637369
0.460895
logger.go
starcoder
package discrete import "fmt" // Factorial calcultes n! which equals 1 * 2 * 3 * ... * n func Factorial(n uint) (f uint) { f = 1 for i := uint(2); i <= n; i++ { f *= i } return } // TotalPermutations calcutes p permutations of n objects, taken r at a time: n! / (n - r)! func TotalPermutations(n, r uint) (p ui...
algorithms.go
0.676406
0.461623
algorithms.go
starcoder
package slice // ReverseBool performs in place reversal of a bool slice func ReverseBool(a []bool) []bool { if len(a) == 0 { return a } s, e := 0, len(a)-1 for s < e { a[s], a[e] = a[e], a[s] s++ e-- } return a } // ReverseByte performs in place reversal of a byte slice func ReverseByte(a []byte) []by...
reverse.go
0.840554
0.689521
reverse.go
starcoder
package trie import ( "bytes" "io" ) type trie struct { height uint32 labelVec labelVector hasChildVec rankVectorSparse loudsVec selectVector suffixes suffixKeyVector values valueVector prefixVec prefixVector } // NewTrie returns a new empty SuccinctTrie func NewTrie() SuccinctTrie { retur...
pkg/trie/trie.go
0.695545
0.444022
trie.go
starcoder
package coltypes import ( "bytes" "fmt" "github.com/weisslj/cockroach/pkg/sql/lex" ) // ColTypeFormatter knows how to format a ColType to a bytes.Buffer. type ColTypeFormatter interface { fmt.Stringer // TypeName returns the base name of the type, suitable to generate // column names for cast expressions. T...
pkg/sql/coltypes/interface.go
0.76934
0.41941
interface.go
starcoder
package serialization import ( "errors" dtMetric "github.com/dynatrace-oss/dynatrace-metric-utils-go/metric" "github.com/dynatrace-oss/dynatrace-metric-utils-go/metric/dimensions" "go.opentelemetry.io/collector/model/pdata" ) func serializeHistogram(name, prefix string, dims dimensions.NormalizedDimensionList, ...
exporter/dynatraceexporter/serialization/histogram.go
0.791982
0.451266
histogram.go
starcoder
package constant import ( "fmt" "github.com/llir/llvm/ir/enum" "github.com/llir/llvm/ir/types" ) // --- [ Other expressions ] --------------------------------------------------- // ~~~ [ icmp ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ExprICmp is an LLVM IR icmp expression. type ExprI...
ir/constant/expr_other.go
0.776623
0.495117
expr_other.go
starcoder
// This is a modified, simplified version of code from golang.org/x/time/rate. // Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package rate provides a rate limiter. package rate import ( "sync" "time"...
tstime/rate/rate.go
0.798265
0.437042
rate.go
starcoder
package iso20022 // Electronic money product that provides the cardholder with a portable and specialised computer device, which typically contains a microprocessor. type PaymentCard18 struct { // Type of card, for example, credit card. Type *CardType1Code `xml:"Tp"` // Number embossed on a card that links the ca...
PaymentCard18.go
0.727492
0.40592
PaymentCard18.go
starcoder
package vector import ( "math" "math/rand" "github.com/Sirupsen/logrus" colorful "github.com/lucasb-eyer/go-colorful" ) var ( Up = Vector{0, 1, 0} Right = Vector{1, 0, 0} Forward = Vector{0, 0, 1} Origo = Vector{0, 0, 0} ) type Vector struct { X, Y, Z float64 } // DivideScalar divides each compon...
vector/vector.go
0.790732
0.504639
vector.go
starcoder
package siafile import ( "path/filepath" "github.com/turtledex/TurtleDexCore/modules" "github.com/turtledex/errors" "github.com/turtledex/writeaheadlog" ) // CombinedChunkIndex is a helper method which translates a chunk's index to the // corresponding combined chunk index dependng on the number of combined chun...
modules/renter/filesystem/turtledexfile/partialsturtledexfile.go
0.55254
0.420005
partialsturtledexfile.go
starcoder
package main import "fmt" // Algebraic returns the description of a Move in standard algebraic notation. func Algebraic(pos Position, m Move) string { var s string switch side, ok := m.IsCastle(); { case ok && side == QS: s = "O-O-O" case ok && side == KS: s = "O-O" default: if m.Piece == Pawn { if m.Is...
algebraic.go
0.604866
0.459501
algebraic.go
starcoder
package types import ( "database/sql/driver" "fmt" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "math/big" "reflect" ) // HashLength is the expected length of the hash type. const HashLength = 32 // Hash represents the 32 byte hash of arbitrary data. // It's inspire...
internal/types/hash.go
0.803714
0.404949
hash.go
starcoder
package main import ( "fmt" "math" "math/rand" "runtime" "github.com/Edgaru089/implot-go" "github.com/inkyblackness/imgui-go/v4" ) var plotSize = imgui.Vec2{X: -1, Y: 200} // floatRange returns a float64 in range [min, max). func floatRange(min, max float64) float64 { return min + rand.Float64()*(max-min) } ...
example.go
0.617974
0.491334
example.go
starcoder
package plan import ( "fmt" "io" "github.com/dolthub/go-mysql-server/sql" ) // ShowIndexes is a node that shows the indexes on a table. type ShowIndexes struct { UnaryNode IndexesToShow []sql.Index } // NewShowIndexes creates a new ShowIndexes node. The node must represent a table. func NewShowIndexes(table sq...
sql/plan/show_indexes.go
0.584271
0.446977
show_indexes.go
starcoder
package util import "time" var ( // Combinatorics is a namespace containing combinatoric functions. Combinatorics = combinatorics{} ) type combinatorics struct{} // PairsOfInt returns unordered pairs of integers from an array. func (c combinatorics) PairsOfInt(values ...int) [][2]int { if len(values) == 0 { re...
util/combinatorics.go
0.735737
0.713997
combinatorics.go
starcoder
// Package kahnsort provides topological sorting using Kahn's algorithm. package kahnsort import ( "log" ) // Node represents a node in a directed acyclic graph. // Node implementations must be comparable using go equality. type Node interface { // Down returns a list of downstream nodes adjacent to this node. //...
lang/circuit/kahnsort/kahnsort.go
0.8288
0.477067
kahnsort.go
starcoder
package p493 import ( "sort" ) /** Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j]. You need to return the number of important reverse pairs in the given array. Example1: Input: [1,3,2,3,1] Output: 2 Example2: Input: [2,4,3,5,1] Output: 3 Note: The length of the giv...
algorithms/p493/493.go
0.692954
0.573201
493.go
starcoder
package packet // Structure of packets and functions for writing/reading them import ( "errors" ) // AckPacket is a UDT packet acknowledging previously-received data packets and describing the state of the link type AckPacket struct { ctrlHeader AckSeqNo uint32 // ACK sequence number PktSeqHi PacketID // The...
udt/packet/packet_ack.go
0.705481
0.448547
packet_ack.go
starcoder
package docs import ( "bytes" "encoding/json" "fmt" "strings" "text/template" "github.com/Jeffail/benthos/v3/lib/util/config" "github.com/Jeffail/gabs/v2" "gopkg.in/yaml.v3" ) // AnnotatedExample is an isolated example for a component. type AnnotatedExample struct { // A title for the example. Title string...
internal/docs/component.go
0.717309
0.706868
component.go
starcoder
package protocol import ( "bytes" "encoding/binary" "fmt" "image/color" ) const ( MapObjectTypeEntity = iota MapObjectTypeBlock ) // MapTrackedObject is an object on a map that is 'tracked' by the client, such as an entity or a block. This // object may move, which is handled client-side. type MapTrackedObject...
minecraft/protocol/map.go
0.676406
0.449876
map.go
starcoder
package mlmetrics import ( "math" "sync" ) // Regression is a basic regression evaluator type Regression struct { weight float64 // total weight observed sum float64 // sum of all values resSum float64 // residual sum resSum2 float64 // residual sum of squares logSum2 float64 // logarithmic residual su...
regression.go
0.729423
0.677816
regression.go
starcoder
package mapWrapper const keyObjectValuePointerTemplate = `{{range .Types}} type {{.KeyTitle}}{{.Value}}Map struct { s map[{{.Key}}]*{{.Value}} } func New{{.KeyTitle}}{{.Value}}Map() *{{.KeyTitle}}{{.Value}}Map { return &{{.KeyTitle}}{{.Value}}Map{} } func (m *{{.KeyTitle}}{{.Value}}Map) Clear() { m.s = make(map[{...
mapWrapper/keyObjectValuePointerTemplate.go
0.762424
0.586464
keyObjectValuePointerTemplate.go
starcoder
package sorting import algorithms "github.com/irenicaa/go-algorithms" const ( wasNotSwapped = -1 forwardStep = 1 backwardStep = -1 ) // BubbleSort ... func BubbleSort(items []algorithms.Less) { end := len(items) - 1 for { lastSwappedIndex := bubbleSortPass(items, 0, end, forwardStep, 1) if lastSwappedInd...
sorting/sorting.go
0.713631
0.480174
sorting.go
starcoder