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 tmplwalk
import "text/template/parse"
// A Visitor's Visit method is invoked for each node encountered by Walk.
// If the result visitor w is not nil, Walk visits each of the children
// of node with the visitor w, followed by a call of w.Visit(nil).
type Visitor interface {
Visit(node parse.Node) (w Visitor... | tmplwalk/walk.go | 0.752649 | 0.482978 | walk.go | starcoder |
package decimal
import (
"math"
"math/big"
"math/rand"
"strconv"
"gonum.org/v1/gonum/floats/scalar"
)
const Epsilon = 1e-7
var (
MarshalAsString = true
Inf = Decimal(math.Inf(1))
NegInf = Decimal(math.Inf(-1))
)
func Zero() Decimal {
return 0
}
func One() Decimal {
return 1
}
func ... | decimal/decimal.go | 0.810479 | 0.462959 | decimal.go | starcoder |
package searcharray
type SearchType int
type SearchResult int
// Enumerated constants are created using the iota enumerator
const (
LessThan SearchType = iota
LessThanEquals
Equals
GreaterThanEquals
GreaterThan
)
const (
NotFound SearchResult = iota
FoundExact
FoundGreater
FoundLess
)
const (
DESCENDING =... | searcharray.go | 0.665737 | 0.535827 | searcharray.go | starcoder |
Package v1 contains Rufs REST API Version 1.
Admin control endpoint
/admin
The admin endpoint can be used for various admin tasks such as registering
new branches or mounting known branches.
A GET request to the admin endpoint returns the current tree
configuration; an object of all known branches and the current m... | api/v1/admin.go | 0.680666 | 0.599925 | admin.go | starcoder |
package graphql
import (
"fmt"
"math"
"strconv"
"github.com/graphql-go/graphql/language/ast"
)
func coerceInt(value interface{}) interface{} {
switch value := value.(type) {
case bool:
if value == true {
return 1
}
return 0
case int:
return value
case int8:
return int(value)
case int16:
retur... | vendor/github.com/graphql-go/graphql/scalars.go | 0.635788 | 0.423875 | scalars.go | starcoder |
package model
import (
"bytes"
"reflect"
"strings"
"fmt"
"github.com/lquesada/cavernal/lib/g3n/engine/loader/obj"
"github.com/lquesada/cavernal/lib/g3n/engine/math32"
)
var (
MeterScaleFactor float32 = 1/1.26
GlobalScaleFactor float32 = 0.01
X2 = &Transform{Scale: &math32.Vector3{2, 2, ... | model/model.go | 0.583559 | 0.504089 | model.go | starcoder |
package similgraph
import (
"math"
"github.com/pkg/errors"
)
// New creates a new similgraph from the edges iterator; vertexACount, vertexBCount and edgeCount contain size estimates, used for efficient memory allocation.
func New(edges func() (info Edge, ok bool), vertexACount, vertexBCount, edgeCount int) (g *Sim... | newsimilgraph.go | 0.713831 | 0.644533 | newsimilgraph.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
"strconv"
)
// Int2VectorArrayFromIntSliceSlice returns a driver.Valuer that produces a PostgreSQL int2vector[] from the given Go [][]int.
func Int2VectorArrayFromIntSliceSlice(val [][]int) driver.Valuer {
return int2VectorArrayFromIntSliceSlice{val: val... | pgsql/int2vectorarr.go | 0.797083 | 0.711631 | int2vectorarr.go | starcoder |
// Package concurrency contain some functions to support concurrent programming. eg, goroutine, channel, async.
package concurrency
import (
"context"
"sync"
)
// Channel is a logic object which can generate or manipulate go channel
// all methods of Channel are in the book tilted《Concurrency in Go》
type Channel s... | concurrency/channel.go | 0.705684 | 0.428473 | channel.go | starcoder |
package set
import (
"fmt"
"github.com/knutsonchris/stackilackey/cmd"
)
type network struct {
}
/*
Description
Sets the network address of a network.
Arguments
{network}
The name of the network.
Parameters
{address=string}
Address that the named network should have.
*/
func (network *network) Addres... | set/network.go | 0.739705 | 0.402744 | network.go | starcoder |
package datastructs
import (
"strconv"
)
// Key is an integer key in a symbol table.
type Key int
// Value is a string value in a symbol table.
type Value string
type node struct {
key Key
val Value
left, right *node
size int // number of nodes rooted at this node (i.e. number of nodes ... | pkg/datastructs/bst.go | 0.852752 | 0.608856 | bst.go | starcoder |
package algs
import (
"math"
"unicode"
)
/*
MyAtoi solves the following problem:
Implement atoi which converts a string to an integer.
The function first discards as many whitespace characters as necessary
until the first non-whitespace character is found.
Then, starting from this character, takes an optional ... | algs/0008.string_to_integer.go | 0.657758 | 0.701764 | 0008.string_to_integer.go | starcoder |
package geopoint
import (
"math"
)
const (
mileInKilometres = 1.60934 // kilometres -> miles conversion.
degToRad = math.Pi / 180.0 // degrees -> radians conversion.
earthRadiusInKilometres = 6371
)
// Kilometres are units of distance.
type Kilometres float64
// Miles converts kilo... | geopoint.go | 0.846133 | 0.716256 | geopoint.go | starcoder |
package output
import (
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/output/writer"
"github.com/Jeffail/benthos/lib/types"
)
//------------------------------------------------------------------------------
func init() {
Constructors[TypeHTTPClien... | lib/output/http_client.go | 0.777511 | 0.407216 | http_client.go | starcoder |
package trace
// This file implements histogramming for RPC statistics collection.
import (
"bytes"
"fmt"
"html/template"
"log"
"math"
"sync"
"gx/ipfs/QmRvYNctevGUW52urgmoFZscT6buMKqhHezLUS64WepGWn/go-net/internal/timeseries"
)
const (
bucketCount = 38
)
// histogram keeps counts of values in buckets that... | vendor/gx/ipfs/QmRvYNctevGUW52urgmoFZscT6buMKqhHezLUS64WepGWn/go-net/trace/histogram.go | 0.701713 | 0.46217 | histogram.go | starcoder |
package model
import (
"errors"
"math/rand"
)
type Player int
// Players
const (
White Player = iota
Red
Spaces = 26
BarPosition = Spaces - 1
HomePosition = 0
)
// Board backgammon board
type Board struct {
Turn int
Board [2][Spaces]int
Hit [2]int
Borne [2]int
Pips [2]int
}
func reverse(numbers ... | model/board.go | 0.566258 | 0.470858 | board.go | starcoder |
package trea
import (
"encoding/xml"
"github.com/fairxio/finance-messaging/iso20022"
)
type Document00200102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:trea.002.001.02 Document"`
Message *AmendNonDeliverableForwardOpeningV02 `xml:"AmdNDFOpngV02"`
}
func (d *Docum... | iso20022/trea/AmendNonDeliverableForwardOpeningV02.go | 0.706393 | 0.403391 | AmendNonDeliverableForwardOpeningV02.go | starcoder |
package main
// user represents an user in the system.
type user struct {
name string
email string
}
func main() {
// -------------
// Pass by value
// -------------
// Declare variable of type int with a value of 10.
// This value is put on a stack with a value of 10.
count := 10
// To get the address of... | Language_Specification/build-in-type/pointers/pointers.go | 0.516595 | 0.408808 | pointers.go | starcoder |
package prototype
import (
"errors"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
log "github.com/sirupsen/logrus"
"github.com/perun-network/erdstall/tee"
)
type (
// Epoch manages deposits, transactions, and exits, as well as the
// progression of time in the system.
Epoch struct {
number t... | tee/prototype/epoch.go | 0.569254 | 0.443721 | epoch.go | starcoder |
package blockchain
import (
"fmt"
"time"
chaincfg "git.parallelcoin.io/dev/pod/pkg/chain/config"
"git.parallelcoin.io/dev/pod/pkg/chain/fork"
chainhash "git.parallelcoin.io/dev/pod/pkg/chain/hash"
database "git.parallelcoin.io/dev/pod/pkg/db"
"git.parallelcoin.io/dev/pod/pkg/util"
cl "git.parallelcoin.io/dev/... | pkg/chain/process.go | 0.634204 | 0.424472 | process.go | starcoder |
package bls12377
import (
"crypto/rand"
"io"
"math/big"
)
const frByteSize = 32
const frBitSize = 253
const frNumberOfLimbs = 4
const fourWordBitSize = 256
// halfR = 2**256 / 2
var halfR = &wideFr{0, 0, 0, 0x8000000000000000, 0, 0, 0}
var halfRBig = bigFromHex("0x8000000000000000000000000000000000000000000000000... | fr.go | 0.594669 | 0.414306 | fr.go | starcoder |
package aws implements autoscaling integration for AWS cloud provider
Design
------
+-------------------------+ +--------------------------+
| | | |
| | ... | lib/autoscale/aws/doc.go | 0.747524 | 0.505249 | doc.go | starcoder |
package geom
import (
. "math"
)
// A 2D Vector
type Vector2 [2]float64
// A 3D Vector
type Vector3 [3]float64
// A 4D Vector
type Vector4 [4]float64
// Get the value of the X axis
func (v Vector2) X() float64 {
return v[0]
}
// Get the value of the Y axis
func (v Vector2) Y() float64 {
return v[1]
}
// Get t... | geom/vectors.go | 0.889168 | 0.855127 | vectors.go | starcoder |
package convey
import "github.com/smartystreets/assertions"
var (
ShouldEqual = assertions.ShouldEqual
ShouldNotEqual = assertions.ShouldNotEqual
ShouldAlmostEqual = assertions.ShouldAlmostEqual
ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual
ShouldResemble = assertions.ShouldResem... | Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions.go | 0.689515 | 0.687682 | assertions.go | starcoder |
package validate
// ValidateV means one validator process all string, next process all string
// ValidateS means all validator process one string, all process next string
// ValidateM means one validator process one string, next process next string,
// remains validator process last string
// *2Last means validate unt... | validate/validate.go | 0.516839 | 0.466785 | validate.go | starcoder |
package tonacity
import (
"fmt"
"math"
)
// StandardConcertPitch The almost-completely agreed-upon pitch of A4
const StandardConcertPitch = 440
// PitchClass All musical tones separated by an octave. A major scale has 7, the chromatic scale has 11, etc.
type PitchClass struct {
value HalfSteps
}
// Transpose Tra... | pitch.go | 0.864525 | 0.57326 | pitch.go | starcoder |
package parser
/*
Simplifications to Go:
No shadowing of identifiers in nested scopes.
Cannot reuse builtin names. Cannot reuse global names.
`const` and `type` are only allowed at outer level.
`const` are untyped bool, integer, or string.
`type` is only used to define struct and interface.
Structs can only be d... | parser/doc.go | 0.795539 | 0.789437 | doc.go | starcoder |
package merge
import (
"fmt"
"github.com/attic-labs/noms/go/d"
"github.com/attic-labs/noms/go/types"
)
func threeWayListMerge(a, b, parent types.List) (merged types.List, err error) {
aSpliceChan, bSpliceChan := make(chan types.Splice), make(chan types.Splice)
aStopChan, bStopChan := make(chan struct{}, 1), ma... | go/merge/three_way_list.go | 0.690246 | 0.49823 | three_way_list.go | starcoder |
package anagram
import (
"fmt"
"sort"
"strings"
leven "github.com/texttheater/golang-levenshtein/levenshtein"
)
// Anagram represents a collection of words which are anagrams of one another.
type Anagram struct {
// Words are each anagrams of one another.
// Words in Anagrams returned by library functions are ... | anagram.go | 0.741768 | 0.478773 | anagram.go | starcoder |
package iso20022
// Creation/cancellation of investment units on the books of the fund or its designated agent, as a result of executing an investment fund order.
type InvestmentFundTransaction3 struct {
// Type of investment fund transaction.
TransactionType *TransactionType2Code `xml:"TxTp"`
// Type of investme... | InvestmentFundTransaction3.go | 0.804675 | 0.469399 | InvestmentFundTransaction3.go | starcoder |
package fv
// the references: in order: of the Base set of Fighter Verses
var BaseSet = []entry{
{BibleOrder: 4, SetOrder: 101, Set: "Base", Ref: "Deuteronomy 7:9"},
{BibleOrder: 5, SetOrder: 102, Set: "Base", Ref: "Deuteronomy 10:12–13"},
{BibleOrder: 133, SetOrder: 103, Set: "Base", Ref: "John 1:12–13"},
{BibleO... | fv/base.go | 0.574753 | 0.594375 | base.go | starcoder |
package graph
import (
"strings"
"sync"
)
type AxisGraph struct {
Plane [41][41]Point
highest float64
Graphs []string
storage []string
}
func (graph *AxisGraph) New() {
for y := 0; y < len(graph.Plane); y++ {
for x := 0; x < len(graph.Plane[0]); x++ {
graph.Plane[y][x]... | graph/axisgraph.go | 0.623148 | 0.48054 | axisgraph.go | starcoder |
package main
import (
"flag"
"fmt"
)
var depth = flag.Int("depth", 8112, "The depth of the cave system.")
var targetX = flag.Int("targetX", 13, "The target's X coordinate.")
var targetY = flag.Int("targetY", 743, "The target's Y coordinate.")
var margin = flag.Int("margin", 150, "The margin by which we'll check 'lo... | 2018/day22.go | 0.546254 | 0.403537 | day22.go | starcoder |
package math3d
import (
"fmt"
"math"
)
type Vector3 struct {
X float64
Y float64
Z float64
}
var (
ZeroVector3 = Vector3{}
)
// MakeVector3 returns a pointer to a new Vector3.
func MakeVector3(x float64, y float64, z float64) *Vector3 {
return &Vector3{x, y, z}
}
func (v Vector3) String() string {
return f... | math3d/vector.go | 0.769514 | 0.653493 | vector.go | starcoder |
package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
)
// Python-style modulus function (-1 % 5 == 4, not -1)
func modulus(i int, m int) (r int) {
r = i % m
if r < 0 {
r += m
}
return
}
// Grid for cellular automata, mazes, etc.
type Grid [][]byte
// Coordinate is a position on a Grid, i.e., grid[y]... | 2020/20/b.go | 0.828523 | 0.400632 | b.go | starcoder |
// Sample program to show how you can use embedding to reuse behavior from
// another type and override specific methods.
package main
import (
"fmt"
"log"
"time"
)
// Document is the core data model we are working with.
type Document struct {
Key string
Title string
}
// ====================================... | topics/go/language/embedding/exercises/exercise1/exercise1.go | 0.68616 | 0.401629 | exercise1.go | starcoder |
package advanced
import (
"math"
"github.com/ldsec/lattigo/v2/ckks"
"github.com/ldsec/lattigo/v2/utils"
)
// LinearTransformType is a type used to distinguish different linear transformations.
type LinearTransformType int
// CoeffsToSlots and SlotsToCoeffs are two linear transformations.
const (
CoeffsToSlots =... | ckks/advanced/homomorphic_encoding.go | 0.756897 | 0.683287 | homomorphic_encoding.go | starcoder |
package metrics_metadata
// A JSON object (dictionary) that contains the metadata for a single dimension that matched the query
type Dimension struct {
// The dimension name (key) for the dimension. Dimension names have these requirements: <br> * UTF-8 string, maximum length of 128 characters (512 bytes) * Must s... | metrics_metadata/model_dimension.go | 0.840848 | 0.446133 | model_dimension.go | starcoder |
package math
import (
"math"
"github.com/goplus/interp"
)
func init() {
interp.RegisterPackage("math", extMap, typList)
}
var extMap = map[string]interface{}{
"math.Abs": math.Abs,
"math.Acos": math.Acos,
"math.Acosh": math.Acosh,
"math.Asin": math.Asin,
"math.As... | pkg/math/export.go | 0.52829 | 0.496399 | export.go | starcoder |
package geos
/*
#include "geos.h"
*/
import "C"
// GeometryType represents the various geometry types supported by GEOS, and
// correspond to OGC Simple Features geometry types.
type GeometryType C.int
const (
// POINT is a 0-dimensional geometric object, a single location is geometric
// space.
POINT GeometryTyp... | vendor/github.com/paulsmith/gogeos/geos/types.go | 0.694406 | 0.41478 | types.go | starcoder |
package chess
import (
"encoding/json"
"fmt"
"math/rand"
"sort"
"strconv"
"time"
)
//Get Next move using mini max algorithm
func GetNextMoveUsingMiniMax(dat []string, prev_move string) string {
var move string
var stats string
active_color := "b"
node := createChessNodeUsingArray(dat, active_color, prev_mov... | go/src/chess/ai.go | 0.609059 | 0.413951 | ai.go | starcoder |
package httproutegen
import (
"errors"
"log"
)
const boundaryOfSequenceNumber = 0x9D
// SymbolType represent type of symbol.
type SymbolType int
// Symbol types
const (
SymbolTypeNoop SymbolType = iota
SymbolTypeByte
SymbolTypeSequence
)
// Symbol represent one input byte or variable.
type Symbol struct {
Ty... | httproutegen/symbol.go | 0.627152 | 0.411052 | symbol.go | starcoder |
package esquery
import (
"github.com/fatih/structs"
)
type matchType uint8
const (
// TypeMatch denotes a query of type "match"
TypeMatch matchType = iota
// TypeMatchBool denotes a query of type "match_bool_prefix"
TypeMatchBoolPrefix
// TypeMatchPhrase denotes a query of type "match_phrase"
TypeMatchPhras... | query_match.go | 0.875321 | 0.439386 | query_match.go | starcoder |
package ast
import (
"encoding/json"
"github.com/open-policy-agent/opa/util"
)
// ValueMap represents a key/value map between AST term values. Any type of term
// can be used as a key in the map.
type ValueMap struct {
hashMap *util.HashMap
}
// NewValueMap returns a new ValueMap.
func NewValueMap() *ValueMap {... | vendor/github.com/open-policy-agent/opa/ast/map.go | 0.762601 | 0.433262 | map.go | starcoder |
package tfutil
import (
"fmt"
tf "github.com/tensorflow/tensorflow/tensorflow/go"
"github.com/tensorflow/tensorflow/tensorflow/go/op"
)
// Sub fetches sub a new tensor without altering original.
// startIndices if nil is set to a slice
// of zeros indicating starting from the beginning of the tensor. Length of
//... | pkg/tfutil/subtensor.go | 0.843573 | 0.553143 | subtensor.go | starcoder |
package vme
import (
"encoding/binary"
"errors"
"github.com/coschain/contentos-go/common"
"reflect"
"unsafe"
)
func decodeBool(data []byte) (bool, int) {
if len(data) >= 1 {
return data[0] != 0, 1
}
return false, 0
}
func decodeInt8(data []byte) (int8, int) {
if len(data) >= 1 {
return int8(data[0]), 1
... | common/encoding/vme/decode.go | 0.599368 | 0.403479 | decode.go | starcoder |
package yasup
import (
crypto "crypto/rand"
"math/big"
"math/rand"
)
var zeroValueFloat32 float32
//Float32Insert will append elem at the position i. Might return ErrIndexOutOfBounds.
func Float32Insert(sl *[]float32, elem float32, i int) error {
if i < 0 || i > len(*sl) {
return ErrIndexOutOfBounds
}
*sl =... | float32Slices.go | 0.721154 | 0.459319 | float32Slices.go | starcoder |
package clickgame
import (
"mcs/pkg/chaingame"
)
// A Hand stores legal moves.
type Hand chaingame.ColorTiles
// Draw randomly removes a move from the hand.
func (h Hand) Draw() (Move, Hand) {
tiles := chaingame.ColorTiles(h)
tile := tiles.PickTile(chaingame.NoColor)
return Move(tile), Hand(tiles)
}
// Len re... | games/clickomania/iface.go | 0.884713 | 0.495789 | iface.go | starcoder |
package chromath
// Gamma22 is the most common defintion for a RGB transform gamma of 2.2
const Gamma22 = 563 / 256.0
// An RGBSpace defines the parameters necessary for transforming most commonly defined RGB working
// spaces into XYZ. The definition includes the affine linear RGB to XYZ transform, a reference to
//... | vendor/github.com/jkl1337/go-chromath/datum.go | 0.670393 | 0.646823 | datum.go | starcoder |
package level
// FloorInfo describes the properties of a floor.
type FloorInfo byte
// AbsoluteHeight returns the floor height in range of [0..TileHeightUnitMax-1].
func (info FloorInfo) AbsoluteHeight() TileHeightUnit {
return TileHeightUnit(info & 0x1F)
}
// WithAbsoluteHeight returns a floor info that specifies ... | ss1/content/archive/level/FloorCeilingInfo.go | 0.8959 | 0.585901 | FloorCeilingInfo.go | starcoder |
package graph
import "time"
/*
A Port describes an instance of either an input or output port of a
graph node. Input ports are where graph nodes receive data from.
Output ports are where graph nodes send computed results through.
Each input port can only be binded to a single output port.
Each output port can be bind... | port.go | 0.636127 | 0.516595 | port.go | starcoder |
package cast
import (
"reflect"
"strings"
"github.com/cuigh/auxo/ext/reflects"
)
func TryToValue(i interface{}, t reflect.Type) (v reflect.Value, err error) {
var value interface{}
if t == reflects.TypeDuration {
value, err = TryToDuration(i)
} else if t == reflects.TypeTime {
value, err = TryToTime(i)
}... | util/cast/reflect.go | 0.526099 | 0.430506 | reflect.go | starcoder |
package solar
import (
"image/color"
"math"
"github.com/golang/geo/r2"
)
// DrawLine renders a line that moves back and forth
type DrawLine struct {
// where line starts
startPosition r2.Point
// where line neds
endPosition r2.Point
// time it takes for line to travel from start to end
traverseTime float... | solar/drawLine.go | 0.87068 | 0.555013 | drawLine.go | starcoder |
package engine
// Add arbitrary terms to B_eff, Edens_total.
import (
"fmt"
"github.com/mumax/3cl/data"
"github.com/mumax/3cl/opencl"
"github.com/mumax/3cl/util"
)
var (
B_custom = NewVectorField("B_custom", "T", "User-defined field", AddCustomField)
Edens_custom = NewScalarField("Edens_custom", "J/m3"... | engine/customfield.go | 0.815233 | 0.495484 | customfield.go | starcoder |
package utils
// https://github.com/SonarSystems/Modern-OpenGL-Tutorials/blob/master/%5BADVANCED%20OPENGL%5D/%5B17%5D%20Cubemap:Skybox/main.cpp
import (
"fmt"
"image"
"image/draw"
"unsafe"
// Required in order to use jpeg files.
_ "image/jpeg"
"os"
"github.com/go-gl/gl/v4.6-core/gl"
)
// Texture Texture
ty... | internal/utils/texture.go | 0.724383 | 0.432902 | texture.go | starcoder |
package main
import (
"github.com/PieterD/glimmer/gli"
"github.com/PieterD/glimmer/mat"
"github.com/go-gl/glfw/v3.1/glfw"
"github.com/go-gl/mathgl/mgl32"
)
const d2r = 3.14159 * 2 / 360
type Crane struct {
posBase mgl32.Vec3
angBase float32
posBaseLeft mgl32.Vec3
posBaseRight mgl32.Vec3
s... | glimmer/old/ogli/examples/ex08-crane-model/crane.go | 0.511473 | 0.49646 | crane.go | starcoder |
package ionossdk
import (
"encoding/json"
)
// KubernetesNodePoolLabel map of labels attached to node pool
type KubernetesNodePoolLabel struct {
// Key of the label. String part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character.
Key *string `json:"key,... | cluster-autoscaler/cloudprovider/ionoscloud/ionos-cloud-sdk-go/model_kubernetes_node_pool_label.go | 0.697197 | 0.412767 | model_kubernetes_node_pool_label.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/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
)
//-----------------------------------------------------------------... | lib/input/nats_stream.go | 0.810629 | 0.750667 | nats_stream.go | starcoder |
package basic
// SortTest is template
func SortTest() string {
return `
func TestSort<FTYPE>(t *testing.T) {
expectedList := []<TYPE>{1, 2, 3, 4, 5}
sortedList := Sort<FTYPE>s([]<TYPE>{5, 1, 4, 2, 3})
matched := reflect.DeepEqual(sortedList, expectedList)
if !matched {
t.Errorf("Sotred<TYPE>s failed")
}
sort... | internal/template/basic/sorttest.go | 0.604516 | 0.620392 | sorttest.go | starcoder |
package schema
import "strings"
func buildJSSchema() {
const src = `{
"id": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Core schema meta-schema",
"definitions": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items... | vendor/github.com/lestrrat/go-jsschema/default.go | 0.744749 | 0.509215 | default.go | starcoder |
package gokvstores
import "time"
// DummyStore is a noop store (caching disabled).
type DummyStore struct{}
// Get returns value for the given key.
func (DummyStore) Get(key string) (interface{}, error) {
return nil, nil
}
// MGet returns map of key, value for a list of keys.
func (DummyStore) MGet(keys []string) ... | vendor/github.com/ulule/gokvstores/dummy.go | 0.83056 | 0.415373 | dummy.go | starcoder |
package util
import (
"image/color"
"math"
"github.com/anthonynsimon/bild/math/f64"
)
// RGBToHSL converts from RGB to HSL color model.
// Parameter c is the RGBA color and must implement the color.RGBA interface.
// Returned values h, s and l correspond to the hue, saturation and lightness.
// The hue is of ran... | util/colormodel.go | 0.810929 | 0.504944 | colormodel.go | starcoder |
package common
/*
Locations is a list (slice) of latitude-longitude pairs.
Description
The minimum length of a Locations is 2:
the first element being the route start location,
and the second element being the route end location.
Each element in a Locations value is a latitude-longitude pair encoded as a slice of s... | common/type.go | 0.769167 | 0.704033 | type.go | starcoder |
package main
import (
"fmt"
"math"
"os"
"gonum.org/v1/plot/plotter"
)
// ExplicitEuler returns data for plot building based on explicit Euler method.
func ExplicitEuler(start, end, y0 float64, count int) plotter.XYs {
step, xRange := GetRange(start, end, count)
solution := make(plotter.XYs, count)
for i := ... | methods.go | 0.787278 | 0.536374 | methods.go | starcoder |
package level
import (
m "github.com/divVerent/aaaaxy/internal/math"
)
// Contents indicates what kind of tiles/objects we want to hit.
type Contents int
const (
NoContents Contents = 0
OpaqueContents Contents = 1
PlayerSolidContents Contents = 2
ObjectSolidContents Contents = 4
SolidContents ... | internal/level/tile.go | 0.742515 | 0.529568 | tile.go | starcoder |
package eval
import (
"fmt"
"panda/ast"
"strings"
)
func (inter *Interpreter) evalAddExpression(express *ast.InfixExpression) (interface{}, error) {
leftValue, err := inter.evalExpress(express.Left)
if err != nil {
return nil, err
}
rightValue, err := inter.evalExpress(express.Right)
if err != nil {
retur... | eval/eval_infixexpress.go | 0.52683 | 0.481332 | eval_infixexpress.go | starcoder |
package textencoding
const baseWinAnsi = "WinAnsiEncoding"
var (
winAnsi = newSimpleMapping(baseWinAnsi, winAnsiCharToRune)
)
func init() {
RegisterSimpleEncoding(baseWinAnsi, NewWinAnsiEncoder)
}
// NewWinAnsiEncoder returns a simpleEncoder that implements WinAnsiEncoding.
func NewWinAnsiEncoder() SimpleEncoder ... | bot/vendor/github.com/pzduniak/unipdf/internal/textencoding/simple_winansi.go | 0.565539 | 0.405007 | simple_winansi.go | starcoder |
package maze
// visitedCells represents the cells whose numbers are mapped to their respective addresses.
// It is used in creating and navigating through the maze.
var visitedCells = map[int]cellAddress{}
// Dimensions defines the actual number of cells that make up the maze along the vertical and
// the horizontal ... | maze/maze.go | 0.798305 | 0.652684 | maze.go | starcoder |
package pwned
// This borrows from <NAME>'s great (real) Bloom filter.
// See https://github.com/yourbasic/bloom
import (
"context"
"encoding/binary"
"io"
"math"
pb "github.com/pedrosland/pwned-check/proto"
)
const (
shift = 6
mask = 0x3f
)
// Filter represents a kind-of-Bloom filter.
type Filter struct {
... | filter.go | 0.727879 | 0.402568 | filter.go | starcoder |
package advent
import (
"github.com/davidparks11/advent2021/internal/math"
)
var _ Problem = &theTreacheryOfWhales{}
type theTreacheryOfWhales struct {
dailyProblem
}
func NewTheTreacheryOfWhales() Problem {
return &theTreacheryOfWhales{
dailyProblem{
day: 7,
},
}
}
func (t *theTreacheryOfWhales) Solve(... | internal/advent/day7.go | 0.572245 | 0.556701 | day7.go | starcoder |
package gubernator
import (
"time"
)
// Implements token bucket algorithm for rate limiting. https://en.wikipedia.org/wiki/Token_bucket
func tokenBucket(s Store, c Cache, r *RateLimitReq) (resp *RateLimitResp, err error) {
item, ok := c.GetItem(r.HashKey())
if s != nil {
if !ok {
// Check our store for the it... | algorithms.go | 0.679285 | 0.406273 | algorithms.go | starcoder |
package trie
// Trie Represent a node of trie
// Not advised to create the node directly. Use helper function CreateNode() instead
type Trie struct {
Node
}
// New Creates an initialized trie data structure
func New() *Trie {
return &Trie{
*CreateNode(0),
}
}
// Insert allow one or more keyword to be inserted i... | trie.go | 0.743075 | 0.536738 | trie.go | starcoder |
package fingerprint
import (
"fmt"
"math"
"github.com/goccmack/godsp/ppeaks"
)
// GetHighestMatchRate returns the highest match rate between the fingerprint of the sample and the fingerprint of the target audio.
func GetHighestMatchRate(sampleFilename string, sampleFingerprint [][]int, audioFilename string, audio... | fingerprint/fingerprint.go | 0.671686 | 0.486088 | fingerprint.go | starcoder |
package anomalies
import (
"time"
"gopkg.in/olivere/elastic.v5"
"github.com/trackit/trackit-server/config"
)
const (
// aggregationMaxSize is the maximum size of an Elastic Search Aggregation
aggregationMaxSize = 0x7FFFFFFF
// queryMaxSize is the maximum size of an Elastic Search Query
queryMaxSize = 10000... | anomaliesDetection/es_request_constructor.go | 0.728265 | 0.491761 | es_request_constructor.go | starcoder |
package aoc2020
import (
"fmt"
"reflect"
)
type airport [][]int // 0 -> floor, 1 -> empty, 2 -> occupied
func (a airport) occupied(row, col int) (occ, unocc, inbounds bool) {
if row < 0 || row >= len(a) {
return false, false, false
}
ar := a[row]
if col < 0 || col >= len(ar) {
return false, false, false
}... | 11.go | 0.527073 | 0.429728 | 11.go | starcoder |
package rango
import "math"
func subdivide(src Triangle, dest *[4]Triangle, radius float64) {
/* mid points of the edges of the triangle */
mid0 := FloatVecMult(radius, Normalize(Add(src.V0, src.V1)))
mid1 := FloatVecMult(radius, Normalize(Add(src.V1, src.V2)))
mid2 := FloatVecMult(radius, Normalize(Add(src.V2, s... | rango/sphere.go | 0.69035 | 0.539832 | sphere.go | starcoder |
package ast
import "fmt"
// Transformer defines the interface for transforming AST elements. If the
// transformer returns nil and does not indicate an error, the AST element will
// be set to nil and no transformations will be applied to children of the
// element.
type Transformer interface {
Transform(v interfac... | ast/transform.go | 0.555073 | 0.461988 | transform.go | starcoder |
package service
import (
"image"
"image/color"
"math"
)
var bili = Bilinear{}
// Bilinear Bilinear.
type Bilinear struct{}
// BilinearSrc BilinearSrc.
type BilinearSrc struct {
// Top-left and bottom-right interpolation sources
low, high image.Point
// Fraction of each pixel to take. The 0 suffix indicates
/... | app/interface/main/captcha/service/bilinear.go | 0.610337 | 0.676905 | bilinear.go | starcoder |
package validation
import (
"fmt"
"reflect"
)
var (
bytesType = reflect.TypeOf([]byte(nil))
)
// EnsureString ...
func EnsureString(v reflect.Value) (string, error) {
if v.Kind() == reflect.String {
return v.String(), nil
}
if v.Type() == bytesType {
return string(v.Interface().([]byte)), nil
}
return "... | util.go | 0.728748 | 0.46952 | util.go | starcoder |
package carrierpricing
import (
"errors"
"log"
"math"
"sort"
"strconv"
)
const (
// VehicleTypeBicycle means that a bicycle is used to carry parcels around.
VehicleTypeBicycle = "bicycle"
// VehicleTypeMotorbike means that a motorbike is used to carry parcels around.
VehicleTypeMotorbike = "motorbike"
// ... | service.go | 0.645567 | 0.425844 | service.go | starcoder |
package flags
import (
"strconv"
"time"
flag "github.com/spf13/pflag"
)
type intNullableArgument struct {
variableToSet **int
}
type float64NullableArgument struct {
variableToSet **float64
}
func newIntNullableArgument(variable **int) *intNullableArgument {
return &intNullableArgument{
variableToSet: vari... | cmd/flags/flags.go | 0.671686 | 0.40295 | flags.go | starcoder |
package gson
import "strconv"
func collate2gson(code []byte, config *Config) (interface{}, int) {
if len(code) == 0 {
return nil, 0
}
var scratch [64]byte
n := 1
switch code[0] {
case TypeMissing:
return MissingLiteral, 2
case TypeNull:
return nil, 2
case TypeTrue:
return true, 2
case TypeFalse:... | collate_value.go | 0.513912 | 0.4474 | collate_value.go | starcoder |
package lab
import (
"hash/crc32"
"math/rand"
"time"
)
// AudienceAim is something that determines the audience that should be shown the experiment.
type AudienceAim interface {
// shows says if the Visitor will be in the audience that will be shown the experiment.
shows(Visitor, StrategyGetter) bool
}
// Strat... | aim.go | 0.664431 | 0.562777 | aim.go | starcoder |
package gridly
import (
"encoding/json"
)
// CreateGrid struct for CreateGrid
type CreateGrid struct {
Metadata *map[string]string `json:"metadata,omitempty"`
Name *string `json:"name,omitempty"`
TemplateGridId *string `json:"templateGridId,omitempty"`
}
// NewCreateGrid instantiates a new CreateGrid object
// ... | model_create_grid.go | 0.774157 | 0.41484 | model_create_grid.go | starcoder |
package geom
// A LineString represents a single, unbroken line, linearly interpreted
// between zero or more control points.
type LineString struct {
geom1
}
// NewLineString returns a new LineString with layout l and no control points.
func NewLineString(l Layout) *LineString {
return NewLineStringFlat(l, nil)
}
... | linestring.go | 0.915399 | 0.465813 | linestring.go | starcoder |
package operations
import (
"strconv"
"strings"
. "github.com/mitjaziv/qmanager/internal/structures"
)
type (
ArithmeticSolver struct {
}
)
var (
// Precedence map
precedence = map[string]int{
"(": 0,
")": 0,
"+": 1,
"-": 1,
"*": 2,
"/": 2,
}
)
// process function takes input and process operat... | worker/operations/arithmetic.go | 0.583915 | 0.446857 | arithmetic.go | starcoder |
//go:generate go run gen-benchmarks.go
// Package vectorIntNodes defines the vector of integers function collection available for the GEP algorithm.
package vectorIntNodes
import (
"log"
"github.com/gmlewis/gep/v2/functions"
)
type VectorInt = functions.VectorInt
// VectorIntNode is a vector of integers functio... | functions/vector_int_nodes/vector_int.go | 0.598899 | 0.791982 | vector_int.go | starcoder |
package models
import (
"errors"
)
// Provides operations to manage the collection of bookingBusiness entities.
type BookingPriceType int
const (
// The price of the service is not defined.
UNDEFINED_BOOKINGPRICETYPE BookingPriceType = iota
// The price of the service is fixed.
FIXEDPRICE_BOOKINGPR... | models/booking_price_type.go | 0.554229 | 0.46873 | booking_price_type.go | starcoder |
package go2linq
// Reimplementing LINQ to Objects: Part 13 - Aggregate
// https://codeblog.jonskeet.uk/2010/12/30/reimplementing-linq-to-objects-part-13-aggregate/
// https://docs.microsoft.com/dotnet/api/system.linq.enumerable.aggregate
// Aggregate applies an accumulator function over a sequence.
func Aggregate[So... | aggregate.go | 0.780495 | 0.443239 | aggregate.go | starcoder |
package disttwoatoms
import (
"bufio"
"errors"
"fmt"
"io"
"math"
"os"
"github.com/ortiye/molsolvent/pkg/util"
"github.com/pelletier/go-toml"
)
// Type is name of the calculation.
var Type = "dist_two_atoms"
// DistTwoAtoms is a structure containing the parameters that can be parsed from
// a TOML configura... | pkg/disttwoatoms/disttwoatoms.go | 0.647241 | 0.442637 | disttwoatoms.go | starcoder |
package datasource
import (
"github.com/arturom/datadiff/histogram"
"gopkg.in/olivere/elastic.v1"
)
const facetLabel = "ids"
// ES0DataSource uses an Elasticsearch 0.90 backend to implement the datasource interface
type ES0DataSource struct {
Client elastic.Client
IndexName string
TypeName string
FieldName... | datasource/elasticsearch0.go | 0.691602 | 0.461199 | elasticsearch0.go | starcoder |
package bind
import (
"encoding/json"
"fmt"
"github.com/jefflinse/melatonin/expect"
)
// Bool creates a predicate requiring a value to be a bool,
// binding the value to a target variable.
func Bool(target *bool) expect.Predicate {
if target == nil {
return expect.Bool()
}
return expect.Bool().Then(func(act... | bind/bind.go | 0.801392 | 0.577257 | bind.go | starcoder |
package actions
import (
"fmt"
"github.com/inkyblackness/res/data/interpreters"
)
func forType(typeID int) func(*interpreters.Instance) bool {
return func(inst *interpreters.Instance) bool {
return inst.Get("Type") == uint32(typeID)
}
}
var transportHackerDetails = interpreters.New().
With("TargetX", 0, 4).A... | data/levelobj/actions/actions.go | 0.519034 | 0.465266 | actions.go | starcoder |
package storj
import (
"encoding/base32"
"github.com/zeebo/errs"
)
// EncryptionParameters is the cipher suite and parameters used for encryption
type EncryptionParameters struct {
// CipherSuite specifies the cipher suite to be used for encryption.
CipherSuite CipherSuite
// BlockSize determines the unit size... | vendor/storj.io/common/storj/encryption.go | 0.804214 | 0.50293 | encryption.go | starcoder |
package audio
import "github.com/moshenahmias/gopherboy/memory"
// AddrNR21 is the NR21 register address
const AddrNR21 uint16 = 0xFF16
// AddrNR22 is the NR22 register address
const AddrNR22 uint16 = 0xFF17
// AddrNR23 is the NR23 register address
const AddrNR23 uint16 = 0xFF18
// AddrNR24 is the NR24 register ad... | audio/square2.go | 0.696371 | 0.462473 | square2.go | starcoder |
package conversion
import (
"strings" // Used for efficient string builder (more efficient than simply appending strings)
)
const Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
// Base64Encode encodes the received input bytes slice into a base64 string.
// The implementation follows ... | conversion/base64.go | 0.763484 | 0.416678 | base64.go | starcoder |
package rawp
import (
"image"
"reflect"
imageExt "github.com/chai2010/image"
)
func defaultDepthKind(depth int) reflect.Kind {
switch depth {
case 8:
return reflect.Uint8
case 16:
return reflect.Uint16
case 32:
return reflect.Float32
}
return reflect.Uint16
}
func newBytes(size int, buf []byte) []by... | rawp/util.go | 0.63861 | 0.483466 | util.go | starcoder |
package yamled
import (
"fmt"
"io"
yaml "gopkg.in/yaml.v2"
)
type Document struct {
root yaml.MapSlice
}
func Load(r io.Reader) (*Document, error) {
var data yaml.MapSlice
if err := yaml.NewDecoder(r).Decode(&data); err != nil {
return nil, fmt.Errorf("failed to decode input YAML: %v", err)
}
return NewF... | pkg/yamled/document.go | 0.652352 | 0.401512 | document.go | starcoder |
package koyeb
import (
"encoding/json"
)
// ListRegionsReply struct for ListRegionsReply
type ListRegionsReply struct {
Regions *[]RegionListItem `json:"regions,omitempty"`
Limit *int64 `json:"limit,omitempty"`
Offset *int64 `json:"offset,omitempty"`
Count *int64 `json:"count,omitempty"`
}
// NewListRegionsRep... | api/v1/koyeb/model_list_regions_reply.go | 0.748168 | 0.430686 | model_list_regions_reply.go | starcoder |
package model
import (
"sort"
"github.com/pkg/errors"
)
// TransactionsOrderedByFeeRate represents a set of MempoolTransactions ordered by their fee / mass rate
type TransactionsOrderedByFeeRate struct {
slice []*MempoolTransaction
}
// GetByIndex returns the transaction in the given index
func (tobf *Transactio... | domain/miningmanager/mempool/model/ordered_transactions_by_fee_rate.go | 0.828696 | 0.414069 | ordered_transactions_by_fee_rate.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.