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 paths /* 576. 出界的路径数 https://leetcode-cn.com/problems/out-of-boundary-paths/ 给定一个 m × n 的网格和一个球。球的起始坐标为 (i,j) ,你可以将球移到相邻的单元格内,或者往上、下、左、右四个方向上移动使球穿过网格边界。 但是,你最多可以移动 N 次。找出可以将球移出边界的路径数量。 答案可能非常大,返回 结果 mod 109 + 7 的值。 示例 1: 输入: m = 2, n = 2, N = 2, i = 0, j = 0 输出: 6 解释: 示例 2: 输入: m = 1, n = 3, N = 3, i = 0, j ...
solutions/out-of-boundary-paths/d.go
0.563858
0.40987
d.go
starcoder
package draw import ( "math" "github.com/pzduniak/unipdf/model" ) // CubicBezierCurve is defined by: // R(t) = P0*(1-t)^3 + P1*3*t*(1-t)^2 + P2*3*t^2*(1-t) + P3*t^3 // where P0 is the current point, P1, P2 control points and P3 the final point. type CubicBezierCurve struct { P0 Point // Starting point. P1 Point ...
bot/vendor/github.com/pzduniak/unipdf/contentstream/draw/bezier_curve.go
0.888002
0.603815
bezier_curve.go
starcoder
package bulletproofs import ( "github.com/incognitochain/incognito-chain/privacy/operation" "github.com/incognitochain/incognito-chain/privacy/privacy_util" "github.com/pkg/errors" ) // ConvertIntToBinary represents a integer number in binary func ConvertUint64ToBinary(number uint64, n int) []*operation.Scalar { ...
privacy/privacy_v2/bulletproofs/bulletproofs_helper.go
0.620047
0.481941
bulletproofs_helper.go
starcoder
package dynamicarray // errors: used to handle CheckRangeFromIndex function with a reasonable error value import ( "errors" ) var defaultCapacity = 10 // DynamicArray structure // size: length of array // capacity: the maximum length of the segment // elementData: an array of any type of data with interface type D...
data_structures/dynamic_array/dynamicarray.go
0.771843
0.528655
dynamicarray.go
starcoder
package mocks import "github.com/bryanl/doit/do" import "github.com/stretchr/testify/mock" import "github.com/digitalocean/godo" type ImagesService struct { mock.Mock } // List provides a mock function with given fields: public func (_m *ImagesService) List(public bool) (do.Images, error) { ret := _m.Called(publi...
do/mocks/ImagesService.go
0.647798
0.417865
ImagesService.go
starcoder
package contrast import ( "image" "image/color" "math" "hawx.me/code/img/altcolor" "hawx.me/code/img/utils" ) const Epsilon = 1.0e-10 // Adjust changes the contrast in the Image. A value of 0 has no effect. func Adjust(img image.Image, value float64) image.Image { return utils.MapColor(img, AdjustC(value)) } ...
contrast/adjust.go
0.877975
0.510619
adjust.go
starcoder
package context import ( "github.com/murphybytes/analyze/errors" "github.com/murphybytes/analyze/internal/ast" "regexp" ) // @len(arr) returns the length of an array func _len(args []interface{}) (interface{}, error) { if len(args) != 1 { return nil, errors.New(errors.SyntaxError, "wrong number of arguments for...
context/builtin_functions.go
0.57344
0.535159
builtin_functions.go
starcoder
package section import ( "math" ) // TriangleSection - section created by triangles. It is a universal type of section type TriangleSection struct { Elements []Triangle // Slice of triangles } // Area - cross-section area func (s TriangleSection) Area() (area float64) { for _, tr := range s.Elements { if tr.che...
section/sectionTriangles.go
0.656548
0.507873
sectionTriangles.go
starcoder
package chron import ( "time" "github.com/dustinevan/chron/dura" "fmt" "reflect" "database/sql/driver" "strings" ) // Time implementations are instants in time that are transferable to // other instants with a different precision--year, month, day, hour, // minute, second, milli, micro, chron--which has nanose...
time.go
0.699562
0.483344
time.go
starcoder
package propcheck import ( "fmt" "strings" "time" ) type SimpleRNG struct { Seed int } func (w SimpleRNG) String() string { return fmt.Sprintf("SimpleRMG{Seed: %v}", w.Seed) } func NextInt(r SimpleRNG) (int, SimpleRNG) { newSeed := (r.Seed*0x5DEECE66D + 0xB) & 0xFFFFFFFFFFFF nextRNG := SimpleRNG{newSeed} n ...
propcheck/gen.go
0.778565
0.47859
gen.go
starcoder
package grammar import ( "fmt" "regexp" ) // Token type represent the symbol or a substring of // a grammar. type Token string // NonTerminal is the type respresenting the right-hand side // of a rule in CNF with 2 symbols. type NonTerminal struct { Left Token Right Token } // GetToken returns the token of a R...
grammar/grammar.go
0.784773
0.490785
grammar.go
starcoder
package internal import ( "fmt" "github.com/nsf/termbox-go" "io" "math/rand" ) /* Maze represents the configuration of a specific Maze within InfiniMaze */ type Maze struct { Directions [][]int //Each Point on the map is represented as an integer that defines the directions that can be traveled from that Point...
internal/maze.go
0.548432
0.44077
maze.go
starcoder
package main import ( "fmt" "math" . "github.com/jakecoffman/cp" "github.com/jakecoffman/cp/examples" ) var queryStart Vector func main() { space := NewSpace() queryStart = Vector{} space.Iterations = 5 // fat segment { mass := 1.0 length := 100.0 a := Vector{-length / 2.0, 0} b := Vector{length ...
examples/query/query.go
0.703346
0.555676
query.go
starcoder
package docs import ( "bytes" "encoding/json" "strings" "github.com/alecthomas/template" "github.com/swaggo/swag" ) var doc = `{ "swagger": "2.0", "info": { "description": "{{.Description}}", "version": "{{.Version}}", "title": "{{.Title}}", "contact": {}, "license": {} }, "host": "{{.Host}}...
docs/docs.go
0.511473
0.440048
docs.go
starcoder
package machine import ( "Go-SAP3/machine/types" "math/bits" ) // ArithmeticLogicUnit is asynchronous (un-clocked) ; Its value will change as soon as input words change. type ArithmeticLogicUnit struct { A types.Word B types.Word Sum types.Word WriteEnable types.State AluMode Al...
machine/alu.go
0.597608
0.405979
alu.go
starcoder
package consolidators import ( "math" "github.com/m3db/m3/src/dbnode/client" "github.com/m3db/m3/src/dbnode/encoding" "github.com/m3db/m3/src/dbnode/ts" "github.com/m3db/m3/src/query/block" "github.com/m3db/m3/src/query/models" "github.com/m3db/m3/src/query/storage/m3/storagemetadata" "github.com/m3db/m3/src...
src/query/storage/m3/consolidators/types.go
0.69368
0.446072
types.go
starcoder
package service import ( "fmt" "log" "strings" "time" "github.com/bwmarrin/discordgo" ) func mentionUser(ID string) string { return "<@" + ID + ">" } // SplitChannelMessageSend properly splits long output in order to accepted by the discord servers. // also properly wrap single codeblocks that were split duri...
service/discord_utils.go
0.50293
0.423458
discord_utils.go
starcoder
package govalidator import ( "math" "reflect" ) // Abs returns absolute value of number func Abs(value float64) float64 { return math.Abs(value) } // Sign returns signum of number: 1 in case of value > 0, -1 in case of value < 0, 0 otherwise func Sign(value float64) float64 { if value > 0 { return 1 } else if...
vendor/github.com/asaskevich/govalidator/numerics.go
0.896767
0.714242
numerics.go
starcoder
package sidecar import ( "bytes" "crypto/rand" "crypto/sha256" "fmt" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/ecdsa" "github.com/btcsuite/btcd/btcutil" "github.com/lightningnetwork/lnd/lnwire" ) // Version is the version of the sidecar ticket format. type Version uint8 const ( ...
sidecar/interfaces.go
0.602529
0.465448
interfaces.go
starcoder
package testing import ( "fmt" "net/http" "testing" "github.com/magicmemories/go-jerakia" th "github.com/magicmemories/go-jerakia/testhelper" fake "github.com/magicmemories/go-jerakia/testhelper/client" "github.com/stretchr/testify/assert" ) // LookupBasicResponse provides a GET response of a lookup. const ...
testing/lookup_fixtures.go
0.669637
0.435541
lookup_fixtures.go
starcoder
package geoindex import ( "math" "sort" "time" ) // A geoindex that stores points. type PointsIndex struct { index *geoIndex currentPosition map[string]Point } // NewPointsIndex creates new PointsIndex that maintains the points in each cell. func NewPointsIndex(resolution Meters) *PointsIndex { newSe...
points-index.go
0.835383
0.61757
points-index.go
starcoder
package holtwinters import "math" type HoltWintersT struct { Series []float64 SeasonLenth int Npreds int Alpha float64 Beta float64 Gamma float64 ScalingFactor float64 Result []float64 Smooth []float64 Season...
hw.go
0.578329
0.454896
hw.go
starcoder
package main import ( "image" "image/color" "math/rand" "github.com/DumDumGeniuss/ggol" ) type gameOfMatrixUnit struct { WordsLength int CountWords int // One column (height of game size) can only have a word stream at a time, so we have this count CountHeight int } var initialGameOfMatrixUnit gameOfMatrix...
example/game_of_matrix.go
0.516108
0.503906
game_of_matrix.go
starcoder
package plaid import ( "encoding/json" ) // DistributionBreakdown Information about the accounts that the payment was distributed to. type DistributionBreakdown struct { // Name of the account for the given distribution. AccountName NullableString `json:"account_name,omitempty"` // The name of the bank that the ...
plaid/model_distribution_breakdown.go
0.791499
0.406685
model_distribution_breakdown.go
starcoder
package plaid import ( "encoding/json" ) // Deductions An object with the deduction information found on a paystub. type Deductions struct { Subtotals *[]Total `json:"subtotals,omitempty"` Breakdown []DeductionsBreakdown `json:"breakdown"` Totals *[]Total `json:"totals,omitempty"` Total DeductionsTotal `json:"t...
plaid/model_deductions.go
0.505615
0.471406
model_deductions.go
starcoder
package unsafe import "unsafe" //sliceOf creates a new byte slice from the given pointer. //The capacity of the returned slice is the same as the length. //This function assumes that the caller keeps the ptr reachable. func sliceOf(ptr unsafe.Pointer, length int) []byte { return unsafe.Slice((*byte)(ptr), length) } ...
internal/unsafe/go1.17.go
0.763748
0.493958
go1.17.go
starcoder
package main import ( "fmt" "math" "github.com/rolfschmidt/advent-of-code-2021/helper" ) var lights string; var matrix map[int]map[int]string; var flip = false func main() { fmt.Println("Part 1", Part1()) fmt.Println("Part 2", Part2()) } func Part1() int { return Run(false) } func Part2() i...
day20/main.go
0.701917
0.412353
main.go
starcoder
package schemas import ( "fmt" "hash/crc32" "regexp" "strconv" "github.com/mvisonneau/gitlab-ci-pipelines-exporter/pkg/config" ) const ( mergeRequestRegexp string = `^((\d+)|refs/merge-requests/(\d+)/head)$` // RefKindBranch refers to a branch RefKindBranch RefKind = "branch" // RefKindTag refers to a tag...
pkg/schemas/ref.go
0.705481
0.416975
ref.go
starcoder
package ptr import "time" // To returns the value of the pointer passed in or the default value if the pointer is nil. func To[T any](v *T) T { var zero T if v == nil { return zero } return *v } // ToInt returns the value of the int pointer passed in or int if the pointer is nil. // ToInt returns the value of ...
to.go
0.826991
0.543045
to.go
starcoder
package problem054 // assume a valid solution exists type game struct { numberAt [][]int rowSet []map[int]bool columnSet []map[int]bool boxSet [][]map[int]bool } const empty = 0 func (thisGame *game) set(row int, column int, number int) *game { if number == empty { delete(thisGame.rowSet[row], thisGam...
problem054/problem054.go
0.53437
0.481149
problem054.go
starcoder
package fuzz import ( "math" "reflect" ) // DeepEqual is reflect.DeepEqual except that: // 1. nil and empty slice/string are considered equal // 2. NaNs compare equal. func DeepEqual(a1, a2 interface{}) bool { if a1 == nil || a2 == nil { return a1 == a2 } return deepValueEqual(reflect.ValueOf(a1), reflect.Val...
fuzz/util.go
0.618665
0.640256
util.go
starcoder
package psql import "fmt" // Eq returns an Expression representing the equality comparison between a and b. func Eq(a, b Expression) comparison { return comparison{a, b, eq} } // NotEq returns an Expression representing the inequality comparison between a and b. func NotEq(a, b Expression) comparison { return comp...
comparison.go
0.899461
0.557123
comparison.go
starcoder
package equipslottype import ( "github.com/kasworld/goguelike/config/gameconst" ) func (et EquipSlotType) Attack() bool { return attrib[et].Attack } func (et EquipSlotType) Defence() bool { return attrib[et].Defence } func (et EquipSlotType) Rune() string { return attrib[et].Rune } func (et EquipSlotType) Nam...
enum/equipslottype/attrib.go
0.556159
0.40439
attrib.go
starcoder
package rangedbtest import ( "context" "fmt" "sync" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/inklabs/rangedb" "github.com/inklabs/rangedb/pkg/clock" "github.com/inklabs/rangedb/pkg/clock/provider/sequentialclock" "github.com/inklabs/rangedb/pk...
rangedbtest/verify_store.go
0.575946
0.415788
verify_store.go
starcoder
package ast import ( "github.com/pkg/errors" "github.com/sjhitchner/go-pred/token" "regexp" "strconv" ) type Attrib interface{} // Functions used to build the AST // They are included in the grammar.bnf so the parser // can build the AST func NewLogicalAnd(a, b Attrib) (*LogicalNode, error) { return &LogicalNo...
ast/ast.go
0.725551
0.51068
ast.go
starcoder
package interfacelib import ( "strconv" ) func ToFloat64(params interface{}) (res float64) { switch params.(type) { case int64: t, _ := params.(int64) res = float64(t) case int32: t, _ := params.(int32) res = float64(t) case int16: t, _ := params.(int16) res = float64(t) case int8: t, _ := par...
interfacelib/interfacelib.go
0.643441
0.442335
interfacelib.go
starcoder
package dithering import ( "image" "image/color" "math" ) // PixelError represents the error for each canal in the image // when dithering an image // Errors are floats because they are the result of a division type PixelError struct { // TODO(brouxco): the alpha value does not make a lot of sense in a PixelError...
error.go
0.606382
0.541894
error.go
starcoder
package units const bunArea = "square metre" // areaFamily represents the collection of units of area var areaFamily = &Family{ baseUnitName: bunArea, description: "unit of area", name: Area, } // AreaNames maps names to units of area var areaNames = map[string]Unit{ // metric bunArea: { 0, 0, 1, a...
units/area.go
0.548915
0.535827
area.go
starcoder
package otp import ( "math" "net/url" "strconv" "time" ) // Time base one time password generator type TimeBased struct { // General calculation information Info // a function which retrieves the time which is used for calculation GetTimeFn func() time.Time // indicates how long a single otp is valid. Perio...
totp.go
0.68941
0.507507
totp.go
starcoder
package kyber //The first block of constants define internal parameters. //SEEDBYTES holds the lenght in byte of the random number to give as input, if wanted. //The remaining constants are exported to allow for fixed-lenght array instantiation. For a given security level, the consts are the same as the output of the ...
crystals-kyber/params.go
0.673406
0.412648
params.go
starcoder
package cruncher import ( "container/heap" "fmt" "io" "math" "sort" ) const ( // InitialRemedianSize is the number of entries pre-allocated for maintaining // the median InitialRemedianSize = 4 ) // IntStats contains all the stats accumulated. It's best to // maintain references only to the IntStats once the...
cruncher.go
0.700075
0.555435
cruncher.go
starcoder
package types import ( "math" "strconv" ) // Vector3 is a three-dimensional Euclidean vector. type Vector3 struct { X, Y, Z float32 } // NewVector3 returns a vector initialized with the given components. func NewVector3(x, y, z float64) Vector3 { return Vector3{X: float32(x), Y: float32(y), Z: float32(z)} } // ...
Vector3.go
0.930545
0.904144
Vector3.go
starcoder
package influxql import ( "encoding/binary" "errors" "fmt" "hash/fnv" "sort" "strings" "time" ) // DB represents an interface to the underlying storage. type DB interface { // Returns a list of series data ids matching a name and tags. MatchSeries(name string, tags map[string]string) []uint32 // Returns a ...
influxql/engine.go
0.715623
0.447883
engine.go
starcoder
package main import ( "sort" "strconv" "strings" ) type Pair struct { key int value int } type PairList []Pair func (p PairList) Len() int { return len(p) } func (p PairList) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p PairList) Less(i, j int) bool { return p[j].value < p[i].value } // ...
day7.go
0.629205
0.464051
day7.go
starcoder
package raymarcher import ( "math" "time" ) var ( NoPixel = D3{ X: math.Inf(1), Y: math.Inf(1), Z: math.Inf(1), } ) // Marcher is a ray-marcher which generates a 3D image. type Marcher struct { Epsilon float64 MaxSteps int MaxDepth float64 W int H int Worl...
raymarcher/raymarcher.go
0.667256
0.523116
raymarcher.go
starcoder
package main import ( "fmt" "math" rl "github.com/gen2brain/raylib-go/raylib" ) const MAX_INSTANCES = 100000 func main() { var ( screenWidth = int32(800) // Framebuffer width screenHeight = int32(450) // Framebuffer height fps = 60 // Frames per second speed ...
examples/shaders/mesh_instancing/main.go
0.684897
0.438785
main.go
starcoder
package treenode import ( "fmt" "strconv" "strings" ) // TreeNode Definition for a binary tree node. type TreeNode struct { Val int Left *TreeNode Right *TreeNode } // // 中序遍历 // func MiddleOrder(tn *TreeNode) string { // if tn.Left != nil { // MiddleOrder(tn.Left) // } // } /* Given the root node of ...
treenode/node.go
0.618665
0.544256
node.go
starcoder
package imageutil import ( "image" "runtime" "sync" ) // RP is a rectangle processor, any function that accepts a single // image.Rectangle value as an argument. type RP func(image.Rectangle) // PP is a point processor, any function that accepts a single image.Point // value as an argument. type PP func(image.Poi...
rectangle.go
0.827863
0.693259
rectangle.go
starcoder
package machine // ExecuteInstruction ... func ExecuteInstruction(computer Machine, instructionInstance Instruction) { switch instructionInstance.Opcode { case LoadConstantOpcode: constant := instructionInstance.Parameters[0] registerIndex := instructionInstance.Parameters[1] computer.Registers[registerIndex]...
execute_instruction.go
0.604049
0.446555
execute_instruction.go
starcoder
package gafit import ( "fmt" "math" "strings" "gonum.org/v1/gonum/mat" ) // Dataset is a type that represents a linear model type Dataset struct { X *mat.Dense Y *mat.VecDense // ColNames gives the name of the "feature" stored in each column of X ColNames []string TargetName string } // Copy returns a c...
gafit/dataset.go
0.729231
0.581541
dataset.go
starcoder
package h231 // Row of data table. type Row struct { ID string Description string Comment string } // Table of data. type Table struct { ID string Name string Row []Row } // TableLookup provides valid values for field types. var TableLookup = map[string]Table{ `0001`: {ID: `0001`, Name: `Sex`...
h231/table.go
0.698535
0.75021
table.go
starcoder
package aoc2015 /* --- Day 3: Perfectly Spherical Houses in a Vacuum --- Santa is delivering presents to an infinite two-dimensional grid of houses. He begins by delivering a present to the house at his starting location, and then an elf at the North Pole calls him via radio and tells him where to move next. Moves ar...
app/aoc2015/aoc2015_03.go
0.544559
0.735831
aoc2015_03.go
starcoder
package main import ( "fmt" "github.com/heimdalr/dag" "math" "time" ) type largeVertex struct { value int } // implement the interface{}'s interface method Id() func (v largeVertex) ID() string { return fmt.Sprintf("%d", v.value) } func main() { d := dag.NewDAG() root := largeVertex{1} key, _ := d.AddVerte...
cmd/timing/main.go
0.566258
0.432363
main.go
starcoder
package utils import ( "fmt" ) type ScaleParams struct { Offset float64 Scale float64 Clip float64 } func scale(r Raster, params ScaleParams) (*ByteRaster, error) { scale := float32(params.Scale) if scale <= 0.0 { if params.Clip <= 0.0 { scale = float32(1.0) } else { scale = float32(float32(254.0)...
utils/raster_scaler.go
0.575349
0.401189
raster_scaler.go
starcoder
package sceneitems import requests "github.com/andreykaipov/goobs/api/requests" /* SetSceneItemPropertiesParams represents the params body for the "SetSceneItemProperties" request. Sets the scene specific properties of a source. Unspecified properties will remain unchanged. Coordinates are relative to the item's par...
api/requests/scene_items/xx_generated.setsceneitemproperties.go
0.833019
0.401776
xx_generated.setsceneitemproperties.go
starcoder
package suncal import ( "fmt" . "math" "time" ) const ( // Private constants pi2 = 2 * Pi jd2000 = 2451545.0 ) type SunInfo struct { Rise time.Time Set time.Time } type GeoCoordinates struct { Latitude float64 Longitude float64 } func (c GeoCoordinates) String() string { return fmt.Sprintf("Latitud...
suncal.go
0.76207
0.487307
suncal.go
starcoder
package bookingclient import ( "encoding/json" "time" ) // ReservationAssignedUnitTimeRangeModel struct for ReservationAssignedUnitTimeRangeModel type ReservationAssignedUnitTimeRangeModel struct { // The start date and time of the period for which the unit is assigned to the reservation<br />A date and time (wit...
api/clients/bookingclient/model_reservation_assigned_unit_time_range_model.go
0.790409
0.469703
model_reservation_assigned_unit_time_range_model.go
starcoder
package main import ( "fmt" "io" ) func mainUsage(f io.Writer) { fmt.Fprint(f, mainHelp) } var mainHelp = ` gg is a cache-based wrapper around go generate directives. Usage: gg [-p n] [-r n] [-trace] [-skipCache] [-tags 'tag list'] [packages] gg runs go generate directives found in packages according to...
cmd/gg/help.go
0.589362
0.437703
help.go
starcoder
package geometry type Rect struct { Min, Max Point } func (rect Rect) Move(deltaX, deltaY float64) Rect { return Rect{ Min: Point{X: rect.Min.X + deltaX, Y: rect.Min.Y + deltaY}, Max: Point{X: rect.Max.X + deltaX, Y: rect.Max.Y + deltaY}, } } func (rect Rect) Index() []byte { return nil } func (rect Rect) ...
rect.go
0.868562
0.750404
rect.go
starcoder
package kdbush // Interface, that should be implemented by indexing structure // It's just simply returns points coordinates // Called once, only when index created, so you could calc values on the fly for this interface type Point interface { Coordinates() (X, Y float64) } // SimplePoint minimal struct, that implem...
kdbush.go
0.646349
0.55254
kdbush.go
starcoder
package iso20022 // Account between an investor(s) and a fund manager or a fund. The account can contain holdings in any investment fund or investment fund class managed (or distributed) by the fund manager, within the same fund family. type InvestmentAccount29 struct { // Name of the account. It provides an additio...
InvestmentAccount29.go
0.695441
0.447581
InvestmentAccount29.go
starcoder
package genworldvoronoi import ( "github.com/Flokey82/go_gens/vectors" "github.com/fogleman/delaunay" "log" "math" "math/rand" ) // generateFibonacciSphere generates a number of points along a spiral on a sphere. func generateFibonacciSphere(seed int64, numPoints int, jitter float64) []float64 { rnd := rand.New...
genworldvoronoi/sphere_mesh.go
0.841403
0.48749
sphere_mesh.go
starcoder
package main import "fmt" // An interface that has a single method, Invert type Inverter interface { Invert() } // Type TwoDPoint implements the Inverter interface type TwoDPoint struct { X, Y float64 } // Implicit implementation of the Inverter interface func (tdp *TwoDPoint) Invert() { tdp.X = -tdp.X tdp.Y = ...
go-code-examples/methods-interfaces/interfaces/interfaces.go
0.644001
0.51013
interfaces.go
starcoder
package otkafka import ( "time" "github.com/go-kit/kit/metrics" "github.com/segmentio/kafka-go" ) type writerCollector struct { factory WriterFactory stats *WriterStats interval time.Duration } // WriterStats is a collection of metrics for kafka writer info. type WriterStats struct { Writes metrics.Cou...
otkafka/writer_metrics.go
0.54359
0.441553
writer_metrics.go
starcoder
package renderer import ( "strings" "github.com/stackrox/rox/pkg/features" "github.com/stackrox/rox/pkg/images/defaults" "github.com/stackrox/rox/pkg/stringutils" ) // ComputeImageOverrides takes in a full image reference as well as default registries, names, // and tags, and computes the components of the image...
pkg/renderer/images.go
0.720958
0.438845
images.go
starcoder
package main import ( "github.com/ReconfigureIO/fixed" "github.com/ReconfigureIO/math/rand" ) // Ret is our return structure, which is the output of our mapper. // In order to simplify the implementation, we'll just calculate the // sum FPGA side, and divide by length to get the mean on the CPU. A // more robust i...
examples/monte-carlo/input.go
0.663124
0.701956
input.go
starcoder
package keeper import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/kava-labs/kava/x/incentive/types" ) // AccumulateHardDelegatorRewards updates the rewards accumulated for the input reward period func (k Keeper) AccumulateHardDelegatorRewards(ctx sdk.Context, rewardPeriod types.RewardPeriod) err...
x/incentive/keeper/rewards_delegator.go
0.733547
0.422088
rewards_delegator.go
starcoder
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) type tile struct { x, y int } func (t tile) String() string { return strconv.Itoa(t.x) + "," + strconv.Itoa(t.y) } const ( black bool = true white bool = false e string = "e" ne string = "ne" se string = "se" w string = "w" sw string = ...
day_24/main.go
0.502197
0.407392
main.go
starcoder
package timestore import ( "sort" "time" ) type BoolSamples struct { times []time.Time data []bool } func (s *BoolSamples) Len() int { return len(s.data) } func (s *BoolSamples) All() ([]bool, []time.Time) { return s.data, s.times } func (s *BoolSamples) Add(t time.Time, data bool) { // If this is our fir...
generated-binary.go
0.670716
0.461017
generated-binary.go
starcoder
package node // Parse tree - a binary tree of objects of type Node, // and associated utility functions and methods. import ( "bytes" "fmt" "io" "tableaux-in-go/src/lexer" ) // Node has all elements exported, everything reaches inside instances // of Node to find things out, or to change Left and Right. Private...
src/node/node.go
0.59514
0.428233
node.go
starcoder
package dataaccess // FmtDef defines the format of a csv data file for a security. type FmtDef struct { delimiter string header int columns int date string time string decimalDigits int } // Delimiter gets the delimiter of the csv file. func (fd FmtDef) Delimiter() string { r...
dataaccess/filedefs.go
0.640861
0.569793
filedefs.go
starcoder
package geojson import ( "encoding/json" "errors" "fmt" "strconv" ) // Position represents a longitude and latitude with optional elevation/altitude. type Position struct { Longitude float64 Latitude float64 Elevation OptionalFloat64 } // NewPosition from longitude and latitude. func NewPosition(long, lat fl...
position.go
0.916437
0.679069
position.go
starcoder
package proto import ( "encoding/json" "time" ) // TimeSinceEpoch UTC time in seconds, counted from January 1, 1970. // To convert a time.Time to TimeSinceEpoch, for example: // proto.TimeSinceEpoch(time.Now().Unix()) // For session cookie, the value should be -1. type TimeSinceEpoch float64 // Time interface...
lib/proto/patch.go
0.694717
0.418281
patch.go
starcoder
package lavatubes import ( "sort" "github.com/sneils/adventofcode2021/convert" ) type LavaTube struct { x, y, z int } type Region struct { tubes []LavaTube x, y int } func Parse(inputs []string) Region { region := Region{} region.x = len(inputs[0]) region.y = len(inputs) for y, row := range inputs { fo...
lavatubes/lavatubes.go
0.568655
0.451568
lavatubes.go
starcoder
package ixconfig import ( "strconv" ) // String stores v in a new string value and returns a pointer to it. func String(v string) *string { return &v } // Bool stores v in a new bool value and returns a pointer to it. func Bool(v bool) *bool { return &v } // NumberInt stores v in a new float32 value and returns a...
internal/ixconfig/multivalue.go
0.848408
0.435361
multivalue.go
starcoder
package decoder import ( "fmt" ) var feminineLeaning = ` This job description uses more words that are stereotypically feminine than words that are stereotypically masculine. Research suggests this will have only a slight effect on how appealing the job is to men, and will encourage women applicants. ` var masc...
pkg/decoder/results.go
0.555194
0.427815
results.go
starcoder
package world import ( "github.com/cebarks/TinGrizzly/internal/util" "github.com/cebarks/TinGrizzly/internal/world/tiles" "github.com/kelindar/tile" "github.com/rs/zerolog/log" ) type World struct { Lookup map[uint32]*TileData Grid *tile.Grid State *State Entities []*Entity } type tileUpdate struct ...
internal/world/world.go
0.565299
0.536313
world.go
starcoder
package graph // Graph represents a corresponding abstract data structure type Graph struct { vertexes map[int]Vertex edges map[string]Edge } // Vertex represents a graph node type Vertex struct { Value int Edges []*Edge } // Vertex represents a graph relation type Edge struct { Label string X, Y *Vertex } //...
Graph/graph.go
0.837221
0.684111
graph.go
starcoder
package popper import "errors" var ( // ErrEmptyElements is returned when a pop operation is attempted on an empty set of elements. ErrEmptyElements = errors.New("empty elements") // ErrElementNotFound is returned when the element designated to pop out of the collection is not found. ErrElementNotFound = errors.N...
popper.go
0.693265
0.540499
popper.go
starcoder
package main import ( "fmt" "math" "regexp" "strconv" ) func main() { // expected answer = 17 input := []string{ "1, 1", "1, 6", "8, 3", "3, 4", "5, 5", "8, 9", } coordinates := parseInput(input) grid := initGrid(coordinates) for y, row := range grid { for x := range row { closestInd := d...
cmd/06a/06a.go
0.520009
0.414247
06a.go
starcoder
package v1alpha1 // AcceleratorListerExpansion allows custom methods to be added to // AcceleratorLister. type AcceleratorListerExpansion interface{} // AcceleratorNamespaceListerExpansion allows custom methods to be added to // AcceleratorNamespaceLister. type AcceleratorNamespaceListerExpansion interface{} // Ban...
client/listers/ga/v1alpha1/expansion_generated.go
0.590307
0.425963
expansion_generated.go
starcoder
package main import ( "fmt" "image" "image/color" "math" "os" "sort" "golang.org/x/image/font" "golang.org/x/image/font/basicfont" "golang.org/x/image/math/fixed" "github.com/google/hilbert" ) // Source: https://gist.github.com/sergiotapia/7882944 func getImageFileDimension(imagePath string) (int, int, e...
bin/stitch/util.go
0.770896
0.431824
util.go
starcoder
package models import ( i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time" i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) // ExpirationPattern type ExpirationPattern struct { // Stores additional data no...
models/expiration_pattern.go
0.70253
0.402392
expiration_pattern.go
starcoder
package knot import "errors" var ( SlideError = errors.New("knot: cannot slide arc: must be next to the cross") UntwistError = errors.New("knot: cannot untwist cross: arc must cross itself") ) // Twist performs the first Reidemeister move. // The resulting new cross is returned for convenience. func Twist(a *Arc...
go/knot/reidemeister_moves.go
0.772917
0.434941
reidemeister_moves.go
starcoder
package parser import ( "strconv" ) type NumericLiteral struct { Node tok token } func (this *NumericLiteral) token() token { return this.tok } func (this *NumericLiteral) String() string { return this.tok.value } func (this *NumericLiteral) Float64Value() float64 { if len(this.tok.value) >= 3 && this.tok.va...
parser/ast_literals.go
0.586404
0.435902
ast_literals.go
starcoder
package gt import ( "database/sql/driver" "encoding/json" "strconv" ) /* Shortcut: parses successfully or panics. Should be used only in root scope. When error handling is relevant, use `.Parse`. */ func ParseNullUint(src string) (val NullUint) { try(val.Parse(src)) return } /* Variant of `uint64` where zero va...
gt_null_uint.go
0.751283
0.604107
gt_null_uint.go
starcoder
package cron import ( "time" ) type job struct { Month, Day, Weekday int8 Hour, Minute, Second int8 Task func(time.Time) } const any = -1 var ( jobs []job CheckDelay = time.Duration(1 * time.Second) // minimum delay between checks ) // This function creates a new job that occurs at the...
cron.go
0.605099
0.418697
cron.go
starcoder
package schema import ( "context" "fmt" ) // EncodeScalar is a function that is capable of turning a Go value into // a literal value type EncodeScalar func(ctx context.Context, v interface{}) (LiteralValue, error) // DecodeScalar is a function that is capable of turning a literal value // into a Go value type De...
schema/scalar.go
0.777764
0.421611
scalar.go
starcoder
package model import ( "sort" ) // SeparatorByte is a byte that cannot occur in valid UTF-8 sequences and is // used to separate label names, label values, and other strings from each other // when calculating their combined hash value (aka signature aka fingerprint). const SeparatorByte byte = 255 var ( // cache...
vendor/gx/ipfs/QmSERhEpow33rKAUMJq8yfJVQjLmdABGg899cXg7GcX1Bk/common/model/signature.go
0.761006
0.600716
signature.go
starcoder
package main // SimulationShader defines shader sources for a simulation. // This implements the Wireworld rules. var SimulationShader = ShaderSource{ Vertex: ` #version 420 layout(location = 0) in vec2 vertPos; layout(location = 1) in vec2 vertUV; out vec2 fragUV; void main() { gl_Position = vec4(vert...
shader_simulation.go
0.650689
0.568356
shader_simulation.go
starcoder
package solver import ( "fmt" ) // A Problem is a list of clauses & a nb of vars. type Problem struct { NbVars int // Total nb of vars Clauses []*Clause // List of non-empty, non-unit clauses Status Status // Status of the problem. Can be trivially UNSAT (if empty clause was met or inferred...
solver/problem.go
0.644896
0.45532
problem.go
starcoder
package interpreter import "piquant/lang/ast" func specialQuote(e Env, head ast.Node, args []ast.Node) packet { return respond(args[0]) } func specialApply(e Env, head ast.Node, args []ast.Node) packet { f := args[0] l := toListValue(trampoline(func() packet { return evalNode(e, args[1]) })) nodes := append([...
lang/interpreter/specials.go
0.567937
0.402715
specials.go
starcoder
package miner import ( "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/abi/big" "github.com/filecoin-project/specs-actors/actors/builtin" ) // IP = InitialPledgeFactor * BR(precommit time) var InitialPledgeFactor = big.NewInt(20) // FF = (DeclaredFaultFactorN...
actors/builtin/miner/monies.go
0.580709
0.463444
monies.go
starcoder
package tracer import ( "math" "math/rand" "github.com/go-gl/mathgl/mgl64" ) type Bounce struct { Attenuation mgl64.Vec3 Scattered Ray } type Material interface { Scatter(ray Ray, rec *HitRecord) *Bounce } type Lambertian struct { Albedo mgl64.Vec3 } func (l Lambertian) Scatter(ray Ray, rec *HitRecord) *...
material.go
0.800614
0.433682
material.go
starcoder
package matchers import ( "fmt" "reflect" "github.com/bsm/gomega/format" ) type PanicMatcher struct { Expected interface{} object interface{} } func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error) { if actual == nil { return false, fmt.Errorf("PanicMatcher expects a non-nil act...
matchers/panic_matcher.go
0.744749
0.42054
panic_matcher.go
starcoder
package function import ( "fmt" "regexp" "runtime" "strings" "sync" ) // Namespace is a representation of a location of a function. type Namespace string // NewNamespace creates a new namespace from a string. func NewNamespace(s string) (ns Namespace) { ns = Namespace(s) return ns } // DeepCopy creates a cop...
function/registry.go
0.786828
0.492005
registry.go
starcoder
package slack import ( "fmt" "github.com/sbstjn/hanu" ) /* Contains some of the "gopher" bot's commands taken from the https://gophers.slack.com/messages/@gopher/. */ const gopherNewbieResourcesReply = `Here are some resources you should check out if you are learning / new to Go: First you should take the languag...
slack/command_gopher.go
0.715126
0.53437
command_gopher.go
starcoder
package matchers import ( "errors" "fmt" "github.com/splitio/go-split-commons/dtos" "github.com/splitio/go-toolkit/injection" "github.com/splitio/go-toolkit/logging" ) const ( // MatcherTypeAllKeys string value MatcherTypeAllKeys = "ALL_KEYS" // MatcherTypeInSegment string value MatcherTypeInSegment = "IN_S...
splitio/engine/grammar/matchers/matchers.go
0.599368
0.428831
matchers.go
starcoder
package ledgerstate import ( "fmt" "github.com/iotaledger/hive.go/cerrors" "github.com/iotaledger/hive.go/marshalutil" "golang.org/x/xerrors" ) const ( // Pending represents the state of Transactions and Branches that have not been assigned a final state regarding // their inclusion in the ledger state. Pendi...
packages/ledgerstate/inclusion_state.go
0.70477
0.414247
inclusion_state.go
starcoder
package state import ( "math/big" "github.com/hyperledger/burrow/genesis" "github.com/hyperledger/burrow/acm/validator" "github.com/hyperledger/burrow/storage" "github.com/hyperledger/burrow/crypto" ) // Initialises the validator Ring from the validator storage in forest func LoadValidatorRing(version int64, ...
execution/state/validators.go
0.646237
0.426441
validators.go
starcoder