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 sweetiebot
import (
"encoding/json"
"reflect"
"strings"
"github.com/bwmarrin/discordgo"
)
type SetConfigCommand struct {
}
func (c *SetConfigCommand) Name() string {
return "SetConfig"
}
func (c *SetConfigCommand) Process(args []string, msg *discordgo.Message, info *GuildInfo) (string, bool) {
if len(... | sweetiebot/config_command.go | 0.596668 | 0.664445 | config_command.go | starcoder |
package bat
import (
"fmt"
"math"
"strconv"
"github.com/robert-zaremba/errstack"
)
// I64toa converts int64 value to 10-based string
func I64toa(x int64) string {
return strconv.FormatInt(x, 10)
}
// I64tox converts int64 value to 16-based string
func I64tox(x int64) string {
return strconv.FormatInt(x, 16)
}... | number.go | 0.648355 | 0.471223 | number.go | starcoder |
package jet
// TimestampExpression interface
type TimestampExpression interface {
Expression
EQ(rhs TimestampExpression) BoolExpression
NOT_EQ(rhs TimestampExpression) BoolExpression
IS_DISTINCT_FROM(rhs TimestampExpression) BoolExpression
IS_NOT_DISTINCT_FROM(rhs TimestampExpression) BoolExpression
LT(rhs Tim... | internal/jet/timestamp_expression.go | 0.797793 | 0.494263 | timestamp_expression.go | starcoder |
// Package lex provides all the lexing functions that transform text into
// lexical tokens, using token types defined in the pi/token package.
// It also has the basic file source and position / region management
// functionality.
package lex
import (
"fmt"
"sort"
"github.com/goki/ki/nptime"
"github.com/goki/pi... | lex/lex.go | 0.779867 | 0.521349 | lex.go | starcoder |
package sortmap
import (
"fmt"
"reflect"
"sort"
"time"
)
// Item is a key-value pair representing element in the map
type Item struct {
Key, Value interface{}
}
// Less compares two map elements and returns true if x < y
type Less func(x, y Item) bool
// flatmap is a flattened map with a comparator to be used ... | vendor/github.com/tg/gosortmap/sortmap.go | 0.688049 | 0.455683 | sortmap.go | starcoder |
package objects
type DWDMModuleState struct {
baseObj
ModuleId uint8 `SNAPROUTE: "KEY", CATEGORY:"Optical", ACCESS:"r", MULTIPLICITY: "*", DESCRIPTION: "DWDM Module identifier"`
ModuleState string `DESCRIPTION: "Current MSA state of dwdm module"`
ModuleVoltage float64 `DESCRIP... | objects/opticdObjects.go | 0.716814 | 0.46642 | opticdObjects.go | starcoder |
package view
import (
"fmt"
"github.com/protolambda/ztyp/codec"
. "github.com/protolambda/ztyp/tree"
)
type BitVectorTypeDef struct {
BitLength uint64
ComplexTypeBase
}
func BitVectorType(length uint64) *BitVectorTypeDef {
byteSize := (length + 7) / 8
return &BitVectorTypeDef{
BitLength: length,
ComplexTy... | view/bitvector.go | 0.54698 | 0.471588 | bitvector.go | starcoder |
package dectype
import (
"fmt"
"github.com/swamp/compiler/src/decorated/dtype"
)
type TypeReferenceScopedOrNormal interface {
dtype.Type
NameReference() *NamedDefinitionTypeReference
}
func compareAtoms(pureExpected dtype.Atom, pureActual dtype.Atom) error {
expectedIsAny := IsAtomAny(pureExpected)
actualIsAn... | src/decorated/types/type_lookup.go | 0.669637 | 0.472136 | type_lookup.go | starcoder |
package adsb
import (
"errors"
)
// decodeAlt13 converts a 13-bit altitude code field to an integer
// altitude value in feet. The highest three bits of the uint16
// argument passed must be zero.
func decodeAlt13(a uint16) (int64, error) {
if a&0xE000 != 0 { // data is not properly aligned
return 0, errors.New... | adsb/altitude.go | 0.734881 | 0.561335 | altitude.go | starcoder |
package examples
import (
"math"
"runtime"
"github.com/go-gl/gl/v2.1/gl"
. "github.com/jakecoffman/cp"
"fmt"
)
const DrawPointLineScale = 1
var program uint32
// 8 bytes
type v2f struct {
x, y float32
}
func V2f(v Vector) v2f {
return v2f{float32(v.X), float32(v.Y)}
}
func v2f0() v2f {
return v2f{0, 0}
}... | examples/drawing.go | 0.67971 | 0.528655 | drawing.go | starcoder |
package helper
import (
"reflect"
"strings"
)
// Empty php empty()
func Empty(val interface{}) bool {
if val == nil {
return true
}
v := reflect.ValueOf(val)
switch v.Kind() {
case reflect.String, reflect.Array:
return v.Len() == 0
case reflect.Map, reflect.Slice:
return v.Len() == 0 || v.IsNil()
case ... | variable.go | 0.550124 | 0.426441 | variable.go | starcoder |
// Package bsontype is a utility package that contains types for each BSON type and the
// a stringifier for the Type to enable easier debugging when working with BSON.
package bsontype
// These constants uniquely refer to each BSON type.
const (
Double Type = 0x01
String Type = 0x02
EmbeddedDo... | bsontype/bsontype.go | 0.580352 | 0.572723 | bsontype.go | starcoder |
package wire
import (
"bytes"
"errors"
"fmt"
)
// errNotEquals is a sentinel error used while iterating through ValueLists to
// indicate that two values did not match.
var errNotEquals = errors.New("values are not equal")
// ValuesAreEqual checks if two values are equal.
func ValuesAreEqual(left, right Value) b... | wire/value_equals.go | 0.733929 | 0.580501 | value_equals.go | starcoder |
package models
import (
"errors"
"fmt"
"reflect"
"strings"
"time"
"github.com/astaxie/beego/orm"
)
type CarInsurances struct {
Id int `orm:"column(id);auto"`
Make string `orm:"column(make);size(32)"`
Model string `orm:"column(model)... | models/car_insurances.go | 0.609989 | 0.442938 | car_insurances.go | starcoder |
package template
import (
"fmt"
"io"
"regexp"
)
// Node is a type for hierarchical data.
type Node struct {
label string
replacements []replacement
children []*Node
}
type replacement struct {
expr *regexp.Regexp
repl string
}
// NewRoot returns a new root node.
func NewRoot() *Node {
return &N... | pkg/sql/ir/irgen/template/instantiate.go | 0.703753 | 0.407628 | instantiate.go | starcoder |
package main
import "fmt"
type Number interface {
int64 | float64 | string
}
func main() {
// Initialize a map for the integer values
ints := map[string]int64{
"first": 34,
"second": 12,
}
// Initialize a map for the float values
floats := map[string]float64{
"first": 35.98,
"second": 26.99,
}
//... | 81_generics/2_sum generic/main.go | 0.70304 | 0.487002 | main.go | starcoder |
package lua
import (
"context"
"fmt"
"os"
)
type LValueType int
const (
LTNil LValueType = iota
LTBool
LTNumber
LTString
LTFunction
LTUserData
LTThread
LTTable
LTChannel
)
var lValueNames = [9]string{"nil", "boolean", "number", "string", "function", "userdata", "thread", "table", "channel"}
func (vt LV... | value.go | 0.662906 | 0.48377 | value.go | starcoder |
package immutableList
import "fmt"
type node interface {
size() int
get(index int) Object
getFirst() Object
getLast() Object
append(value Object) node
prepend(value Object) node
appendNode(n node) node
prependNode(n node) node
insert(index int, value Object) node
delete(index int) node
set(index int, value... | node.go | 0.570092 | 0.521471 | node.go | starcoder |
package missing_identity_provider_isolation
import (
"github.com/threagile/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "missing-identity-provider-isolation",
Title: "Missing Identity Provider Isolation",
Description: "Highly sensitive identity provider assets and ... | risks/built-in/missing-identity-provider-isolation/missing-identity-provider-isolation-rule.go | 0.690976 | 0.478651 | missing-identity-provider-isolation-rule.go | starcoder |
package ion
import (
"bytes"
)
// This file contains the container-like types: List, SExp, and Struct.
const (
textNullList = "null.list"
textNullSExp = "null.sexp"
textNullStruct = "null.struct"
)
// List is an ordered collections of Values. The contents of the list are
// heterogeneous, each element can ... | ion/types_container.go | 0.626467 | 0.476397 | types_container.go | starcoder |
package keyfilter
import "github.com/CyCoreSystems/ari"
// Kind filters a list of keys by a particular Kind
func Kind(kind string, in []*ari.Key) (out []*ari.Key) {
for _, k := range in {
if k.Kind == kind {
out = append(out, k)
}
}
return
}
// Applications returns the Application keys from the given list ... | ext/keyfilter/keyfilter.go | 0.745676 | 0.4206 | keyfilter.go | starcoder |
package graph
import (
"sort"
"github.com/Tom-Johnston/mamba/ints"
"github.com/Tom-Johnston/mamba/sortints"
)
//SparseGraph is a data structure for representing a simple undirected graph. *SparseGraph implements the graph insterface.
//SparseGraph stores the number of vertices, the number of edges, the degree seq... | graph/graph_sparse.go | 0.527073 | 0.708566 | graph_sparse.go | starcoder |
package dfl
import (
"strings"
"github.com/pkg/errors"
"github.com/spatialcurrent/go-adaptive-functions/pkg/af"
"github.com/spatialcurrent/go-reader-writer/pkg/io"
)
// In is a BinaryOperator that evaluates to true if the left value is in the right value.
// Unlike "in", it is case insensitive.
// If the right... | pkg/dfl/IIn.go | 0.723993 | 0.420302 | IIn.go | starcoder |
package function
import (
"fmt"
"strings"
"gopkg.in/src-d/go-errors.v1"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/expression"
)
// SRID is a function that returns SRID of Geometry object or returns a new object with altered SRID.
type SRID struct {
expression.NaryExpres... | sql/expression/function/srid.go | 0.715623 | 0.417865 | srid.go | starcoder |
package trie
import "strings"
// data represents information that a tree edge holds.
type data struct {
// label is an arbitrary string associated with an edge.
label string
// count is the number of times the label was seen when inserting to a tree.
count uint
}
// edge of a tree.
type edge struct {
// target ... | internal/trie/trie.go | 0.809841 | 0.661834 | trie.go | starcoder |
// Copied and modified from https://github.com/issue9/identicon/ (MIT License)
// Generate pseudo-random avatars by IP, E-mail, etc.
package identicon
import (
"crypto/sha256"
"fmt"
"image"
"image/color"
)
const minImageSize = 16
// Identicon is used to generate pseudo-random avatars
type Identicon struct {
f... | modules/avatar/identicon/identicon.go | 0.600071 | 0.609205 | identicon.go | starcoder |
package main
import (
"fmt"
"reflect"
"time"
"github.com/sanderploegsma/advent-of-code/2019/utils"
)
var input = [][]int{
{3, 2, -6, 0, 0, 0},
{-13, 18, 10, 0, 0, 0},
{-8, -1, 13, 0, 0, 0},
{5, 10, 4, 0, 0, 0},
}
func main() {
start := time.Now()
ans := TotalEnergy(SimulateN(input, 1000))
fmt.Println(1, ... | 2019/go/12/main.go | 0.601594 | 0.402921 | main.go | starcoder |
package core
import (
"fmt"
"reflect"
"strconv"
"strings"
"time"
"github.com/mattn/anko/vm"
)
// ImportToX adds all the toX to the env given
func ImportToX(env *vm.Env) {
env.Define("toBool", func(v interface{}) bool {
nt := reflect.TypeOf(true)
rv := reflect.ValueOf(v)
if rv.Type().ConvertibleTo(nt) {... | core/toX.go | 0.507324 | 0.425009 | toX.go | starcoder |
package genomeGraph
// SortGraph will reorder nodes in a graph such that the order and Ids of the output graph are topologically sorted
func SortGraph(g *GenomeGraph) *GenomeGraph {
answer := &GenomeGraph{}
answer.Nodes = make([]Node, len(g.Nodes))
order := GetSortOrder(g)
for sortedIdx, originalIdx := range order... | genomeGraph/sort.go | 0.567577 | 0.69894 | sort.go | starcoder |
package specs
import (
"testing"
"github.com/go-rel/rel"
"github.com/go-rel/rel/where"
"github.com/stretchr/testify/assert"
)
// Update tests specification for updating a record.
func Update(t *testing.T, repo rel.Repository) {
var (
note = "s<PASSWORD>"
user = User{
Name: "update",
}
)
repo.MustIns... | adapter/specs/update.go | 0.561936 | 0.62415 | update.go | starcoder |
package utils
import (
"bytes"
"fmt"
)
// TableDataSource defines the interface a data source need to implement so that we can render
// a tabular representation from the data source. We get number of columns from the length of
// column header. the data source itself should ensure that for each get value call wit... | utils/table_writer.go | 0.646572 | 0.526769 | table_writer.go | starcoder |
package core
import "strings"
// ListType represents a list of values in the language.
// They can have infinite number of elements inside.
type ListType struct {
first Value
rest Value
}
// Eval evaluates a value into a WHNF.
func (l *ListType) eval() Value {
return l
}
var (
emptyList = ListType{}
// Empty... | src/lib/core/list.go | 0.698021 | 0.542621 | list.go | starcoder |
package gonsumer
import (
"fmt"
"github.com/rcrowley/go-metrics"
)
// PartitionConsumerMetrics is an interface for accessing and modifying PartitionConsumer metrics.
type PartitionConsumerMetrics interface {
// BatchDuration is a timer that measures time to process a single batch of data from Kafka broker by enclo... | vendor/github.com/serejja/gonsumer/partition_consumer_metrics.go | 0.709824 | 0.489626 | partition_consumer_metrics.go | starcoder |
package packed
// Efficient sequential read/write of packed integers.
type BulkOperationPacked6 struct {
*BulkOperationPacked
}
func newBulkOperationPacked6() BulkOperation {
return &BulkOperationPacked6{newBulkOperationPacked(6)}
}
func (op *BulkOperationPacked6) decodeLongToInt(blocks []int64, values []int32, i... | core/util/packed/bulkOperation6.go | 0.600423 | 0.710779 | bulkOperation6.go | starcoder |
// Package logic world.go Defines our world type that runs the game.
package logic
import (
"github.com/bluemun/munfall"
"github.com/bluemun/munfall/traits"
)
// World container that manages the game world.
type world struct {
actors map[uint]*actor
traitDictionary *traitDictionary
endtasks []fu... | logic/world.go | 0.659953 | 0.463323 | world.go | starcoder |
// Sample program that takes a stream of bytes and looks for the bytes
// “elvis” and when they are found, replace them with “Elvis”. The code
// cannot assume that there are any line feeds or other delimiters in the
// stream and the code must assume that the stream is of any arbitrary length.
// The solution cannot ... | topics/profiling/memcpu/stream.go | 0.652684 | 0.545407 | stream.go | starcoder |
package main
import (
"fmt"
"github.com/cavaliercoder/go-abs"
)
type direction uint8
const (
right direction = iota
up direction = iota
left direction = iota
down direction = iota
)
type spiralNodeCoords struct {
x, y int64
}
type spiralNode struct {
parent *spiral
coords spiralNodeCoords
next *s... | 2017/03/02/day3_part2.go | 0.70304 | 0.555737 | day3_part2.go | starcoder |
package DG2D
import (
"math"
"github.com/notargets/gocfd/DG1D"
"github.com/notargets/gocfd/utils"
)
// Purpose : Compute (x,y) nodes in equilateral triangle for
// polynomial of order N
func Nodes2D(N int) (x, y utils.Vector) {
var (
alpha ... | DG2D/element_utils.go | 0.537527 | 0.670716 | element_utils.go | starcoder |
package securecompare
// Many primitive operations that run in fixed time
import (
"math/big"
"unsafe"
)
// 64-bit platform?
const sixtyfourbit = uint64(uint(0x7fffffffffffffff)) == uint64(0x7fffffffffffffff)
// 0 -> false
// 1 -> true
func IntToBool(i int) bool {
return *(*bool)(unsafe.Pointer(&i))
}
// ret... | securecompare.go | 0.687945 | 0.543469 | securecompare.go | starcoder |
package cryptospecials
import (
"crypto/elliptic"
"crypto/rand"
"errors"
"fmt"
"hash"
"math/big"
)
//OPRF is an exportable struct
type OPRF struct {
RSecret []byte
RSecretInv []byte
elliptic.Curve
}
//Mask is an exportable method
/*
* OPRF.Send() represents EC-OPRF sec. 3.1 Steps (1) and (2) with hashin... | cryptospecials/eccoprf.go | 0.634204 | 0.441613 | eccoprf.go | starcoder |
package rgb16
// Conversion of natively non-D50 RGB colorspaces with D50 illuminator to CIE XYZ and back.
// Bradford adaptation was used to calculate D50 matrices from colorspaces' native illuminators.
// RGB values must be linear and in the nominal range [0, 255].
// XYZ values are usually in [0, 255] but may be... | i16/rgb16/rgb_d50.go | 0.725746 | 0.431644 | rgb_d50.go | starcoder |
package orderbook
import (
"errors"
"fmt"
"sort"
math "github.com/thrasher-corp/gocryptotrader/common/math"
"github.com/thrasher-corp/gocryptotrader/log"
)
// WhaleBombResult returns the whale bomb result
type WhaleBombResult struct {
Amount float64
MinimumPrice float64
MaximumPrice ... | exchanges/orderbook/calculator.go | 0.678966 | 0.440289 | calculator.go | starcoder |
package values
import (
"fmt"
"github.com/influxdata/platform/query/ast"
"github.com/influxdata/platform/query/semantic"
)
type BinaryFunction func(l, r Value) Value
type BinaryFuncSignature struct {
Operator ast.OperatorKind
Left, Right semantic.Type
}
func LookupBinaryFunction(sig BinaryFuncSignature) (B... | query/values/binary.go | 0.688468 | 0.50769 | binary.go | starcoder |
package blinkt
import (
"fmt"
"log"
"os"
"os/signal"
"time"
"github.com/alexellis/rpi"
)
const DAT int = 23
const CLK int = 24
const redIndex int = 0
const greenIndex int = 1
const blueIndex int = 2
const brightnessIndex int = 3
// default raw brightness. Not to be used user-side
const defaultBrightnessInt ... | blinkt.go | 0.714827 | 0.470919 | blinkt.go | starcoder |
package models
import (
"reflect"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
// consistencyCheckable a type that can be tested for database consistency
type consistencyCheckable interface {
checkForConsistency(t *testing.T)
}
// CheckConsistencyForAll test that the entire database is consisten... | models/consistency.go | 0.622 | 0.655115 | consistency.go | starcoder |
package curve
import (
"errors"
"fmt"
"math/big"
GF "github.com/armfazh/tozan-ecc/field"
)
// weCurve is a Weierstrass curve
type weCurve struct{ *params }
type W = *weCurve
func (e *weCurve) String() string { return "y^2=x^3+Ax+B\n" + e.params.String() }
func (e *weCurve) New() EllCurve {
if e.IsValid() {
... | curve/weierstrass.go | 0.780704 | 0.448306 | weierstrass.go | starcoder |
package phomath
import "math"
// Vector2Like is something that has an XY method that returns x and y coordinate values
type Vector2Like interface {
XY() (float64, float64)
}
// static check that Vector2 is Vector2Like
var _ Vector2Like = &Vector2{}
// NewVector2 creates a new Vector2
func NewVector2(x, y float64) ... | phomath/vector2.go | 0.961335 | 0.844985 | vector2.go | starcoder |
package testza
import (
"fmt"
"math"
"math/rand"
"testing"
"github.com/MarvinJWendt/testza/internal"
)
// MockInputsFloats64Helper contains integer test sets.
// Use testza.Use.Mock.Inputs.Floats64.
type MockInputsFloats64Helper struct{}
func (h MockInputsFloats64Helper) Full() (floats []float64) {
for i := 0... | mock-floats64.go | 0.801159 | 0.489015 | mock-floats64.go | starcoder |
package main
import (
"math"
"math/rand"
"image"
"image/color"
"image/png"
"io"
"os"
)
const tolerance = 0.000000001
var world []sphere
func sq(x float64) float64 {
return x*x
}
func minroot(a, b, c float64) float64 {
if math.Abs(a) < tolerance {
return b / -c
}
discrt := ma... | raytrace.go | 0.819316 | 0.575528 | raytrace.go | starcoder |
package gs
import (
"fmt"
"github.com/dairaga/gs/funcs"
)
// Try is simplified Scala Try. Try like Either is either Success or Failure, and Failure contains error value.
type Try[T any] interface {
fmt.Stringer
// Fetch returns successful value and nil error if this is a Success, or v is zero value and err is ... | try.go | 0.700588 | 0.419232 | try.go | starcoder |
package calendar
import (
"reflect"
"time"
"github.com/jinzhu/now"
)
// Week have time.Time data to represent week.
type Week []time.Time
// Next returns time.Time collection to represent next week.
func (week Week) Next() (nextWeek Week) {
for _, t := range week {
nextWeek = append(nextWeek, t.AddDate(0, 0, ... | calendar.go | 0.818229 | 0.459379 | calendar.go | starcoder |
package spider
import (
"math"
)
type LegPosition uint8
type Joint uint8
// Leg positions.
const (
FrontRight LegPosition = iota
FrontLeft
BackRight
BackLeft
)
// Servo connection order, within a leg.
const (
BodyCoxa Joint = iota
CoxaFemur
FemurTibia
)
const (
CoxaLength = 23.5
FemurLength = 38.0
Tib... | tinygo/pkg/spider/leg.go | 0.667364 | 0.475666 | leg.go | starcoder |
package pm
import (
"math/big"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
// Constants for byte sizes of Solidity types
const (
addressSize = 20
uint256Size = 32
bytes32Size = 32
)
// SignedTicket is a wrapper around a Ticket with the sender's signature over ... | pm/ticket.go | 0.826922 | 0.426202 | ticket.go | starcoder |
package indexset
import (
"errors"
)
/*
___ ____
-------
-------
_______
__
_______
_______
________
__
*/
type indexRangeOverlap struct {
a, b indexRange
rightIsNewRange bool
}
func makeIndexRangeOverlap(a, b indexRange) indexRangeOverlap {
relation := ind... | index_range_overlap.go | 0.604282 | 0.609553 | index_range_overlap.go | starcoder |
package eval
import (
"strconv"
"github.com/alecthomas/participle/lexer"
"github.com/alecthomas/repr"
)
// Evaluatable abstracts part of an expression that can be evaluated for an instance
type Evaluatable interface {
Evaluate(instance Instance) (interface{}, error)
}
// Function describes a function callable ... | pkg/compliance/eval/eval.go | 0.811303 | 0.51379 | eval.go | starcoder |
package mesh
/*
Package for making meshes, outputs should be json Object
structs from geometry which can be exported as json
*/
import (
geometry "basic-ray/pkg/geometry"
)
const ICO_EDGE_LENGTH = 0.9510565163 // sin(2*pi/5)
type Sphere struct {
Radius float64
Origin geometry.Point
}
func (sphere *Sphere) Create... | pkg/mesh/sphere.go | 0.707304 | 0.76207 | sphere.go | starcoder |
package pt
import (
"image"
"math"
)
type Channel int
const (
ColorChannel = iota
VarianceChannel
StandardDeviationChannel
SamplesChannel
)
type Pixel struct {
Samples int
M, V Color
}
func (p *Pixel) AddSample(sample Color) {
p.Samples++
if p.Samples == 1 {
p.M = sample
return
}
m := p.M
p.M =... | pt/buffer.go | 0.774626 | 0.40439 | buffer.go | starcoder |
package date
import (
"bytes"
"encoding/binary"
"encoding/json"
"time"
)
// unixEpoch is the moment in time that should be treated as timestamp 0.
var unixEpoch = time.Date(1970, time.January, 1, 0, 0, 0, 0, time.UTC)
// UnixTime marshals and unmarshals a time that is represented as the number
// of seconds (ign... | vendor/github.com/hashicorp/consul/vendor/github.com/hashicorp/go-discover/provider/azure/vendor/github.com/Azure/go-autorest/autorest/date/unixtime.go | 0.823115 | 0.40539 | unixtime.go | starcoder |
package ebpf
import "fmt"
var (
_ Instruction = (*JumpEqual)(nil)
_ Jumper = (*JumpEqual)(nil)
_ Valuer = (*JumpEqual)(nil)
)
type JumpEqual struct {
Dest Register
Offset int16
Value int32
}
func (a *JumpEqual) Raw() ([]RawInstruction, error) {
return []RawInstruction{
{Op: BPF_JEQ | BPF_K | B... | ebpf/jeq.go | 0.60964 | 0.452596 | jeq.go | starcoder |
package visitor
import (
"github.com/Bartosz-D3V/grafik/common"
"github.com/vektah/gqlparser/ast"
)
// parseOpTypes parses selectionSet of each GraphQL operation and all variables.
func (v *visitor) parseOpTypes(opList ast.OperationList) {
for _, opDef := range opList {
v.parseSelectionSet(opDef.SelectionSet, ma... | visitor/helper.go | 0.639961 | 0.471406 | helper.go | starcoder |
package main
import "C"
import (
"fmt"
"reflect"
"runtime/cgo"
"testing"
"github.com/gwos/tcg/sdk/transit"
"github.com/stretchr/testify/assert"
)
func test_SetCategory(t *testing.T) {
value := "test-test"
tests := []struct {
name string
target interface{}
field string
}{{
name: "InventoryResour... | libtransit/libtransit_tst.go | 0.502686 | 0.424084 | libtransit_tst.go | starcoder |
// Package strings adds additional string utility functions.
package strings
import (
"strings"
)
// Compare strings a and b, return -1 if a is lower, 1 if greater, 0 if equal.
// Case sensitive.
func Compare(a, b string) int {
if a < b {
return -1
}
if a > b {
return 1
}
return 0
}
// Compare strings a a... | strings.go | 0.731634 | 0.434341 | strings.go | starcoder |
package predicate
// turning movement count (TMC) queries
import (
"github.com/mitroadmaps/gomapinfer/common"
)
func init() {
predicates["uav"] = StartEndPredicate(
common.Rect(362, 446, 706, 1080).ToPolygon(),
common.Rect(784, 176, 1920, 642).ToPolygon(),
)
predicates["warsawlr"] = WaypointPredicate([]comm... | predicate/tmc.go | 0.577495 | 0.551211 | tmc.go | starcoder |
package iso20022
// Calculation of the net asset value for an investment fund/fund class.
type PriceValuation2 struct {
// Unique technical identifier for an instance of a price valuation within a price report, as assigned by the issuer of the report.
Identification *Max35Text `xml:"Id"`
// Date and time of the p... | PriceValuation2.go | 0.798147 | 0.42931 | PriceValuation2.go | starcoder |
package main
import (
"github.com/MattSwanson/raylib-go/physics"
"github.com/MattSwanson/raylib-go/raylib"
)
const (
velocity = 0.5
)
func main() {
screenWidth := float32(800)
screenHeight := float32(450)
rl.SetConfigFlags(rl.FlagMsaa4xHint)
rl.InitWindow(int32(screenWidth), int32(screenHeight), "Physac [ray... | examples/physics/physac/restitution/main.go | 0.581541 | 0.435121 | main.go | starcoder |
package checkers
import (
"fmt"
)
const (
//ROWS is the number of rows in a checkers board
ROWS = 8
//COLS is the number of cols in a checkers board
//this variable is represented as half the amount of the columns
//on a typical checkers board as half of the slots on the board are
//unused. This implementatio... | board.go | 0.603581 | 0.456349 | board.go | starcoder |
package helper
import (
"encoding/hex"
"encoding/json"
"github.com/joeqian10/neo3-gogogo/io"
"strings"
)
const UINT256SIZE = 32
var UInt256Zero = NewUInt256()
/// This class stores a 256 bit unsigned int, represented as a 32-byte little-endian byte array
/// Composed by ulong(64) + ulong(64) + ulong(64) + ulong... | helper/uint256.go | 0.746046 | 0.420183 | uint256.go | starcoder |
package imagelib
import (
"image"
"image/color"
"math"
)
// Pick out only the red colors from an image
func Red(m image.Image) image.Image {
var (
rect = m.Bounds()
c color.Color
cr color.RGBA
newImage = image.NewRGBA(image.Rect(0, 0, rect.Max.X-rect.Min.X, rect.Max.Y-rect.Min.Y))
)
for... | vendor/github.com/xyproto/imagelib/color.go | 0.832407 | 0.538801 | color.go | starcoder |
package directdebitpayment
import (
"context"
"github.com/xendit/xendit-go"
)
// CreateDirectDebitPayment created new direct debit payment
func CreateDirectDebitPayment(data *CreateDirectDebitPaymentParams) (*xendit.DirectDebitPayment, *xendit.Error) {
return CreateDirectDebitPaymentWithContext(context.Background... | directdebit/directdebitpayment/directdebitpayment.go | 0.607314 | 0.475605 | directdebitpayment.go | starcoder |
package ameda
import (
"reflect"
"unsafe"
)
// UnsafeBytesToString convert []byte type to string type.
func UnsafeBytesToString(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}
// UnsafeStringToBytes convert string type to []byte type.
// NOTE:
// panic if modify the member value of the []byte.
func Un... | vendor/github.com/henrylee2cn/ameda/typconv.go | 0.675444 | 0.40589 | typconv.go | starcoder |
package graph
import (
"fmt"
"strconv"
"strings"
)
// FIXME: Add tests!
// Node represents a generic Graph node
type Node interface {
String() string
}
// Nodes consists of a list of Node
type Nodes []Node
// NodeMap consists of a map of Node
type NodeMap map[Node]bool
// Graph represents a direct... | graph.go | 0.585931 | 0.594228 | graph.go | starcoder |
package expect
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
)
// Equal asserts that two values are identical. If the values are not identical
// then their differences are printed and the current test is marked to have
// failed.
func Equal(t *testing.T, got, expected interface{}, msg string, opts ... | expect.go | 0.805594 | 0.66063 | expect.go | starcoder |
package main
/*
Programming question 2 from Stanford Datastructures and Algorithms
The file, quicksort.txt, contains all of the integers between 1 and
10,000 inclusive, with no repeats) in unsorted order. The integer in
the i-th row of the file gives you the i-th entry of an input array.
Your task is to com... | Stanford/ProgrammingQuestion2_QuicksortComparisons/main.go | 0.747339 | 0.602559 | main.go | starcoder |
package contexttest
import (
"context"
"sync"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// WithCancel can be tested to have the behavior of context.WithCancel.
type WithCancel func(ctx context.Context) (context.Context, context.CancelFunc)
// TestWithCancel tests th... | cancel.go | 0.605566 | 0.521898 | cancel.go | starcoder |
package engine
import (
"image"
"image/color"
"math"
"math/rand"
)
// Tilemap contains tile data for
// IsoRenderer to use.
type Tilemap struct {
// TileWidth is the tiles width in pixels.
TileWidth int
// Data contains values representing tiles.
Data [2][][]int
// Mapper maps data values to tile images.
Ma... | engine/tilemap.go | 0.744563 | 0.623463 | tilemap.go | starcoder |
package ta
import (
"math"
)
// Calculates the directional movement. Returns (diffM, diffP)
func directionalMovement(curHigh float64, curLow float64, prevHigh float64, prevLow float64) (float64, float64) {
diffP := curHigh-prevHigh /* Plus Delta */
diffM := prevLow-curLow /* Minus Delta */
if (diffM >... | ta/adx.go | 0.715325 | 0.445831 | adx.go | starcoder |
package af
import "github.com/rannoch/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE, dd MMMM y", Long: "dd MMMM y", Medium: "dd MMM y", Short: "y-MM-dd"},
Time: cldr.CalendarDateFormat{Full: "h:mm:ss a zzzz", Long: "h:mm:ss a z", Medium: "h:m... | resources/locales/af/calendar.go | 0.517083 | 0.447823 | calendar.go | starcoder |
package main
import (
"fmt"
"os"
"os/exec"
"time"
)
// Grid is a 2D slice
type Grid struct {
Width int
Height int
Cells []int
}
// NewGrid creates a Grid
func NewGrid(width int, height int) Grid {
grid := &Grid{Width: width, Height: height}
size := width * height
grid.Cells = make([]int, size, size)
ret... | go/conway1.go | 0.765856 | 0.584923 | conway1.go | starcoder |
package shapes
import (
"math"
"github.com/factorion/graytracer/pkg/primitives"
)
// Triangle Represents a triangle
type Triangle struct {
ShapeBase
Point1, Point2, Point3, Edge1, Edge2, Norm primitives.PV
}
// MakeTriangle Create a triangle from three points
func MakeTriangle(point1, point2, point3 primitives.... | pkg/shapes/triangle.go | 0.901852 | 0.590779 | triangle.go | starcoder |
package proto
import (
"fmt"
"math/big"
"github.com/xlab-si/emmy/crypto/cl"
"github.com/xlab-si/emmy/crypto/common"
"github.com/xlab-si/emmy/crypto/df"
"github.com/xlab-si/emmy/crypto/ec"
"github.com/xlab-si/emmy/crypto/qr"
"github.com/xlab-si/emmy/crypto/schnorr"
)
type PbConvertibleType interface {
GetNat... | proto/translations.go | 0.567457 | 0.41745 | translations.go | starcoder |
package internal
import (
"fmt"
"reflect"
"github.com/onsi/gomega/types"
)
type Assertion struct {
actuals []interface{} // actual value plus all extra values
actualIndex int // value to pass to the matcher
vet vetinari // the vet to call before calling Gomega matcher
offset in... | vendor/github.com/onsi/gomega/internal/assertion.go | 0.696165 | 0.685002 | assertion.go | starcoder |
package mailbox
import (
"crypto/rand"
"runtime/debug"
"github.com/kkdai/bstream"
"github.com/lightningnetwork/lnd/aezeed"
"golang.org/x/crypto/scrypt"
)
const (
// NumPassphraseWords is the number of words we use for the pairing
// phrase.
NumPassphraseWords = 10
// NumPassphraseEntropyBytes is the number... | mailbox/crypto.go | 0.663233 | 0.517571 | crypto.go | starcoder |
package fsm
import (
"errors"
)
type transitionFunc func() error
// FSM is an implementation of a finite state machine.
type FSM struct {
// currentState is the current state that the FSM is in
currentState string
// transitionMap maps a single state to N valid transition states
transitionMap map[string][]stri... | fsm.go | 0.562898 | 0.509032 | fsm.go | starcoder |
package table
import (
"bufio"
"bytes"
"fmt"
"io"
"regexp"
"strings"
"unicode/utf8"
)
// Alignment represents the supported cell content alignment modes.
type Alignment uint8
const (
AlignLeft Alignment = iota
AlignCenter
AlignRight
)
// CharacterFilter defines the character filter modes supported by the ... | vendor/github.com/geckoboard/cli-table/table.go | 0.708313 | 0.405566 | table.go | starcoder |
package days
import (
"fmt"
"strconv"
"strings"
"joshatron.io/aoc2021/input"
)
func Day08Puzzle1() string {
displays := getDisplays(input.SplitIntoLines(input.ReadDayInput("08")))
count := 0
for _, display := range displays {
for _, output := range display.output {
length := len(output)
if length == ... | days/day08.go | 0.549641 | 0.411406 | day08.go | starcoder |
package vwap
import (
"sync"
"github.com/shopspring/decimal"
"golang.org/x/xerrors"
)
const defaultMaxSize = 200
// DataPoint represents a single data point from coinbase.
type DataPoint struct {
Price decimal.Decimal
Volume decimal.Decimal
ProductID string
}
// List represents a queue of DataPoints.
... | internal/vwap/vwap.go | 0.719975 | 0.482429 | vwap.go | starcoder |
package svg
import (
"github.com/goki/gi/gi"
"github.com/goki/ki/ki"
"github.com/goki/ki/kit"
"github.com/goki/mat32"
)
// Rect is a SVG rectangle, optionally with rounded corners
type Rect struct {
NodeBase
Pos mat32.Vec2 `xml:"{x,y}" desc:"position of the top-left of the rectangle"`
Size mat32.Vec2 `xm... | svg/rect.go | 0.70477 | 0.506713 | rect.go | starcoder |
package aimdcloser
import (
"math"
"time"
"golang.org/x/time/rate"
)
// RateLimiter is any object that can dynamically alter its reservation rate to allow more or less requests over time.
type RateLimiter interface {
// OnFailure is triggered each time we should lower our request rate.
OnFailure(now time.Time)
... | aimd.go | 0.543833 | 0.476519 | aimd.go | starcoder |
package calendar
import (
"fmt"
"time"
"github.com/QuestScreen/api/modules"
"github.com/QuestScreen/api/render"
"github.com/QuestScreen/api/server"
shared "github.com/QuestScreen/plugin-tutorial"
)
/*title: Module Renderer
This file contains the code that renders the module to the screen.
*/
// calendarRender... | calendar/renderer.go | 0.822046 | 0.548915 | renderer.go | starcoder |
package cases
import (
"sort"
"testing"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/stretchr/testify/require"
)
// SortedLabelsTest exports a single, constant metric with labels in the wrong order
// and checks that we receive the metrics with sorted labels.
func SortedLabelsTest() Test {
return T... | cases/labels.go | 0.754915 | 0.523481 | labels.go | starcoder |
package main
import (
"fmt"
"math"
)
//math funcs (start)
func addNum(a1 int, a2 int) int { return a1 + a2 }
func subtractNum(a1 int, a2 int) int { return a1 - a2 }
func multiplyNum(a1 int, a2 int) int { return a1 * a2 }
func divideNum(a1 int, a2 int) int { return a1 / a2 }
func sinNu... | main.go | 0.716913 | 0.580084 | main.go | starcoder |
package good
import (
"bufio"
"bytes"
"fmt"
"image"
"image/color"
"image/draw"
"image/jpeg"
"golang.org/x/image/colornames"
"golang.org/x/image/font"
"golang.org/x/image/font/basicfont"
"golang.org/x/image/math/fixed"
)
func HLine(image *image.RGBA, y, x1, x2 int, c color.Color) {
for i := x1; i < x2; i+... | render.go | 0.513181 | 0.403244 | render.go | starcoder |
package openapi
import (
"encoding/json"
)
// NumaDistance struct for NumaDistance
type NumaDistance struct {
Destination int32 `json:"destination"`
Distance int32 `json:"distance"`
}
// NewNumaDistance instantiates a new NumaDistance object
// This constructor will assign default values to properties that ha... | src/runtime/virtcontainers/pkg/cloud-hypervisor/client/model_numa_distance.go | 0.823151 | 0.42925 | model_numa_distance.go | starcoder |
package algorithms
import (
"line-simplify/tracks"
"math"
"sort"
"time"
)
// Line describes a line between two vectors
type Line struct {
V1 tracks.Datum
V2 tracks.Datum
}
// Diff returns the difference of v1 and v2
func Diff(v1, v2 tracks.Datum) tracks.Datum {
var vR tracks.Datum
vR.Lon = v2.Lon - v1.Lon
v... | algorithms/douglasPeucker.go | 0.813016 | 0.481759 | douglasPeucker.go | starcoder |
package beartol
import (
"fmt"
)
// FagTolerancesInteractor implements TolerancesInteractor.
type FagTolerancesInteractor struct{}
func (thiz *FagTolerancesInteractor) GetInnerDiameterTolerance(rb RollingBearing) (int, int, error) {
id, err := thiz.toToleranceId(rb.Type)
if err != nil {
return 0, 0, err
}
tol... | FagTolerancesInteractor.go | 0.519034 | 0.44089 | FagTolerancesInteractor.go | starcoder |
package classification
import (
"fmt"
"math"
"github.com/eriq-augustine/goml/base"
"github.com/eriq-augustine/goml/features"
"github.com/eriq-augustine/goml/optimize"
"github.com/eriq-augustine/goml/util"
"github.com/gonum/blas/blas64"
)
const (
LR_DEFAULT_L2_PENALTY = 1.0
)
type LogisticRe... | classification/logisticRegression.go | 0.780495 | 0.469095 | logisticRegression.go | starcoder |
package table
import (
"regexp"
"strings"
)
// FieldMatcher is a function type which is consumed by different table Cell finder functions.
type FieldMatcher func([]string) (string, bool)
// LineContaining returns a predicate checking whether a line contains specified tokens
func LineContaining(ss ...string) func(s... | line.go | 0.784732 | 0.450662 | line.go | starcoder |
package schema
import "github.com/google/uuid"
// ValidPayment an example of a valid payment
func ValidPayment() *Payment {
ID := uuid.New().String()
return &Payment{
ID: ID,
Type: "Payment",
Version: 0,
OrganisationID: uuid.New().String(),
Attributes: ValidPaymentAttribut... | implementation/schema/examples.go | 0.796925 | 0.444444 | examples.go | starcoder |
package model
import (
"strings"
"math"
"k8s.io/klog"
)
var count map[string]int
var bicount map[string]map[string]int
var tricount map[string]map[string]map[string]int
var quadcount map[string]map[string]map[string]map[string]int
//laplase smoothing
var laplace_alpha float64
type Key struct {
first, seco... | model/model.go | 0.623377 | 0.423816 | model.go | starcoder |
package validator
import (
"github.com/KludgePub/TheMazeRunner/maze"
)
// GetSolvedPath show path in map
func GetSolvedPath(m maze.Map, from, to maze.Point) []maze.Point {
stackPath := []maze.Point{from}
g := maze.DispatchToGraph(&m)
var isCanMove func(g *maze.Graph, cNode *maze.Node, endPoint maze.Point) bool
... | validator/path.go | 0.692538 | 0.630372 | path.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.