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 ecs
import (
"fmt"
"strings"
)
// IntegerDiff represents a difference on an integer value
type IntegerDiff struct {
was *int64
isNow *int64
}
// StringDiff represents a difference on an integer value
type StringDiff struct {
was *string
isNow *string
}
// ContainerConfigDiff all the changes in a t... | ecs/diff.go | 0.615435 | 0.425844 | diff.go | starcoder |
package core
const Usage = `Usage of ssc:
Standard:
commit [flags] (argument) [options] Create a commit
log [flags] (argument) List recent commits
init Initilize a repository
revert [flags] (argument) Revert repository to previous commit
config [flags] (argument) Handle the ssc configuration file
Inner:
cat-fil... | core/usage.go | 0.670608 | 0.442215 | usage.go | starcoder |
package main
import (
_ "embed"
"fmt"
"math"
sh "github.com/leonhfr/aoc/shared"
)
var ta = targetArea{124, 174, -123, -86}
func main() {
maxh, lowestX, highestX := part1()
fmt.Printf("Part 1: %v\n", maxh)
fmt.Printf("Part 2: %v\n", part2(lowestX, highestX))
}
type targetArea struct {
xmin, xmax, ymin, ymax... | 2021/17/main.go | 0.691914 | 0.481698 | main.go | starcoder |
package dockerfile
import (
"errors"
"fmt"
"unicode"
)
var (
errMissingSeparator = errors.New("missing separator")
errMissingValue = errors.New("missing value")
)
// parseKeyVals parses a whitespace-delimited string consisting of <key>=<value>
// pairs into a map. Both keys and values may optionally contai... | lib/parser/dockerfile/parse_key_values.go | 0.631481 | 0.400808 | parse_key_values.go | starcoder |
package glmki3d
import (
"github.com/go-gl/gl/v3.3-core/gl"
// "github.com/go-gl/mathgl/mgl32"
"github.com/mki1967/go-mki3d/mki3d"
)
// references to the objects defining the shape and parameters of mki3d object
// GLBufTr contains references to GL triangle buffers for triangle shader's input attributes
type GLBu... | glmki3d/gl-data.go | 0.64512 | 0.454896 | gl-data.go | starcoder |
package p5
import (
"math"
"gioui.org/f32"
"gioui.org/op/clip"
"gioui.org/op/paint"
)
// Ellipse draws an ellipse at (x,y) with the provided width and height.
func (p *Proc) Ellipse(x, y, w, h float64) {
if !p.doFill() && !p.doStroke() {
return
}
w *= 0.5
h *= 0.5
var (
ec float64
f1 f32.Point
f2... | shapes.go | 0.755907 | 0.492005 | shapes.go | starcoder |
package vec
import (
"github.com/chewxy/math32"
"github.com/itohio/EasyRobot/pkg/core/math"
)
type Vector2D [2]float32
func (v *Vector2D) Sum() float32 {
var sum float32
for _, val := range v {
sum += val
}
return sum
}
func (v *Vector2D) Vector() Vector {
return v[:]
}
func (v *Vector2D) Slice(start, en... | pkg/core/math/vec/vec2d.go | 0.77569 | 0.597725 | vec2d.go | starcoder |
package main
import (
twodee "../libs/twodee"
"math"
"time"
)
const (
// 6.67e-11 m^3kg^-1s^-2
GravitationalConst = 6.67e-11
// Play GC in m^3kg^-1ms^-2
GravConst = 5e-8
BoundsBuffer = 10.0
)
type Simulation struct {
Sun *PlanetaryBody
Planets []*PlanetaryBody
AggregatePopul... | src/simulation.go | 0.584627 | 0.504578 | simulation.go | starcoder |
package kernel
import (
"fmt"
"image"
"image/color"
)
// Kernel describes an image kernel
type Kernel struct {
Width int
Height int
Coefficients [][]float32
}
type neighbour struct {
xOffset int
yOffset int
clr color.Color
}
// New returns a Kernel wrapping the given coefficients matrix
fu... | kernel/kernel.go | 0.848471 | 0.40342 | kernel.go | starcoder |
package sqltypes
import (
"log"
"strconv"
"strings"
)
// Explain wraps the explain query results for a given table
type Explain struct {
Field *string
Type *string
Null *string
Key *string
Default *string
Extra *string
}
// SQLType unwraps a SQL data type
type SQLType struct {
notNull string... | sqltypes/sqltypes.go | 0.557604 | 0.482917 | sqltypes.go | starcoder |
package s2e2
import (
"fmt"
"github.com/mzinin/s2e2.go/pkg/s2e2/functions"
"github.com/mzinin/s2e2.go/pkg/s2e2/operators"
)
const (
// Null value in an input expression.
nullValue = "NULL"
// Expected stack size after processing all tokens.
finalStackSize = 1
)
// Evaluator evaluates string value of an expre... | pkg/s2e2/evaluator.go | 0.666931 | 0.452113 | evaluator.go | starcoder |
package geo
import (
"bytes"
"io"
"math"
"strconv"
"strings"
)
const EARTH_RADIUS = 6371008.8 // m
var DEGREES_TO_RADIANS = math.Pi / 180.0
var RADIANS_TO_DEGREES = 180.0 / math.Pi
// LatLng represents a 'latitude,longitude' pair.
type LatLng struct {
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
}
// La... | geo.go | 0.794744 | 0.48987 | geo.go | starcoder |
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"math/big"
"strconv"
"strings"
)
type frac struct {
n, d big.Int
}
func (f1 frac) sum(f2 frac) frac {
var newN1, newN2, newD, newN big.Int
newN1.Mul(&f1.n, &f2.d)
newN2.Mul(&f1.d, &f2.n)
newD.Mul(&f1.d, &f2.d)
newN.Add(&newN1, &newN2)
f := frac{n: ... | main.go | 0.562657 | 0.414425 | main.go | starcoder |
package engine
import (
"math/rand"
)
// generateLab generates a new, random labyrinth.
// lab must have odd number of rows and columns.
func generateLab(lab [][]Block) {
rows, cols := len(lab), len(lab[0])
// Create a "frame":
for row := range lab {
lab[row][0] = BlockWall
lab[row][cols-1] = BlockWall
}
f... | engine/gen-lab.go | 0.675336 | 0.525734 | gen-lab.go | starcoder |
package langs
const javaAnnotationPackage = "@LudwiegPackage(id = {{.id}})"
const javaAnnotationStruct = "@Serializable"
const javaFieldAnnotationNative = "@LudwiegField(index = {{.index}}, protocolType = ProtocolType.{{.type}})"
const javaFieldAnnotationNativeArray = "@LudwiegField(index = {{.index}}, protocolType =... | langs/java_structures.go | 0.807233 | 0.416203 | java_structures.go | starcoder |
package main
import (
"fmt"
"sync"
)
/*
Suppose we have a class:
public class Foo {
public void first() { print("first"); }
public void second() { print("second"); }
public void third() { print("third"); }
}
The same instance of Foo will be passed to three different threads.
Thread A will call first(), thre... | Concurrency/PrintOrder/main.go | 0.509764 | 0.436922 | main.go | starcoder |
package rdate
import "time"
type PeriodRule interface {
Calculate(pivot time.Time, tf TimeFactory) (from, to Time)
Shortcut() PeriodShortcut
}
type periodRuleThisDay struct{}
func (p *periodRuleThisDay) Calculate(pivot time.Time, tf TimeFactory) (from, to Time) {
return tf.Require(pivot, TimeStartOfThisDay),
... | period_rule.go | 0.837188 | 0.589126 | period_rule.go | starcoder |
package compare
import (
"encoding/json"
"reflect"
)
// Equal comparer
type Equal struct{}
// Greater comparer
type Greater struct {
Equal bool `json:"equal"`
}
// Lesser Comparer
type Lesser struct {
Equal bool `json:"equal"`
}
// Compare equal imp
func (e *Equal) Compare(a, b interface{}) bool {
return refl... | compare/comparators.go | 0.654232 | 0.413536 | comparators.go | starcoder |
package data
import "bytes"
// Vector is a fixed-length array of Values
type Vector []Value
// EmptyVector represents an empty Vector
var EmptyVector = Vector{}
// NewVector creates a new Vector instance
func NewVector(v ...Value) Vector {
return v
}
// Count returns the number of elements in the Vector
func (v V... | data/vector.go | 0.850469 | 0.74674 | vector.go | starcoder |
package main
import "fmt"
// Node holds a Value of type int as well as a pointer to the node in
// front (Next) and a pointer to the node behind (Previous) it. These
// two pointers are the foundation of a doubly linked list.
type Node struct {
Value int
Next, Previous *Node
}
// DoublyLinkedList holds on... | data_structures/linked_list/go/DoublyLinkedList.go | 0.65202 | 0.575648 | DoublyLinkedList.go | starcoder |
package date
import "fmt"
import "time"
const dateNoTimeFormat = "2006.01.02"
var localTimeLocation *time.Location
func init() {
// time.LoadLocation costs ~1ms, so do it just once and cache in a global
localTimeLocation,_ = time.LoadLocation("America/Los_Angeles")
}
// All these FooPdt functions should be renam... | date/date.go | 0.725649 | 0.420005 | date.go | starcoder |
package datastructures
type BinaryTree interface {
GetTreeNodeValue() interface{}
// []TreeNode slice is a pointer to the underlying array, so we don't have
// to return a reference to the slice itself
GetTreeChildren() []*BinaryTree
GetLeftChild() *BinaryTree
GetRightChild() *BinaryTree
Se... | golang/datastructures/trees.go | 0.766119 | 0.421909 | trees.go | starcoder |
package geo
import(
"fmt"
)
const (
kKmPerLatitudeDegreeAtSFO = 111.2 // (36,-122)->(37,-122) == 111 KM (heading north)
kKmPerLongitudeDegreeAtSFO = 88.08 // (36,-122)->(36,-121) == 88 KM (heading east)
)
type LatlongBox struct {
SW, NE Latlong
Floor, Ceil int64 // altitude, feet; zero means "don'... | latlongbox.go | 0.737158 | 0.411022 | latlongbox.go | starcoder |
package object
// StandardPropertiesTable returns a properties table based on the standard
// configuration of the existing objprop.dat file.
func StandardPropertiesTable() PropertiesTable {
return NewPropertiesTable(StandardDescriptors())
}
// StandardDescriptors returns an array of class descriptors that represent... | ss1/content/object/Standards.go | 0.769946 | 0.621914 | Standards.go | starcoder |
package mporous
// State holds state variables for porous media with liquid and gas
// References:
// [1] Pedroso DM (2015) A consistent u-p formulation for porous media with hysteresis.
// Int Journal for Numerical Methods in Engineering, 101(8) 606-634
// http://dx.doi.org/10.1002/nme.4808
// [2] P... | mporous/states.go | 0.646349 | 0.436382 | states.go | starcoder |
package network
import (
"github.com/bigpicturelabs/consensusPBFT/pbft/consensus"
"fmt"
)
const periodCheckPoint = 5
func (node *Node) GetCheckPoint(CheckPointMsg *consensus.CheckPointMsg) error {
LogMsg(CheckPointMsg)
node.CheckPoint(CheckPointMsg)
return nil
}
func (node *Node) createCheckPointMsg(sequenceI... | pbft/network/checkpoint.go | 0.634883 | 0.406332 | checkpoint.go | starcoder |
package settings
var Dance *dance = initDance()
func initDance() *dance {
return &dance{
Movers: []string{"spline"},
Spinners: []string{"circle"},
DoSpinnersTogether: true,
SpinnerRadius: 100,
Battle: false,
SliderDance: false,
RandomSliderDance: false,
... | app/settings/dance.go | 0.536799 | 0.428233 | dance.go | starcoder |
package curve
import (
"errors"
"fmt"
"math/big"
GF "github.com/armfazh/tozan-ecc/field"
)
// mtCurve is a Montgomery curve
type mtCurve struct{ *params }
type M = *mtCurve
func (e *mtCurve) String() string { return "By^2=x^3+Ax^2+x\n" + e.params.String() }
func (e *mtCurve) New() EllCurve {
if e.IsValid() {
... | curve/montgomery.go | 0.706899 | 0.464962 | montgomery.go | starcoder |
package model
import "math"
// Model structure export
type Model struct {
Matrix Matrix `json:"matrix"`
Count uint32 `json:"count"`
DataPointCount uint32 `json:"dataPointCount"`
}
// Data export
var Data Model
func min(a, b uint32) uint32 {
if a < b {
return a
}
return b
}
// Initialize th... | projects/expa/src/tierb/application/model/data.go | 0.776284 | 0.798776 | data.go | starcoder |
package main
import (
"math"
)
func applyColorMapping(src *FloatImage, fn func(r, g, b, a float64) (outr, outg, outb, outa float64)) *FloatImage {
width := src.width
height := src.height
dst := MakeFloatImage(width, height)
parallel(height, func(partStart, partEnd int) {
for y := partStart; y < partEnd; y++ {... | perdiff/go/perdiff/adjust_image.go | 0.683736 | 0.410106 | adjust_image.go | starcoder |
package timerange
import (
"errors"
"strings"
"time"
)
type TimeRange struct {
start time.Time
end time.Time
}
// Create a new TimeRange by immediately parsing the incoming string
func NewTimeRange(inputTimeRange string) (*TimeRange, error) {
value := TimeRange{}
err := value.Parse(inputTimeRange)
if err !... | timerange/timerange.go | 0.654674 | 0.45744 | timerange.go | starcoder |
package hit
import (
"bytes"
"fmt"
"golang.org/x/xerrors"
"github.com/Eun/go-hit/errortrace"
)
// StepTime defines when a step should be run.
type StepTime uint8
const (
// combineStep is a special step that runs before everything else and is used exclusively for the function
// CombineSteps().
combineStep ... | step.go | 0.566738 | 0.457076 | step.go | starcoder |
package plot
import (
"math"
"sort"
)
// Percentiles implements drawing percentile line.
type Percentiles struct {
Style
Label string
Data []Point
}
// NewPercentiles creates percentiles from values.
func NewPercentiles(label string, values []float64) *Percentiles {
values = append(values[:0:0], values...)
s... | percentiles.go | 0.882523 | 0.543409 | percentiles.go | starcoder |
package graph
import (
"github.com/hardikbagdi/algorithms/data/linear"
"errors"
"log"
)
// Graph represents an undirected graph
type Graph struct {
v, e int
adjList []*linear.List
}
// New returns a new undirected Graph
func New(nodes int) *Graph {
g := new(Graph)
g.adjList = make([]*linear.List, nodes)
... | data/graph/graph.go | 0.672654 | 0.446917 | graph.go | starcoder |
package traffic
import (
"encoding/json"
"time"
"github.com/selectel/go-selvpcclient/selvpcclient"
)
// Traffic contains information about used and paid traffic.
type Traffic struct {
// Type is a human-readable name of the type of traffic.
Type string `json:"-"`
// TrafficData contains information about traf... | selvpcclient/resell/v2/traffic/schemas.go | 0.715424 | 0.467818 | schemas.go | starcoder |
package manip
import (
"regexp"
)
type RegexpSet struct {
resSet Set
}
func (r *RegexpSet) Res() Set {
return r.resSet
}
func NewRegexpSet(values []*regexp.Regexp) (result *RegexpSet) {
res := make([]interface{}, len(values))
for i := range values {
res[i] = values[i]
}
return &RegexpSet{NewBasicSet(res)}
... | pkg/manip/regexp_set.go | 0.567937 | 0.409398 | regexp_set.go | starcoder |
package mathf
import (
"fmt"
"math"
)
// Vec3 is a 3-dimensional vector
type Vec3 struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Z float64 `json:"z"`
}
// NewVec3 create a vector with theiven values
func NewVec3(x float64, y float64, z float64) *Vec3 {
return &Vec3{
X: x,
Y: y,
Z: z,
}
}
// NewZero... | server/mathf/vec3.go | 0.90633 | 0.681985 | vec3.go | starcoder |
package price
import (
"errors"
"fmt"
"math"
"math/big"
"strconv"
"github.com/kinecosystem/go/xdr"
)
// Parse calculates and returns the best rational approximation of the given
// real number price while still keeping both the numerator and the denominator
// of the resulting value within the precision limit... | price/main.go | 0.782538 | 0.529811 | main.go | starcoder |
package utils
import (
"reflect"
)
var __valueType = reflect.TypeOf((*reflect.Value)(nil)).Elem()
// reflect.Type -> reflect.Type
// reflect.Value -> reflect.Type
// (*int)(nil) -> reflect.Value get int type, must be a pointer
// convert the reflect.Type type
func TypeOf(v interface{}) (t reflect.Type) {
switch r... | utils/reflect.go | 0.618665 | 0.432543 | reflect.go | starcoder |
package kol
type Iterable[E comparable] interface {
// All returns `true` if all elements match the given predicate.
All(predicate func(element E) bool) bool
// Any returns `true` if collection has at least one element matched the given predicate.
Any(predicate func(element E) bool) bool
// Contains returns `true... | iterable.go | 0.819821 | 0.592107 | iterable.go | starcoder |
package unary
import (
"github.com/matrixorigin/matrixone/pkg/container/nulls"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/vectorize/space"
"github.com/matrixorigin/matrixone/pkg/vm/process"
"golang.org/x... | pkg/sql/plan2/function/builtin/unary/space.go | 0.505859 | 0.661574 | space.go | starcoder |
package v1
import (
"math/big"
inf "gopkg.in/inf.v0"
)
const (
// maxInt64Factors is the highest value that will be checked when removing factors of 10 from an int64.
// It is also the maximum decimal digits that can be represented with an int64.
maxInt64Factors = 18
)
var (
// Commonly needed big.Int values-... | types/v1/math.go | 0.671794 | 0.436502 | math.go | starcoder |
package pgsql
import (
"database/sql"
"database/sql/driver"
"strconv"
)
// Float8ArrayFromFloat32Slice returns a driver.Valuer that produces a PostgreSQL float8[] from the given Go []float32.
func Float8ArrayFromFloat32Slice(val []float32) driver.Valuer {
return float8ArrayFromFloat32Slice{val: val}
}
// Float8A... | pgsql/float8arr.go | 0.783368 | 0.440469 | float8arr.go | starcoder |
package geom
import (
"fmt"
)
type doublyConnectedEdgeList struct {
faces []*faceRecord // only populated in the overlay
halfEdges []*halfEdgeRecord
vertices map[XY]*vertexRecord
}
type faceRecord struct {
cycle *halfEdgeRecord
labels [2]label
extracted bool
}
func (f *faceRecord) String() string... | geom/dcel.go | 0.643889 | 0.498413 | dcel.go | starcoder |
package iso20022
// Choice of formats for the identification of a financial instrument.
type SecurityIdentification25Choice struct {
// International Securities Identification Number (ISIN). A numbering system designed by the United Nation's International Organisation for Standardisation (ISO). The ISIN is composed ... | SecurityIdentification25Choice.go | 0.737725 | 0.670585 | SecurityIdentification25Choice.go | starcoder |
package main
import (
"fmt"
"math/rand"
)
const (
win = 100
gamesPerSeries = 10
)
// A general feature of the functional approach to programming is a global state
// object which gets passed arround from function to function. This makes things
// so much easier to reason about, given that there are no hidden sta... | go/golang.org/pig/pig.go | 0.692226 | 0.4917 | pig.go | starcoder |
package tensorflow
import "sqlflow.org/sqlflow/go/ir"
type evaluateFiller struct {
DataSource string
Select string
ResultTable string
// below members come from trainStmt
Estimator string
FieldDescs map[string][]*ir.FieldDesc
FeatureColumnCode string
Y *ir.FieldDesc
Mode... | go/codegen/tensorflow/template_evaluate.go | 0.578091 | 0.414958 | template_evaluate.go | starcoder |
package faker
import (
"reflect"
"strconv"
)
// Struct is a faker struct for Struct
type Struct struct {
Faker *Faker
}
// Fill elements of a struct with random data
func (s Struct) Fill(v interface{}) {
s.r(reflect.TypeOf(v), reflect.ValueOf(v), "", 0)
}
func (s Struct) r(t reflect.Type, v reflect.Value, funct... | struct.go | 0.540924 | 0.532121 | struct.go | starcoder |
package lzfse
import (
"bytes"
"encoding/binary"
"io"
)
type lzvnDecoder struct {
r io.Reader
w *cachedWriter
buffer *bytes.Buffer
header struct {
N_raw_bytes uint32
N_payload_bytes uint32
}
}
// at the beginning of each lzvn block
func newLzvnDecoder(r io.Reader, w *cachedWriter) (*lzvnDe... | lzvn.go | 0.605099 | 0.454412 | lzvn.go | starcoder |
package should
import smarty "github.com/smartystreets/assertions"
var (
// AlmostEqual is imported from smartystreets/assertions. See https://gowalker.org/github.com/smartystreets/assertions
AlmostEqual = smarty.ShouldAlmostEqual
// BeBetween is imported from smartystreets/assertions. See https://gowalker.org/git... | should/smartystreets.go | 0.816113 | 0.826642 | smartystreets.go | starcoder |
package calendar
import (
"container/list"
"github.com/6tail/lunar-go/SolarUtil"
"math"
"strconv"
"time"
)
type SolarWeek struct {
year int
month int
day int
start int
}
func NewSolarWeek(start int) *SolarWeek {
return NewSolarWeekFromDate(time.Now(), start)
}
func NewSolarWeekFromYmd(year int, month i... | calendar/SolarWeek.go | 0.651133 | 0.424591 | SolarWeek.go | starcoder |
package valprotocol
import (
"fmt"
"math/big"
"math/rand"
"github.com/offchainlabs/arbitrum/packages/arb-util/common"
"github.com/offchainlabs/arbitrum/packages/arb-util/hashing"
"github.com/offchainlabs/arbitrum/packages/arb-util/protocol"
)
type ChildType uint
const (
InvalidInboxTopChildType ChildType = ... | packages/arb-validator-core/valprotocol/nodeData.go | 0.662141 | 0.424949 | nodeData.go | starcoder |
package itype
import (
"math"
)
// Vec2i is a two-element int vector
type Vec2i [2]int
func (v Vec2i) ToFloat32() Vec2f { return Vec2f{float32(v[0]), float32(v[1])} }
func (v Vec2i) Add(add Vec2i) Vec2i { return Vec2i{v[0] + add[0], v[1] + add[1]} }
func (v Vec2i) MultiplyInt(mult int) Vec2i { return Vec2i{... | itype/vec.go | 0.829975 | 0.617123 | vec.go | starcoder |
package plot
import (
"encoding/json"
"fmt"
"math"
"sort"
"time"
)
// Plot represents a graph plot.
type Plot struct {
Time time.Time `json:"time"`
Value Value `json:"value"`
}
// MarshalJSON handles JSON marshalling of the Plot type.
func (plot Plot) MarshalJSON() ([]byte, error) {
return json.Marshal(... | pkg/plot/plot.go | 0.888572 | 0.466056 | plot.go | starcoder |
package solver
import (
"errors"
"github.com/yourbasic/graph"
)
// Params:
// from: string, the word to start from. Needs to have the same length as to
// to: string, the word to get to. Needs to have the same length as from
// wordsList: []string, a list of string that can be used as steps to get to 'to' from ... | solver.go | 0.539469 | 0.401834 | solver.go | starcoder |
package dns
/**
* Configuration for DNS parameter resource.
*/
type Dnsparameter struct {
/**
* Maximum number of retry attempts when no response is received for a query sent to a name server. Applies to end resolver and forwarder configurations.
*/
Retries int `json:"retries,omitempty"`
/**
* Minimum permissibl... | resource/config/dns/dnsparameter.go | 0.841533 | 0.448849 | dnsparameter.go | starcoder |
package oak
import (
"image"
"sync"
"github.com/oakmound/oak/v2/dlog"
"github.com/oakmound/oak/v2/event"
"github.com/oakmound/oak/v2/physics"
)
var (
// ViewPos represents the point in the world which the viewport is anchored at.
ViewPos = image.Point{}
// ViewPosMutex is used to grant extra saftey in viewpo... | viewport.go | 0.607896 | 0.458955 | viewport.go | starcoder |
package window
type entry struct {
value float64
index int
}
// Max is a circular buffer which keeps track of the maximum value observed in a particular time.
// Based on the "ascending minima algorithm" (http://web.archive.org/web/20120805114719/http://home.tiac.net/~cri/2001/slidingmin.html).
type Max struct {
m... | max.go | 0.839438 | 0.534612 | max.go | starcoder |
package main
import (
"github.com/otyg/threagile/model"
"github.com/otyg/threagile/model/confidentiality"
"github.com/otyg/threagile/model/criticality"
)
type unguardedDirectDatastoreAccess string
var RiskRule unguardedDirectDatastoreAccess
func (r unguardedDirectDatastoreAccess) Category() model.RiskCategory {
... | risks/unguarded-direct-datastore-access/unguarded-direct-datastore-access-rule.go | 0.590897 | 0.401746 | unguarded-direct-datastore-access-rule.go | starcoder |
// Package cryptofmt provides constants and convenience methods that define the
// format of ciphertexts and signatures.
package cryptofmt
import (
"encoding/binary"
"fmt"
tinkpb "github.com/google/tink/go/proto/tink_go_proto"
)
const (
// NonRawPrefixSize is the prefix size of Tink and Legacy key types.
NonRa... | go/core/cryptofmt/cryptofmt.go | 0.690142 | 0.461927 | cryptofmt.go | starcoder |
package ascii
import (
"fmt"
"github.com/chr-ras/advent-of-code-2019/util/geometry"
"github.com/chr-ras/advent-of-code-2019/util/intcode"
q "github.com/enriquebris/goconcurrentqueue"
)
// Calibrate runs the ASCII program and returns the sum of the alignment parameters.
func Calibrate(program []int64) int {
fin... | 17-set-and-forget/ascii/ascii.go | 0.748536 | 0.50653 | ascii.go | starcoder |
package sort
// merge function for MergeSort
func merge(data []int, low int, mid int, high int) {
aux := make([]int, high-low+1)
i := low
j := mid + 1
k := 0
for i <= mid && j <= high {
if data[i] < data[j] {
aux[k] = data[i]
i++
} else {
aux[k] = data[j]
j++
}
k++
}
for i <= mid {
aux[k... | Go/sort/merge.go | 0.658308 | 0.566918 | merge.go | starcoder |
package rfc5090
import (
"layeh.com/radius"
)
const (
DigestResponse_Type radius.Type = 103
DigestRealm_Type radius.Type = 104
DigestNonce_Type radius.Type = 105
DigestResponseAuth_Type radius.Type = 106
DigestNextnonce_Type radius.Type = 107
DigestMethod_Type radius.Typ... | rfc5090/generated.go | 0.579757 | 0.53959 | generated.go | starcoder |
package cmd
import (
"encoding/json"
"errors"
"strconv"
vaultapi "github.com/hashicorp/vault/api"
vault "github.com/innovia/secrets-consumer-env/pkg/vault"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// secretConfigs in JSON strings format
var (
secretConfigs []string
kubernetesBackend ... | cmd/vault.go | 0.693784 | 0.485051 | vault.go | starcoder |
package foaf
import "github.com/cayleygraph/quad/voc"
func init() {
voc.RegisterPrefix(Prefix, NS)
}
const (
NS = `http://xmlns.com/foaf/0.1/#`
Prefix = `foaf:`
)
const (
// Core
// An agent (eg. person, group, software or physical artifact).
Agent = Prefix + `Agent`
// A person.
Person =... | kbase/voc/foaf/foaf.go | 0.603348 | 0.421433 | foaf.go | starcoder |
package gs
import (
"fmt"
"reflect"
"github.com/dairaga/gs/funcs"
)
// Option is simplified Scala Option. Option like Either is either Some or None.
// Some means this is defined and has a value; None means Nothing or Nil.
// Suggest to return Option from function or method instead of nil.
type Option[T any] int... | option.go | 0.726717 | 0.431824 | option.go | starcoder |
package isodates
import (
"errors"
"fmt"
"strconv"
"time"
)
// ZeroMonth is our 'no value' month that we return when the operation fails.
const ZeroMonth = time.Month(0)
// ZeroTime is our 'no value' time that we return when the operation fails.
var ZeroTime = time.Time{}
// Midnight creates a date/time instanc... | core.go | 0.784526 | 0.407157 | core.go | starcoder |
package integration
import (
"testing"
"github.com/CyCoreSystems/ari"
"github.com/CyCoreSystems/ari/client/arimocks"
"github.com/pkg/errors"
)
func TestAsteriskInfo(t *testing.T, s Server) {
runTest("noFilter", t, s, func(t *testing.T, m *mock, cl ari.Client) {
var ai ari.AsteriskInfo
ai.SystemInfo.EntityI... | internal/integration/asterisk.go | 0.520253 | 0.444565 | asterisk.go | starcoder |
package main
import (
"fmt"
"strconv"
"strings"
"github.com/joaocarmo/advent-of-code/helpers"
)
// getCommandAndDisplacement returns the command and displacement from a well
// formed string.
func getCommandAndDisplacement(line string) (string, int) {
// get the command
command := ""
displacement := 0
// sp... | 2021/02/main.go | 0.780997 | 0.46557 | main.go | starcoder |
package gotodo
// ByCreatedDate provides sorting by Todo.CreationDate
type ByCreatedDate TodoList
// Len returns length of the slice
func (s ByCreatedDate) Len() int {
return len(s)
}
// Swap inverts positions of two elements
func (s ByCreatedDate) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
// Less compares two e... | internal/gotodo/sorting.go | 0.63861 | 0.493775 | sorting.go | starcoder |
package go_kafka_client
import (
"crypto/md5"
"encoding/hex"
"fmt"
"io"
"math"
"reflect"
"sort"
"strconv"
"strings"
)
const (
/* Range partitioning works on a per-topic basis. For each topic, we lay out the available partitions in numeric order
and the consumer threads in lexicographic order. We then divid... | partition_assignment.go | 0.590071 | 0.470068 | partition_assignment.go | starcoder |
package roaring
import (
"fmt"
"sort"
"github.com/mschoch/smat"
"github.com/willf/bitset"
)
// fuzz test using state machine driven by byte stream.
func Fuzz(data []byte) int {
return smat.Fuzz(&smatContext{}, smat.ActionID('S'), smat.ActionID('T'),
smatActionMap, data)
}
var smatDebug = false
func smatLog(... | vendor/github.com/RoaringBitmap/roaring/smat.go | 0.526343 | 0.431405 | smat.go | starcoder |
package jaeger
import (
"fmt"
"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/thrift-gen/jaeger"
)
// FromDomain takes an arrya of model.Span and returns
// an array of jaeger.Span. If errors are found during
// conversion of tags, then error tags are appended.
func FromDomain(spans []*... | model/converter/thrift/jaeger/from_domain.go | 0.624294 | 0.503662 | from_domain.go | starcoder |
package graphics
import (
"sync"
)
const (
ShaderImageNum = 4
// PreservedUniformVariablesNum represents the number of preserved uniform variables.
// Any shaders in Ebiten must have these uniform variables.
PreservedUniformVariablesNum = 1 + // the destination texture size
1 + // the texture sizes array
1... | vendor/github.com/hajimehoshi/ebiten/v2/internal/graphics/vertex.go | 0.607896 | 0.599778 | vertex.go | starcoder |
package storage
import "github.com/nspcc-dev/neo-go/pkg/interop/iterator"
// Context represents storage context that is mandatory for Put/Get/Delete
// operations. It's an opaque type that can only be created properly by
// GetContext, GetReadOnlyContext or ConvertContextToReadOnly. It's similar
// to Neo .net framew... | pkg/interop/storage/storage.go | 0.809201 | 0.418281 | storage.go | starcoder |
package cp
import "math"
type PolyShape struct {
*Shape
r float64
count int
// The untransformed planes are appended at the end of the transformed planes.
planes []SplittingPlane
}
func (poly PolyShape) Count() int {
return poly.count
}
func (poly PolyShape) Vert(i int) Vector {
assert(i >= 0 && i < poly.... | poly.go | 0.814496 | 0.698275 | poly.go | starcoder |
package barcode
//ReaderParams - Represents BarcodeReader object.
type ReaderParams struct {
// The type of barcode to read.
Type DecodeBarcodeType `json:"Type,omitempty"`
// Enable checksum validation during recognition for 1D barcodes. Default is treated as Yes for symbologies which must contain checksum, as No w... | barcode/model_reader_params.go | 0.843477 | 0.447158 | model_reader_params.go | starcoder |
package main
import (
"errors"
"fmt"
"reflect"
"github.com/fatih/structs"
)
// Function pluck is used to retrieve an array of subset of fields(branch) present in original structure(plant).
// Input : 'plant' is the source from which a branch needs to be plucked. An array of structure ... | pluck.go | 0.755997 | 0.548553 | pluck.go | starcoder |
package svg
import (
"fmt"
"io"
"math"
)
type Plotter interface {
Surface(io.Writer, func(x, y float64) float64)
}
const (
width, height = 600, 320 // canvas size in pixels
cells = 100 // number of grid cells
xyrange = 33 // axis ranges (-xyrange..+xyrange)
//xyscale = width / ... | ex_07.16-Expr_web_calculator/svg/surface.go | 0.719482 | 0.484441 | surface.go | starcoder |
package detectlicense
import (
"regexp"
)
var reCcBySa40 = regexp.MustCompile(`\s*` + reWrap(reQuote(``+
`Attribution-ShareAlike 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal ... | vendor/github.com/datawire/go-mkopensource/pkg/detectlicense/license_cc.go | 0.727975 | 0.532425 | license_cc.go | starcoder |
package schemax
import "sync"
/*
DITStructureRuleCollection describes all of the following types:
- *DITStructureRules
- *SuperiorDITStructureRules
*/
type DITStructureRuleCollection interface {
// Get returns the *DITStructureRule instance retrieved as a result
// of a term search, based on Name or ID. If no mat... | dsr.go | 0.790894 | 0.568236 | dsr.go | starcoder |
package lab7
import (
"fmt"
"strings"
"time"
)
const timeOnly = "15:04:05"
const datetimeFormat = "2006/01/02, 15:04:05"
const dateFormat = "2006/01/02"
const timeLen = len(datetimeFormat)
// ChZap represents a channel change event (Zap)
type ChZap struct {
Time time.Time
IP string
ToChan string
... | chzap.go | 0.734501 | 0.419232 | chzap.go | starcoder |
package iso20022
// Parameters applied to the settlement of a security transfer.
type FundSettlementParameters3 struct {
// Date and time at which the securities are to be delivered or received.
SettlementDate *ISODate `xml:"SttlmDt,omitempty"`
// Place where the settlement of transaction will take place. In the ... | FundSettlementParameters3.go | 0.769773 | 0.492493 | FundSettlementParameters3.go | starcoder |
Package timeutil contains common function for time related operations.
*/
package timeutil
import (
"bytes"
"fmt"
"sort"
"strconv"
"strings"
"sync"
"time"
"github.com/krotik/common/errorutil"
)
/*
Cron is an object which implements cron-like functionality. It can be
used to schedule jobs at certain time inte... | timeutil/cron.go | 0.679179 | 0.426322 | cron.go | starcoder |
package pipescript
import "math"
var NegTransform = &Transform{
Name: "neg",
Description: "Negation of numbers",
Constructor: NewBasic(nil, func(dp *Datapoint, args []*Datapoint, consts []interface{}, pipes []*Pipe, out *Datapoint) (*Datapoint, error) {
b, ok := dp.Data.(bool)
if ok {
out.Data = !b
... | arithmetic.go | 0.637031 | 0.438124 | arithmetic.go | starcoder |
package perforator
import (
"fmt"
"sort"
"time"
)
// A Result represents a single event, marked by Label, and the counter value
// returned by the perf monitor.
type Result struct {
Label string
Value uint64
}
// Metrics stores a set of results and the time elapsed while they were
// profiling.
type Metrics str... | metrics.go | 0.546738 | 0.430566 | metrics.go | starcoder |
package util
import (
"math"
"github.com/gotracker/gomixing/panning"
"github.com/gotracker/gomixing/volume"
"gotracker/internal/song/note"
)
const (
// DefaultC2Spd is the default C2SPD for XM samples
DefaultC2Spd = 8363
floatDefaultC2Spd = float32(DefaultC2Spd)
c2Period = float32(1712)
// XMBas... | internal/format/xm/playback/util/util.go | 0.74008 | 0.408601 | util.go | starcoder |
package viz
import (
"fmt"
"image/color"
"time"
"github.com/gonum/plot"
"github.com/gonum/plot/plotter"
. "github.com/cloudfoundry-incubator/cicerone/dsl"
)
//NewEntryPairsHistogram plots a Historam (using n bins) of the durations in the passed in EntryPairs
//The weight (i.e. height) of each bin is simply th... | viz/entry_pair_histogram.go | 0.740268 | 0.602529 | entry_pair_histogram.go | starcoder |
package cp
type GrooveJoint struct {
*Constraint
GrooveN, GrooveA, GrooveB Vector
AnchorB Vector
grooveTn Vector
clamp float64
r1, r2 Vector
k Mat2x2
jAcc, bias Vector
}
func NewGrooveJoint(a, b *Body, grooveA, grooveB, anchorB Vector) *Constraint {
joint := &GrooveJoint{
G... | groovejoint.go | 0.858199 | 0.703276 | groovejoint.go | starcoder |
// Package ristretto allows simple and abstracted operations in the Ristretto255 group
package ristretto
import (
"fmt"
"github.com/gtank/ristretto255"
"github.com/bytemare/crypto/group/internal"
)
// Point implements the Point interface for the Ristretto255 group element.
type Point struct {
point *ristretto2... | group/ristretto/element.go | 0.86674 | 0.554893 | element.go | starcoder |
package ach
import (
"fmt"
"strings"
)
// Addenda05 is a Addendumer addenda which provides business transaction information for Addenda Type
// Code 05 in a machine readable format. It is usually formatted according to ANSI, ASC, X12 Standard.
type Addenda05 struct {
// ID is a client defined string used as a ref... | addenda05.go | 0.759136 | 0.52975 | addenda05.go | starcoder |
package args
import (
"fmt"
"reflect"
"strconv"
)
// convertValue converts value to the type at target and assigns the converted
// value to the variable at target.
func convertValue(value string, target interface{}) error {
if reflect.ValueOf(target).Kind() != reflect.Ptr {
return fmt.Errorf(`target for value ... | types.go | 0.713531 | 0.535098 | types.go | starcoder |
package infrastructure
import (
"fmt"
"net/url"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/types"
)
// BeSemanticallyEqualToRolePolicyDocument returns a matcher that checks if a role policy document is semantically equal to the given one.
func BeSemanticallyEqualToRolePo... | pkg/aws/matchers/iam_role_policy_document.go | 0.762336 | 0.429848 | iam_role_policy_document.go | starcoder |
package pipelines
import (
"encoding/json"
"time"
)
// Pipeline A pipeline definition.
type Pipeline struct {
// The stages associated with the pipeline. They can be retrieved and updated via the pipeline stages endpoints.
Stages []PipelineStage `json:"stages"`
// The date the pipeline was created. The default ... | generated/pipelines/model_pipeline.go | 0.836855 | 0.477189 | model_pipeline.go | starcoder |
package vector
import (
"math"
"polyGo/tools"
)
// Sum returns the sum of two vectors
func Sum(a, b Vec) Vec {
return Vec{
a[0] + b[0],
a[1] + b[1],
}
}
// FromAtoB returns a vector from point A to point B where these points are
// given by their position vectors
// FromAtoB :: Vec -> Vec -> Vec
func FromAto... | vector/funcs.go | 0.918178 | 0.735262 | funcs.go | starcoder |
package ssbo
import (
"math"
gl "github.com/adrianderstroff/pbr/pkg/core/gl"
)
// SSBO is a buffer that can hold different kinds of data.
// The typesize specifies the byte size of one element and len specifes the number of elements.
type SSBO struct {
handle uint32
typesize int
len int
pos int32
}... | pkg/buffer/ssbo/ssbo.go | 0.675765 | 0.449574 | ssbo.go | starcoder |
package openapi
import (
"encoding/json"
)
// BinAndDebitNetwork struct for BinAndDebitNetwork
type BinAndDebitNetwork struct {
// The ID of the bank network
BankNetworkId string `json:"bank_network_id"`
Bin Bin `json:"bin"`
DebitNetwork DebitNetwork `json:"debit_network"`
}
// NewBinAndDebitNetwork instantiat... | synctera/model_bin_and_debit_network.go | 0.649023 | 0.407274 | model_bin_and_debit_network.go | starcoder |
package stargen
import "math"
func calculateMomentOfInertiaCoefficient(mass, radius float64) float64 {
return calculateMomentOfInertia(mass, radius) / (mass * math.Pow(radius, 2.0))
}
func calculateMomentOfInertia(mass, radius float64) float64 {
return (2.0 / 5.0) * mass * math.Pow(radius, 2.0)
}
func AVE(x, y fl... | server/game/universe/generator/stargen/inertia.go | 0.754463 | 0.518363 | inertia.go | starcoder |
package main
import (
"math"
"math/rand"
"github.com/MattSwanson/raylib-go/raylib"
box2d "github.com/neguse/go-box2d-lite/box2dlite"
)
// Game type
type Game struct {
World *box2d.World
TimeStep float64
}
// NewGame - Start new game
func NewGame() (g Game) {
g.Init()
return
}
// Init - Initialize game
... | examples/physics/box2d/main.go | 0.548915 | 0.410845 | main.go | starcoder |
package gft
import (
"image"
"image/draw"
)
// Filter is an image filter.
// Must be a pointer.
type Filter interface {
// Returns the bounds after applying filter.
Bounds(src image.Rectangle) image.Rectangle
// Applies the filter to the src image and draws the result to the dst image.
Apply(dst draw.Image, sr... | gft/gft.go | 0.683947 | 0.447823 | gft.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.