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 msgraph
// ProvisioningStepType undocumented
type ProvisioningStepType int
const (
// ProvisioningStepTypeVImport undocumented
ProvisioningStepTypeVImport ProvisioningStepType = 0
// ProvisioningStepTypeVScoping undocumented
ProvisioningStepTypeVScoping ProvisioningStepType = 1
// ProvisioningStepTypeVM... | beta/ProvisioningStepTypeEnum.go | 0.53777 | 0.492798 | ProvisioningStepTypeEnum.go | starcoder |
package modify
import (
"github.com/ozonru/file.d/cfg"
"github.com/ozonru/file.d/fd"
"github.com/ozonru/file.d/pipeline"
"go.uber.org/zap"
)
/*{ introduction
It modifies the content for a field. It works only with strings.
You can provide an unlimited number of config parameters. Each parameter handled as `cfg.Fi... | plugin/action/modify/modify.go | 0.72662 | 0.468183 | modify.go | starcoder |
package tpdu
// Deliver represents a SMS-Deliver PDU as defined in 3GPP TS 23.038 Section 9.2.2.1.
type Deliver struct {
TPDU
OA Address
// The SCTS timestamp indicates the time the SMS was sent.
// The time is the originator's local time, the timezone of which may differ from the
// receiver's.
SCTS Timestamp
... | encoding/tpdu/deliver.go | 0.793626 | 0.599573 | deliver.go | starcoder |
package bcolumn
import (
"github.com/tobgu/qframe/internal/column"
"github.com/tobgu/qframe/internal/hash"
"github.com/tobgu/qframe/internal/index"
"github.com/tobgu/qframe/qerrors"
"github.com/tobgu/qframe/types"
"reflect"
"strconv"
)
func (c Comparable) Compare(i, j uint32) column.CompareResult {
x, y := c.... | internal/bcolumn/column.go | 0.605099 | 0.437223 | column.go | starcoder |
package blockchain
// BlockHeader contains metadata about a block
import (
"bytes"
"encoding/json"
"github.com/ubclaunchpad/cumulus/common/util"
)
// DefaultBlockSize is the default block size, can be augmented by the user.
const DefaultBlockSize = 1 << 18
// BlockHeader contains metadata about a block
type Bloc... | blockchain/block.go | 0.752286 | 0.461563 | block.go | starcoder |
package ameda
import (
"fmt"
"reflect"
)
// InterfaceToInterfacePtr converts interface to *interface.
func InterfaceToInterfacePtr(i interface{}) *interface{} {
return &i
}
// InterfaceToString converts interface to string.
func InterfaceToString(i interface{}) string {
return fmt.Sprintf("%v", i)
}
// Interfac... | vendor/github.com/henrylee2cn/ameda/interface.go | 0.52342 | 0.438485 | interface.go | starcoder |
package xmath
import (
"fmt"
"strings"
)
type Matrix []Vector
// Diag creates a new diagonal Matrix with the given elements in the diagonal
func Diag(v Vector) Matrix {
m := Mat(len(v))
for i := range v {
m[i] = Vec(len(v))
m[i][i] = v[i]
}
return m
}
// Mat creates a newMatrix of the given dimension
func... | xmath/matrix.go | 0.86785 | 0.69181 | matrix.go | starcoder |
package datamodel
import (
"fmt"
"strconv"
)
const (
TypePoint = "Point"
TypeLineString = "LineString"
TypePolygon = "Polygon"
TypeMultiPoint = "MultiPoint"
TypeMultiLineString = "MultiLineString"
TypeMultiPolygon = "MultiPolygon"
)
var MismatchTypeError = fmt.Errorf("given str... | datamodel/location.go | 0.776029 | 0.445288 | location.go | starcoder |
package yuv
import (
"image"
"image/color"
)
type YCbCrSubsampleRatio int
const (
NV12 YCbCrSubsampleRatio = iota
)
type YUV struct {
Y, U, V []uint8
YStride int
CStride int
SubsampleRatio YCbCrSubsampleRatio
Rect image.Rectangle
}
func (p *YUV) ColorModel() color.Model {
re... | vendor/github.com/shethchintan7/yuv/yuv.go | 0.826362 | 0.422862 | yuv.go | starcoder |
// parser package defines the parser and lexer for translating a *supported subset* of
// WebIDL (http://www.w3.org/TR/WebIDL/) into an AST.
package parser
import (
"fmt"
"github.com/ben-clayton/webidlparser/ast"
)
// tryConsumeIdentifier attempts to consume an expected identifier.
func (p *sourceParser) tryConsu... | parser/parser.go | 0.751648 | 0.529932 | parser.go | starcoder |
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func IB(root *TreeNode, sum int, found bool) bool {
if (found) {
return found
}
if root == nil {return false}
if root.Left == nil && root.Right == nil {
... | submissions/Path_Sum_All.go | 0.809577 | 0.44571 | Path_Sum_All.go | starcoder |
package validation
import (
"fmt"
"reflect"
"sort"
)
// Constraints is simply a collection of many constraints. All of the constraints will be run, and
// their results will be aggregated and returned.
type Constraints []Constraint
// Violations ...
func (cc Constraints) Violations(ctx Context) []ConstraintViolat... | constraints.go | 0.73431 | 0.416856 | constraints.go | starcoder |
package record
import (
"fmt"
)
// A Record represents a group of fields.
type Record interface {
// Iterate goes through all the fields of the record and calls the given function by passing each one of them.
// If the given function returns an error, the iteration stops.
Iterate(fn func(Field) error) error
// G... | record/record.go | 0.771801 | 0.435361 | record.go | starcoder |
package nvm
import "math"
var (
_v *V
_ Vector = _v
)
// V represents a vector.
type V struct {
Data []float64
}
// NewV creates a new vector of dimension `d`. NewV will panic if `d <= 0`.
func NewV(d int) *V {
if d <= 0 {
panic(ErrDim)
}
return &V{Data: make([]float64, d)}
}
// NewVShare creates a new v... | nvm/vector_dense.go | 0.851058 | 0.506469 | vector_dense.go | starcoder |
package diff
import (
"bytes"
)
// Comparable interface
type Comparable interface {
// Hash for comparison
Hash() []byte
}
// LCS computes the lcs of x and y
func LCS(x, y []Comparable) []Comparable {
x, y = sort(x, y)
x, y, prefix, suffix := scaleDown(x, y)
c := lcsTable(x, y)
return append(append(
pref... | lib/diff/lcs.go | 0.754282 | 0.489076 | lcs.go | starcoder |
package magnets
import (
"github.com/erikbryant/magnets/common"
)
// exceedsColLimits returns true if this row has exceeded the
// legal positive/negative count for this column, false otherwise.
func (game *Game) exceedsColLimits(col int) bool {
if game.Guess.CountCol(col, common.Positive) > game.CountCol(col, comm... | magnets/backtrackSolver.go | 0.828245 | 0.437163 | backtrackSolver.go | starcoder |
package main
import (
"flag"
"fmt"
"image"
"image/color"
_ "image/gif"
_ "image/jpeg"
"image/png"
"log"
"math"
"math/rand"
"os"
"strings"
)
// color_diff_euklid is a function to calculate the distance between to colors.
// The parameters are a: a RGB-array with 16bit color values and b: a RGB-array with 8... | img2color.go | 0.58261 | 0.48932 | img2color.go | starcoder |
package datablock
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"sync"
"github.com/sirupsen/logrus"
)
const emptyFileID = ""
// FileCache manages a set of bytes as a cache
type FileCache struct {
size uint64 // Total size of the cache
blob []byte // The cache st... | vendor/github.com/xyproto/datablock/filecache.go | 0.621311 | 0.474692 | filecache.go | starcoder |
package solver
import "github.com/truggeri/go-sudoku/cmd/go-sudoku/puzzle"
type solveTechnique struct {
set func(int, int) puzzle.Set
index func(int, int) int
}
type solution struct {
x, y int
square puzzle.Square
}
// Solve Returns the given puzzle with all elements solved
func Solve(puz puzzle.Puzzle) puz... | cmd/go-sudoku/solver/solver.go | 0.656328 | 0.494263 | solver.go | starcoder |
package bench
import (
"fmt"
"time"
histwriter "github.com/kishansairam9/bench/v2/hdrhistogram-writer"
"github.com/HdrHistogram/hdrhistogram-go"
)
// Summary contains the results of a Benchmark run.
type Summary struct {
Connections uint64
RequestRate uint64
SuccessTotal ... | summary.go | 0.788543 | 0.474631 | summary.go | starcoder |
package ws
import (
"errors"
"fmt"
)
// ServiceErrorCategory indicates the broad 'type' of a service error, used to determine the correct HTTP status code to use.
type ServiceErrorCategory int
const (
// Unexpected is an unhandled error that will generally result in an HTTP 500 status code being set.
Unexpected... | ws/error.go | 0.740644 | 0.495117 | error.go | starcoder |
package subspace
import (
"bytes"
"errors"
"github.com/abdullin/lex-go/tuple"
"github.com/abdullin/lex-go"
)
// Subspace represents a well-defined region of keyspace in a FoundationDB
// database.
type Subspace interface {
// Sub returns a new Subspace whose prefix extends this Subspace with the
// encoding o... | subspace/subspace.go | 0.8789 | 0.435181 | subspace.go | starcoder |
package tuples
import (
"math"
)
// Tuple data type
type Tuple struct {
X float64
Y float64
Z float64
W float64
}
// NewTuple returns tuple
func NewTuple(x float64, y float64, z float64, w float64) Tuple {
return Tuple{x, y, z, w}
}
// NewPoint returns tuple with w = 1
func NewPoint(x float64, y float64, z fl... | pkg/tuples/tuples.go | 0.876555 | 0.739611 | tuples.go | starcoder |
package core
import (
"math/big"
"github.com/offchainlabs/arbitrum/packages/arb-util/common"
"github.com/offchainlabs/arbitrum/packages/arb-util/hashing"
)
type NodeState struct {
ProposedBlock *big.Int
InboxMaxCount *big.Int
*ExecutionState
}
type Assertion struct {
Before *ExecutionState
After *Execution... | packages/arb-util/core/assertion.go | 0.635222 | 0.421016 | assertion.go | starcoder |
package utils
import (
"encoding/binary"
"errors"
"fmt"
"log"
"math"
"strings"
)
func CheckError(err error) {
if err != nil {
log.Panic(err)
}
}
// Int32ToByteArray transforms int32 value to byte array using fixed length encoding
// Returns byte array of size 4
// Reversed conversion is possible only with... | internal/pkg/utils/utils.go | 0.78695 | 0.465448 | utils.go | starcoder |
package faker
import (
"fmt"
"math/rand"
"strings"
"time"
)
// Faker is struct for Faker
type Faker struct {
Generator *rand.Rand
firstNameMale []string
firstNameFemale []string
lastName []string
maleNameFormat []string
femaleNameFormat []string
usernameFormat []string
// Generic to... | internal/faker/faker.go | 0.53048 | 0.430327 | faker.go | starcoder |
package types
type Data map[string]interface{}
func (d *Data) Set(key string, value interface{}) {
if *d == nil {
*d = make(Data)
}
(*d)[key] = value
}
func (d Data) Get(key string) interface{} {
return d[key]
}
func (d Data) Has(key string) bool {
_, ok := d[key]
return ok
}
func (d Data) Lookup(key strin... | types/data.go | 0.722233 | 0.473657 | data.go | starcoder |
package btree
// https://en.wikipedia.org/wiki/Binary_tree
import (
"github.com/ray-g/goalgos/data-structures/queue"
"github.com/ray-g/goalgos/data-structures/stack"
number "github.com/ray-g/goalgos/math/number-theory"
)
type Node struct {
Value interface{}
Parent *Node
Left, Right *Node
}
func mak... | data-structures/trees/binary-tree/binary_tree.go | 0.770119 | 0.460713 | binary_tree.go | starcoder |
package utilz
import (
crand "crypto/rand"
"math/big"
mathrand "math/rand"
"strconv"
"time"
)
// Percent calculate what is [percent]% of [number]
// For Example 25% of 200 is 50
// It returns result as float64
func Percent(pcent int64, all int64) float64 {
percent := ((float64(all) * float64(pcent)) / float64(1... | math.go | 0.779028 | 0.461927 | math.go | starcoder |
package types
import (
"bytes"
"encoding/binary"
"encoding/hex"
"fmt"
"io"
"math/bits"
"strconv"
"strings"
)
// A SpendPolicy describes the conditions under which an input may be spent.
type SpendPolicy struct {
Type interface{ isPolicy() }
}
// PolicyTypeAbove requires the input to be spent above a given b... | types/policy.go | 0.676834 | 0.441011 | policy.go | starcoder |
package mathh
// RoundFloat32ToInt returns nearest int for given float32.
func RoundFloat32ToInt(f float32) int {
const d = 0.5
switch {
case IsNaNFloat32(f):
return 0
case f < MinInt+d:
return MinInt
case f > MaxInt-d:
return MaxInt
case f < d && f > -d:
return 0
case f > 0:
return int(f + d)
defau... | back/vendor/github.com/apaxa-go/helper/mathh/float-round-gen.go | 0.799325 | 0.546738 | float-round-gen.go | starcoder |
package counting_elements
/*
You are given N counters, initially set to 0, and you have two possible operations on them:
increase(X) − counter X is increased by 1,
max counter − all counters are set to the maximum value of any counter.
A non-empty zero-indexed array A of M integers is given. This array represents con... | counting-elements/MaxCounters.go | 0.840586 | 0.773088 | MaxCounters.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTEllipseDescription866 struct for BTEllipseDescription866
type BTEllipseDescription866 struct {
BTCurveDescription1583
BtType *string `json:"btType,omitempty"`
MajorAxis *BTVector3d389 `json:"majorAxis,omitempty"`
MajorRadius *float64 `json:"majorRadius,omitempty"`
... | onshape/model_bt_ellipse_description_866.go | 0.803212 | 0.456591 | model_bt_ellipse_description_866.go | starcoder |
package instanceselector
const azureInstanceJson = `
{
"France Central": [
{
"baseline": 1.0,
"generation": "current",
"price": 0.022,
"burstable": false,
"instanceType": "Standard_A0",
"memory": 0.75,
"cpu": 1
},
... | pkg/util/instanceselector/azure_instance_data.go | 0.708616 | 0.547827 | azure_instance_data.go | starcoder |
package sqi
import (
"math"
"reflect"
)
// interfacesEqual() answers true if both interfaces are the same underlying data.
// If strict is true, numbers must be of the same type. If it's false,
// numbers will attempt to convert for a comparison.
func interfacesEqual(a, b interface{}, strict bool) (bool, error) {
... | compare.go | 0.601594 | 0.52543 | compare.go | starcoder |
package vector
import (
"fmt"
"strings"
)
const (
bits uint32 = 3 // will produce nodes with degree 2^3 = 8
degree uint32 = 1 << bits
mask uint32 = degree - 1
)
type props struct {
bits uint32 // number of bits to use per level
degree uint32 // degree is always 2^bits
mask uint32 // mask is degree -... | persistent/vector/internals.go | 0.520253 | 0.444263 | internals.go | starcoder |
package encoding
import (
"reflect"
)
// IsNiler is an interface implemented by an object with a nil value that may
// differ from Go's default nil value. This is used in encoding/map with the
// "omitnil" struct tag to give fields a chance to specify when they should be
// omitted due to containing a nil value.
typ... | encoding.go | 0.820613 | 0.55447 | encoding.go | starcoder |
package base
import (
"encoding/csv"
"fmt"
"os"
"sort"
"strconv"
"strings"
)
// BaseModel contains basic attributes and methods to get going
type BaseModel struct {
FileName string
ClassIndex int
Data [][]float64
categoricalAttributes map[int]map[string]float64
... | base/models.go | 0.697094 | 0.440469 | models.go | starcoder |
package kinc
import "unsafe"
type ComputeConstantLocation struct {
ref *kinc_compute_constant_location
}
type ConstantLocation struct {
ref *kinc_g4_constant_location
}
func ComputeSetBool(location ComputeConstantLocation, value bool) {
kinc_compute_set_bool(*location.ref, value)
}
func ComputeSetInt(location C... | kinc/shader.go | 0.740456 | 0.527438 | shader.go | starcoder |
package functions
import (
"fmt"
"math/rand"
"time"
)
// Boring function will print a message with a counter in random periods
func Boring(msg string) {
for i :=0; ; i++ {
fmt.Printf("%s %d\n", msg, i)
time.Sleep(time.Duration(rand.Intn(2e3)) * time.Millisecond)
}
}
// BoringWithChannelInput will write mess... | functions/boring.go | 0.564339 | 0.431345 | boring.go | starcoder |
package main
import (
"sort"
"github.com/otyg/threagile/model"
"github.com/otyg/threagile/model/confidentiality"
"github.com/otyg/threagile/model/criticality"
)
type missingNetworkSegmentation string
var RiskRule missingNetworkSegmentation
const raaLimit = 50
func (r missingNetworkSegmentation) Category() mod... | risks/missing-network-segmentation/missing-network-segmentation-rule.go | 0.743075 | 0.421611 | missing-network-segmentation-rule.go | starcoder |
The Go package simplecsv is a simple mini-library to handle csv files. I'm building it to help me writing small command line scripts. Maybe it's useful to someone else as well.
Some notes:
- all read methods return the value in the csv and a second true/false value that is true if the value exists
- all write metho... | doc.go | 0.590661 | 0.586819 | doc.go | starcoder |
package vector2f
type Rect struct {
Min Vector2f
Max Vector2f
// X, Y float64
// W, H float64
}
func NewRect(v1, v2 Vector2f) Rect {
rtn := Rect{
Min: v1,
Max: v2,
}
for i := 0; i < 2; i++ {
if rtn.Min[i] > rtn.Max[i] {
rtn.Max[i], rtn.Min[i] = rtn.Min[i], rtn.Max[i]
}
}
return rtn
}
func NewRe... | lib/vector2f/rect.go | 0.592313 | 0.573917 | rect.go | starcoder |
package header
/**
* The Warning header field is used to carry additional information about the
* status of a response. Warning header field values are sent with responses
* and contain a three-digit warning code, agent name, and warning text.
* <ul>
* <li>Warning Text: The "warn-text" should be in a natural lang... | sip/header/WarningHeader.go | 0.857365 | 0.458955 | WarningHeader.go | starcoder |
package cryptypes
import "database/sql/driver"
// EncryptedUint8 supports encrypting Uint8 data
type EncryptedUint8 struct {
Field
Raw uint8
}
// Scan converts the value from the DB into a usable EncryptedUint8 value
func (s *EncryptedUint8) Scan(value interface{}) error {
return decrypt(value.([]byte), &s.Raw)
}... | cryptypes/type_uint8.go | 0.80406 | 0.407923 | type_uint8.go | starcoder |
package prommatch
import (
"bytes"
"fmt"
"regexp"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
"github.com/prometheus/common/model"
)
// Expression can match or reject one time series.
type Expression interface {
matches(sp *model.Sample) bool
}
type funcMatcher func(sp *... | testutil/prommatch/prommatch.go | 0.779825 | 0.491273 | prommatch.go | starcoder |
package sexp
func (atom Bool) Copy() Form { return Bool(atom) }
func (atom Int) Copy() Form { return Int(atom) }
func (atom Float) Copy() Form { return Float(atom) }
func (atom Str) Copy() Form { return Str(atom) }
func (atom Symbol) Copy() Form { return Symbol(atom) }
func (atom Var) Copy() Form {
return Va... | src/sexp/copy.go | 0.663887 | 0.4474 | copy.go | starcoder |
package maths
import (
"sync"
)
// Inspiration taken from golang.org/x/tour/tree
// A Tree is has a value and two sub trees.
type Tree struct {
Left *Tree
Value int
Right *Tree
}
// CreateBinaryTree returns a (mostly) symmetric binary tree, filling with values from top to bottom, left to right.
// CreateBinary... | tree.go | 0.788583 | 0.522385 | tree.go | starcoder |
package deregexp
import (
"fmt"
"strings"
)
// Node is either an AndNode or OrNode in the tree.
// The tree describes an expression of ANDs and ORs and words.
type Node interface {
Expr() string
}
// AndNode expresses a set of words and OrNodes that must all match for this node to match.
type AndNode struct {
Wo... | treeify.go | 0.628749 | 0.419529 | treeify.go | starcoder |
package schema
// language=JSON
const V1 = `{
"$schema": "http://json-schema.org/draft-07/schema#",
"id": "https://github.com/fe3dback/go-arch-lint/v1",
"title": "Go Arch Lint V1",
"type": "object",
"description": "Arch file scheme version 1",
"required": ["version", "components", "deps"],
"additionalProperties... | internal/schema/v1.go | 0.546012 | 0.47725 | v1.go | starcoder |
package gohome
import (
"github.com/PucklaMotzer09/mathgl/mgl32"
"image/color"
)
const (
SHAPE3D_SHADER_NAME string = "Shape3D"
)
// A 3D shape as a RenderObject
type Shape3D struct {
NilRenderObject
// The name of this shape
Name string
shapeInterface Shape3DInterface
transform Transfor... | src/gohome/shape3d.go | 0.768299 | 0.557665 | shape3d.go | starcoder |
package paytocontract
import (
"crypto/ecdsa"
"math/big"
"github.com/btcsuite/btcd/btcec"
)
/*
PAY TO CONTRACT DEFINITIONS
KEY PAIR
let (x, P) be a public/private key pair with the public key P given by:
P = x*G (1)
for private key x and elliptic curve generator G
TWEAKED PUBLIC KEY
An altered... | pay_to_contract.go | 0.676834 | 0.509215 | pay_to_contract.go | starcoder |
package reflext
import (
"reflect"
)
// Zeroer :
type Zeroer interface {
IsZero() bool
}
// Init : initialise the first level of reflect.Value
func Init(v reflect.Value) reflect.Value {
if v.Kind() == reflect.Ptr && v.IsNil() {
v.Set(reflect.New(v.Type().Elem()))
}
if v.Kind() == reflect.Map && v.IsNil() {
... | reflext/helper.go | 0.612078 | 0.482978 | helper.go | starcoder |
package redundant_connection
import "reflect"
/*
684. 冗余连接
https://leetcode-cn.com/problems/redundant-connection
在本问题中, 树指的是一个连通且无环的无向图。
输入一个图,该图由一个有着N个节点 (节点值不重复1, 2, ..., N) 的树及一条附加的边构成。
附加的边的两个顶点包含在1到N中间,这条附加的边不属于树中已存在的边。
结果图是一个以边组成的二维数组。
每一个边的元素是一对[u, v] ,满足 u < v,表示连接顶点u 和v的无向图的边。
返回一条可以删去的边,使得结果图是一个有着N个节点的树... | solutions/redundant-connection/d.go | 0.507324 | 0.598165 | d.go | starcoder |
package main
import (
"fmt"
"math/bits"
"regexp"
"strings"
"github.com/scottyw/adventofcode2020/pkg/aoc"
)
func main() {
input := aoc.FileToString("input/20.txt")
tiles := parseTiles(input)
fmt.Println(findCorners(tiles))
}
func findCorners(tiles map[int][4]uint) int {
// Build a map that lists all tiles ... | cmd/day20a/main.go | 0.595728 | 0.44089 | main.go | starcoder |
package attester
import (
"context"
"sort"
api "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/phase0"
)
// MergeDuties merges attester duties given by an Ethereum 2 client into vouch's per-slot structure.
func MergeDuties(ctx context.Context, attesterDuties []*api.Att... | services/attester/helpers.go | 0.585575 | 0.409044 | helpers.go | starcoder |
package terminal
import (
"context"
"runtime"
"sync"
"github.com/searKing/golang/go/error/exception"
"github.com/searKing/golang/go/util/class"
"github.com/searKing/golang/go/util/spliterator"
)
type Task interface {
GetSpliterator() spliterator.Spliterator
/**
* Returns the parent of this task, or null i... | go/container/stream/op/terminal/task.go | 0.781372 | 0.420064 | task.go | starcoder |
package treepalette
import (
"image"
"image/color"
"sort"
)
// paletted wraps A source image into A 'paletted' image.
type paletted struct {
src image.Image // src original image
p *Palette
}
func (i *paletted) ColorModel() color.Model {
return i.p
}
func (i *paletted) Bounds() image.Rectangle {
return i.sr... | image.go | 0.829975 | 0.469885 | image.go | starcoder |
package parser
import "github.com/pkg/errors"
type resultingTypeDeclarations interface {
ResultingTypeDeclarations() ([]*TypeDeclaration, error)
}
type baseExpression struct {
nodeSource
typeDeclarations []*TypeDeclaration
}
type dualInputExpression struct {
baseExpression
Left Expression
Right Expression
}
... | parser/ast_expression.go | 0.722135 | 0.403273 | ast_expression.go | starcoder |
package canvas
type CanvasCompositeOperationsRule int
var CanvasCompositeOperationsRules = [...]string{
"",
"source-over",
"source-atop",
"source-in",
"source-out",
"destination-over",
"destination-atop",
"destination-in",
"destination-out",
"lighter",
"copy",
"xor",
}
func (el CanvasCompositeOperationsR... | _canvas/typeCompositeOperationsRule.go | 0.675122 | 0.447762 | typeCompositeOperationsRule.go | starcoder |
package msgraph
// RatingCanadaMoviesType undocumented
type RatingCanadaMoviesType string
const (
// RatingCanadaMoviesTypeVAllAllowed undocumented
RatingCanadaMoviesTypeVAllAllowed RatingCanadaMoviesType = "AllAllowed"
// RatingCanadaMoviesTypeVAllBlocked undocumented
RatingCanadaMoviesTypeVAllBlocked RatingCan... | v1.0/RatingCanadaMoviesTypeEnum.go | 0.59796 | 0.436742 | RatingCanadaMoviesTypeEnum.go | starcoder |
Package parser contains a ECAL parser.
Lexer for Source Text
Lex() is a lexer function to convert a given search query into a list of tokens.
Based on a talk by <NAME>: Lexical Scanning in Go
https://www.youtube.com/watch?v=HxaD_trXwRE
The lexer's output is pushed into a channel which is consumed by the parser.
Th... | parser/const.go | 0.706292 | 0.478163 | const.go | starcoder |
package pgtypes
import "github.com/apaxa-go/helper/mathh"
// SetInt sets z to x and returns z.
func (z *Numeric) SetInt(x int) *Numeric {
if x == 0 {
return z.SetZero()
}
if x < 0 {
z.sign = numericNegative
} else {
z.sign = numericPositive
}
z.weight = -1
z.digits = make([]int16, 0, 1) // as x!=0 the... | numeric-ints-gen.go | 0.639736 | 0.567218 | numeric-ints-gen.go | starcoder |
package common
/*
#include <stdlib.h>
#include <stdbool.h>
#include "openvision/common/common.h"
*/
import "C"
import (
"unsafe"
)
// Rectangle represents a Rectangle
type Rectangle struct {
X float64
Y float64
Width float64
Height float64
}
// Rect returns a Retancle
func Rect(x, y, w, h float64) Re... | go/common/geometry.go | 0.699357 | 0.482124 | geometry.go | starcoder |
package validator
import "fmt"
// DigitsBetweenUint64 returns true if value lies between left and right border
func DigitsBetweenUint64(value, left, right uint64) bool {
if left > right {
left, right = right, left
}
return value >= left && value <= right
}
// compareUint64 determine if a comparison passes betw... | validator_unit.go | 0.772015 | 0.55646 | validator_unit.go | starcoder |
package game
import (
"fmt"
"math"
)
var potentialValueRanges = [][]int {
{100, 200, 300, 400, 500},
{200, 400, 600, 800, 1000},
{400, 800, 1200, 1600, 2000},
}
// FixValues corrects duplicate values, fixes values that sit outside the
// normal procession, and changes the values so that they matc... | server/src/github.com/baconstrip/kiken/game/values.go | 0.727395 | 0.503418 | values.go | starcoder |
package main
import (
"math"
)
// Circle Maps a circle object
type Circle ObjectElement
func generateCircleFilledFromObject(object *Object) (Circle) {
return generateCircle(object.Distance, object.Radius, object.Radiate)
}
func generateCircleFromObject(object *Object) (Circle) {
return generateCircle(object.... | circle.go | 0.783036 | 0.461684 | circle.go | starcoder |
package twilight
import (
"math"
)
func daysSince2000(y, m, d int) float64 {
return float64(367*(y) - ((7 * ((y) + (((m) + 9) / 12))) / 4) + ((275 * (m)) / 9) + (d) - 730530)
}
const (
inv360 = float64(1.0 / 360.0)
radToDeg = 180.0 / math.Pi
degToRad = math.Pi / 180.0
)
// revolution will reduce the angle to... | helper.go | 0.816699 | 0.557604 | helper.go | starcoder |
package xpytest
import (
"context"
"fmt"
"math"
"path/filepath"
"regexp"
"runtime"
"sort"
"strings"
"sync"
"time"
"github.com/bmatcuk/doublestar"
"github.com/chainer/xpytest/pkg/pytest"
"github.com/chainer/xpytest/pkg/reporter"
"github.com/chainer/xpytest/pkg/resourcebuckets"
xpytest_proto "github.com... | pkg/xpytest/xpytest.go | 0.565299 | 0.469095 | xpytest.go | starcoder |
package sq
import "github.com/MaxSlyugrov/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE, d MMMM y", Long: "d MMMM y", Medium: "d MMM y", Short: "d.M.yy"},
Time: cldr.CalendarDateFormat{Full: "HH:mm:ss zzzz", Long: "HH:mm:ss z", Medium: "HH:mm... | resources/locales/sq/calendar.go | 0.53777 | 0.435481 | calendar.go | starcoder |
package docs
import (
"strings"
"github.com/Jeffail/benthos/v3/lib/util/config"
"github.com/Jeffail/gabs/v2"
)
// FieldSpecCtx provides a field spec and rendered extras for documentation
// templates to use.
type FieldSpecCtx struct {
Spec FieldSpec
// FullName describes the full dot path name of the field rel... | internal/docs/field_template.go | 0.714728 | 0.619989 | field_template.go | starcoder |
package messages
/*
This go file centralizes error log messages so we have them all in one place.
Although having the names of the consts as the error code (i.e CSPFK014E) and not as a descriptive name (i.e InvalidStoreType)
can reduce readability of the code that raises the error, we decided to do so for the foll... | pkg/log/messages/error_messages.go | 0.508056 | 0.556701 | error_messages.go | starcoder |
package miscmodule
import (
"database/sql"
"strings"
"time"
"github.com/bwmarrin/discordgo"
bot "github.com/erikmcclure/sweetiebot/sweetiebot"
)
// MiscModule contains miscellaneous commands
type MiscModule struct {
}
// Name of the module
func (w *MiscModule) Name() string {
return "Miscellaneous"
}
// New ... | miscmodule/MiscModule.go | 0.62498 | 0.505493 | MiscModule.go | starcoder |
package main
import "math"
/*
4XY
VIBRATO means to "oscillate the sample pitch using a particular waveform
with amplitude yyyy notes, such that (xxxx * speed)/64 full oscillations
occur in the line". The waveform to use in vibrating is set using effect
E4 (see below). By placing vibrato effects on consecutiv... | effectWaveform.go | 0.550607 | 0.479747 | effectWaveform.go | starcoder |
package types
// An interface and structure together that can turn any struct into a tree structure with parent/child relationships
// To use it, simply embed the TreeNode structure into another structure and call Init. This TreeNodeI structure will
// be convertable to the parent object
type TreeNodeI interface {
Ad... | ideas/types/treeNode.go | 0.708616 | 0.522385 | treeNode.go | starcoder |
package field
import (
"gorm.io/gorm/clause"
)
type Int Field
func (field Int) Eq(value int) Expr {
return expr{e: clause.Eq{Column: field.RawExpr(), Value: value}}
}
func (field Int) Neq(value int) Expr {
return expr{e: clause.Neq{Column: field.RawExpr(), Value: value}}
}
func (field Int) Gt(value int) Expr {
... | field/int.go | 0.771413 | 0.537041 | int.go | starcoder |
package manipulate
import (
"context"
"go.aporeto.io/elemental"
)
// Manipulator is the interface of a storage backend.
type Manipulator interface {
// RetrieveMany retrieves the a list of objects with the given elemental.Identity and put them in the given dest.
RetrieveMany(mctx Context, dest elemental.Identi... | manipulate.go | 0.668015 | 0.456713 | manipulate.go | starcoder |
The original Space-Saving algorithm:
https://icmi.cs.ucsb.edu/research/tech_reports/reports/2005-23.pdf
The Filtered Space-Saving enhancement:
http://www.l2f.inesc-id.pt/~fmmb/wiki/uploads/Work/misnis.ref0a.pdf
This implementation follows the algorithm of the FSS paper, but not the
suggested implementation. Specifi... | topk.go | 0.849847 | 0.424651 | topk.go | starcoder |
package bytes
import (
"crypto/rand"
"encoding/base64"
"encoding/hex"
"fmt"
)
// BitCount returns the count of bits in the byte slice
func BitCount(bytes []byte) (count int) {
for _, b := range bytes {
count += bitCounts[b]
}
return
}
// EditDistance returns the Hamming distance between the byte slides
func... | bytes/bytes.go | 0.732305 | 0.414721 | bytes.go | starcoder |
package expr
import (
"fmt"
"reflect"
)
func isBool(val interface{}) bool {
return val != nil && reflect.TypeOf(val).Kind() == reflect.Bool
}
func toBool(val interface{}) bool {
return reflect.ValueOf(val).Bool()
}
func isText(val interface{}) bool {
return val != nil && reflect.TypeOf(val).Kind() == reflect.S... | utils.go | 0.549641 | 0.545346 | utils.go | starcoder |
package httpref
// RegisteredPorts is the list of all known IANA registered ports
var RegisteredPorts = References{
{
Name: "Registered Ports",
IsTitle: true,
Summary: "The range of port numbers from 1024 to 49151 (2^10 to 2^14 + 2^15 − 1)",
Description: `The range of port numbers from 1024 to 49151 (210 t... | registered-ports.go | 0.680985 | 0.543469 | registered-ports.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// Hashes
type Hashes struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as we... | models/microsoft/graph/hashes.go | 0.626238 | 0.421552 | hashes.go | starcoder |
package heap
// Heap is a struct which wraps the slice of provided type and internally
// maintains integrity of heap datastructure.
type Heap[T any] struct {
queue []T
less func(left, right T) bool
setIndex func(e T, i int)
}
// NewHeap converts provided slice into a heap. The queue provided
// should not ... | heap/heap.go | 0.773259 | 0.449634 | heap.go | starcoder |
package psi
func PointerField(psi []byte) uint8 {
return psi[0]
}
// TableID returns the psi table header table id
func TableID(psi []byte) uint8 {
return tableID(psi[1+PointerField(psi):])
}
// SectionSyntaxIndicator returns true if the psi contains section syntax
func SectionSyntaxIndicator(psi []byte) bool {
r... | psi/psi.go | 0.756268 | 0.414129 | psi.go | starcoder |
package layers
import (
"fmt"
"github.com/aunum/log"
g "gorgonia.org/gorgonia"
t "gorgonia.org/tensor"
)
// FC is a fully connected layer of neurons.
type FC struct {
// Input is the number of units in input.
Input int
// Output is the number of units in the output.
Output int
// Name of the layer.
Name ... | vendor/github.com/aunum/gold/pkg/v1/model/layers/fc.go | 0.757256 | 0.494751 | fc.go | starcoder |
package cvss2
import "fmt"
type BaseMetrics struct {
AccessVector
AccessComplexity
Authentication
ConfidentialityImpact
IntegrityImpact
AvailabilityImpact
}
type AccessVector int
const (
AccessVectorLocal AccessVector = iota + 1
AccessVectorAdjecentNetwork
AccessVectorNetwork
)
var (
weightsAccessVector... | cvss2/base_metrics.go | 0.673084 | 0.432303 | base_metrics.go | starcoder |
package complex
import (
"sort"
"gioui.org/widget"
"currents/pkg/audio"
)
type gradientData struct {
name string
gradient audio.Gradient
// Button to select the gradient in the editor list
selectBtn widget.Clickable
// Picker buttons to display each colour at each position
// and shows a color picker ... | pkg/gui/complex/gradient_data.go | 0.567098 | 0.484319 | gradient_data.go | starcoder |
package interestvalue
import (
"fmt"
"math"
"github.com/pkg/errors"
)
// CalculateDelta calculations for all banks
func (cireq CreateInterestRequest) CalculateDelta() (CreateInterestResponse, error) {
bks, delta, err := cireq.computeBanksDelta()
if err != nil {
return CreateInterestResponse{}, err
}
ciresp... | interestcal/interestvalue/cal.go | 0.654343 | 0.403244 | cal.go | starcoder |
package model
type BackendDummy struct {
}
func NewBackendDummy() (Backend, error) {
return BackendDummy{}, nil
}
func (b BackendDummy) FindUserByID(id int) (map[string]UserGroup, error) {
if id == 1 {
return map[string]UserGroup{
"test": &User{
Base: Base{
ID: 1,
Name: "test",
},
... | v2/model/dummy.go | 0.556641 | 0.417865 | dummy.go | starcoder |
package dns
import (
"fmt"
)
const (
// AType is the RR type representing a host address
AType Type = 1
// NSType is the RR type representing an authoritative name server
NSType Type = 2
// MDType is the RR type representing a mail destination (obsolote, use MX)
MDType Type = 3
// MFType is the RR type repres... | dns/rr.go | 0.603815 | 0.544135 | rr.go | starcoder |
package rasterx
import (
"image"
"math"
"image/color"
"golang.org/x/image/math/fixed"
"golang.org/x/image/vector"
)
type (
ColorFuncImage struct {
image.Uniform
colorFunc ColorFunc
}
// Rasterizer converts a path to a raster using the grainless algorithm.
ScannerGV struct {
r vector.Rasterizer
//... | vendor/github.com/whosonfirst/go-whosonfirst-static/vendor/github.com/whosonfirst/go-whosonfirst-image/vendor/github.com/srwiley/rasterx/scan.go | 0.759493 | 0.490114 | scan.go | starcoder |
package helpers
import (
"fmt"
"time"
)
// MaxInt returns the larger int value of the two given values.
func MaxInt(a, b int) int {
if a > b {
return a
}
return b
}
// MinInt returns the lower int value of the two given values.
func MinInt(a, b int) int {
if a < b {
return a
}
return b
}
// FormatByte... | pkg/term/helpers/helpers.go | 0.794385 | 0.518485 | helpers.go | starcoder |
package main
import (
"crypto/elliptic"
"crypto/rand"
"math/big"
"fmt"
"encoding/hex"
)
var fakeRandom = true
type Scalar struct {
data []byte
}
type Point struct {
x *big.Int
y *big.Int
}
type DhSecret struct {
data []byte // pre-form of an actual DH secret on elliptic curve
}
... | crypto.go | 0.835181 | 0.439326 | crypto.go | starcoder |
package datagen
import (
"errors"
"math"
"time"
"github.com/paulidealiste/goalgs/utilgen"
)
type Heap struct {
Heapsize int
Length int
Inslice []float64
}
type Bst struct {
Bstsize int
Rootnode *Bstnode
Innerslice []float64
Inslice []Bstnode
}
type Bstnode struct {
data float64
leftch... | datagen/datagen.go | 0.741955 | 0.483648 | datagen.go | starcoder |
package statistics
import (
"encoding/binary"
"math"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/sessionctx/stmtctx"
"github.com/pingcap/tidb/trace_util_0"
"github.com/pingcap/tidb/types"
)
// calcFraction is used to calculate the fraction of the interval [lower, upper] that lies within the [lo... | statistics/scalar.go | 0.718002 | 0.453988 | scalar.go | starcoder |
package field
import (
"crypto/rand"
"io"
"math/big"
)
type fp2Elt struct {
a, b *big.Int
}
func (e fp2Elt) String() string {
return "\na: 0x" + e.a.Text(16) +
"\nb: 0x" + e.b.Text(16) + " * i"
}
func (e fp2Elt) Copy() Elt { r := &fp2Elt{}; r.a.Set(e.a); r.b.Set(e.b); return r }
type fp2 struct {
p *big... | go-h2c/field/fp2.go | 0.561936 | 0.428712 | fp2.go | starcoder |
package algorithms
import (
"fmt"
"github.com/azeezolaniran2016/algorithm-tests/utils"
)
/*
A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.
For example, number 9 has binary representation 1001 and con... | algorithms/binary_gap.go | 0.716516 | 0.577883 | binary_gap.go | starcoder |
package torrent
import (
"math/rand"
"sort"
)
// BitTorrent choking policy.
// The choking policy's view of a peer. For current policies we only care
// about identity and download bandwidth.
type Choker interface {
DownloadBPS() float32 // bps
}
type ChokePolicy interface {
// Only pass in interested peers.
/... | torrent/choker.go | 0.609873 | 0.441854 | choker.go | starcoder |
package gi
import (
"image/color"
"math"
"sort"
)
type stop struct {
pos float64
color color.Color
}
type stops []stop
// Len satisfies the Sort interface.
func (s stops) Len() int {
return len(s)
}
// Less satisfies the Sort interface.
func (s stops) Less(i, j int) bool {
return s[i].pos < s[j].pos
}
//... | gradient.go | 0.774498 | 0.409752 | gradient.go | starcoder |
package asetypes
import (
"database/sql/driver"
"fmt"
"reflect"
)
// ConvertValue converts a value-interface of an ASE data type into
// a database/sql/driver.Value with the respective golang data type.
func (t DataType) ConvertValue(v interface{}) (driver.Value, error) {
sv := reflect.ValueOf(v)
// Return val... | asetypes/convert.go | 0.669961 | 0.475423 | convert.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.