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 state
import (
"sync"
"sync/atomic"
)
// State captures the state of a Babble node: Babbling, CatchingUp, Joining,
// Leaving, Suspended, or Shutdown
type State uint32
const (
// Babbling is the state in which a node gossips regularly with other nodes
// as part of the hashgraph consensus algorithm, and ... | src/node/state/state.go | 0.560734 | 0.413536 | state.go | starcoder |
package list
import (
"fmt"
"github.com/flowonyx/functional"
"github.com/flowonyx/functional/errors"
"github.com/flowonyx/functional/option"
)
// Head returns the first item from values.
// If values contains no items, it returns the zero value for the type
// and a IndexOutOfRangeErr.
func Head[T any](values []... | list/headTailLast.go | 0.784608 | 0.51312 | headTailLast.go | starcoder |
package winipcfg
import "fmt"
// NDIS_MEDIUM defined in ntddndis.h
// (https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntddndis/ne-ntddndis-_ndis_medium)
type NdisMedium uint32
const (
NdisMedium802_3 NdisMedium = 0
NdisMedium802_5 NdisMedium = 1
NdisMediumFddi NdisMedi... | vendor/golang.zx2c4.com/winipcfg/ndis_medium.go | 0.648578 | 0.463141 | ndis_medium.go | starcoder |
package main
import (
"math"
"math/rand"
"time"
)
func main() {
p := Perceptron{
input: [][]float64{{0, 0, 1}, {1, 1, 1}, {1, 0, 1}, {0, 1, 0}}, // Input Data
actualOutput: []float64{0, 1, 1, 0}, // Actual Output
epochs: 100000, ... | main.go | 0.663124 | 0.504516 | main.go | starcoder |
package slice
import (
"fmt"
"reflect"
)
var errorType = reflect.TypeOf((*error)(nil)).Elem()
func assertSlice(v reflect.Value) {
if k := v.Kind(); k != reflect.Slice {
panic(fmt.Errorf("%s (%s) is not a slice", v.Type().Name(), k))
}
}
func assertSliceFun(fType reflect.Type) {
if fType.Kind() != reflect.Fun... | iterator/slice/slice.go | 0.658857 | 0.452838 | slice.go | starcoder |
package genheightmap
import (
"github.com/Flokey82/go_gens/vectors"
"math"
"math/rand"
opensimplex "github.com/ojrac/opensimplex-go"
)
type Terrain interface {
//ApplyGen(f GenFunc)
MinMax() (float64, float64)
}
type GenFunc func(x, y float64) float64
func GenSlope(direction vectors.Vec2) GenFunc {
return f... | genheightmap/genheightmap.go | 0.691914 | 0.527621 | genheightmap.go | starcoder |
package yit
import (
"strings"
"gopkg.in/yaml.v3"
)
var (
All = func(node *yaml.Node) bool {
return true
}
None = func(node *yaml.Node) bool {
return false
}
StringValue = Intersect(
WithKind(yaml.ScalarNode),
WithShortTag("!!str"),
)
)
func Intersect(ps ...Predicate) Predicate {
return func(node... | vendor/github.com/dprotaso/go-yit/predicates.go | 0.570092 | 0.491761 | predicates.go | starcoder |
package binarytransforms
import (
"encoding/binary"
"errors"
"fmt"
"strings"
)
// LittleEndianBinaryToInt64 converts a little endian byte slice to int64.
func LittleEndianBinaryToInt64(inBytes []byte) (outInt64 int64, err error) {
inBytesLength := len(inBytes)
if inBytesLength > 8 || inBytesLength == 0 {
err... | binarytransforms.go | 0.659076 | 0.44348 | binarytransforms.go | starcoder |
package workshop
import (
"errors"
"log"
"math"
"strconv"
)
func add2Numbers(x, y int) int {
return x + y
}
func printFormattedResponse(name string) string {
return name + " hello there"
}
func wordSwap(word1, word2 string) (string, string) {
return word2, word1
}
func nakedReturn(x, y, z *int) (x1, y1, z1 ... | functions.go | 0.718199 | 0.412234 | functions.go | starcoder |
package stats
import "time"
// MovingAverage models a series of arbitrary uint64 values placed equidistantly in the time domain.
type MovingAverage struct {
totals []uint64
maxTotals int
sampleInterval time.Duration // TODO: Don't terminologically restrict the moving average to the time domain.
sampl... | pkg/stats/moving_average.go | 0.517815 | 0.539954 | moving_average.go | starcoder |
package v1alpha1
import (
v1alpha1 "kubeform.dev/kubeform/apis/aws/v1alpha1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// WafregionalRateBasedRuleLister helps list WafregionalRateBasedRules.
type WafregionalRateBasedRuleLister interface {
// List lis... | client/listers/aws/v1alpha1/wafregionalratebasedrule.go | 0.59302 | 0.449634 | wafregionalratebasedrule.go | starcoder |
package testinggo
import (
"aletheiaware.com/cryptogo"
"bytes"
"crypto/rsa"
"encoding/base64"
"github.com/golang/protobuf/proto"
"regexp"
"testing"
)
func AssertNoError(t *testing.T, err error) {
t.Helper()
if err != nil {
t.Fatalf("Expected no error, instead got '%s'", err)
}
}
func AssertError(t *testi... | assert.go | 0.59302 | 0.472379 | assert.go | starcoder |
package archive
import (
"gocms/pkg/page"
"sort"
"time"
)
// Record type that allows us to use a common index value for the various kinds of archive lists, be they in a map or a slice.
// Then it is easy to sort the order of the lists.
// Ranging over a map in Go is in a random order by design, and before, I used ... | pkg/archive/archive.go | 0.599368 | 0.460471 | archive.go | starcoder |
Package gofpdf implements a PDF document generator with high level support for
text, drawing and images.
Features
• Choice of measurement unit, page format and margins
• Page header and footer management
• Automatic page breaks, line breaks, and text justification
• Inclusion of JPEG, PNG, GIF and basic path-only ... | doc.go | 0.774669 | 0.739069 | doc.go | starcoder |
package graph
import (
"fmt"
"sync"
"github.com/pkg/errors"
)
const (
rootNodeID = "acb_root"
)
// Node represents a vertex in a Dag.
type Node struct {
Name string
Value *Step
children map[string]*Node
mu sync.Mutex
degree int
}
// NewNode creates a new Node based on the provided name and... | graph/dag.go | 0.738575 | 0.435001 | dag.go | starcoder |
package v3
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"strings"
"github.com/golang/protobuf/proto"
equality "github.com/solo-io/protoc-gen-ext/pkg/equality"
)
// ensure the imports are used
var (
_ = errors.New("")
_ = fmt.Print
_ = binary.LittleEndian
_ = bytes.Compare
_ = strings.Compare
_ = e... | projects/gloo/pkg/api/external/envoy/config/core/v3/health_check.pb.equal.go | 0.540196 | 0.412648 | health_check.pb.equal.go | starcoder |
package tchart
import (
"fmt"
"image"
"github.com/derailed/tview"
"github.com/gdamore/tcell/v2"
)
const (
// DeltaSame represents no difference.
DeltaSame delta = iota
// DeltaMore represents a higher value.
DeltaMore
// DeltaLess represents a lower value.
DeltaLess
gaugeFmt = "0%dd"
)
type delta int
... | internal/tchart/gauge.go | 0.739046 | 0.412471 | gauge.go | starcoder |
package gl
import (
"strings"
"unsafe"
"github.com/go-gl/mathgl/mgl32"
"github.com/thinkofdeath/gl/v3.2-core/gl"
)
// ShaderType is type of shader to be used, different types run
// at different stages in the pipeline.
type ShaderType uint32
// Valid shader types.
const (
VertexShader ShaderType = gl.VERTEX... | render/gl/shader.go | 0.789112 | 0.46873 | shader.go | starcoder |
package object
import (
"bytes"
"hash/fnv"
"strconv"
"strings"
)
// Type is a type of objects.
type Type string
const (
// IntegerType represents a type of integers.
IntegerType Type = "Integer"
// FloatType represents a type of floating point numbers.
FloatType = "Float"
// BooleanType represents a type of... | object/object.go | 0.855836 | 0.483709 | object.go | starcoder |
package iqfeed
import "time"
// UpdSummaryMsg is the main struct for both update and summary messages.
type UpdSummaryMsg struct {
SevenDayYield float64 // A price field, the value from a Money Market fund over the last seven days.
Ask float64 // The lowest price a market maker or br... | updatesummary.go | 0.592195 | 0.6372 | updatesummary.go | starcoder |
package powerlogger
import (
"go.opentelemetry.io/otel/label"
"go.uber.org/zap"
)
type LabelType int
const (
// INVALID is used for a Value with no value set.
INVALID LabelType = iota
BOOL
INT32
INT64
UINT32
UINT64
FLOAT32
FLOAT64
STRING
ARRAY
)
// Label struct for context information
type Label interf... | labels.go | 0.559049 | 0.42483 | labels.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// SignIn
type SignIn struct {
Entity
// The application name displayed in th... | models/sign_in.go | 0.655997 | 0.483405 | sign_in.go | starcoder |
package astar
import (
. "github.com/Jcowwell/go-algorithm-club/Utils"
)
type Node[E comparable] struct {
vertex E // The graph vertex.
cost float32 // The actual cost between the start vertex and this vertex.
estimate float32 // Estimated (heuristic) cost betweent this vertex and the target vertex.
}... | A-Star/a_star.go | 0.75985 | 0.529628 | a_star.go | starcoder |
package tart
// Developed by <NAME> and <NAME>, StochRSI is an oscillator that
// measures the level of RSI relative to its high-low range over a set time period.
// StochRsi applies the Stochastics formula to RSI values, rather than price values,
// making it an indicator of an indicator. The result is an oscillator ... | stochrsi.go | 0.69368 | 0.535281 | stochrsi.go | starcoder |
package oteltest
import (
"context"
"fmt"
"strconv"
"strings"
"sync"
"testing"
"go.opentelemetry.io/otel"
)
type ctxKeyType string
// TextMapCarrier provides a testing storage medium to for a
// TextMapPropagator. It records all the operations it performs.
type TextMapCarrier struct {
mtx sync.Mutex
gets... | oteltest/text_map_propagator.go | 0.697403 | 0.41052 | text_map_propagator.go | starcoder |
package assocentity
import (
"math"
"github.com/ndabAP/assocentity/v6/internal/iterator"
"github.com/ndabAP/assocentity/v6/tokenize"
)
type direction int
var (
posDir direction = 1
negDir direction = -1
)
// Do returns the entity distances
func Do(tokenizer tokenize.Tokenizer, psd tokenize.PoSDetermer, entiti... | assocentity.go | 0.753013 | 0.407392 | assocentity.go | starcoder |
package main
import (
"fmt"
"strings"
)
// We often need our programs to perform operations on collections of data,
// like selecting all items that satisfy a given predicate or mapping all items
// to a new collection with a custom function.
// In some languages it’s idiomatic to use generic data structures and
/... | 43-collection-functions/main.go | 0.725551 | 0.44083 | main.go | starcoder |
// Package stack implements a singly-linked list with stack behaviors.
package stack
import (
"fmt"
coll "github.com/maguerrido/collection"
)
// node of a Stack.
type node struct {
// value stored in the node.
value interface{}
// next points to the next node.
// If the node is the bottom node, then points to... | stack/stack.go | 0.861217 | 0.541712 | stack.go | starcoder |
// Package term provides structures and helper functions to work with
// terminal (state, sizes).
package term
import (
"errors"
"fmt"
"io"
"os"
"os/signal"
"syscall"
)
var (
// ErrInvalidState is returned if the state of the terminal is invalid.
ErrInvalidState = errors.New("Invalid terminal state")
)
// S... | vendor/github.com/docker/docker/pkg/term/term.go | 0.572842 | 0.418875 | term.go | starcoder |
package enums
import (
"bytes"
"encoding"
"errors"
github_com_eden_framework_enumeration "gitee.com/eden-framework/enumeration"
)
var InvalidDroneCiType = errors.New("invalid DroneCiType")
func init() {
github_com_eden_framework_enumeration.RegisterEnums("DroneCiType", map[string]string{
"ssh": "which... | internal/project/drone/enums/drone_ci_type__generated.go | 0.670824 | 0.438004 | drone_ci_type__generated.go | starcoder |
package nodeset
import (
"github.com/insolar/insolar/network/consensus/common/cryptkit"
"github.com/insolar/insolar/network/consensus/gcpv2/api/member"
"github.com/insolar/insolar/network/consensus/gcpv2/api/proofs"
"github.com/insolar/insolar/network/consensus/gcpv2/api/transport"
)
type NodeVectorHelper struct... | network/consensus/gcpv2/phasebundle/nodeset/node_vector.go | 0.532668 | 0.418905 | node_vector.go | starcoder |
package sam
import (
"github.com/biogo/hts/sam"
"github.com/guigolab/bamstats/annotation"
"github.com/guigolab/bamstats/utils"
)
type Record struct {
*sam.Record
}
// Export original sam.Record functions
var (
NewTag = sam.NewTag
NewAux = sam.NewAux
)
func NewRecord(r *sam.Record) *Record {
return &Record{r}... | sam/record.go | 0.522689 | 0.422862 | record.go | starcoder |
package mathutil
import (
"fmt"
"strconv"
)
type Comparable interface {
Less(Comparable) bool
Sub(Comparable) Comparable
}
type Int64 int64
func (v Int64) Less(other Comparable) bool {
return v < other.(Int64)
}
func (v Int64) Sub(other Comparable) Comparable {
return v - other.(Int64)
}
const defaultPercent... | math/mathutil/mathutil.go | 0.580828 | 0.455441 | mathutil.go | starcoder |
package schema
import (
"github.com/goccy/go-yaml"
)
// MarshalYAML return custom JSON byte
func (t Table) MarshalYAML() ([]byte, error) {
if len(t.Columns) == 0 {
t.Columns = []*Column{}
}
if len(t.Indexes) == 0 {
t.Indexes = []*Index{}
}
if len(t.Constraints) == 0 {
t.Constraints = []*Constraint{}
}
i... | schema/yaml.go | 0.500977 | 0.40869 | yaml.go | starcoder |
package sample
import (
"fmt"
"math/rand"
)
type sampleState struct {
rate uint64
seed int64
sampleCount uint64
trueCount uint64
rnd *rand.Rand
}
// A Sampler is a source of sampling decisions.
type Sampler interface {
// Sample returns a sampling decision based on a random number.
S... | sample.go | 0.78316 | 0.514034 | sample.go | starcoder |
package model
import (
"sort"
)
const (
// DefaultFilterSize represents the default filter search size.
DefaultFilterSize = 100
// FilterSizeLimit represents the largest filter size.
FilterSizeLimit = 1000
// GeoBoundsFilter represents a geobound filter type.
GeoBoundsFilter = "geobounds"
// CategoricalFilte... | model/filter.go | 0.829216 | 0.58053 | filter.go | starcoder |
package api
import (
. "github.com/gocircuit/circuit/gocircuit.org/render"
)
func RenderAnchorPage() string {
figs := A{
"FigHierarchy": RenderFigurePngSvg(
"Virtual anchor hierarchy and its mapping to Go <code>Anchor</code> objects.", "hierarchy", "600px"),
}
return RenderHtml("Navigating and using the anch... | gocircuit.org/api/anchor.go | 0.792384 | 0.676844 | anchor.go | starcoder |
package sigma
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
type lexer struct {
input string // we'll store the string being parsed
start int // the position we started scanning
position int // the current position of our scan
width int // we'll be using runes which can be ... | pkg/sigma/v2/lexer.go | 0.549641 | 0.422683 | lexer.go | starcoder |
package geogoth
import (
"math"
)
// MinDistance searches for the smallest distance
func MinDistance(distarr []float64) float64 {
distance := distarr[0]
for i := range distarr {
if distarr[i] < distance {
distance = distarr[i]
}
}
return distance
}
// NegToPosRad converts brng to positive if it's negati... | geojson/helper.go | 0.841011 | 0.662742 | helper.go | starcoder |
package components
import (
"sync"
"github.com/go-gl/mathgl/mgl32"
)
const (
// TypeVelocity represents a velocity component's type.
TypeVelocity = "velocity"
)
// Velocity represents the velocity of an entity.
type Velocity interface {
Component
// Rotational retrieves the rotational velocity in radians per ... | components/velocity.go | 0.847999 | 0.594345 | velocity.go | starcoder |
package main
import (
"encoding/binary"
"math"
)
// Types
const AMF3_TYPE_UNDEFINED = 0x00
const AMF3_TYPE_NULL = 0x01
const AMF3_TYPE_FALSE = 0x02
const AMF3_TYPE_TRUE = 0x03
const AMF3_TYPE_INTEGER = 0x04
const AMF3_TYPE_DOUBLE = 0x05
const AMF3_TYPE_STRING = 0x06
const AMF3_TYPE_XML_DOC = 0x07
const AMF3_TYPE_D... | amf3.go | 0.509032 | 0.409103 | amf3.go | starcoder |
package fp
func (l BoolArray) Take(n int) BoolArray {
size := len(l)
Require(n >= 0, "index should be >= 0")
if n >= size { n = size }
acc := make([]bool, n)
copy(acc, l[0: n])
return acc }
func (l StringArray) Take(n int) StringArray {
size := len(l)
Require(n >= 0, "index should be >= 0")
if n >=... | fp/bootstrap_array_take.go | 0.61451 | 0.662633 | bootstrap_array_take.go | starcoder |
package midi
import (
"bytes"
"fmt"
"gitlab.com/gomidi/midi/v2/internal/utils"
)
// Message represents a MIDI message. It can be created from the MIDI bytes of a message, by calling NewMessage.
type Message struct {
// MsgType represents the message type of the MIDI message
MsgType
// Data contains the bytes... | v2/message.go | 0.621541 | 0.416025 | message.go | starcoder |
// This package implements a basic LISP interpretor for embedding in a go program for scripting.
// This file implements data elements.
package golisp
import (
"errors"
"fmt"
"math"
"os"
"sort"
"strings"
"sync/atomic"
"unsafe"
"github.com/SteelSeries/set.v0"
)
const (
NilType = iota
ConsCellType
AlistT... | data.go | 0.721449 | 0.45417 | data.go | starcoder |
package byteorder
import "math"
var _ = (LittleEndian)(nil)
// LE is an Alias for LittleEndian.
type LE = LittleEndian
// LittleEndian defines little-endian serialization.
type LittleEndian []byte
// ReadUint16 reads the first 2 bytes. An optimized unsafe read on a little endian machine may look like this:
// b :... | littleendian.go | 0.554229 | 0.48871 | littleendian.go | starcoder |
// Package planner contains a query planner for Rego queries.
package planner
import (
"fmt"
"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/internal/ir"
)
type planiter func() error
// Planner implements a query planner for Rego queries.
type Planner struct {
strings []ir.StringConst
... | internal/planner/planner.go | 0.627837 | 0.474814 | planner.go | starcoder |
package Labyrinth
import "github.com/golang/The-Lagorinth/Point"
import "math/rand"
//Global variables used in the project.
//This way it is easy to modify objects in the fly.
var Wall string = "0"
var Pass string = " "
var Treasure string = "$"
var Trap string = "*"
var Monster string = "i"
var CharSymbol string = "... | Labyrinth/labyrinth.go | 0.575111 | 0.495911 | labyrinth.go | starcoder |
package sheetfile
import (
"github.com/fourstring/sheetfs/master/config"
"github.com/fourstring/sheetfs/master/datanode_alloc"
"github.com/fourstring/sheetfs/master/filemgr/file_errors"
"gorm.io/gorm"
"sync"
)
/*
SheetFile
Represents a file containing a sheet.
Every SheetFile is made of lots of Cell. Almost ever... | master/sheetfile/sheetfile.go | 0.520253 | 0.496582 | sheetfile.go | starcoder |
package text
// line_scanner.go contains code that finds lines within text.
import (
"strings"
"text/scanner"
"github.com/mum4k/termdash/internal/runewidth"
)
// wrapNeeded returns true if wrapping is needed for the rune at the horizontal
// position on the canvas.
func wrapNeeded(r rune, cvsPosX, cvsWidth int,... | vendor/github.com/mum4k/termdash/widgets/text/line_scanner.go | 0.641198 | 0.425665 | line_scanner.go | starcoder |
package bdd
import (
"fmt"
"time"
"github.com/onsi/gomega/format"
)
// IsSameTimeAs succeeds if actual is the same time or later
// than the passed-in time.
var IsSameTimeAs = &matcher{
minArgs: 1,
maxArgs: 1,
name: "IsSameTimeAs",
apply: func(actual interface{}, expected []interface{}) Result {
t1, ok :... | matcher_time.go | 0.551815 | 0.541045 | matcher_time.go | starcoder |
Package rollout defines a protocol for automating the gradual rollout of changes
throughout a VitessCluster by splitting rolling update logic into
composable pieces: deciding what changes to make, deciding when and in what
order to apply changes, and then actually applying the changes.
Controllers like VitessShard dec... | pkg/operator/rollout/rollout.go | 0.823825 | 0.403449 | rollout.go | starcoder |
The Shunting Yard algorithm is stack based.
For the conversion there are two strings the input and the output.
The stack is used to hold the operators not yet added to the output queue eg. +, -, ×
The algorithm then does something depending on what operator is read in eg. "3 + 4" --> "3 4 +"
For the full algorithm in... | shunt/shunt.go | 0.738575 | 0.723334 | shunt.go | starcoder |
package drawing
// NewLineStroker creates a new line stroker.
func NewLineStroker(c LineCap, j LineJoin, flattener Flattener) *LineStroker {
l := new(LineStroker)
l.Flattener = flattener
l.HalfLineWidth = 0.5
l.Cap = c
l.Join = j
return l
}
// LineStroker draws the stroke portion of a line.
type LineStroker st... | drawing/stroker.go | 0.765111 | 0.407098 | stroker.go | starcoder |
package plaid
import (
"encoding/json"
)
// HistoricalBalance An object representing a balance held by an account in the past
type HistoricalBalance struct {
// The date of the calculated historical balance, in an [ISO 8601](https://wikipedia.org/wiki/ISO_8601) format (YYYY-MM-DD)
Date string `json:"date"`
// Th... | plaid/model_historical_balance.go | 0.855881 | 0.586641 | model_historical_balance.go | starcoder |
package input
import (
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/input/reader"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message/batch"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffai... | lib/input/kafka_balanced.go | 0.70416 | 0.785843 | kafka_balanced.go | starcoder |
package grids
import (
"math"
"github.com/shomali11/go-interview/algorithms/astar"
)
// GridNode grid node
type GridNode struct {
X int
Y int
Cost float64
IsObstacle bool
world *GridWorld
}
// EstimateDistanceToGoal get distance to the goal
func (n *GridNode) EstimateDistanceToGo... | algorithms/astar/grids/grid_node.go | 0.782288 | 0.592667 | grid_node.go | starcoder |
package symbol_table
import (
"github.com/midnight-vivian/go-data-structures/algorithms/searching/binary"
"github.com/midnight-vivian/go-data-structures/utils"
)
var _ SymbolTableSuper = (*STTwoArrays)(nil)
type STTwoArrays struct {
keys []utils.Comparabler
values []interface{}
n int
}
func NewSTTwoArra... | data-structures/symbol-table/st_two_arrays.go | 0.58059 | 0.42316 | st_two_arrays.go | starcoder |
// Package list provides utilities for handling lists of dynamically-typed elements
package list
import (
"fmt"
"reflect"
)
// List is an interface to a list of dynamically-typed elements
type List interface {
// Count returns the number if items in the list
Count() int
// Get returns the element at the index ... | third_party/tint/tools/src/list/list.go | 0.696475 | 0.430985 | list.go | starcoder |
package trie
import (
"fmt"
)
const (
EOLCharacter rune = '\n'
)
// Error related to trie data structure and related operation
type Error struct {
message string
}
func (e *Error) Error() string {
return e.message
}
func newError(message string) *Error {
return &Error{
message: message,
}
}
// Node of a t... | internal/trie/trie.go | 0.621081 | 0.42316 | trie.go | starcoder |
package util
import (
"fmt"
"strconv"
"strings"
"time"
)
func SplitFindContains(str, target, sep string, match bool) bool {
ss := strings.Split(str, sep)
isContain := false
for _, s := range ss {
if strings.Contains(target, s) {
isContain = true
break
}
}
return isContain && match
}
func SplitFin... | pkg/util/util.go | 0.640973 | 0.476458 | util.go | starcoder |
package regen
import (
"fmt"
)
// CharClass represents a regular expression character class as a list of ranges.
// The runes contained in the class can be accessed by index.
type tCharClass struct {
Ranges []tCharClassRange
TotalSize int32
}
// CharClassRange represents a single range of characters in a chara... | char_class.go | 0.761804 | 0.47658 | char_class.go | starcoder |
package influxdb
import (
"bytes"
"fmt"
"strings"
"github.com/influxdata/influxql"
log "github.com/sirupsen/logrus"
)
// ExprReturn represents the type returned by the expr.
type ExprReturn int
const (
// Unknown type.
Unknown ExprReturn = 0
// Scalar type.
Scalar ExprReturn = 1
// SeriesSet type.
Series... | proto/influxdb/internalExprParser.go | 0.607081 | 0.433202 | internalExprParser.go | starcoder |
package queryme
// A Field is the name of a field.
type Field string
// A Value is any constant used in queries.
type Value interface{}
// A SortOrder is an ordering over a field.
type SortOrder struct {
Field Field
Ascending bool
}
// A Predicate is an expression that can is evaluated as either true or false.
ty... | go/expressions.go | 0.798423 | 0.485234 | expressions.go | starcoder |
package sentences
import (
"strings"
)
/*
AnnotateTokens is an interface used for the sentence tokenizer to add properties to
any given token during tokenization.
*/
type AnnotateTokens interface {
Annotate([]*Token) []*Token
}
/*
TypeBasedAnnotation performs the first pass of annotation, which makes decisions
bas... | vendor/gopkg.in/neurosnap/sentences.v1/annotate.go | 0.656988 | 0.500793 | annotate.go | starcoder |
package ng
import (
"math/big"
)
func Gop_istmp(a interface{}) bool {
return false
}
// -----------------------------------------------------------------------------
type UntypedBigint *big.Int
type UntypedBigrat *big.Rat
type UntypedBigfloat *big.Float
type UntypedBigint_Default = Bigint
type UntypedBigrat_Defa... | builtin/ng/big.go | 0.67822 | 0.468183 | big.go | starcoder |
package sprite
const Font_JR_A = `
XXXX
X X
X X
XXXXX
X X
X X
XX XX`
const Font_JR_B = `
XXXX
X X
X X
XXXXX
X X
X X
XXXXXX`
const Font_JR_C = `
XXX X
X XX
X
X
X
X X
XXXX`
const Font_JR_D = `
XXXXX
X X
X X
X X
X X
X X
XXXXXX`
const Font_JR_E = `
XXXXXXX
X ... | font_jr.go | 0.512937 | 0.454654 | font_jr.go | starcoder |
package apicalypse
import (
"github.com/Henry-Sarabia/blank"
"github.com/pkg/errors"
"strconv"
"strings"
)
var (
// ErrMissingInput occurs when a function is called without input parameters (e.g. nil slice)
ErrMissingInput = errors.New("missing input parameters")
// ErrBlankArgument occurs when a function is c... | option.go | 0.681833 | 0.434341 | option.go | starcoder |
package tgmock
import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/nnqq/td/bin"
)
// TestingT is simplified *testing.T interface.
type TestingT interface {
require.TestingT
assert.TestingT
Helper()
Cleanup(cb func())
}
// Mock is a mock for tg.Invoker with testify/... | tgmock/mock.go | 0.706393 | 0.437824 | mock.go | starcoder |
package client
import (
"encoding/binary"
"errors"
"fmt"
"io"
)
// Variable size structure prefix-header byte lengths
const (
CertificateLengthBytes = 3
PreCertificateLengthBytes = 3
ExtensionsLengthBytes = 2
)
// Reads a variable length array of bytes from |r|. |numLenBytes| specifies the
// number of... | go/client/serialization.go | 0.744378 | 0.406332 | serialization.go | starcoder |
package sources
import (
"fmt"
"github.com/ericr/solanalyzer/parser"
)
const (
// ExpressionUnknown represents an unknown expression.
ExpressionUnknown = iota
// ExpressionPrimary represents a primary expression.
ExpressionPrimary
// ExpressionNew represents a 'new' expression.
ExpressionNew
// ExpressionUna... | sources/expression.go | 0.618435 | 0.439627 | expression.go | starcoder |
package models
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// AssignmentReviewSettings
type AssignmentReviewSettings struct {
// The default... | models/assignment_review_settings.go | 0.616936 | 0.436442 | assignment_review_settings.go | starcoder |
package handler
var (
badgeUnknown = `<svg xmlns="http://www.w3.org/2000/svg" width="115" height="20">
<title>Djinn CI: unknown</title>
<rect width="100" height="20" fill="#383e51"/>
<rect x="53" width="60" height="20" fill="#6a7393"/>
<rect width="100" height="20" fill="url(#a)"/>
<g fill="#fff" text-anchor="mi... | namespace/handler/badge.go | 0.621885 | 0.408218 | badge.go | starcoder |
package circuit
import (
// "os"
"log"
"regexp"
"strings"
"io/ioutil"
gc "github.com/rthornton128/goncurses"
"github.com/furryfaust/textelectronics/components"
)
var (
IO_CHECK = map[int]map[string]int {
0: map[string]int {
"com_x": -1, "com_y": 0, "type_x": 1, "typ... | circuit/circuit.go | 0.656328 | 0.449332 | circuit.go | starcoder |
package dither
import (
"image"
"image/color"
)
type Settings struct {
Filter [][]float32
}
type Dither struct {
Type string
Settings
}
func (dither Dither) Color(input image.Image, errorMultiplier float32) image.Image {
bounds := input.Bounds()
img := image.NewRGBA(bounds)
for x := bounds.Min.X; x < bounds... | dither_color.go | 0.510252 | 0.42919 | dither_color.go | starcoder |
package builtin
import "github.com/kode4food/ale/data"
// Add returns the sum of the provided numbers
var Add = data.Applicative(func(args ...data.Value) data.Value {
if len(args) > 0 {
var res = args[0].(data.Number)
for _, n := range args[1:] {
res = res.Add(n.(data.Number))
}
return res
}
return data... | core/internal/builtin/numeric.go | 0.702632 | 0.596786 | numeric.go | starcoder |
package orbit
import (
"math"
"github.com/dayaftereh/discover/server/mathf"
)
func OrbitFromParams(params *OrbitParameter) *Orbit {
params = extendParams(params)
rP := perifocalPosition(
*params.AngularMomentum,
*params.Eccentricity,
*params.TrueAnomaly,
*params.MU,
)
vP := perifocalVelocity(
*para... | server/mathf/orbit/parameter.go | 0.883374 | 0.494507 | parameter.go | starcoder |
package unityai
// Reference to navigation polygon.
type NavMeshPolyRef uint64
// Reference to navigation mesh tile.
type NavMeshTileRef uint64
const (
kPolyRefSaltBits NavMeshPolyRef = 16 // Number of salt bits in the poly/tile ID.
kPolyRefTileBits NavMeshPolyRef = 28 // Number of tile bits in the poly/tile ID.
... | nav_mesh_types.go | 0.640411 | 0.429968 | nav_mesh_types.go | starcoder |
package model
import (
"fmt"
"github.com/mailru/easyjson/jlexer"
"strings"
"time"
)
// OANDA docs - http://developer.oanda.com/rest-live-v20/pricing-ep/
// A PriceBucket represents a price available for an amount of liquidity
type PriceBucket struct {
// The Price offered by the PriceBucket
Price PriceValue `j... | model/pricing.go | 0.572484 | 0.422088 | pricing.go | starcoder |
package engine
import (
"github.com/divVerent/aaaaxy/internal/level"
m "github.com/divVerent/aaaaxy/internal/math"
)
const (
// GameWidth is the width of the displayed game area.
GameWidth = 640
// GameHeight is the height of the displayed game area.
GameHeight = 360
// GameTPS is the game ticks per second.
... | internal/engine/constants.go | 0.524638 | 0.555556 | constants.go | starcoder |
package reflector
import (
"reflect"
"time"
"github.com/graphql-go/graphql"
)
var defaultTypeMap TypeMap
func init() {
defaultTypeMap = buildDefaultTypeMap()
}
// GetValueFromResolveParams gets the value of p, translating a graphql construct
// to a golang `reflect.Value`
func GetValueFromResolveParams(p graph... | reflector/gql_reflector_builtin_types.go | 0.590307 | 0.44059 | gql_reflector_builtin_types.go | starcoder |
package data
import (
"fmt"
rt "git.townsourced.com/townsourced/gorethink"
"git.townsourced.com/townsourced/gorethink/types"
)
/*
LocationUnit defines units of measure for location based queries
*/
const (
LocationUnitMeter = "m"
LocationUnitKilometer = "km"
LocationUnitMile = "mi"
Locatio... | data/location.go | 0.796055 | 0.417034 | location.go | starcoder |
package interpolator
import (
"math"
"github.com/urandom/drawgl"
"github.com/urandom/drawgl/operation/transform/matrix"
)
type kernel struct {
// Support is the kernel support and must be >= 0. At(t) is assumed to be
// zero when t >= Support.
Support float64
// At is the kernel function. It will only be call... | interpolator/kernel.go | 0.648132 | 0.490419 | kernel.go | starcoder |
package common
import (
"github.com/OpenWhiteBox/primitives/matrix"
"github.com/OpenWhiteBox/primitives/random"
)
type Surface int
const (
Inside Surface = iota
Outside
)
type MaskType int
const (
RandomMask MaskType = iota
IdentityMask
)
type KeyGenerationOpts interface{}
// IndependentMasks generates the... | constructions/common/keygen_primitives.go | 0.637595 | 0.538073 | keygen_primitives.go | starcoder |
package spritesheet
import (
"errors"
"image"
"image/draw"
)
const (
DefaultImgsPerRow = 5
)
var (
ErrNoImages = errors.New("no images passed to the encoder")
ErrBadDimensions = errors.New("width and/or height of images passed is zero")
)
// NewAlpha returns new image.Alpha
func NewAlpha(r image.Rectangl... | encode.go | 0.763307 | 0.535159 | encode.go | starcoder |
package tracer
import (
"image"
"math"
"math/rand"
)
type Camera struct {
Eye, Direction, Up Vector
right Vector //vector pointing right
phi, theta float64 //latitude and longitude of look direction
imagePlaneWidth, imagePlaneHeight float64 //width and height of the view plane
distance ... | tracer/camera.go | 0.889084 | 0.850717 | camera.go | starcoder |
package structschema
import (
"context"
"fmt"
"reflect"
"strings"
"github.com/housecanary/gq/ast"
"github.com/housecanary/gq/schema"
)
func areTypesEqual(a, b ast.Type) bool {
if reflect.TypeOf(a) != reflect.TypeOf(b) {
return false
}
switch t := a.(type) {
case *ast.SimpleType:
return t.Name == (b.(... | schema/structschema/resolver.go | 0.623492 | 0.464476 | resolver.go | starcoder |
package store
import (
"errors"
pb "github.com/yemingfeng/sdb/pkg/protobuf"
"math"
)
var idEmptyError = errors.New("id is empty")
var keyEmptyError = errors.New("key is empty")
// Collection is an abstraction of data structure, dataType = List/Set/SortedSet
// A Collection corresponds to a row containing
// Each ... | internal/store/collection.go | 0.684264 | 0.703607 | collection.go | starcoder |
package grid
import (
"upsilon_cities_go/lib/cities/map/pattern"
"upsilon_cities_go/lib/cities/node"
"upsilon_cities_go/lib/cities/nodetype"
)
//CompoundedGrid allow to acces to a grid overlay. accessor will provide data based on base + delta grid. Expect delta grid to be initialized with 0 ;)
type CompoundedGrid ... | lib/cities/map/grid/compounded_grid.go | 0.712632 | 0.407216 | compounded_grid.go | starcoder |
package aoc
import (
"bufio"
"io"
"regexp"
"strconv"
)
type Point struct {
X int
Y int
}
type Line struct {
First Point
Second Point
}
var (
linePattern *regexp.Regexp
)
func min(first int, second int) int {
if first < second {
return first
}
return second
}
func max(first int, second int) int {
i... | internal/aoc/vents.go | 0.571288 | 0.433262 | vents.go | starcoder |
// Package termstat provides a stats implementation which periodically logs the
// statistics to the given writer. It is meant to be used for testing and
// debugging at the terminal in lieu of an actual collector writing to an
// external tool like graphite or datadog. It provides stub implementations for
// some fun... | termstat/termstat.go | 0.668339 | 0.623406 | termstat.go | starcoder |
package openapi
import (
"encoding/json"
)
// VulnerabilityScoreSet struct for VulnerabilityScoreSet
type VulnerabilityScoreSet struct {
BaseScore *float64 `json:"BaseScore,omitempty"`
TemporalScore *float64 `json:"TemporalScore,omitempty"`
EnvironmentalScore *float64 `json:"EnvironmentalScore,o... | openapi/model_vulnerability_score_set.go | 0.763219 | 0.438244 | model_vulnerability_score_set.go | starcoder |
package donutmaze
import (
"github.com/bogosj/advent-of-code/fileinput"
"github.com/bogosj/advent-of-code/intmath"
)
const (
space = '.'
wall = '#'
)
// Maze represents a donut maze on Pluto.
type Maze struct {
m [][]rune
warps []intmath.Point
visited map[int]map[intmath.Point]bool
IsRec... | 2019/day20/donutmaze/donutmaze.go | 0.730001 | 0.401541 | donutmaze.go | starcoder |
package model
import (
"github.com/sudachen/go-ml/fu"
"reflect"
)
/*
Classification metrics factory
*/
type Classification struct {
Accuracy float64 // accuracy goal
Error float64 // error goal
Confidence float32 // threshold for binary classification
}
/*
Names is the list of calculating metrics
*/
func... | model/classificaction.go | 0.627152 | 0.423875 | classificaction.go | starcoder |
package inmemory
import (
"errors"
"reflect"
"github.com/hellofresh/goengine/metadata"
)
var ErrUnsupportedType = errors.New("the value is not a scalar type")
func asScalar(value interface{}) (interface{}, error) {
switch value.(type) {
case int,
int8,
int16,
int32,
int64,
uint,
uint8,
uint16,
... | driver/inmemory/matcher_gen.go | 0.604749 | 0.450903 | matcher_gen.go | starcoder |
package ed
import (
"unicode/utf8"
// "fmt"
)
func min(a, b int) int {
if a < b {
return a
}
return b
}
/*
String calculates the edit-distance between two strings. Input strings must be UTF-8 encoded.
The time complexity is O(mn) where m and n are lengths of a and b, and space complexity is O(n).
*/
fun... | ed/ed.go | 0.650911 | 0.480174 | ed.go | starcoder |
package catalog
import (
"github.com/iand/growth/plot"
)
type Entry struct {
Depth int
plot.Grammar
plot.Plotter
}
var Entries = map[string]Entry{
"big-h": {
Depth: 10,
Plotter: plot.Plotter{
InitialAngle: 0,
AngleDelta: 90,
Step: 200,
StepDelta: 0.65,
LineWidth: 9,... | catalog/catalog.go | 0.571647 | 0.598899 | catalog.go | starcoder |
package stats
// Data represents a collection of float64 values. In which
// operations are done
type Data []float64
// Get items in slice
func (d Data) Get(i int) float64 { return d[i] }
// Len return length of slice
func (d *Data) Len() int { return len(*d) }
// Mean Computes the of the data set
func (d *Data) Me... | stats/data.go | 0.938216 | 0.908982 | data.go | starcoder |
package poly
import (
"fmt"
"math"
)
// A polynom-like object. Can handle multiplication, integration, sum, etc.
type Poly struct {
// The coefficients of the polynom object. The first coefficient corresponds to the 0th element, and this then continues
// Null Polynoms have a nil coefficient
Coefficients []float... | polynom.go | 0.701509 | 0.564819 | polynom.go | starcoder |
package matsa
import (
"math"
"math/rand"
"time"
"sort"
"errors"
)
func (list List_f64) Sum() float64 {
if list.Length() == 0 {
return 0
}
var sum float64
// Add em up
for _, n := range list {
sum += n
}
return sum
}
func (list List_f64) Mean() float64 {
l :... | statistics.go | 0.845496 | 0.586404 | statistics.go | starcoder |
package database
import (
"time"
"gorm.io/gorm"
)
type (
Diff struct {
Target
ExpectedState string
ActualState string
ScanID time.Time
Comment string
}
DiffAB struct {
Target
StateA string
StateB string
ScanA time.Time
ScanB time.Time
}
)
func CurrentState(db *gorm.DB) (state []ActualS... | scanalyzer/internal/database/query.go | 0.558327 | 0.402099 | query.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.