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 ts
import (
"fmt"
"time"
)
// Resolution is used to enumerate the different resolution values supported by
// ZNBase.
type Resolution int64
func (r Resolution) String() string {
switch r {
case Resolution10s:
return "10s"
case Resolution30m:
return "30m"
case resolution1ns:
return "1ns"
case re... | pkg/ts/resolution.go | 0.841598 | 0.496704 | resolution.go | starcoder |
package carbon
import (
"bytes"
"time"
)
// formats common formatting symbols
// 常规格式化符号
var formats = map[byte]string{
'd': "02", // Day: Day of the month, 2 digits with leading zeros. Eg: 01 to 31.
'D': "Mon", // Day: A textual representation of a day, three le... | helper.go | 0.548674 | 0.508361 | helper.go | starcoder |
package lnk
import (
"encoding/binary"
"encoding/hex"
"fmt"
"io"
"strings"
)
// ExtraDataSection represents section 2.5 of the specification.
type ExtraDataSection struct {
Blocks []ExtraDataBlock
// Terminal block at the end of the ExtraData section.
// Value must be smaller than 0x04.
TerminalBlock uint32
... | extradata.go | 0.606732 | 0.4133 | extradata.go | starcoder |
package code
import "math"
func Unreachable() Instruction {
return Instruction{Opcode: OpUnreachable}
}
func Nop() Instruction {
return Instruction{Opcode: OpNop}
}
func Block(blockType ...uint64) Instruction {
typ := uint64(BlockTypeEmpty)
if len(blockType) != 0 {
typ = blockType[0]
}
return Instruction{Op... | wasm/code/instructions.go | 0.783409 | 0.539711 | instructions.go | starcoder |
package staticarray
import (
"github.com/influxdata/flux/array"
"github.com/influxdata/flux/memory"
"github.com/influxdata/flux/semantic"
"github.com/influxdata/flux/values"
)
type times struct {
data []values.Time
alloc *memory.Allocator
}
func Time(data []values.Time) array.Time {
return ×{data: data}... | internal/staticarray/time.go | 0.651798 | 0.552057 | time.go | starcoder |
package main
// Rect is a position, width and height
type Rect struct {
X int
Y int
W int
H int
}
// Box has one outer and one innner rectangle.
// This is useful when having margins that surrounds content.
type Box struct {
frame *Rect // The rectangle around the box, for placement
inner *Rect // The rectangle... | cmd/widget/boxes.go | 0.909581 | 0.461138 | boxes.go | starcoder |
package pilosa
import (
"fmt"
"github.com/m3dbx/pilosa/roaring"
)
// iterator is an interface for looping over row/column pairs.
type iterator interface {
Seek(rowID, columnID uint64)
Next() (rowID, columnID uint64, eof bool)
}
// bufIterator wraps an iterator to provide the ability to unread values.
type bufI... | iterator.go | 0.776708 | 0.541348 | iterator.go | starcoder |
package tetra3d
import "github.com/kvartborg/vector"
// The goal of fastmath.go is to provide vector operations that don't clone the vector to use. This means the main usage is not to use the results
// directly, but rather as intermediary steps (i.e. use fastVectorSub to compare distances, or fastMatrixMult to multi... | fastmath.go | 0.697815 | 0.700319 | fastmath.go | starcoder |
package util
var LittleEndian littleEndian
// BigEndian is the big-endian implementation of ByteOrder.
var BigEndian bigEndian
type littleEndian struct{}
func (littleEndian) Uint16(b []byte) uint16 { return uint16(b[0]) | uint16(b[1])<<8 }
func (littleEndian) PutUint16(b []byte, v uint16) {
b[0] = byte(v)
b[1] =... | bblive/util/util.go | 0.511473 | 0.516656 | util.go | starcoder |
package permits
import (
"sync"
"time"
"k8s.io/klog/v2"
)
// PermitGiver provides different operations regarding permit for a given key
type PermitGiver interface {
RegisterPermits(key string, numPermits int)
TryPermit(key string, timeout time.Duration) bool
ReleasePermit(key string)
DeletePermits(key string)... | vendor/github.com/gardener/machine-controller-manager/pkg/util/permits/permits.go | 0.578805 | 0.404037 | permits.go | starcoder |
package ent
import (
"fmt"
"time"
"github.com/jmoiron/sqlx"
"github.com/lolopinto/ent/ent/sql"
)
// LoadNodeRawData is the public API to load the raw data for an ent without privacy checks
func LoadNodeRawData(id string, entLoader Loader) (map[string]interface{}, error) {
l := &loadNodeLoader{
id: id,... | ent/primitives.go | 0.680135 | 0.411998 | primitives.go | starcoder |
package output
import (
"encoding/json"
"errors"
"sync/atomic"
"time"
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/processor/condition"
"github.com/Jeffail/benthos/lib/response"
"github.com/Jeffail/benthos/lib/types"
"github.com/Jeffail/benth... | lib/output/switch.go | 0.714329 | 0.518912 | switch.go | starcoder |
package util
import (
"reflect"
"strconv"
"mongoid/log"
)
// MarshalFromDB casts the given fromValue into the given intoType according to expected DB value conversions, returning an interface to the newly cast value.
// If fromValue is already the type of intoType, it may be returned directly, but it is not guara... | util/marshal_from_db.go | 0.59514 | 0.564819 | marshal_from_db.go | starcoder |
package util
import (
"bytes"
"encoding/binary"
"fmt"
"math/big"
"time"
)
const (
// uint256Size is the number of bytes needed to represent an unsigned
// 256-bit integer.
uint256Size = 32
)
// BigToLEUint256 returns the passed big integer as an unsigned 256-bit integer
// encoded as little-endian bytes. N... | util/conversion.go | 0.738103 | 0.421433 | conversion.go | starcoder |
package image
import (
"fmt"
"image"
"image/color"
"image/draw"
statepb "github.com/GoogleCloudPlatform/testgrid/pb/state"
tspb "github.com/GoogleCloudPlatform/testgrid/pb/test_status"
"github.com/GoogleCloudPlatform/testgrid/pkg/updater"
)
var Decode = image.Decode
// Tiles converts a tile-set image into an... | hackathon/pkg/image/image.go | 0.657978 | 0.469885 | image.go | starcoder |
package dataset
import (
"path"
log "github.com/unchartedsoftware/plog"
"github.com/uncharted-distil/distil-compute/model"
"github.com/uncharted-distil/distil-compute/primitive/compute"
"github.com/uncharted-distil/distil/api/env"
"github.com/uncharted-distil/distil/api/serialization"
)
// D3M captures the n... | api/dataset/d3m.go | 0.608361 | 0.447581 | d3m.go | starcoder |
package plaid
import (
"encoding/json"
)
// InvestmentTransaction A transaction within an investment account.
type InvestmentTransaction struct {
// The ID of the Investment transaction, unique across all Plaid transactions. Like all Plaid identifiers, the `investment_transaction_id` is case sensitive.
Investment... | plaid/model_investment_transaction.go | 0.820937 | 0.572125 | model_investment_transaction.go | starcoder |
// Collection of comparison functions used in testing
package compare
import (
"fmt"
"os"
"regexp"
"testing"
)
func SkipOnDemand(envVar string, t *testing.T) {
if os.Getenv(envVar) != "" {
t.Skip(fmt.Sprintf("Skipped on user request: environment variable '%s' was set ", envVar))
}
}
func OkIsNil(label strin... | compare/compare.go | 0.665628 | 0.548432 | compare.go | starcoder |
package pdk
import (
"log"
"time"
)
// Statter is the interface that stats collectors must implement to get stats out of the PDK.
type Statter interface {
Count(name string, value int64, rate float64, tags ...string)
Gauge(name string, value float64, rate float64, tags ...string)
Histogram(name string, value fl... | statlogiface.go | 0.692746 | 0.422981 | statlogiface.go | starcoder |
package ocr
import (
"errors"
"strings"
)
// Recognize returns the numbers in the given 3 x 4 grids of pipes, underscores, and spaces.
// Non recognized digits are returned as '?'.
func Recognize(input string) (numbers []string) {
partitionedInput, err := partitionInput(input)
if err != nil {
return []string{"?... | solutions/go/ocr-numbers/ocr_numbers.go | 0.579876 | 0.474814 | ocr_numbers.go | starcoder |
package anansi
import (
"bytes"
"io"
"unicode/utf8"
"github.com/jcorbin/anansi/ansi"
)
// Buffer implements a deferred buffer of ANSI output, providing
// convenience methods for writing various ansi escape sequences, and keeping
// an observant processor up to date.
type Buffer struct {
buf bytes.Buffer
off i... | buffer.go | 0.709724 | 0.415017 | buffer.go | starcoder |
package main
import (
"fmt"
"path/filepath"
"github.com/derWhity/AdventOfCode/lib/input"
)
// grid represents a 3-dimensional grid of cube states
type grid map[int]map[int]map[int]bool
func (g grid) set(x, y, z int, val bool) {
plane, ok := g[x]
if !ok {
plane = map[int]map[int]bool{}
g[x] = plane
}
row,... | 2020/day_17/star_01/main.go | 0.546254 | 0.456107 | main.go | starcoder |
package siastats
import (
"encoding/json"
)
// PlotBand struct for PlotBand
type PlotBand struct {
Color *string `json:"color,omitempty"`
From *int64 `json:"from,omitempty"`
To *int64 `json:"to,omitempty"`
Label *PlotBandLabel `json:"label,omitempty"`
}
// NewPlotBand instantiates a ... | model_plot_band.go | 0.852537 | 0.428114 | model_plot_band.go | starcoder |
package vibrant
import (
"image/color"
)
// Constants used for manipulating a QuantizedColor.
const (
quantizeWordWidth = 5
quantizeWordMask = (1 << quantizeWordWidth) - 1
shouldRoundUpMask = 1 << ((8 - quantizeWordWidth) - 1)
roundUpMask = shouldRoundUpMask << 1
)
// QuantizedColorSlice attaches the met... | vendor/github.com/RobCherry/vibrant/quantized_color.go | 0.777764 | 0.461805 | quantized_color.go | starcoder |
package shapes
import (
"image"
"github.com/remogatto/mathgl"
gl "github.com/remogatto/opengles2"
"github.com/remogatto/shaders"
)
var (
// DefaultSegmentVS is a default vertex shader for the segment.
DefaultSegmentVS = (shaders.VertexShader)(
`precision mediump float;
attribute vec4 pos;
... | segment.go | 0.803714 | 0.454593 | segment.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTExportModelEdgeGeometry1125 struct for BTExportModelEdgeGeometry1125
type BTExportModelEdgeGeometry1125 struct {
BtType *string `json:"btType,omitempty"`
EndPoint *BTVector3d389 `json:"endPoint,omitempty"`
EndVector *BTVector3d389 `json:"endVector,omitempty"`
Lengt... | onshape/model_bt_export_model_edge_geometry_1125.go | 0.792344 | 0.529203 | model_bt_export_model_edge_geometry_1125.go | starcoder |
package types
import (
"strings"
"time"
)
const (
//TimeLongMonth long format of month
TimeLongMonth = "January"
//TimeMonth format of month
TimeMonth = "Jan"
//TimeNumMonth number format of month
TimeNumMonth = "1"
//TimeZeroMonth zero format of month
TimeZeroMonth = "01"
//TimeLongWeekDay long format o... | types/time_helper.go | 0.514888 | 0.468 | time_helper.go | starcoder |
package day21
import "fmt"
func Transformations(pattern string) []string {
size := sizeOf(pattern)
if instructions, found := transformations[size]; found {
return transformPattern(pattern, instructions)
} else {
panic(fmt.Sprintln("Grid size something other than 2 or 3:", size))
}
}
func transformPattern(pat... | go/2017/day21/transform.go | 0.560253 | 0.5564 | transform.go | starcoder |
package iterator
import (
"sync/atomic"
"github.com/apache/arrow/go/arrow"
"github.com/apache/arrow/go/arrow/array"
"github.com/gomem/gomem/internal/debug"
)
// StepValue holds the value for a given step.
type StepValue struct {
Values []interface{}
ValuesJSON []interface{}
Exists []bool
Dtypes ... | pkg/iterator/stepiterator.go | 0.672332 | 0.407864 | stepiterator.go | starcoder |
package value
import (
"fmt"
"strings"
)
type Row []Value
func (r *Row) String() string {
result := make([]string, len(*r))
for i, val := range *r {
result[i] = val.String()
}
return strings.Join(result, "\t")
}
type Value interface {
Gt(Value) bool
Ge(Value) bool
Lt(Value) bool
Le(Value) bool
Eq(Value... | value/value.go | 0.585931 | 0.413181 | value.go | starcoder |
package dog
import (
"github.com/emer/etable/etable"
"github.com/emer/etable/etensor"
"github.com/goki/mat32"
)
// dog.Filter specifies a DoG Difference of Gaussians filter function.
type Filter struct {
On bool `desc:"is this filter active?"`
Wt float32 `viewif:"On" desc:"how much relative we... | dog/dog.go | 0.740268 | 0.44354 | dog.go | starcoder |
package asetypes
import (
"bytes"
"encoding/binary"
"fmt"
"strings"
"time"
"unicode/utf16"
"github.com/SAP/go-dblib/asetime"
)
// GoValue returns a value-interface based on a given byte slice and
// depending on the ASE data type.
func (t DataType) GoValue(endian binary.ByteOrder, bs []byte) (interface{}, er... | asetypes/goValue.go | 0.578567 | 0.478285 | goValue.go | starcoder |
package transform
import (
"kanzi/util"
)
// Bijective version of the Burrows-Wheeler Transform
// The main advantage over the regular BWT is that there is no need for a primary
// index (hence the bijectivity). BWTS is about 10% slower than BWT.
// Forward transform based on the code at https://code.google.com/p/mk... | go/src/kanzi/transform/BWTS.go | 0.714628 | 0.420897 | BWTS.go | starcoder |
package bytes
import (
"errors"
)
var (
// ErrNoEnoughHeader represents no enough space for header to store data in a buffer.
ErrNoEnoughHeader = errors.New("bytes.WriteOnlyBuffer: no enough header space to write")
)
// WriteOnlyBuffer defines a buffer only used for easy-write and full-read.
// For write header, ... | bytes/writeonly_buffer.go | 0.625781 | 0.411052 | writeonly_buffer.go | starcoder |
package canvas
import (
"image"
"image/color"
"math"
"github.com/Laughs-In-Flowers/warhola/lib/util/mth"
"github.com/Laughs-In-Flowers/warhola/lib/util/prl"
"github.com/Laughs-In-Flowers/xrr"
)
// An interface for performing (relatively default & easy) operations on an image.
type Operator interface {
Adjuste... | lib/canvas/operator.go | 0.639286 | 0.519948 | operator.go | starcoder |
package main
import (
"fmt"
"math/rand"
"time"
)
import (
"github.com/nickdavies/go-astar/astar"
)
func main() {
var start_t int64
var end_t int64
var seed int64 = 0
// Setup the aStar structs
ast := astar.NewAStar(50, 50)
p2p := astar.NewPointToPoint()
p2l := astar.Ne... | example.go | 0.567457 | 0.471771 | example.go | starcoder |
package yamlpath
/*
filterNode represents a node of a filter expression parse tree. Each node is labelled with a lexeme.
Terminal nodes have one of the following lexemes: root, lexemeFilterAt, lexemeFilterIntegerLiteral,
lexemeFilterFloatLiteral, lexemeFilterStringLiteral.
root and lexemeFilterAt nodes al... | pkg/yamlpath/filter_parser.go | 0.888209 | 0.789153 | filter_parser.go | starcoder |
package merkletree
import (
"bytes"
"errors"
"fmt"
)
type RootMismatchError struct {
ExpectedRoot []byte
CalculatedRoot []byte
}
func (e RootMismatchError) Error() string {
return fmt.Sprintf("calculated root:\n%v\n does not match expected root:\n%v", e.CalculatedRoot, e.ExpectedRoot)
}
// MerkleVerifier is... | vendor/github.com/cloudflare/cfssl/vendor/github.com/google/certificate-transparency/go/merkletree/merkle_verifier.go | 0.728941 | 0.572215 | merkle_verifier.go | starcoder |
package redisai
import (
"fmt"
"github.com/RedisAI/redisai-go/redisai/converters"
"github.com/gomodule/redigo/redis"
"reflect"
)
// TensorInterface is an interface that represents the skeleton of a tensor ( n-dimensional array of numerical data )
// needed to map it to a RedisAI Model with the proper operations
t... | redisai/tensor.go | 0.52975 | 0.601828 | tensor.go | starcoder |
package rog
// FOVAlgo takes a FOVMap x,y vantage, radius of the view, whether to include walls and then marks in the map which cells are viewable.
type FOVAlgo func(*Map, int, int, int, bool)
func max(a, b int) int {
if a > b {
return a
}
return b
}
func min(a, b int) int {
if a < b {
return a
}
return b
... | fov.go | 0.592549 | 0.572125 | fov.go | starcoder |
// Quicksort is a divide and conquer algorithm. Quicksort first divides a large array into two smaller sub-arrays: the
// low elements and the high elements. Quicksort can then recursively sort the sub-arrays.
// The steps are:
// Pick an element, called a pivot, from the array.
// Partitioning: reorder the array so t... | quick-sort/quickSort.go | 0.752649 | 0.752149 | quickSort.go | starcoder |
package iso20022
// Structured information supplied to enable the matching, ie, reconciliation, of a payment with the items that the payment is intended to settle, eg, commercial invoices in an accounts receivable system.
type StructuredRemittanceInformation2 struct {
// Specifies the nature of the referred document... | StructuredRemittanceInformation2.go | 0.748444 | 0.424531 | StructuredRemittanceInformation2.go | starcoder |
package bruteForce
import (
"image/color"
compgeo "github.com/200sc/go-compgeo"
"github.com/200sc/go-compgeo/dcel"
"github.com/200sc/go-compgeo/dcel/pointLoc"
"github.com/200sc/go-compgeo/dcel/pointLoc/visualize"
"github.com/200sc/go-compgeo/geom"
)
// PlumbLine method is a name for a linear PIP check that
//... | dcel/pointLoc/bruteForce/plumbline.go | 0.809238 | 0.420719 | plumbline.go | starcoder |
package bloom
import (
"fmt"
"math"
"github.com/damnever/bitarray"
"github.com/spaolacci/murmur3"
)
// Bloom interface encapsulates our useful features
type Bloom interface {
Add(item string) error
Check(item string) (bool, error)
}
type bloom struct {
// Public Vars
Capacity int
ErrorRate float64
// P... | pkg/bloom/bloom.go | 0.643441 | 0.439687 | bloom.go | starcoder |
package strategy
import (
"github.com/zimmski/tavor/log"
"github.com/zimmski/tavor/rand"
"github.com/zimmski/tavor/token"
"github.com/zimmski/tavor/token/sequences"
)
// RandomStrategy implements a fuzzing strategy that generates a random permutation of a token graph.
// The strategy does exactly one iteration wh... | fuzz/strategy/random.go | 0.596316 | 0.40116 | random.go | starcoder |
package srg
import (
"github.com/serulian/compiler/compilergraph"
"github.com/serulian/compiler/sourceshape"
)
// SRGImplementableIterator is an iterator of SRGImplementable's.
type SRGImplementableIterator struct {
nodeIterator compilergraph.NodeIterator
srg *SRG // The parent SRG.
}
func (sii SRGImpl... | graphs/srg/implementable.go | 0.756178 | 0.504455 | implementable.go | starcoder |
package mario
type AllOne struct {
list *frequencyList // freq list
freqNodeMap map[int]*frequencyNode // freq - freq node
keyNodeMap map[string]*keysNode // key - key node
}
func Constructor() AllOne {
return AllOne{
list: newFrequencyList(),
freqNodeMap: make(map[int]*frequencyNode)... | solutions/1-1000/401-500/431-440/432/main.go | 0.513912 | 0.403743 | main.go | starcoder |
package strdist
import (
"strings"
"unicode/utf8"
)
// DfltHammingFinder is a HammingFinder with some suitable default values
// already set.
var DfltHammingFinder *Finder
// CaseBlindHammingFinder is a HammingFinder with some suitable default
// values already set.
var CaseBlindHammingFinder *Finder
func init() ... | strdist/hamming.go | 0.659295 | 0.40251 | hamming.go | starcoder |
package gonpy
//go:generate go run gen.go defs.template
import (
"encoding/binary"
"fmt"
"io"
"os"
"regexp"
"strconv"
"strings"
)
// NpyReader can read data from a Numpy binary array into a Go slice.
type NpyReader struct {
// The numpy data type of the array
Dtype string
// The endianness of the binary ... | reader.go | 0.663669 | 0.441131 | reader.go | starcoder |
package cipherio;
// A reader specifically for encrypted data.
// This will wrap another reader that is expected to deliver encrypted content.
// This will buffer any content necessary to get enough data to decrypt chunks.
import (
"crypto/cipher"
"io"
"syscall"
"github.com/pkg/errors"
"github.com/er... | cipherio/reader.go | 0.7413 | 0.400984 | reader.go | starcoder |
package tchart
import (
"fmt"
)
var dots = []rune{' ', '⠂', '▤', '▥'}
// Segment represents a dial segment.
type Segment []int
// Segments represents a collection of segments.
type Segments []Segment
// Matrix represents a number dial.
type Matrix [][]rune
// Orientation tracks char orientations.
type Orientatio... | internal/tchart/dot_matrix.go | 0.778986 | 0.508788 | dot_matrix.go | starcoder |
package ghcdieselfuelprice
import (
"fmt"
"time"
"github.com/gobuffalo/pop/v5"
"go.uber.org/zap"
"github.com/transcom/mymove/pkg/models"
"github.com/transcom/mymove/pkg/unit"
)
func priceInMillicents(price float64) unit.Millicents {
priceInMillicents := unit.Millicents(int(price * 100000))
return priceInMi... | pkg/services/ghcdieselfuelprice/ghc_diesel_fuel_price_storer.go | 0.717507 | 0.4184 | ghc_diesel_fuel_price_storer.go | starcoder |
package config
import (
"reflect"
"sort"
"github.com/go-yaml/yaml"
)
// LastCompareField returns last equal compared field of IsEqualTo evaluation.
func (a *Container) LastCompareField() string {
return a.lastCompareField
}
// IsEqualTo compares the container spec against another one.
// It returns false if at ... | src/compose/config/compare.go | 0.631481 | 0.441553 | compare.go | starcoder |
package main
import (
"io/ioutil"
"net/url"
"path"
"strings"
"sync"
"net/http"
)
// SmokeTest contains a URI and expected status code.
type SmokeTest struct {
URI string `json:"uri"`
ExpectedStatusCode int `json:"status_code"`
Content string `json:"content"`
}
// SmokeTestResult... | vape.go | 0.661048 | 0.435181 | vape.go | starcoder |
package tengo
import (
"errors"
"fmt"
"strings"
)
var (
// ErrStackOverflow is a stack overflow error.
ErrStackOverflow = errors.New("stack overflow")
// ErrObjectAllocLimit is an objects allocation limit error.
ErrObjectAllocLimit = errors.New("object allocation limit exceeded")
// ErrIndexOutOfBounds is a... | errors.go | 0.68679 | 0.419262 | errors.go | starcoder |
package cybuf
import (
"reflect"
)
type CyBufType int
const (
CyBufType_Invalid CyBufType = iota
CyBufType_Nil
CyBufType_Bool
CyBufType_Integer
CyBufType_Char
CyBufType_Float
CyBufType_String
CyBufType_Array
CyBufType_Object
)
func GetInterfaceValueType(v interface{}) CyBufType {
realValue := reflect.Typ... | common/type.go | 0.557845 | 0.477006 | type.go | starcoder |
package interpreter
import (
"fmt"
"github.com/smackem/ylang/internal/lang"
"math"
"reflect"
)
type Line struct {
Point1 Point
Point2 Point
}
func (l Line) Compare(other Value) (Value, error) {
if r, ok := other.(Line); ok {
if l == r {
return Number(0), nil
}
}
return Boolean(lang.FalseVal), nil
}
... | internal/interpreter/line.go | 0.725746 | 0.459197 | line.go | starcoder |
package swu
import (
"math/big"
)
// GF represents galois field over prime
type GF struct {
P *big.Int
}
var (
one = big.NewInt(1)
two = big.NewInt(2)
three = big.NewInt(3)
four = big.NewInt(4)
)
//Neg negates number over GFp
func (g *GF) Neg(a *big.Int) *big.Int {
return new(big.Int).Sub(g.P, a)
}
//N... | swu/gf.go | 0.817283 | 0.441854 | gf.go | starcoder |
package store
import (
"github.com/FourthState/plasma-mvp-sidechain/plasma"
ethcmn "github.com/ethereum/go-ethereum/common"
"math/big"
)
// Wallet holds reference to the total balance, unspent, and spent outputs
// at a given address
type Wallet struct {
Balance *big.Int // total amount available to be s... | store/types.go | 0.646349 | 0.407068 | types.go | starcoder |
package exp
import (
"fmt"
"math"
"strconv"
"github.com/spf13/cobra"
"github.com/timebertt/grypto/modular"
)
func NewCommand() *cobra.Command {
var base, exp, mod int32
cmd := &cobra.Command{
Use: "exp [base] [exponent] [modulus]",
Aliases: []string{"mod-exp", "square-and-multiply"},
... | grypto/cmd/exp/exp.go | 0.776326 | 0.438424 | exp.go | starcoder |
package kubernetes
import "fmt"
// Swagger is a map of schema keys to schema objects loaded in from a swagger file.
type Swagger struct {
Definitions map[string]*Schema
}
// Schema is a swagger schema. I'm sure there's a real definition somewhere but this gets everything this program needs.
type Schema struct {
//... | internal/kubernetes/types.go | 0.508788 | 0.409693 | types.go | starcoder |
package mesh
import (
"errors"
"io"
"github.com/EliCDavis/vector"
)
// Model is built with a collection of polygons
type Model struct {
faces []Polygon
}
// NewModel builds a new model
func NewModel(faces []Polygon) (Model, error) {
if faces == nil {
return Model{}, errors.New("Can not have nil faces")
}
... | model.go | 0.827932 | 0.468 | model.go | starcoder |
package utils
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
)
type ByteSlice struct {
data []byte
cursor uint32
}
func NewByteSlice(bytes []byte) *ByteSlice {
return &ByteSlice{bytes, 0}
}
func (self *ByteSlice) At() uint32 {
return self.cursor
}
func (self *ByteSlice) Size() uint32 {
return uint32... | utils/bytes.go | 0.721253 | 0.438485 | bytes.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// Filter
type Filter struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as w... | models/filter.go | 0.679179 | 0.504639 | filter.go | starcoder |
package aoc2021
import (
"fmt"
"github.com/simonski/goutils"
)
/*
--- Day 16: Packet Decoder ---
As you leave the cave and reach open waters, you receive a transmission from the Elves back on the ship.
The transmission was sent using the Buoyancy Interchange Transmission System (BITS), a method of packing numeric... | app/aoc2021/aoc2021_16.go | 0.724091 | 0.734667 | aoc2021_16.go | starcoder |
import (
"github.com/kaitai-io/kaitai_struct_go_runtime/kaitai"
"io"
)
/**
* A structured binary format native to Minecraft for saving game data and transferring
* it over the network (in multiplayer), such as player data
* ([`<player>.dat`](https://minecraft.gamepedia.com/Player.dat_format); contains
* e.g. p... | minecraft_nbt/src/go/minecraft_nbt.go | 0.695338 | 0.409398 | minecraft_nbt.go | starcoder |
package isc
type ISCListToMap[T any, R any] struct {
ISCList[T]
}
func ListToMapFrom[T any, R any](list ISCList[T]) ISCListToMap[T, R] {
return ISCListToMap[T, R]{
list,
}
}
func (l ISCListToMap[T, R]) FlatMap(f func(T) []R) ISCList[R] {
return ListFlatMap(l.ISCList, f)
}
func (l ISCListToMap[T, R]) FlatMapIn... | isc/listobj_ext.go | 0.517815 | 0.47244 | listobj_ext.go | starcoder |
package query
import (
"bytes"
"encoding/gob"
"fmt"
"github.com/goradd/goradd/pkg/datetime"
"log"
"reflect"
"strings"
"time"
)
// ValueNode represents a value for a built-in type that is to be used in a query.
type ValueNode struct {
value interface{}
}
// Shortcut for converting a constant value to a node
... | pkg/orm/query/valueNode.go | 0.593138 | 0.416797 | valueNode.go | starcoder |
package datasheet
import (
"fmt"
"io"
)
// ActionStore stores all of the Action data. Note that querying actions
// directly on the map will result in an empty Omen field. You should use
// GetAction in order to have an action with a correctly populated field.
type ActionStore struct {
Actions map[uint32]Acti... | core/datasheet/action.go | 0.607314 | 0.420778 | action.go | starcoder |
package geom
import (
"math/rand"
"github.com/paulmach/orb"
"github.com/paulmach/orb/clip"
"github.com/paulmach/orb/geojson"
"github.com/paulmach/orb/planar"
"github.com/paulmach/orb/quadtree"
)
// CentroidPoint is used to manage generating a quadtree while referencing a GeoJSON Feature
// Based on example htt... | pkg/geom/geom.go | 0.869382 | 0.537891 | geom.go | starcoder |
package ink
import (
"fmt"
"strings"
)
// Node represents an abstract syntax tree (AST) node in an Ink program.
type Node interface {
String() string
Position() position
Eval(*StackFrame, bool) (Value, error)
}
// a string representation of the Position of a given node,
// appropriate for an error message
func ... | pkg/ink/parser.go | 0.763836 | 0.427456 | parser.go | starcoder |
package tuplefunc
import (
"context"
"github.com/rogpeppe/generic/tuple"
)
// WithContextAR returns a function with a context argument that
// calls f without the context and returns its result.
func WithContextAR[A, R any](f func(A) R) func(context.Context, A) R {
return func(ctx context.Context, a A) R {
ret... | tuple/tuplefunc/tuplefunc-gen.go | 0.836755 | 0.617859 | tuplefunc-gen.go | starcoder |
package main
const (
// FieldMaxSize contains the maximum size of the field (both width and height).
FieldMaxSize = 80
// HolesEachStep holds after how many steps a hole might occur (if the preconditions are met).
HolesEachStep = 6
// HoleSpeed contains the minimum speed needed for a hole.
HoleSpeed = 3
// Max... | game.go | 0.634656 | 0.407658 | game.go | starcoder |
package fp
func (m BoolArray) Tail() BoolArray { s := len(m); if s > 0 { return m[1:s-1] } else {return []bool{} } }
func (m StringArray) Tail() StringArray { s := len(m); if s > 0 { return m[1:s-1] } else {return []string{} } }
func (m IntArray) Tail() IntArray { s := len(m); if s > 0 { return m[1:s-1] } else {retu... | fp/bootstrap_array_tail.go | 0.629433 | 0.434041 | bootstrap_array_tail.go | starcoder |
package main
import (
"errors"
"fmt"
"log"
"sort"
"github.com/theatlasroom/advent-of-code/go/utils"
)
/**
--- Day 1: Report Repair ---
After saving Christmas five years in a row, you've decided to take a vacation at a nice resort on a tropical island. Surely, Christmas will go on without you.
The tropical isl... | go/2020/1.go | 0.58059 | 0.403802 | 1.go | starcoder |
package client
import (
"encoding/json"
)
// YearlyRetentionOptions struct for YearlyRetentionOptions
type YearlyRetentionOptions struct {
Count int32 `json:"count"`
Type string `json:"type"`
}
// NewYearlyRetentionOptions instantiates a new YearlyRetentionOptions object
// This constructor will assign default v... | client/model_yearly_retention_options.go | 0.78968 | 0.418103 | model_yearly_retention_options.go | starcoder |
package gorough
import (
"math"
"sort"
)
type edgeEntry struct {
ymin float64
ymax float64
x float64
islope float64
}
func (e edgeEntry) less(ee edgeEntry) bool {
if e.ymin < ee.ymin {
return true
}
if e.ymin > ee.ymin {
return false
}
if e.x < ee.x {
return true
}
if e.x > ee.x || e.y... | filler.go | 0.646237 | 0.459743 | filler.go | starcoder |
package gocv
import (
"github.com/fwessels/go-cv-simd/sse2"
)
// Binarization performs binarization of 8-bit gray image.
// All images must have 8-bit gray format and must have the same width and height.
// For every point:
// dst[i] = compare(src[i], value) ? positive : negative;
// where compare(a, b) depends fr... | operation.go | 0.55447 | 0.559591 | operation.go | starcoder |
package inventory
import (
"context"
"fmt"
"time"
"github.com/Jim3Things/CloudChamber/simulation/internal/clients/inventory"
"github.com/Jim3Things/CloudChamber/simulation/internal/clients/namespace"
"github.com/Jim3Things/CloudChamber/simulation/internal/clients/store"
"github.com/Jim3Things/CloudChamber/simu... | simulation/internal/services/inventory/mocks.go | 0.609757 | 0.454472 | mocks.go | starcoder |
package api
import (
"fmt"
"math"
"math/rand"
"time"
)
func NewDistribution(distributionTypeArg string, iterationDuration time.Duration, rateFn RateFunction) (time.Duration, RateFunction, error) {
switch distributionTypeArg {
case "none":
return iterationDuration, rateFn, nil
case "regular":
distributedIte... | internal/trigger/api/iteration_distribution.go | 0.671578 | 0.445891 | iteration_distribution.go | starcoder |
package engine
import (
"image"
"image/color"
"image/draw"
)
// Level is a struct that defines a single level of a game
type Level struct {
BackgroundColour color.RGBA
Gravity float64
GameObjects []*GameObject
Game *Game
PaintOffset Vector
BeforePaint BeforePaint
}
// Rep... | level.go | 0.708818 | 0.508483 | level.go | starcoder |
package generator
const minDictionarySize = 512
// DefaultConfig is the default configuration for the Mapper.
var DefaultConfig = Config{
StartSize: minDictionarySize, // 512B
RatioImprovements: 0.1, // 10% improvement per iteration
SamplePath: "",
DictionaryPath: "./codec/zbor/",... | codec/generator/config.go | 0.803637 | 0.405184 | config.go | starcoder |
package expression
import (
"fmt"
"github.com/linanh/go-mysql-server/sql"
)
// And checks whether two expressions are true.
type And struct {
BinaryExpression
}
// NewAnd creates a new And expression.
func NewAnd(left, right sql.Expression) sql.Expression {
return &And{BinaryExpression{Left: left, Right: right... | sql/expression/logic.go | 0.703244 | 0.44077 | logic.go | starcoder |
package common
import (
"encoding/json"
"github.com/zhangsifeng92/geos/libraries/asio"
"strconv"
"strings"
"time"
)
const format = "2006-01-02T15:04:05"
type Microseconds int64
func MaxMicroseconds() Microseconds { return Microseconds(0x7fffffffffffffff) }
func MinMicroseconds() Microseconds { return Microseco... | common/time.go | 0.602179 | 0.598547 | time.go | starcoder |
package video
import "github.com/32bitkid/huffman"
import "github.com/32bitkid/bitreader"
type motionVectors [2][2][2]int
type motionVectorPredictions motionVectors
func absInt(in int) int {
if in < 0 {
return -in
}
return in
}
type motionVectorsFormed uint
const (
motionVectorsFormed_None = motionV... | video/motion_vectors.go | 0.52975 | 0.474509 | motion_vectors.go | starcoder |
package cs
/**
* Configuration for CS virtual server resource.
*/
type Csvserver struct {
/**
* Name for the content switching virtual server. Must begin with an ASCII alphanumeric or underscore (_) character, and must contain only ASCII alphanumeric, underscore, hash (#), period (.), space, colon (:), at sign (@), ... | resource/config/cs/csvserver.go | 0.838481 | 0.400222 | csvserver.go | starcoder |
package models
import (
"../../common"
"fmt"
"strconv"
)
type Result struct {
id int `json:id`
profile *Profile `json:profile`
code string `json:code`
company *Company `json:company`
lastUpdatedDate string `json:lastUpda... | jmserver/src/classes/jmserver/models/Result.go | 0.654564 | 0.462048 | Result.go | starcoder |
package grid
import (
"sort"
"github.com/google/gapid/test/robot/web/client/dom"
)
// Data holds all the presentable data for the grid.
type Data struct {
Columns map[Key]*HeaderData
Rows map[Key]*HeaderData
Cells map[CellIndex]*CellData
}
// HeaderData holds information about a single row or column head... | test/robot/web/client/widgets/grid/data.go | 0.696578 | 0.53358 | data.go | starcoder |
package datastructs
import "fmt"
const (
RED, BLACK = 0, 1
)
type RbTreeNode struct {
parent, left, right *RbTreeNode
color int
key interface{}
}
type RbTree struct {
root *RbTreeNode
}
func RbTreeHeight(root *RbTreeNode) int {
if root == nil {
return -1
}
left := RbTreeHeig... | datastructs/rbtree.go | 0.528533 | 0.511961 | rbtree.go | starcoder |
package profile
import (
"fmt"
"sort"
"strconv"
"strings"
)
// Merge merges all the profiles in profs into a single Profile.
// Returns a new profile independent of the input profiles. The merged
// profile is compacted to eliminate unused samples, locations,
// functions and mappings. Profiles must have identic... | src/internal/profile/merge.go | 0.715523 | 0.577436 | merge.go | starcoder |
package storetest
import (
"strings"
"testing"
"github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store"
"github.com/stretchr/testify/assert"
)
func TestGroupStore(t *testing.T, ss store.Store) {
t.Run("Create", func(t *testing.T) { testGroupStoreCreate(t, ss) })
t.Run("... | store/storetest/group_supplier.go | 0.525856 | 0.558207 | group_supplier.go | starcoder |
package output
import (
"bytes"
"fmt"
"sort"
"strings"
"github.com/Jeffail/benthos/v3/lib/message/batch"
"github.com/Jeffail/benthos/v3/lib/util/config"
"gopkg.in/yaml.v3"
)
//------------------------------------------------------------------------------
func sanitiseWithBatch(
componentConfig interface{},
... | lib/output/docs.go | 0.70477 | 0.712339 | docs.go | starcoder |
package interactors
import (
"fmt"
"math"
"github.com/CESARBR/knot-babeltower/pkg/thing/entities"
"github.com/go-playground/validator"
)
type schemaType struct {
valueType interface{}
unit interface{}
}
type interval struct {
min int
max int
}
// rules reference table: https://knot-devel.cesar.org.br/... | pkg/thing/interactors/update_config.go | 0.703753 | 0.477189 | update_config.go | starcoder |
package ent
import (
"fmt"
"strings"
"time"
"github.com/bionicstork/contrib/entproto/internal/todo/ent/nilexample"
"entgo.io/ent/dialect/sql"
)
// NilExample is the model entity for the NilExample schema.
type NilExample struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// StrNil ho... | entproto/internal/todo/ent/nilexample.go | 0.698432 | 0.4184 | nilexample.go | starcoder |
package pool
import (
"github.com/xichen2020/eventdb/x/refcnt"
)
// *BucketizedInt64ArrayPool is a generic bucketized value array pool.
// RefCountedPooledInt64Array is a refcounted, pooled generic value array.
type RefCountedPooledInt64Array struct {
closed bool
cnt *refcnt.RefCounter
p ... | x/pool/ref_counted_pooled_int64_array.gen.go | 0.612194 | 0.460168 | ref_counted_pooled_int64_array.gen.go | starcoder |
package latticevector
import (
"errors"
"fmt"
"math"
"wallpaper/entities/utility"
)
// PairMarshal can be marshaled and converted to a Pair
type PairMarshal struct {
XLatticeVector *utility.ComplexNumberForMarshal `json:"x_lattice_vector" yaml:"x_lattice_vector"`
YLatticeVector *utility.ComplexNumberForMars... | entities/formula/latticevector/latticeVector.go | 0.842475 | 0.556641 | latticeVector.go | starcoder |
package nlp
import (
"math/rand"
"github.com/james-bowman/sparse"
"gonum.org/v1/gonum/mat"
)
// SimHash implements the SimHash Locality Sensitive Hashing (LSH) algorithm
// using sign random projections (<NAME>, https://www.cs.princeton.edu/courses/archive/spr04/cos598B/bib/CharikarEstim.pdf)
// The distance betw... | hashing.go | 0.836488 | 0.619284 | hashing.go | starcoder |
package cryptypes
import "database/sql/driver"
// EncryptedString supports encrypting String data
type EncryptedString struct {
Field
Raw string
}
// Scan converts the value from the DB into a usable EncryptedString value
func (s *EncryptedString) Scan(value interface{}) error {
return decrypt(value.([]byte), &s.... | cryptypes/type_string.go | 0.817793 | 0.469399 | type_string.go | starcoder |
package exp
// Predicate represents a single true/false comparison
type Predicate struct {
Field string
Operator string
Value interface{}
}
// New returns a fully populated Predicate
func New(field string, operator string, value interface{}) Predicate {
return Predicate{
Field: field,
Operator: opera... | predicate.go | 0.917511 | 0.587381 | predicate.go | starcoder |
package agent
import (
"encoding/json"
"fmt"
"math"
"math/rand"
tpo "github.com/stellentus/cartpoles/lib/util/type-opr"
"github.com/stellentus/cartpoles/lib/logger"
"github.com/stellentus/cartpoles/lib/rlglue"
"github.com/stellentus/cartpoles/lib/util"
)
const (
maxFeatureAcrobot1 = 1.0
maxFeatureAcrobot2... | lib/agent/esarsa_acrobot.go | 0.722625 | 0.428771 | esarsa_acrobot.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.