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 main
import (
"github.com/gen2brain/raylib-go/physics"
"github.com/gen2brain/raylib-go/raylib"
)
func main() {
screenWidth := int32(800)
screenHeight := int32(450)
raylib.SetConfigFlags(raylib.FlagMsaa4xHint)
raylib.InitWindow(screenWidth, screenHeight, "Physac [raylib] - physics friction")
// Physac... | examples/physics/physac/friction/main.go | 0.684159 | 0.535281 | main.go | starcoder |
package data
import (
"encoding/binary"
"fmt"
"math"
"reflect"
"time"
"github.com/zeroshade/go-drill/internal/rpc/proto/exec/shared"
)
type TimestampVector struct {
*Int64Vector
}
func (TimestampVector) Type() reflect.Type {
return reflect.TypeOf(time.Time{})
}
func NewTimestampVector(data []byte, meta *sh... | internal/data/date_time_vectors.go | 0.679179 | 0.706316 | date_time_vectors.go | starcoder |
package physics
import (
"errors"
"github.com/strangedev/vroom/algebra"
"github.com/strangedev/vroom/gfx"
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
"github.com/faiface/pixel/imdraw"
)
const (
splitThreshold = 2
minBoxWidth = 5
maxItems = 1000
)
type QuadKey struct {
Pnt interface{... | physics/quadtree.go | 0.627495 | 0.453867 | quadtree.go | starcoder |
package storage
import (
"github.com/janelia-flyem/dvid/dvid"
)
// GraphSetter defines operations that modify a graph
type GraphSetter interface {
// CreateGraph creates a graph with the given context.
CreateGraph(ctx Context) error
// AddVertex inserts an id of a given weight into the graph
AddVertex(ctx Conte... | storage/graphdb.go | 0.626581 | 0.660946 | graphdb.go | starcoder |
package blockchain
import (
"bytes"
"crypto/sha256"
"encoding/binary"
"fmt"
"log"
"math"
"math/big"
)
// take the data from the block
// create a counter (nonce) which starts at 0
// create a hash of the data plus the counter
// check the hash to see if it meets a set of requirements. These requirements rep... | blockchain/proof.go | 0.676834 | 0.495422 | proof.go | starcoder |
package ogdate
import "time"
const (
FmtY = "2006"
FmtM = "01"
FmtD = "02"
FmtYMD = "2006-01-02"
)
func Today() Date {
return NewDate(time.Now().In(time.Local))
}
func Yesterday() Date {
return Today().DayAgo(1)
}
func Tomorrow() Date {
return Today().DayLater(1)
}
func On(y int, m time.Month, d int)... | ogdate.go | 0.574037 | 0.531331 | ogdate.go | starcoder |
package osc
import (
"encoding/json"
)
// QuotaTypes One or more quotas.
type QuotaTypes struct {
// The resource ID if it is a resource-specific quota, `global` if it is not.
QuotaType *string `json:"QuotaType,omitempty"`
// One or more quotas associated with the user.
Quotas *[]Quota `json:"Quotas,omitempty"`... | v2/model_quota_types.go | 0.717111 | 0.448064 | model_quota_types.go | starcoder |
package day3
import (
"ryepup/advent2021/utils"
)
/*
--- Day 3: Binary Diagnostic ---
The submarine has been making some odd creaking noises, so you ask it to produce
a diagnostic report just in case.
The diagnostic report (your puzzle input) consists of a list of binary numbers
which, when decoded properly, can t... | day3/part1.go | 0.761627 | 0.627495 | part1.go | starcoder |
package section
import (
"bytes"
"crypto/sha256"
"crypto/sha512"
"encoding/binary"
"errors"
"fmt"
"hash/fnv"
cbor "github.com/britram/borat"
log "github.com/inconshreveable/log15"
"github.com/netsec-ethz/rains/internal/pkg/algorithmTypes"
"github.com/netsec-ethz/rains/internal/pkg/datastructures/bitarray"... | internal/pkg/section/datastructure.go | 0.604165 | 0.413684 | datastructure.go | starcoder |
package reflect
import (
"reflect"
)
const EQUALMETHOD = "Equal"
func Equal(v1, v2 interface{}) bool {
return EqualValue(reflect.ValueOf(v1), reflect.ValueOf(v2))
}
func EqualValue(v1, v2 reflect.Value) bool {
if v1.Kind() != v2.Kind() {
return false
}
switch v1.Kind() {
case reflect.Bool:
return v1.Bool(... | reflect/equal.go | 0.517815 | 0.470858 | equal.go | starcoder |
package slice
import "errors"
// DeleteBool removes an element at a specific index of a bool slice.
// An error is return in case the index is out of bounds or if the slice is nil or empty.
func DeleteBool(a []bool, i int) ([]bool, error) {
if len(a) == 0 {
return nil, errors.New("Cannot delete an element from a n... | delete.go | 0.830353 | 0.535766 | delete.go | starcoder |
package arr
import (
"reflect"
"github.com/yaoapp/yao/lib/exception"
"github.com/yaoapp/yao/lib/t"
)
// Pluck pluck a list of the given key / value pairs from the array/slice.
func Pluck(array interface{}, find interface{}, v interface{}) {
values := reflect.ValueOf(array)
if values.Kind() != reflect.Array && v... | lib/arr/arr.go | 0.609873 | 0.47384 | arr.go | starcoder |
package main
/* This virtual component makes possible the use of configuration file. Its interfaces can be used to fetch configuration data from a configuration file. The interface to use among the three, depends on the kind of data you're trying to fetch.
BACKUPS: The following are some actual components capable of... | aaaaaf.vcConfDataProvider.go | 0.60964 | 0.614654 | aaaaaf.vcConfDataProvider.go | starcoder |
package godig
import (
"github.com/tidwall/gjson"
)
//OneMap retrieves a single record using the provided primary key. The
//returned record is a map of names and values. Everything is a string.
func (t *Table) OneMap(key string) (map[string]string, error) {
var b map[string]string
body, err := t.OneRaw(key)
if... | pkg/mapped.go | 0.793586 | 0.416085 | mapped.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"os"
"time"
)
// To compute x^y under modulo m
func power(x uint64, y uint64, m uint64) uint64 {
if y == 0 {
return 1
}
p := power(x, y/2, m) % m
p = (p * p) % m
if y%2 == 0 {
return p
}
return (x * p) % m
}
// Function to find modular inverse of a under modulo... | day-13/part-2/ayoub.go | 0.554953 | 0.442275 | ayoub.go | starcoder |
package v1
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three p... | sdk/go/google/bigqueryreservation/v1/pulumiTypes.go | 0.674908 | 0.409634 | pulumiTypes.go | starcoder |
package act
import (
"math"
"strings"
)
// Activation functions implemented
// Linear 2
// Sigmoid 3
// ReLU 4
// SoftSign 1
//ActivationFactory takes the 'name' of the function to be used and returns the corresponding struct
//Linear
//sigmoid
//ReLU
//SoftSign
//default is ReLU
func Act... | act/activation.go | 0.641085 | 0.410874 | activation.go | starcoder |
package obj
import (
"github.com/deadsy/sdfx/sdf"
"github.com/ivanpointer/pterosphera/render"
)
// MXSwitchSocket defines the socket for a MX switch.
type MXSwitchSocket struct {
// SocketWH defines the width and height of the "hole" part of a MX switch socket.
SocketWH float64
// SideTabW defines the width of ... | go_sdx/obj/switches.go | 0.652131 | 0.552057 | switches.go | starcoder |
package main
import "fmt"
func main() {
fmt.Println("Slice types")
// Empty slice declaration. The value of an uninitialized slice is nil.
var emptySlice []int
fmt.Printf("Empty slice %v, is nil %t, len %d, cap %d\n", emptySlice, emptySlice == nil,
len(emptySlice), cap(emptySlice))
// A slice literal describ... | lessons/types/slice.go | 0.573678 | 0.414543 | slice.go | starcoder |
package builtins
import (
"fmt"
"github.com/eandre/sqlparse/pkg/util/pgerror"
"github.com/eandre/sqlparse/sem/tree"
"github.com/eandre/sqlparse/sem/types"
)
func initWindowBuiltins() {
// Add all windows to the Builtins map after a few sanity checks.
for k, v := range windows {
if !v.props.Impure {
panic... | sem/builtins/window_builtins.go | 0.619471 | 0.465934 | window_builtins.go | starcoder |
package binheap
import (
"golang.org/x/exp/constraints"
)
// ComparableHeap provides additional Search and Delete methods.
// Could be used for comparable types.
type ComparableHeap[T comparable] struct {
Heap[T]
}
// EmptyComparableHeap creates heap for comparable types.
func EmptyComparableHeap[T comparable](com... | binheap/ordered.go | 0.790166 | 0.467028 | ordered.go | starcoder |
package iso20022
// Set of elements identifying the dates related to the underlying transactions.
type TransactionDates1 struct {
// Point in time when the payment order from the initiating party meets the processing conditions of the account servicing agent (debtor's agent in case of a credit transfer, creditor's a... | TransactionDates1.go | 0.795738 | 0.699511 | TransactionDates1.go | starcoder |
package types
import (
"encoding/json"
"fmt"
"regexp"
log "github.com/sirupsen/logrus"
"github.com/smartystreets/assertions"
"github.com/stretchr/objx"
"gopkg.in/yaml.v3"
)
const (
DefaultMatcher = "ShouldEqual"
)
type Assertion func(actual interface{}, expected ...interface{}) string
var asserts = map[str... | server/types/matchers.go | 0.659734 | 0.528229 | matchers.go | starcoder |
package exporters
import (
"github.com/learnitall/gobench/define"
)
// ChainExporter is used to allow for multiple exporters to function through one Expoerterable interface.
// It's important to initiate Exporters and marshalled appropriately
type ChainExporter struct {
Exporters []define.Exporterable
Marshalled ... | exporters/chain.go | 0.580114 | 0.471649 | chain.go | starcoder |
package dmc
type DefColor struct {
ColorName string
Floss string
Hex string
R string
G string
B string
}
type DmcColors struct {
ColorBank []DefColor
HexMap map[string]string
}
var colorBank []DefColor
func fillColorBank() *DmcColors {
// v2 will implement a webscraper... | colorBank.go | 0.507568 | 0.666062 | colorBank.go | starcoder |
package math
import (
"errors"
"fmt"
"log"
)
type Matrix3 struct {
elements [9]float32
}
func NewDefaultMatrix3() *Matrix3 {
matrix := &Matrix3{
elements: [9]float32{0, 0, 0, 0, 0, 0, 0, 0, 0},
}
matrix.SetIdentity()
return matrix
}
func NewMatrix3(n11, n12, n13, n21, n22, n23, n31, n32, n33 float32) *Mat... | matrix3.go | 0.736116 | 0.617541 | matrix3.go | starcoder |
package tonality
import (
"errors"
"strings"
)
// KeyNotation is the type representing a type of key notation.
type KeyNotation int
// Key notatations are the available notations for converting to and from.
const (
CamelotKeys KeyNotation = iota
OpenKey
Musical
MusicalAlt
Beatport
)
var (
// NotationCamelot... | vendor/github.com/tombell/tonality/tonality.go | 0.517571 | 0.451327 | tonality.go | starcoder |
package dsp
import "math"
// http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
type BiQuadFilter struct {
B0, B1, B2 float64
A0, A1, A2 float64
prevIn, prevOut [2]float64
}
func (f *BiQuadFilter) Filter(input, output []float64) {
b0a0 := f.B0 / f.A0
b1a0 := f.B1 / f.A0
b2a0 := f.B2 / f.A0
a1a0 :=... | dsp/biquad.go | 0.591487 | 0.471588 | biquad.go | starcoder |
package geocube
import (
"encoding/binary"
"fmt"
"image"
"unsafe"
"github.com/airbusgeo/geocube/internal/utils"
"github.com/airbusgeo/godal"
)
// Bitmap decribes any image as a bitmap of bytes
type Bitmap struct {
// Bytes is the []byte representation of the image
Bytes []byte
// Bands is the number of inte... | internal/geocube/image.go | 0.758421 | 0.560674 | image.go | starcoder |
package types
import (
"io"
"math"
"github.com/lyraproj/puppet-evaluator/eval"
)
type TupleType struct {
size *IntegerType
givenOrActualSize *IntegerType
types []eval.Type
}
var Tuple_Type eval.ObjectType
func init() {
Tuple_Type = newObjectType(`Pcore::TupleType`,
`Pcore::AnyType... | types/tupletype.go | 0.620507 | 0.493836 | tupletype.go | starcoder |
package day22
import (
"log"
"strconv"
)
type Hand []int
type HandScores struct {
score1, score2 int
}
// Plays a game of combat and returns the winner's score
func PlayCombat(player1Hand []string, player2Hand []string) int {
hand1 := parseHand(player1Hand)
hand2 := parseHand(player2Hand)
var winner Hand
fo... | day22/day22.go | 0.682468 | 0.467757 | day22.go | starcoder |
package gogeom
import "math"
//Ax+By+c =0
type GeneralLine struct {
A, B, C float64
}
//Ax+By+c =0
//Dx+Ey+F=0
type GeneralLines struct {
A, B, C, D, E, F float64
}
type TwoPointFormLine struct {
X1, Y1, X2, Y2 float64
}
// Slope of the line
func (l *GeneralLine) SlopeOfLine() float64 {
return -(l.A / l.B)
}
... | line.go | 0.77373 | 0.438785 | line.go | starcoder |
package core
import (
"reflect"
"strings"
)
const (
// DefAssignAddArr appends the array to array
DefAssignAddArr = `AssignAddºArr`
// DefAssignAddArrArr appends the array to array
DefAssignAddArrArr = `AssignAddºArrArr`
// DefAssignAddMap appends the map to array
DefAssignAddMap = `AssignAddºArrMap`
// Def... | core/embed.go | 0.520009 | 0.429429 | embed.go | starcoder |
package model
import (
"encoding/json"
"strconv"
)
type AttributeMap struct {
values map[string]AttributeValue
}
func NewAttributeMap() *AttributeMap {
values := make(map[string]AttributeValue)
return &AttributeMap{values}
}
func NewAttributeMapWithValues(values map[string]AttributeValue) *AttributeMap {
retu... | collector/model/attribute_map.go | 0.736685 | 0.512388 | attribute_map.go | starcoder |
package main
import (
"log"
"math"
)
/**
a sevenish number is defined as a value that is a unique power of 7 or a sum of two unique powers of 7
this function is to find the sevenish number at n in the sequence (eg 1=1, 2=7, 3=8, 4=49, 5=50, 6=51 ...)
*/
func sevenishNumber(num uint64) uint64 {
if num < 1 {
log.... | dec1/main.go | 0.505615 | 0.545467 | main.go | starcoder |
package network
import (
"encoding/json"
"fmt"
"testing"
"github.com/ingrammicro/cio/api/types"
"github.com/ingrammicro/cio/utils"
"github.com/stretchr/testify/assert"
)
// ListListenersMocked test mocked function
func ListListenersMocked(t *testing.T, loadBalancerID string, listenersIn []*types.Listener) []*... | api/network/listeners_api_mocked.go | 0.670177 | 0.402157 | listeners_api_mocked.go | starcoder |
package should
import (
"errors"
"fmt"
"math"
"reflect"
"runtime/debug"
"strings"
"time"
)
// Equal verifies that the actual value is equal to the expected value.
// It uses reflect.DeepEqual in most cases, but also compares numerics
// regardless of specific type and compares time.Time values using the
// tim... | should/equal.go | 0.704668 | 0.481881 | equal.go | starcoder |
package api
import (
"fmt"
"sort"
)
// DeepCopy returns a clone of the original Metrics. It provides a deep copy
// of both the key and the value of the original Hierarchy.
func (h Hierarchy) DeepCopy() Hierarchy {
clone := make(Hierarchy, len(h))
for k, v := range h {
var clonedV []string
clonedV = append(cl... | threescale/api/utilities.go | 0.815085 | 0.550184 | utilities.go | starcoder |
package bitmap
import "sync"
var (
tA = [8]byte{1, 2, 4, 8, 16, 32, 64, 128}
tB = [8]byte{254, 253, 251, 247, 239, 223, 191, 127}
)
func dataOrCopy(d []byte, c bool) []byte {
if !c {
return d
}
ndata := make([]byte, len(d))
copy(ndata, d)
return ndata
}
// NewSlice creates a new byteslice with length l (in... | bitmap.go | 0.749637 | 0.455199 | bitmap.go | starcoder |
package matrixexp
import (
"github.com/gonum/blas"
"github.com/gonum/blas/blas64"
)
// Mul represents matrix multiplication.
type Mul struct {
Left MatrixExp
Right MatrixExp
}
// String implements the Stringer interface.
func (m1 *Mul) String() string {
return m1.Left.String() + ".Mul(" + m1.Right.String() + ... | mul.go | 0.908646 | 0.480966 | mul.go | starcoder |
package octal
var octByteToString = [256]string{
0: `000`,
1: `001`,
2: `002`,
3: `003`,
4: `004`,
5: `005`,
6: `006`,
7: `007`,
8: `010`,
9: `011`,
10: `012`,
11: `013`,
12: `014`,
13: `015`,
14: `016`,
15: `017`,
16: `020`,
17: `021`,
18: `022`,
19: `023`,
20: `024... | pkg/reader/byteFormatters/octal/oct_lookup.go | 0.63341 | 0.414366 | oct_lookup.go | starcoder |
package gjp
//--------------------
// IMPORTS
//--------------------
import "github.com/tideland/golib/errors"
//--------------------
// DIFFERENCE
//--------------------
// Diff manages the two parsed documents and their differences.
type Diff interface {
// FirstDocument returns the first document passed to Dif... | gjp/diff.go | 0.675336 | 0.435962 | diff.go | starcoder |
package glider
import (
"math"
)
type distanceFormula_t uint8
const (
DISTANCE_FORMULA_HAVERSINE distanceFormula_t = iota
DISTANCE_FORMULA_SPHERICAL_LAW_OF_COSINES
DISTANCE_FORMULA_EQUIRECTANGULAR
DISTANCE_FORMULA_CACHED_EQUIRECTANGULAR
)
// Calculate the distance between two points
func Distance(p1, p2 Point)... | glider/navigation.go | 0.76533 | 0.61682 | navigation.go | starcoder |
package epoch
import (
"time"
)
// Monthly models an epoch that changes at the beginning of every month.
type Monthly struct{}
// GetData exposes data for monthly epoch.
func (Monthly) GetData() Data {
return Data{
"Once per month (monthly)",
"The last PR merge commit of each month, by UTC commit timestamp on... | revisions/epoch/gregorian.go | 0.826151 | 0.606702 | gregorian.go | starcoder |
package samples
func init() {
sampleDataProposalCreateOperation[10] = `{
"expiration_time": "2016-01-18T23:59:59",
"extensions": [],
"fee": {
"amount": 1335,
"asset_id": "1.3.120"
},
"fee_paying_account": "1.2.282",
"proposed_ops": [
{
"op": [
43,
{
"amount_to... | gen/samples/proposalcreateoperation_10.go | 0.58261 | 0.461017 | proposalcreateoperation_10.go | starcoder |
package dymessage
import (
"math"
)
type (
// Depending on the context, the entity represents either a regular
// entity with its own primitive and reference values, or the collection
// of either primitive or reference values, sharing the same type.
Entity struct {
// The data type the entity belongs to. This... | datamodel.go | 0.774583 | 0.665078 | datamodel.go | starcoder |
package geario
import (
"fmt"
"regexp"
"strconv"
"strings"
)
type B float64
func (b B) String() string {
return BytesSize(b)
}
// See: http://en.wikipedia.org/wiki/Binary_prefix
const (
// Decimal
KB B = 1000
MB B = 1000 * KB
GB B = 1000 * MB
TB B = 1000 * GB
PB B = 1000 * TB
EB B = 1000 * PB
ZB B = 1... | b.go | 0.794185 | 0.444203 | b.go | starcoder |
package value
import (
"fmt"
"strconv"
"unicode"
)
type (
// Value represents a value at runtime.
Value interface {
// Name returns the name of the type.
Name() string
// Comparable returns true if the 'other' value can be compared with the
// receiver.
Comparable(other Value) bool
// Equal return... | scarlet/value/value.go | 0.802594 | 0.547162 | value.go | starcoder |
package rpctest
import (
"reflect"
"time"
"github.com/drcsuite/drc/chaincfg/chainhash"
"github.com/drcsuite/drc/rpcclient"
)
// JoinType is an enum representing a particular type of "node join". A node
// join is a synchronization tool used to wait until a subset of nodes have a
// consistent state with respect... | integration/rpctest/utils.go | 0.621081 | 0.462473 | utils.go | starcoder |
package aoc2020
/*
The small crab challenges you to a game! The crab is going to mix up some cups, and you have to predict where they'll end up.
The cups will be arranged in a circle and labeled clockwise (your puzzle input). For example, if your labeling were 32415, there would be five cups in the circle; going cloc... | app/aoc2020/aoc2020_23_part1.go | 0.527317 | 0.577912 | aoc2020_23_part1.go | starcoder |
package main
import (
"math/rand"
"strings"
)
type MazeCell struct {
Grid *MazeGrid `json:"grid"`
Room *Room `json:"room"`
Terrain int `json:"terrain"`
Wall bool `json:"wall"`
X int `json:"x"`
Y int `json:"y"`
}
type MazeGrid struct {
Game *Game `jso... | src/maze.go | 0.659186 | 0.402744 | maze.go | starcoder |
package graph
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// SignIn provides operations to manage the auditLogRoot singleton.
type SignIn struct ... | models/microsoft/graph/sign_in.go | 0.737442 | 0.508483 | sign_in.go | starcoder |
package lorawan
import (
"go.thethings.network/lorawan-stack/pkg/errors"
)
var (
errDecode = errors.Define("decode", "could not decode `{lorawan_field}`")
errEncode = errors.Define("encode", "could not encode `{lorawan_field}`")
errEncodedFieldLengthBound = errors... | pkg/encoding/lorawan/errors.go | 0.645567 | 0.480966 | errors.go | starcoder |
package mapper
import (
"reflect"
"strings"
"github.com/pulumi/pulumi/pkg/util/contract"
)
// Mapper can map from weakly typed JSON-like property bags to strongly typed structs, and vice versa.
type Mapper interface {
// Decode decodes a JSON-like object into the target pointer to a structure.
Decode(obj map[s... | pkg/util/mapper/mapper.go | 0.703753 | 0.413181 | mapper.go | starcoder |
package gcp
import (
"context"
"fmt"
"sync"
"time"
"cloud.google.com/go/pubsub"
"github.com/benthosdev/benthos/v4/internal/batch"
"github.com/benthosdev/benthos/v4/internal/bloblang/field"
"github.com/benthosdev/benthos/v4/internal/bundle"
"github.com/benthosdev/benthos/v4/internal/component"
"github.com/b... | internal/impl/gcp/output_pubsub.go | 0.606498 | 0.417093 | output_pubsub.go | starcoder |
package geocube
//go:generate enumer -json -sql -type DatasetStatus -trimprefix DatasetStatus
import (
"fmt"
"strings"
"github.com/google/uuid"
"github.com/twpayne/go-geom"
pb "github.com/airbusgeo/geocube/internal/pb"
"github.com/airbusgeo/geocube/internal/utils"
"github.com/airbusgeo/geocube/internal/utils... | internal/geocube/dataset.go | 0.730482 | 0.53358 | dataset.go | starcoder |
package critpath
/*
From LeetCode Critical Path detector
https://leetcode.com/problems/critical-connections-in-a-network/
Input: n = 4, connections = [[0,1],[1,2],[2,0],[1,3]]
Output: [[1,3]]
Explanation: [[3,1]] is also accepted.
This uses Tarjan's algorith. The idea is to iterate over all the ... | criticalPath/critPathTarjan.go | 0.83622 | 0.459258 | critPathTarjan.go | starcoder |
package rof
import (
"fmt"
"reflect"
"time"
)
type Interpreter struct {
Globals *Environment
Env *Environment
}
func NewInterpreter() Interpreter {
var i Interpreter
i.Globals = NewEnv(nil)
i.Env = i.Globals
i.Globals.Define("clock", NativeFunction{NativeCall: func(Interpreter, []Expr) interface{} { ret... | rof/interpreter.go | 0.51562 | 0.407216 | interpreter.go | starcoder |
package pngutil
import (
"errors"
"io"
)
/*
skipReadSeeker represents a view into a larger reader. It starts at
offset and ends at limit. Once it has read up to limit the Read
method returns an io.EOF error.
In this package all instances of skipReadSeeker use the same underlying
reader passed to ReplaceMeta.
*/
ty... | pngutil/readers.go | 0.600891 | 0.418519 | readers.go | starcoder |
package standard
type andOperator struct {
arg1, arg2 interface{}
}
func (op *andOperator) Evaluate(parameters map[string]interface{}) (interface{}, error) {
first, err := getBoolean(op.arg1, parameters)
if err != nil {
return nil, err
}
second, err := getBoolean(op.arg2, parameters)
if err != nil {
return... | script/standard/logic_operators.go | 0.623262 | 0.45744 | logic_operators.go | starcoder |
package main
import (
"github.com/threagile/threagile/model"
)
type accidentalLoggingOfSensitiveDataRule string
var CustomRiskRule accidentalLoggingOfSensitiveDataRule
func (r accidentalLoggingOfSensitiveDataRule) Category() model.RiskCategory {
return model.RiskCategory{
Id: "accidental... | risks/accidental-logging-of-sensitive-data/accidental-logging-of-sensitive-data-rule.go | 0.531939 | 0.481515 | accidental-logging-of-sensitive-data-rule.go | starcoder |
package parser
import (
"fmt"
"reflect"
"strconv"
"strings"
)
// EncoderToNodeOpts Options for the encoderToNode.
type EncoderToNodeOpts struct {
OmitEmpty bool
TagName string
AllowSliceAsStruct bool
}
// EncodeToNode converts an element to a node.
// element -> nodes.
func EncodeToNode(el... | pkg/config/parser/element_nodes.go | 0.683842 | 0.483953 | element_nodes.go | starcoder |
package cryptypes
import "database/sql/driver"
// EncryptedFloat64 supports encrypting Float64 data
type EncryptedFloat64 struct {
Field
Raw float64
}
// Scan converts the value from the DB into a usable EncryptedFloat64 value
func (s *EncryptedFloat64) Scan(value interface{}) error {
return decrypt(value.([]byte... | cryptypes/type_float64.go | 0.828627 | 0.639975 | type_float64.go | starcoder |
package conf
// Int64Var defines an int64 flag and environment variable with specified name, default value, and usage string.
// The argument p points to an int64 variable in which to store the value of the flag and/or environment variable.
func (c *Configurator) Int64Var(p *int64, name string, value int64, usage stri... | value_int64.go | 0.747984 | 0.668809 | value_int64.go | starcoder |
package synopsis
//SmoothedSeries compresses time series data by representing it as a sequence of averages
type SmoothedSeries struct {
length int
data []float64
caps []int
pos int
fill int
}
//NewSmoothedSeries is a constructor for SmoothedSeries
func NewSmoothedSeries(n int, capFn func(int) int) *Smoo... | kit/synopsis/smoothedseries.go | 0.726231 | 0.721755 | smoothedseries.go | starcoder |
package eoy
import (
"fmt"
"time"
)
//Month is used to provide a primary key for storing stats by month.
type Month struct {
//ID is YYYY-MM
ID string
Month int
Year int
CreatedDate *time.Time
}
//MonthResult holds a month and a stats record.
type MonthResult struct {
ID string
Mont... | pkg/month.go | 0.54819 | 0.419113 | month.go | starcoder |
package rendering
import (
"math"
. "github.com/locatw/go-ray-tracer/element"
. "github.com/locatw/go-ray-tracer/image"
. "github.com/locatw/go-ray-tracer/vector"
)
type Screen struct {
Center Vector
XAxis Vector
YAxis Vector
Resolution Resolution
Width float64
Height float64
}
func... | src/github.com/locatw/go-ray-tracer/rendering/screen.go | 0.865053 | 0.487673 | screen.go | starcoder |
package condition
import (
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/types"
)
//------------------------------------------------------------------------------
func init() {
Constructors[TypeCount] = TypeSpec{
constructor: NewCount,
descript... | lib/processor/condition/count.go | 0.67971 | 0.468791 | count.go | starcoder |
package math32
// Box3 represents a 3D bounding box defined by two points:
// the point with minimum coordinates and the point with maximum coordinates.
type Box3 struct {
Min Vector3
Max Vector3
}
// NewBox3 creates and returns a pointer to a new Box3 defined
// by its minimum and maximum coordinates.
func NewBox... | math32/box3.go | 0.961452 | 0.663369 | box3.go | starcoder |
package appoptics
import (
"fmt"
"time"
log "github.com/sirupsen/logrus"
)
// MeasurementsBatch is a collection of Measurements persisted to the API at the same time.
// It can optionally have tags that are applied to all contained Measurements.
type MeasurementsBatch struct {
// Measurements is the collection o... | measurements_batching.go | 0.720467 | 0.434401 | measurements_batching.go | starcoder |
Graphical Plots of Waveforms
Produces python code viewable using the plot.ly library.
*/
//-----------------------------------------------------------------------------
package main
import (
"fmt"
"os"
"github.com/deadsy/babi/core"
"github.com/deadsy/babi/module/dx"
"github.com/deadsy/babi/module/osc"
"gith... | cmd/plots/main.go | 0.591605 | 0.41567 | main.go | starcoder |
package cross_site_scripting
import (
"github.com/damianmcgrath/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "cross-site-scripting",
Title: "Cross-Site Scripting (XSS)",
Description: "For each web application Cross-Site Scripting (XSS) risks might arise. In terms "... | risks/built-in/cross-site-scripting/cross-site-scripting-rule.go | 0.55447 | 0.466846 | cross-site-scripting-rule.go | starcoder |
package types
import (
"encoding/hex"
"fmt"
"math/big"
"golang.org/x/crypto/sha3"
"github.com/spacemeshos/go-spacemesh/common/util"
"github.com/spacemeshos/go-spacemesh/log"
)
const (
// AddressLength is the expected length of the address.
AddressLength = 20
)
// Address represents the address of a spaceme... | common/types/address.go | 0.817829 | 0.490602 | address.go | starcoder |
package iso20022
// Completion of a securities settlement instruction, wherein securities are delivered/debited from a securities account and received/credited to the designated securities account.
type Transfer2 struct {
// Unique and unambiguous identifier for a transfer execution, as assigned by a confirming part... | Transfer2.go | 0.820613 | 0.448306 | Transfer2.go | starcoder |
package bpemodel
import (
"container/heap"
"math/rand"
)
// Symbol is an abstract reference to a sequence of characters.
type Symbol struct {
// Unique identifier, which implicitly refers to a sequence of characters.
// For example, it might be the ID of a word in a vocabulary.
ID int
// The length in bytes of... | models/bpemodel/word.go | 0.729134 | 0.400808 | word.go | starcoder |
package hook
import (
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/query"
)
// Batching is a datastore with hooks that also supports batching
type Batching struct {
ds datastore.Batching
hds *Datastore
}
// NewBatching wraps a datastore.Batching datastore and adds optional before and after hooks... | batching.go | 0.838647 | 0.444022 | batching.go | starcoder |
package constants
import (
"time"
)
const (
PhysicsFrameDuration = 20 * time.Millisecond
UpdateSendInterval = 10 * time.Millisecond
// DirtyFramesTimeout is a timeout measured in frames after which the ship is marked dirty.
DirtyFramesTimeout = 50
// BoundaryAnnulusWidth is the width of boundary region (in .... | backend/constants/constants.go | 0.673729 | 0.517449 | constants.go | starcoder |
package values
import (
"fmt"
"reflect"
"strings"
yaml "gopkg.in/yaml.v2"
)
// A Value is a Liquid runtime value.
type Value interface {
// Value retrieval
Interface() interface{}
Int() int
// Comparison
Equal(Value) bool
Less(Value) bool
Contains(Value) bool
IndexValue(Value) Value
PropertyValue(Valu... | values/value.go | 0.738952 | 0.444927 | value.go | starcoder |
package gt
import (
"database/sql/driver"
"encoding/json"
"fmt"
"time"
)
/*
Shortcut: parses successfully or panics. Should be used only in root scope. When
error handling is relevant, use `.Parse`.
*/
func ParseInterval(src string) (val Interval) {
try(val.Parse(src))
return
}
// Simplified interval construct... | gt_interval.go | 0.817756 | 0.475118 | gt_interval.go | starcoder |
package mat
import (
"fmt"
"github.com/jacsmith21/gnn/vec"
"strconv"
)
// Make initializes a matrix with i rows and j cols
func Make(i, j int) Matrix {
vecs := make([]vec.Vector, j)
for k := 0; k < j; k++ {
vecs[k] = vec.Make(i)
}
return Matrix{vecs}
}
// InitRows initializes a Matrix with given row vecto... | mat/util.go | 0.87183 | 0.660843 | util.go | starcoder |
package series
import (
"fmt"
"math"
"strings"
)
type boolElement struct {
e *bool
}
func (e boolElement) Set(value interface{}) Element {
var val bool
switch value.(type) {
case string:
if value.(string) == "NaN" {
e.e = nil
return e
}
switch strings.ToLower(value.(string)) {
case "true", "t", ... | vendor/github.com/kniren/gota/series/type-bool.go | 0.58676 | 0.488161 | type-bool.go | starcoder |
package visor
import (
"errors"
"fmt"
"github.com/samoslab/haicoin/src/coin"
"github.com/samoslab/haicoin/src/util/fee"
)
/*
verify.go: Methods for handling transaction verification
There are two levels of transaction constraint: HARD and SOFT
There are two situations in which transactions are verified:
* ... | src/visor/verify.go | 0.551332 | 0.512144 | verify.go | starcoder |
package clr
import (
"fmt"
"math"
)
// RGB Represents a point in the RGB Colorspace.
type RGB struct {
R int `json:"r"`
G int `json:"g"`
B int `json:"b"`
}
// Valid checks if the RGB instance is a valid point in the RGB ColorSpace.
func (rgb RGB) Valid() bool {
return rgb.R <= 255 && rgb.G <= 255 && rgb.B <= 2... | clr/rgb.go | 0.894507 | 0.420481 | rgb.go | starcoder |
package main
/*
Testing of semantics of length and capacity of slices and append.
# Result
-> slices are basically equivalent to ArrayList (Java). An auto-grown array
implementation (i.e., Vector in other parlance).
-> append will grow a slice if needed.
-> append adds an element at position [len(slice... | go/SliceAppend.go | 0.519278 | 0.523481 | SliceAppend.go | starcoder |
package vm
import (
"strconv"
"strings"
"time"
)
func (r *Value) EqualTo(to Value, opt CompareOption) (bool, error) {
switch to.Type {
case ValueNull:
return r.IsNil(), nil
case ValueBool:
return r.EqualToBool(to.BoolValue(), opt)
case ValueString:
return r.EqualToString(to.Str, opt)
case ValueInt64:
... | vm/equal.go | 0.57081 | 0.636353 | equal.go | starcoder |
package iso20022
// Cash movements from or to a fund as a result of investment funds transactions, eg, subscriptions or redemptions.
type FundCashForecast3 struct {
// Unique technical identifier for an instance of a fund cash forecast within a fund cash forecast report as assigned by the issuer of the report.
Iden... | FundCashForecast3.go | 0.860838 | 0.430925 | FundCashForecast3.go | starcoder |
package xsens
// DataType represents an Xsens data type.
type DataType uint16
//go:generate stringer -type DataType -trimprefix DataType
// Data group: Temperature.
const (
DataTypeTemperature DataType = 0x0810
)
// Data group: Timestamp.
const (
DataTypeUTCTime DataType = 0x1010
DataTypePacketCounter ... | datatype.go | 0.6137 | 0.862641 | datatype.go | starcoder |
package ztest
import (
"fmt"
"github.com/dollarshaveclub/node-auto-repair-operator/pkg/naro"
"github.com/montanaflynn/stats"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
const (
// The z-score values for certain percentiles.
ZScore95 = 1.6449
ZScore99 = 2.3263
)
// A FeatureExtractor extracts a si... | pkg/naro/statistics/ztest/ztest.go | 0.710929 | 0.408395 | ztest.go | starcoder |
package tx
import "math/big"
// Transaction struct
type Transaction struct {
id []byte // A SHA2-256 hash of the signature
lastTx string // The ID of the last transaction made from the account. If no previous transactions have been made from the address this field is set to an empty string.
owner ... | tx/types.go | 0.741019 | 0.535584 | types.go | starcoder |
package parametric2d
import (
"fmt"
"sort"
"github.com/gmlewis/go-poly2tri"
"github.com/gmlewis/go3d/float64/vec2"
"github.com/gmlewis/go3d/float64/vec3"
)
// Path represents a 2D collection of SubPaths.
type Path struct {
SubPaths []*SubPath
}
// BBox returns the minimum bounding box of the Path.
func (p *Pa... | path.go | 0.763572 | 0.411939 | path.go | starcoder |
package githubissue
import (
"entgo.io/ent/dialect/gremlin/graph/dsl"
"entgo.io/ent/dialect/gremlin/graph/dsl/__"
"entgo.io/ent/dialect/gremlin/graph/dsl/p"
"github.com/giantswarm/graph/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id string) predicate.GitHubIssue {
return predicate.G... | ent/githubissue/where.go | 0.549761 | 0.419826 | where.go | starcoder |
package godash
import (
"errors"
"reflect"
)
// Intersection creates a slice of unique values that were present in both of the provided slices.
// The order of the items in the resulting slice is determined by the first given slice.
// The new slice is returned as an interface{} and may need to have a type assertio... | intersection.go | 0.756807 | 0.49762 | intersection.go | starcoder |
package raster
import (
"image"
"image/color"
"unsafe"
)
const (
SUBPIXEL_SHIFT = 5
SUBPIXEL_COUNT = 1 << SUBPIXEL_SHIFT
)
var SUBPIXEL_OFFSETS = SUBPIXEL_OFFSETS_SAMPLE_32_FIXED
type SUBPIXEL_DATA uint32
type NON_ZERO_MASK_DATA_UNIT uint8
type Rasterizer8BitsSample struct {
MaskBuffer []SUBPIXEL_DATA
Wi... | draw2d/raster/fillerV2/fillerAA.go | 0.564699 | 0.422624 | fillerAA.go | starcoder |
package nett
import (
"math"
"math/rand"
"strconv"
"strings"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
type Matrix [][]float64
func NewMatrix(r, c int) Matrix {
m := make([][]float64, r)
for i := range m {
m[i] = make([]float64, c)
}
return m
}
func NewMatrixFromSlice(s []float64) Matri... | matrix.go | 0.741768 | 0.617484 | matrix.go | starcoder |
package naturel
import (
"image"
"image/color"
_ "image/gif"
_ "image/jpeg"
"image/png"
"os"
)
// Based on code from https://golang.org/pkg/image for reading
// image pixels and code from a pornscanner withen in python using
// the Python Image Library (PIL)
// Checks given file name for the skin ratio in the ... | naturel.go | 0.707506 | 0.428712 | naturel.go | starcoder |
package cbor
import (
// "bufio"
"bytes"
"encoding/binary"
"fmt"
"io"
"reflect"
"strings"
)
type reader interface {
io.ByteReader
io.Reader
}
func Unmarshal(bs []byte, v interface{}) error {
r := bytes.NewReader(bs)
return unmarshal(r, reflect.ValueOf(v).Elem())
}
func unmarshal(r reader, v reflect.Value... | unmarshal.go | 0.529507 | 0.425367 | unmarshal.go | starcoder |
package models
import "fmt"
// BoardWidth in cells
const BoardWidth = 16
// BoardHeight in cells
const BoardHeight = 16
// Grid is a two-dimensional array of bytes, representing the Grid state
// The lower left corner has coordinates 0, 0
type Grid [BoardWidth][BoardHeight]Cell
// Board rerpesents a game board:
//... | models/board.go | 0.709824 | 0.539772 | board.go | starcoder |
package stripe
import "encoding/json"
// RecipientTransferDestinationType consts represent valid recipient_transfer destinations.
type RecipientTransferDestinationType string
// RecipientTransferFailCode is the list of allowed values for the recipient_transfer's failure code.
// Allowed values are "insufficient_fund... | recipienttransfer.go | 0.6488 | 0.460713 | recipienttransfer.go | starcoder |
package array
import (
"sort"
)
// Equal checks whether two slices a and b are identical (true) or not (false)
// If importing external library is allowed, use cmp.Equal instead
func Equal(a, b []int) bool {
if len(a) != len(b) {
return false
}
for i, v := range a {
if v != b[i] {
return false
}
}
retu... | datastructures/array/array.go | 0.675978 | 0.488405 | array.go | starcoder |
package hll
import (
"math/bits"
"sort"
)
const RHOW_BITS = 6
const RHOW_MASK = uint64(1<<RHOW_BITS) - 1
func encode(sparseIndex uint32, sparseRhoW uint8, p, pPrime uint) uint32 {
mask := (uint32(1) << (pPrime - p)) - 1
if (sparseIndex & mask) != 0 {
return sparseIndex
}
var rhoEncodedFlag uint32
if pPrime... | sparseutil.go | 0.61659 | 0.412885 | sparseutil.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.