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 integration
// EqualsAST does deep equals between the two objects.
func EqualsAST(inA, inB AST) bool {
if inA == nil && inB == nil {
return true
}
if inA == nil || inB == nil {
return false
}
switch a := inA.(type) {
case BasicType:
b, ok := inB.(BasicType)
if !ok {
return false
}
return ... | go/tools/asthelpergen/integration/ast_helper.go | 0.619586 | 0.562297 | ast_helper.go | starcoder |
// Package syscall contains an interface to the low-level operating system
// primitives. The details vary depending on the underlying system.
// Its primary use is inside other packages that provide a more portable
// interface to the system, such as "os", "time" and "net". Use those
// packages rather than this on... | src/pkg/syscall/syscall.go | 0.613352 | 0.503357 | syscall.go | starcoder |
package proj
import (
"fmt"
"math"
"reflect"
"strings"
"gonum.org/v1/gonum/floats"
)
// A Transformer takes input coordinates and returns output coordinates and an error.
type Transformer func(X, Y float64) (x, y float64, err error)
// A TransformerFunc creates forward and inverse Transformers from a projectio... | proj/Proj.go | 0.701406 | 0.400837 | Proj.go | starcoder |
package tetra3d
import (
"sort"
"github.com/kvartborg/vector"
"github.com/takeyourhatoff/bitset"
)
// Model represents a singular visual instantiation of a Mesh. A Mesh contains the vertex information (what to draw); a Model references the Mesh to draw it with a specific
// Position, Rotation, and/or Scale (where... | model.go | 0.852629 | 0.64937 | model.go | starcoder |
package forGraphBLASGo
import (
"github.com/intel/forGoParallel/parallel"
"github.com/intel/forGoParallel/pipeline"
)
type matrixEWiseMultBinaryOp[DC, DA, DB any] struct {
op BinaryOp[DC, DA, DB]
A *matrixReference[DA]
B *matrixReference[DB]
}
func newMatrixEWiseMultBinaryOp[DC, DA, DB any](
op BinaryOp[DC, ... | functional_Matrix_ComputedEWise.go | 0.655336 | 0.477554 | functional_Matrix_ComputedEWise.go | starcoder |
package dyjson
import (
"encoding/json"
"strconv"
)
type jsonDataType uint8
const (
errorDataType jsonDataType = iota
nullDataType
objectDataType
arrayDataType
stringDataType
numberDataType
booleanDataType
)
// JSONValue represents a JSON value, independently of its data type.
type JSONValue struct {
json... | dyjson.go | 0.680454 | 0.434341 | dyjson.go | starcoder |
package findthenearest
import (
"fmt"
"math"
"sort"
"strconv"
)
type xSort [][]float64
func (s xSort) Len() int {
return len(s)
}
func (s xSort) Less(i, j int) bool {
return s[i][0] < s[j][0]
}
func (s xSort) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
type ySort [][]float64
func (s ySort) Len() int {
ret... | pkg/divide_and_conquer/negative_sequence_degree/find_the_nearest/find_the_nearest.go | 0.586049 | 0.4881 | find_the_nearest.go | starcoder |
package refer
type References struct {
references []*Reference
}
func NewEmptyReferences() *References {
return &References{
references: make([]*Reference, 0, 10),
}
}
func NewReferences(tuples []interface{}) *References {
c := NewEmptyReferences()
for index := 0; index < len(tuples); index += 2 {
if index... | refer/References.go | 0.750461 | 0.448185 | References.go | starcoder |
package native
type State = int
const (
NEXT State = iota + 1
SKIP
FINISH
)
type MapContainer struct {
data map[string]bool
Next func(index string, value bool) (string, bool, State)
}
func MapIterator(data map[string]bool) *MapContainer {
return &MapContainer{
data: data,
Next: func(index string, value b... | iterator.go | 0.631026 | 0.489809 | iterator.go | starcoder |
package datatype
import (
"fmt"
"github.com/i-sevostyanov/NanoDB/internal/sql"
)
type Text struct {
value string
}
func NewText(v string) Text {
return Text{value: v}
}
func (t Text) Raw() interface{} {
return t.value
}
func (t Text) DataType() sql.DataType {
return sql.Text
}
func (t Text) Compare(v sql.V... | internal/sql/datatype/text.go | 0.689201 | 0.486636 | text.go | starcoder |
package interpreter
import (
"fmt"
"github.com/smackem/ylang/internal/lang"
"reflect"
)
type Number lang.Number
func (n Number) Compare(other Value) (Value, error) {
if r, ok := other.(Number); ok {
return n - r, nil
}
return nil, nil
}
func (n Number) Add(other Value) (Value, error) {
switch r := other.(t... | internal/interpreter/number.go | 0.819388 | 0.42913 | number.go | starcoder |
package newznab
import (
"fmt"
"strconv"
"strings"
)
// Parameters added to the URL to make a query.
type Param struct {
Name string
Value string
}
// Album returns a Param that restricts the search of music to a specific album title.
func Album(a string) Param {
return Param{
Name: "album",
Value: a,
}... | param.go | 0.778102 | 0.684027 | param.go | starcoder |
package main
import (
"github.com/gen2brain/raylib-go/raylib"
)
var (
maxBuildings int = 100
)
func main() {
screenWidth := int32(800)
screenHeight := int32(450)
raylib.InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera")
player := raylib.NewRectangle(400, 280, 40, 40)
buildings := ma... | examples/core/2d_camera/main.go | 0.556641 | 0.41182 | main.go | starcoder |
package domain
import (
"fmt"
"net/http"
"github.com/dynastymasra/cartographer/config"
"github.com/labstack/gommon/random"
scalar "github.com/dynastymasra/cookbook/graphql"
"github.com/graphql-go/graphql"
)
var (
countryField = graphql.Fields{
"id": &graphql.Field{
Type: scalar.UUID,
},
"name": &gr... | domain/graphql.go | 0.554229 | 0.437884 | graphql.go | starcoder |
package brotli
/* Copyright 2015 Google Inc. All Rights Reserved.
Distributed under MIT license.
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
*/
/* Greedy block splitter for one block category (literal, command or distance).
*/
type blockSplitterDistance struct {
alphabet_size_ ... | vendor/github.com/andybalholm/brotli/metablock_distance.go | 0.693473 | 0.477737 | metablock_distance.go | starcoder |
package data
import (
"reflect"
"github.com/zeroshade/go-drill/internal/rpc/proto/exec/shared"
)
// Int64 vector
type Int64Vector struct {
vector
values []int64
meta *shared.SerializedField
}
func (Int64Vector) Type() reflect.Type {
return reflect.TypeOf(int64(0))
}
func (Int64Vector) TypeLen() (int64, bo... | internal/data/vector_numeric.gen.go | 0.708213 | 0.651258 | vector_numeric.gen.go | starcoder |
package processor
import (
"time"
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/message"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/types"
"github.com/Jeffail/benthos/lib/util/text"
)
//-----------------------------------------------------------------------... | lib/processor/insert_part.go | 0.675978 | 0.553988 | insert_part.go | starcoder |
package bootstrap
import (
"bytes"
"io"
)
type Redactor struct {
replacement []byte
// Current offset from the start of the next input segment
offset int
// Minimum and maximum length of redactable string
minlen int
maxlen int
// Table of Boyer-Moore skip distances, and values to redact matching this end ... | bootstrap/redactor.go | 0.631708 | 0.416144 | redactor.go | starcoder |
package defaults
import "time"
// IntIfZero returns the value deflt if actual is zero, otherwise returns actual.
func IntIfZero(actual, deflt int) int {
if actual == 0 {
return deflt
}
return actual
}
// Int8IfZero returns the value deflt if actual is zero, otherwise returns actual.
func Int8IfZero(actual, defl... | defaults/zero.go | 0.757705 | 0.416263 | zero.go | starcoder |
package plaid
import (
"encoding/json"
)
// ExternalPaymentScheduleBase The schedule that the payment will be executed on. If a schedule is provided, the payment is automatically set up as a standing order. If no schedule is specified, the payment will be executed only once.
type ExternalPaymentScheduleBase struct ... | plaid/model_external_payment_schedule_base.go | 0.825167 | 0.540681 | model_external_payment_schedule_base.go | starcoder |
package universe
import (
"context"
"fmt"
"math"
"regexp"
"sort"
"github.com/influxdata/flux"
"github.com/influxdata/flux/codes"
"github.com/influxdata/flux/execute"
"github.com/influxdata/flux/internal/errors"
"github.com/influxdata/flux/interpreter"
"github.com/influxdata/flux/plan"
"github.com/influxda... | stdlib/universe/histogram.go | 0.682362 | 0.438184 | histogram.go | starcoder |
Noise Generator Module
https://noisehack.com/generate-noise-web-audio-api/
http://www.musicdsp.org/files/pink.txt
https://en.wikipedia.org/wiki/Pink_noise
https://en.wikipedia.org/wiki/White_noise
https://en.wikipedia.org/wiki/Brownian_noise
*/
//----------------------------------------------------------------------... | module/osc/noise.go | 0.745306 | 0.516656 | noise.go | starcoder |
package output
import (
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/output/writer"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffail/benthos/v3/lib/util/aws/session"
)
//---------... | lib/output/aws_sns.go | 0.744006 | 0.442275 | aws_sns.go | starcoder |
package g3
type BoundingBox struct {
Min, Max Vec3
}
type BoundingSphere struct {
Position Vec3
Radius float32
}
type BoundingVolume interface {
ClassifyPoint(v *Vec3) bool
ClassifyPlane(p *Plane) int
}
type HasBoundingBox interface {
GetBoundingBox() *BoundingBox
}
type HasBoundingSphere interface {
GetB... | src/pkg/g3/bbox.go | 0.751283 | 0.50293 | bbox.go | starcoder |
package mathcat
import (
"errors"
"fmt"
"math"
"math/big"
)
type association int
type operator struct {
prec int
assoc association
unary bool
}
const (
AssocLeft association = iota
AssocRight
)
var ErrDivisionByZero = errors.New("Division by zero")
var operators = map[TokenType]operator{
// Assignment... | operators.go | 0.655226 | 0.42668 | operators.go | starcoder |
package yaml
import (
"errors"
yaml "gopkg.in/yaml.v3"
)
// RemoveKey will remove a given key and value from a MappingNode.
func (n *Node) RemoveKey(key string) bool {
idx := n.KeyIndex(key)
if idx == -1 {
return false
}
// Removing the index of the target node twice should drop the key and
// value.
n.Co... | internal/yaml/operations.go | 0.820254 | 0.449272 | operations.go | starcoder |
package services
import (
"fmt"
"github.com/gravitational/teleport/lib/utils"
"github.com/gravitational/teleport/lib/utils/parse"
"github.com/gravitational/trace"
log "github.com/sirupsen/logrus"
)
// TraitsToRoles maps the supplied traits to a list of teleport role names.
// Returns the list of roles mapped f... | lib/services/traits.go | 0.778691 | 0.45944 | traits.go | starcoder |
package z
import (
"fmt"
"math"
"strings"
)
// Creates bounds for an histogram. The bounds are powers of two of the form
// [2^min_exponent, ..., 2^max_exponent].
func HistogramBounds(minExponent, maxExponent uint32) []float64 {
var bounds []float64
for i := minExponent; i <= maxExponent; i++ {
bounds = append... | z/histogram.go | 0.737631 | 0.589007 | histogram.go | starcoder |
package Game
import "github.com/golang/The-Lagorinth/Labyrinth"
import "github.com/golang/The-Lagorinth/Characters"
import "github.com/golang/The-Lagorinth/Point"
import "time"
import "fmt"
import "math/rand"
//triggerDamageTrap handles the event when a character steps on a damage trap.
func (game *Game) triggerDamag... | Game/gameTraps.go | 0.622689 | 0.415729 | gameTraps.go | starcoder |
package models
import (
"bufio"
"fmt"
"io"
"math"
"strconv"
"strings"
)
// Point2D : a struct that stores X and Y coordinate values
type Point2D struct {
XValue float64
YValue float64
}
// Graph2D : list of all 2D points
type Graph2D struct {
Points []Point2D
//numPoints int
}
// Line : linear equation Ax... | src/models/2d.go | 0.748995 | 0.555013 | 2d.go | starcoder |
package deepcopy
import (
"reflect"
"github.com/sirupsen/logrus"
)
// DeepCopyInterface can be implemented by types to have custom deep copy logic.
type DeepCopyInterface interface {
DeepCopy() interface{}
}
// DeepCopy returns a deep copy of x.
// Supports everything except Chan, Func and UnsafePointer.
func De... | common/deepcopy/deepcopy.go | 0.539226 | 0.414306 | deepcopy.go | starcoder |
package annotation
type EntityEqualer struct {
}
func NewEntityEqualer() *EntityEqualer {
return &EntityEqualer{}
}
func (c *EntityEqualer) Equal(x interface{}, y interface{}) bool {
switch x := x.(type) {
case *SimpleSpec:
if yValue, ok := y.(*SimpleSpec); ok {
return c.equalSimpleSpec(x, yValue)
}
case ... | annotation/entity_equaler.go | 0.692538 | 0.592077 | entity_equaler.go | starcoder |
package fp
func (l BoolList) DropRight(n int) BoolList { return l.Reverse().Drop(n).Reverse() }
func (l StringList) DropRight(n int) StringList { return l.Reverse().Drop(n).Reverse() }
func (l IntList) DropRight(n int) IntList { return l.Reverse().Drop(n).Reverse() }
func (l Int64List) DropRight(n int) Int64List { r... | fp/bootstrap_list_dropright.go | 0.683314 | 0.456591 | bootstrap_list_dropright.go | starcoder |
package diff3
import (
"fmt"
"strings"
"github.com/sergi/go-diff/diffmatchpatch"
)
const (
// Sep1 signifies the start of a conflict.
Sep1 = "<<<<<<<"
// Sep2 signifies the middle of a conflict.
Sep2 = "======="
// Sep3 signifies the end of a conflict.
Sep3 = ">>>>>>>"
)
// DiffMatchPatch contains the diff... | diff3.go | 0.507568 | 0.52476 | diff3.go | starcoder |
package dmmf
import (
"github.com/prisma/prisma-client-go/generator/types"
)
// FieldKind describes a scalar, object or enum.
type FieldKind string
// FieldKind values
const (
FieldKindScalar FieldKind = "scalar"
FieldKindObject FieldKind = "object"
FieldKindEnum FieldKind = "enum"
)
// IncludeInStruct shows ... | generator/dmmf/dmmf.go | 0.794425 | 0.401923 | dmmf.go | starcoder |
package executor
import "github.com/xichen2020/eventdb/document/field"
type docIDValues struct {
DocID int32
Values field.Values
}
// cloneDocIDValues clones the incoming (doc ID, values) pair.
func cloneDocIDValues(v docIDValues) docIDValues {
// TODO(xichen): Should pool and reuse the value array here.
v.Valu... | query/executor/doc_id_values.go | 0.506591 | 0.409339 | doc_id_values.go | starcoder |
package ascii
import "strings"
// Filter represents a byte filter fucntion type.
type Filter func(byte) bool
// Range creates a filter that will match any byte in between (inclusive).
func Range(begin, end byte) Filter {
return func(c byte) bool { return begin <= c && c <= end }
}
// Is creates a filter that will ... | filters.go | 0.875774 | 0.695151 | filters.go | starcoder |
package information
import (
"cloud.google.com/go/spanner"
"cloud.google.com/go/spanner/spansql"
)
type (
// Indexes is a collection of Index
Indexes []*Index
// Index is a row in information_schema.indexes (see: https://cloud.google.com/spanner/docs/information-schema#indexes)
Index struct {
// The name of... | pkg/schema/information/index.go | 0.560012 | 0.430985 | index.go | starcoder |
package ncolumn
/*
Package ncolumn contains a "null implementation" of the Column interface. It is typeless and of size 0.
It is for example used when reading zero row CSVs without type hints.
*/
import (
"github.com/tobgu/qframe/config/rolling"
"github.com/tobgu/qframe/internal/column"
"github.com/tobgu/qframe/i... | internal/ncolumn/column.go | 0.668123 | 0.400603 | column.go | starcoder |
package shamir
import (
"errors"
"math/rand"
"time"
)
const (
// ShareOverhead is the byte size overhead of each share when using
// Split on a secret. This is caused by appending a one byte tag to
// the share.
ShareOverhead = 1
)
// Split takes an arbitrarily long secret and generates a `parts` number
// of... | crypto/shamir/main.go | 0.812682 | 0.55911 | main.go | starcoder |
package input
import (
"github.com/benthosdev/benthos/v4/internal/component/input"
"github.com/benthosdev/benthos/v4/internal/component/metrics"
"github.com/benthosdev/benthos/v4/internal/docs"
"github.com/benthosdev/benthos/v4/internal/interop"
"github.com/benthosdev/benthos/v4/internal/log"
"github.com/benthos... | internal/old/input/gcp_pubsub.go | 0.773002 | 0.622086 | gcp_pubsub.go | starcoder |
package circuit
import (
"github.com/consensys/gnark-crypto/ecc"
bls12377fr "github.com/consensys/gnark-crypto/ecc/bls12-377/fr"
bls12379fr "github.com/consensys/gnark-crypto/ecc/bls12-379/fr"
bls12381fr "github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
bls24315fr "github.com/consensys/gnark-crypto/ecc/bls24-3... | circuit/circuit.go | 0.712032 | 0.454109 | circuit.go | starcoder |
This package is an implementation of section 3 of "Detecting Near-Duplicates
for Web Crawling" by Manku, Jain, and Sarma,
http://www2007.org/papers/paper215.pdf
It is hard-coded for hamming distance 3 or 6.
*/
package simstore
import (
"runtime"
"sort"
"sync"
"github.com/dgryski/go-bits"
)
type entry stru... | simstore.go | 0.657978 | 0.454896 | simstore.go | starcoder |
package common
type GraphLabyrinth struct {
nodes []Node
maxLoc Location
}
func NewLabyrinth(maxLoc Location) Labyrinth {
if maxLoc == nil {
return nil
}
graphLabyrinth := GraphLabyrinth{}
graphLabyrinth.nodes = make([]Node, 0)
maxX, maxY, maxZ := maxLoc.As3DCoordinates()
for z := uint(0); z <= maxZ; z++... | common/graphLabyrinth.go | 0.654784 | 0.555375 | graphLabyrinth.go | starcoder |
package graphics
import (
"github.com/hajimehoshi/ebiten/v2/internal/web"
)
const (
ShaderImageNum = 4
// PreservedUniformVariablesNum represents the number of preserved uniform variables.
// Any shaders in Ebiten must have these uniform variables.
PreservedUniformVariablesNum = 1 + // the destination texture ... | internal/graphics/vertex.go | 0.716417 | 0.542379 | vertex.go | starcoder |
package ptr
import (
"time"
)
// Bool returns a pointer value for the bool value passed in.
func Bool(v bool) *bool {
return &v
}
// BoolSlice returns a slice of bool pointers from the values
// passed in.
func BoolSlice(vs []bool) []*bool {
ps := make([]*bool, len(vs))
for i, v := range vs {
vv := v
ps[i] =... | vendor/github.com/aws/smithy-go/ptr/to_ptr.go | 0.851027 | 0.559651 | to_ptr.go | starcoder |
// Package pair provides oh's cons cell type.
package pair
import (
"fmt"
"github.com/michaelmacinnis/oh/internal/common"
"github.com/michaelmacinnis/oh/internal/common/interface/cell"
"github.com/michaelmacinnis/oh/internal/common/interface/literal"
)
const name = "cons"
//nolint:gochecknoglobals
var (
// Nu... | internal/common/type/pair/pair.go | 0.716417 | 0.445288 | pair.go | starcoder |
package model
func predict0(features []float64) float64 {
if (features[2] < 0.5) || (features[2] == -1) {
if (features[1] < 0.5) || (features[1] == -1) {
if (features[0] < 0.5) || (features[0] == -1) {
if (features[7] < 0.108870044) || (features[7] == -1) {
... | examples/xgboost/XGBRegressor/booster0.go | 0.541166 | 0.490602 | booster0.go | starcoder |
package dbr
import (
"database/sql"
"reflect"
)
// Iterator is an interface to iterate over the result of a sql query
// and scan each row one at a time instead of getting all into one slice.
// The principe is similar to the standard sql.Rows type.
type Iterator interface {
Next() bool
Scan(interface{}) error
C... | iterator.go | 0.540196 | 0.422207 | iterator.go | starcoder |
package series
import (
"sort"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/tsdb/chunkenc"
"github.com/grafana/loki/pkg/prom1/storage/metric"
)
// ConcreteSeriesSet implements storage.SeriesSe... | pkg/querier/series/series_set.go | 0.881487 | 0.463566 | series_set.go | starcoder |
package optimization
import (
"fmt"
. "github.com/jakecoffman/graph"
"strings"
)
type World struct {
width, height int
world []Node
}
// NewWorld is the World constructor. Takes a serialized World as input.
func NewWorld(input string) *World {
str := strings.TrimSpace(input)
rows := strings.Split(str,... | optimization/world.go | 0.642096 | 0.422564 | world.go | starcoder |
package maidenhead
import (
"fmt"
"math"
)
const (
// Earth radius
r = 6371
)
var compassBearing = []struct {
label string
start, ended float64
}{
{"N", 000.00, 011.25}, {"NNE", 011.25, 033.75}, {"NE", 033.75, 056.25}, {"ENE", 056.25, 078.75},
{"E", 078.75, 101.25}, {"ESE", 101.25, 123.75}, {"SE", 123... | point.go | 0.853608 | 0.539954 | point.go | starcoder |
package iso20022
// Execution of a subscription order.
type SubscriptionExecution4 struct {
// Unique and unambiguous identifier for an order, as assigned by the instructing party.
OrderReference *Max35Text `xml:"OrdrRef"`
// Unique and unambiguous identifier for an order execution, as assigned by a confirming pa... | SubscriptionExecution4.go | 0.846768 | 0.400456 | SubscriptionExecution4.go | starcoder |
package neuralnet
import (
"github.com/gonum/matrix/mat64"
"math"
"math/rand"
)
type Matrix interface {
mat64.Matrix
mat64.Vectorer
mat64.VectorSetter
mat64.RowViewer
mat64.ColViewer
mat64.Augmenter
mat64.Muler
mat64.Sumer
mat64.Suber
mat64.Adder
mat64.ElemMuler
mat64.ElemDiver
mat64.Equaler
mat64.Ap... | matrix.go | 0.640861 | 0.608041 | matrix.go | starcoder |
package businessdays
import (
"time"
"github.com/mgmayfield/GoHolidayCalendar/holidays"
)
// The United States has 10 business days / federal holidays
// New Years, MLK, President's Day, Memorial Day, Independence Day
// Labor Day, Columbus Day, Veterans Day, Thanksgiving, Christmas
// IsNewYears falls on the 1st... | businessDays/businessDays.go | 0.5769 | 0.566498 | businessDays.go | starcoder |
package gogrid
import (
"errors"
"fmt"
"strings"
)
type Alignment int
const (
Left Alignment = iota
Center
Right
)
type Grid struct {
data [][]string // data[row][column] => cell
colors []string // color to use for a row
ColumnAlignments []Alignment // controls column alignment fo... | gogrid.go | 0.612657 | 0.455017 | gogrid.go | starcoder |
* SOURCE:
* namespace.avsc
*/
package avro
import (
"io"
"fmt"
"github.com/actgardner/gogen-avro/vm"
"github.com/actgardner/gogen-avro/vm/types"
)
type UnionNullBodyworksDataTypeEnum int
const (
UnionNullBodyworksDataTypeEnumNull UnionNullBodyworksDataTypeEnum = 0
UnionNullBodyworksDataTypeEnumBody... | test/namespace-short/union_null_bodyworks_data.go | 0.654453 | 0.464355 | union_null_bodyworks_data.go | starcoder |
package game
import (
"image/color"
"runtime/interrupt"
"github.com/danmrichards/gba-pong/internal/display"
"github.com/danmrichards/gba-pong/internal/input"
"tinygo.org/x/drivers"
"tinygo.org/x/tinydraw"
)
var (
// Using a load of package level variables here because the compiler and
// resulting ROM acts ... | internal/game/game.go | 0.609524 | 0.490724 | game.go | starcoder |
package gocolor
import (
"github.com/Nguyen-Hoang-Nam/go-color/terminal"
"github.com/lucasb-eyer/go-colorful"
)
const (
DistanceRgb = iota
DistanceLab
DistanceLuv
DistanceCIE94
DistanceCIEDE2000
)
func minDistanceRbg(color colorful.Color, limit int) int {
minDistance := color.DistanceRgb(terminal.Xterm256[0]... | distance.go | 0.676299 | 0.5564 | distance.go | starcoder |
package types
import (
"errors"
"fmt"
"strconv"
"strings"
"time"
)
var (
_ Value = BoolValue(false)
_ Value = IntValue(0)
_ Value = FloatValue(0.0)
_ Value = DateValue(time.Unix(0, 0))
_ Value = StringValue("")
_ Value = TableValue{}
_ Value = ArrayValue{}
_ Value = &FormattedValue{}
// Null value spe... | types/value.go | 0.755005 | 0.454714 | value.go | starcoder |
package draw2d
import (
"bosun.org/_third_party/code.google.com/p/freetype-go/freetype/raster"
"math"
)
type MatrixTransform [6]float64
const (
epsilon = 1e-6
)
func (tr MatrixTransform) Determinant() float64 {
return tr[0]*tr[3] - tr[1]*tr[2]
}
func (tr MatrixTransform) Transform(points ...*float64) {
for i... | _third_party/code.google.com/p/draw2d/draw2d/transform.go | 0.756897 | 0.613613 | transform.go | starcoder |
package stringorslice
import (
"encoding/json"
"strings"
)
// StringOrSlice is a type that holds a []string, but marshals to a []string or a string.
type StringOrSlice struct {
values []string
forceEncodeAsArray bool
}
func (s *StringOrSlice) IsEmpty() bool {
return len(s.values) == 0
}
// Slice wi... | pkg/util/stringorslice/stringorslice.go | 0.632843 | 0.437103 | stringorslice.go | starcoder |
// Package vm provides a compiler and virtual machine environment for executing
// mtail programs.
package vm
import "fmt"
type opcode int
const (
bad opcode = iota // Invalid instruction, indicates a bug in the generator.
match // Match a regular expression against input, and set the ma... | vm/bytecode.go | 0.651355 | 0.433742 | bytecode.go | starcoder |
package kdtree
// k-d tree implementation adopted from <NAME>'s 1975 paper:
// Multidimensional Binary Search Trees Used for Associative Searching
// https://dl.acm.org/doi/10.1145/361002.361007
import "sort"
const K = 2 // Number of dimensions
type T = uint // dimension type. minT and maxT functions MUST match T
... | kdtree/kdtree.go | 0.82559 | 0.563318 | kdtree.go | starcoder |
package day2
import "fmt"
/*
Based on your calculations, the planned course doesn't seem to make any sense.
You find the submarine manual and discover that the process is actually slightly
more complicated.
In addition to horizontal position and depth, you'll also need to track a third
value, aim, which also starts ... | day2/part2.go | 0.708818 | 0.6137 | part2.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// PrinterDefaults
type PrinterDefaults struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for s... | models/microsoft/graph/printer_defaults.go | 0.666062 | 0.418103 | printer_defaults.go | starcoder |
package image_conversions
import (
"fmt"
"image"
"image/color"
"github.com/TheZoraiz/ascii-image-converter/aic_package/winsize"
"github.com/disintegration/imaging"
gookitColor "github.com/gookit/color"
"github.com/makeworld-the-better-one/dither/v2"
)
func ditherImage(img image.Image) image.Image {
palette ... | image_manipulation/util.go | 0.692434 | 0.546254 | util.go | starcoder |
package main
// Note: Adjacency list representation of graph was already implemented by me in previous graphs section. Hence I have
// modified few things which converts this adjacency list to adjacency matrix and then the floyd warshall algorithm is
// implemented. However you can directly take user inputs and add it... | algorithms/graphs/floyd_warshall/floyd_warshall.go | 0.577853 | 0.433022 | floyd_warshall.go | starcoder |
package dgopcore
import (
"errors"
"fmt"
"github.com/lyraproj/dgo/dgo"
"github.com/lyraproj/dgo/typ"
"github.com/lyraproj/pcore/px"
"github.com/lyraproj/pcore/types"
)
// ToPcore converts a dgo.Value into its corresponding px.Value.
func ToPcore(v dgo.Value) px.Value {
var cv px.Value
switch v := v.(type) {
... | topcore.go | 0.545528 | 0.420808 | topcore.go | starcoder |
package game
const (
motionByteSize = 1341
motionByteActualSize = motionByteSize - headerSize
wheelDataSize = 16
carMotionCount = 20
wheelDataCount = 5
)
// CarMotion provides the motion data for a single car
type CarMotion struct {
WorldPositionX float32
WorldPositionY float32... | game/motion.go | 0.674694 | 0.435001 | motion.go | starcoder |
package main
/*
Programming Assignment 4, accessed 10 May 2019, from:
Stanford Online Lagunita, Algorithms: Design and Analysis, Part 1.
The file, SCC.txt, contains the edges of a directed graph. Vertices are
labeled as positive integers from 1 to 875714. Every row indicates an
edge, the vertex label in first... | Stanford/ProgrammingQuestion4_FindStronglyConnectedComponents/main.go | 0.657648 | 0.613005 | main.go | starcoder |
package protocol
// TransformMap store the configured crypto suite
// NOTE that this cannot be used to parse incoming list of transforms
// incoming list can have many Transforms of same type in 1 proposal
type TransformMap map[TransformType]*SaTransform
func ProposalFromTransform(prot ProtocolID, trs TransformMap, s... | protocol/transforms.go | 0.721351 | 0.475788 | transforms.go | starcoder |
package year2021
import (
"fmt"
"strings"
"github.com/lanphiergm/adventofcodego/internal/utils"
)
// Transparent Origami Part 1 computes the number of visible dots after one fold
func TransparentOrigamiPart1(filename string) interface{} {
coords, folds := parseOrigamiData(filename)
coords = performFolds(coords,... | internal/puzzles/year2021/day_13_transparent_origami.go | 0.572962 | 0.431524 | day_13_transparent_origami.go | starcoder |
package glmatrix
import (
"fmt"
"math"
"math/rand"
)
// NewVec3 creates a new, empty Vec3
func NewVec3() []float64 {
return []float64{0., 0., 0.}
}
// Vec3Create creates a new Vec3 initialized with values from an existing vector
func Vec3Create() []float64 {
return NewVec3()
}
// Vec3Clone creates a new Vec3 i... | vec3.go | 0.878053 | 0.649224 | vec3.go | starcoder |
Package schwift is a client library for OpenStack Swift
(https://github.com/openstack/swift, https://openstack.org).
Authentication with Gophercloud
Schwift does not implement authentication (neither Keystone nor Swift v1), but
can be plugged into any library that does. The most common choice is
Gophercloud (https:/... | vendor/github.com/majewsky/schwift/doc.go | 0.733738 | 0.432003 | doc.go | starcoder |
package graph
import (
"errors"
)
//Graph represents a graph
type Graph struct {
isDirected bool
nodes map[*Node]bool
}
//SetDirection to the graph
func (g *Graph) SetDirection(directed bool) error {
if g.nodes != nil && len(g.nodes) != 0 {
return errors.New("Direction cannot be set, nodes already exist")... | graph/graph.go | 0.716119 | 0.405743 | graph.go | starcoder |
package rule
const (
tipA = `-A, --append chain rule-specification
Append one or more rules to the end of the selected chain. When the source and/or destination names resolve to more than one address, a
rule will be added for each possible address combination.
-4, --ipv4
This option has no effect in iptabl... | rule/tooltip.go | 0.637821 | 0.543348 | tooltip.go | starcoder |
package missing_build_infrastructure
import (
"github.com/threagile/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "missing-build-infrastructure",
Title: "Missing Build Infrastructure",
Description: "The modeled architecture does not contain a build infrastructure (d... | risks/built-in/missing-build-infrastructure/missing-build-infrastructure-rule.go | 0.642881 | 0.427158 | missing-build-infrastructure-rule.go | starcoder |
package canvas
import (
"image/color"
"math"
"github.com/jesseduffield/fyne"
)
// Declare conformity with CanvasObject interface
var _ fyne.CanvasObject = (*Line)(nil)
// Line describes a colored line primitive in a Fyne canvas.
// Lines are special as they can have a negative width or height to indicate
// an i... | canvas/line.go | 0.830078 | 0.469885 | line.go | starcoder |
package bloom
import (
"math"
"github.com/andy2046/bitmap"
)
type (
bloomFilterBit struct {
bitmap *bitmap.Bitmap // bloom filter bitmap
k uint64 // number of hash functions
n uint64 // number of elements in the bloom filter
m uint64 // size of the bloom filter bits
... | pkg/bloom/bloombit.go | 0.732879 | 0.568775 | bloombit.go | starcoder |
package iso20022
// Specifies periods.
type CorporateActionPeriod2 struct {
// Period during which the assented line is available.
AssentedLinePeriod *Period1 `xml:"AssntdLinePrd,omitempty"`
// Period during which the specified option, or all options of the event, remains valid, eg, offer period.
ActionPeriod *P... | CorporateActionPeriod2.go | 0.843766 | 0.422862 | CorporateActionPeriod2.go | starcoder |
package main
// importing fmt package
import (
"fmt"
)
// add method
func add(matrix1 [2][2]int, matrix2 [2][2]int) [2][2]int {
var m int
var l int
var sum [2][2]int
for l = 0; l < 2; l++ {
for m = 0; m < 2; m++ {
sum[l][m] = matrix1[l][m] + matrix2[l][m]
}
}
return sum
}
// subtract method
func subtra... | Chapter05/twodmatrix.go | 0.553988 | 0.425187 | twodmatrix.go | starcoder |
package grid
import "github.com/xwjdsh/2048-ai/utils"
type Direction int
const (
UP Direction = iota
RIGHT
DOWN
LEFT
NONE
)
type Grid struct {
Data [4][4]int `json:"data"`
}
func (g *Grid) Clone() *Grid {
gridClone := &Grid{}
*gridClone = *g
return gridClone
}
func (g *Grid) Max() int {
max := 0
for _... | grid/grid.go | 0.5 | 0.454048 | grid.go | starcoder |
package elements
import (
. "github.com/drbrain/go-unicornify/unicornify/core"
. "github.com/drbrain/go-unicornify/unicornify/rendering"
"math"
)
type Bone struct {
Balls [2]*Ball
XFunc, YFunc func(float64) float64 // may be nil
}
func NewBone(b1, b2 *Ball) *Bone {
return NewNonLinBone(b1, b2, nil, nil)... | unicornify/elements/bone.go | 0.666822 | 0.419826 | bone.go | starcoder |
package flags
import (
"fmt"
"strconv"
)
// BoolValue represents a boolean argument value.
type BoolValue bool
// NewBoolValue creates a new BoolValue.
func NewBoolValue(init bool) *BoolValue {
p := new(bool)
*p = init
return (*BoolValue)(p)
}
// Set will attempt to convert the given string to a value.
func (p... | values.go | 0.786213 | 0.422266 | values.go | starcoder |
package freejson
import (
"github.com/nanwanwang/stardust/encodingx/jsonx"
"time"
)
type Array []interface{}
func (a Array) Len() int {
return len(a)
}
func (a Array) Has(index int) bool {
return index >= 0 && index < len(a)
}
func (a Array) Each(f func(index int, v interface{})) {
for i, v := range a {
f(i... | encodingx/jsonx/freejson/array.go | 0.63114 | 0.440289 | array.go | starcoder |
package math
import "math"
type Vector4 struct {
X float64
Y float64
Z float64
W float64
}
func NewVector4( x, y, z float64) *Vector4 {
v := &Vector4{ X:x, Y:y , Z:z, W:1 }
return v
}
func (v *Vector4) Set( x, y, z, w float64 ) *Vector4 {
v.X = x
v.Y = y
v.Z = z
v.W = w
return v
}
func (v *Vector4) Se... | math/vector4.go | 0.782787 | 0.706553 | vector4.go | starcoder |
package leader
import (
"math"
)
/*
A zero-indexed array A consisting of N integers is given. The dominator of array A is
the value that occurs in more than half of the elements of A.
For example, consider array A such that
A[0] = 3 A[1] = 4 A[2] = 3
A[3] = 2 A[4] = 3 A[5] = -1
A[6] = 3 A[7] = 3... | leader/Dominator.go | 0.744006 | 0.72911 | Dominator.go | starcoder |
package day20
import (
"fmt"
"io"
"math"
)
const MaxTicks = 1000
type Coord struct {
X, Y, Z int
}
type Particle struct {
Position, Velocity, Acceleration Coord
Destroyed bool
}
func (p *Particle) Tick() {
p.Velocity.X += p.Acceleration.X
p.Velocity.Y += p.Acceleration.Y
p.Velocity.Z... | 2017/day20/day20.go | 0.627267 | 0.491334 | day20.go | starcoder |
package game
import "github.com/nsf/termbox-go"
// Direction is the type that reppresents the current direction of the snake
type Direction uint8
// UP means that the snake is going up
// RIGHT means that the snake is going right
// DOWN means that the snake is going down
// LEFT means that the snake is going left
c... | game/player.go | 0.530966 | 0.433502 | player.go | starcoder |
package main
import (
"fmt"
"strconv"
"time"
)
func main() {
start := time.Now()
one, two := CheckPasswords(254032, 789860)
end := time.Since(start)
fmt.Printf("[PART ONE] passwords that meet criteria: %d\n", one)
fmt.Printf("[PART TWO] passwords that meet criteria: %d\n", two)
fmt.Printf("took %s\n", end)
}... | 2019/go/04/main.go | 0.764012 | 0.448487 | main.go | starcoder |
package hre
import (
"fmt"
"regexp/syntax"
"strings"
)
var (
// ^^
reLeftEdge = re(`\^+`)
// $$
reRightEdge = re(`\$+`)
// {...}
// βββ΄β (1)
reZeroWidth = re(`
--- open brace
\{
--- inside of brace
( [^}]+ )
--- close brace
\}
`)
// {...}$$
// β β ββ΄β (2)
// βββ΄β (1)
reLookahead = re(`... | assertions.go | 0.530723 | 0.49707 | assertions.go | starcoder |
package jsonlogic
func opEqual(value interface{}, data interface{}) (interface{}, error) {
var leftValue, rightValue interface{}
var err error
var valuearray []interface{}
switch value.(type) {
case []interface{}:
valuearray = value.([]interface{})
case interface{}:
leftValue = value
}
if len(valuearray) ... | op_compare.go | 0.521715 | 0.47098 | op_compare.go | starcoder |
package main
import (
"fmt"
"math"
)
type Shape interface {
Perimeter() float64
}
type Circle struct {
radius float64
}
func (c Circle) Circumference() float64 {
return 2 * math.Pi * c.radius
}
func (c Circle) Perimeter() float64 {
return c.Circumference()
}
type ConvexPolygon interface {
NumSides() int
}
... | Go/euclidean_geometry.go | 0.853104 | 0.50293 | euclidean_geometry.go | starcoder |
package main
import (
"math"
"os"
"github.com/EliCDavis/mango"
"github.com/EliCDavis/vector"
)
func Cylinder(
sides int,
height float64,
bottomRadius float64,
topRadius float64,
bottomOffset vector.Vector3,
topOffset vector.Vector3,
) mango.Mesh {
shaft := mango.BuildRing(sides, height, bottomRadius, topR... | cmd/cake1/main.go | 0.662141 | 0.481454 | main.go | starcoder |
package search
import (
"fmt"
"net/url"
"strings"
)
// ParseQuery provides an alternative to url.ParseQuery when the order of parameters must be retained. ParseQuery
// parses the URL-encoded query string and returns a URLQueryParameters object that can be used to get the ordered list
// of parameters, a map of t... | search/url_query_parser.go | 0.700383 | 0.400661 | url_query_parser.go | starcoder |
package cview
import "github.com/gdamore/tcell/v2"
// Theme defines the colors used when primitives are initialized.
type Theme struct {
// Title, border and other lines
TitleColor tcell.Color // Box titles.
BorderColor tcell.Color // Box borders.
GraphicsColor tcell.Color // Graphics.
// Text
PrimaryText... | styles.go | 0.603348 | 0.450662 | styles.go | starcoder |
package bradleyterry
import (
"math"
"math/rand"
)
// Pair is a struct combining the outcome of a single match, and contains the name of the
// winner and the name of the loser.
type Pair struct {
Winner string
Loser string
}
const convergenceErr = 1e-15
const maxIter = 10e8
// Model takes in a dataset of Pair... | model.go | 0.599837 | 0.452778 | model.go | starcoder |
package evt
import "github.com/shasderias/ilysa/chroma"
// WithNameFilter causes event to only affect rings with the name filter (e.g.
// SmallTrackLaneRings, BigTrackLaneRings).
func WithNameFilter(filter string) withNameFilterOpt {
return withNameFilterOpt{filter}
}
type withNameFilterOpt struct {
nameFilter str... | evt/rotation_opt.go | 0.852522 | 0.473049 | rotation_opt.go | starcoder |
package network
import (
"fmt"
"github.com/benjohns1/neural-net-go/matutil"
"github.com/benjohns1/neural-net-go/network/activation"
"gonum.org/v1/gonum/mat"
)
// Config network constructor.
type Config struct {
InputCount int
LayerCounts []int
Activation ActivationType
Rate float64
RandSeed uin... | network/network.go | 0.786746 | 0.441432 | network.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.