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 types
/*
This slightly unconventional use of type aliasing is meant to provide a hook for documentation
of the different uses of interface{} that exists in QFrame. Since there is nothing like a union
or a sum type in Go, QFrame settles for the use of interface{} for some input.
Hopefully this construct says a... | types/aliases.go | 0.668339 | 0.627181 | aliases.go | starcoder |
package containerscan
var nginxScanJSON = `
{
"customerGUID": "1<PASSWORD>-92ce-44f8-914e-cbe71830d566",
"imageTag": "nginx:1.18.0",
"imageHash": "",
"wlid": "wlid://cluster-test/namespace-test/deployment-davidg",
"containerName": "nginx-1",
"timestamp": 1628091365,
"layers": [
{
... | containerscan/jsonrawscan.go | 0.511961 | 0.41834 | jsonrawscan.go | starcoder |
package plaid
import (
"encoding/json"
)
// TransferAuthorizationDecisionRationale The rationale for Plaid's decision regarding a proposed transfer. Will be null for `approved` decisions.
type TransferAuthorizationDecisionRationale struct {
// A code representing the rationale for permitting or declining the propo... | plaid/model_transfer_authorization_decision_rationale.go | 0.810929 | 0.675934 | model_transfer_authorization_decision_rationale.go | starcoder |
package orderedcodec
import (
"bytes"
"errors"
"math"
"github.com/matrixorigin/matrixone/pkg/container/types"
)
var (
errorDoNotComeHere = errors.New("do not come here")
)
const (
//Actually,the 0x00 represents the NULL in encoded bytes.
//So, 0x00 escaped to {0x00 0xff}
byteToBeEscaped byte = 0x00... | pkg/vm/engine/tpe/orderedcodec/encoder.go | 0.595963 | 0.516717 | encoder.go | starcoder |
package main
import (
"aoc2021/utils"
"fmt"
"sort"
)
type Point struct {
row int
col int
}
// recursively check the current point and adjacent neighbors, summing the larger points (up until 9)
func traverse(x, y int, grid [][]int, visitedPoints utils.Set[Point]) int {
if (visitedPoints.Contains(Point{x, y})) {... | daphillips/09/day9.go | 0.581303 | 0.534127 | day9.go | starcoder |
package mat
import (
"gonum.org/v1/gonum/blas"
"gonum.org/v1/gonum/blas/blas64"
)
var (
diagDense *DiagDense
_ Matrix = diagDense
_ Diagonal = diagDense
_ MutableDiagonal = diagDense
_ Triangular = diagDense
_ Symmetric = diagDense
_ ... | vendor/gonum.org/v1/gonum/mat/diagonal.go | 0.829665 | 0.515864 | diagonal.go | starcoder |
package missing_cloud_hardening
import (
"github.com/threagile/threagile/model"
"sort"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "missing-cloud-hardening",
Title: "Missing Cloud Hardening",
Description: "Cloud components should be hardened according to the cloud vendor best pra... | risks/built-in/missing-cloud-hardening/missing-cloud-hardening-rule.go | 0.61682 | 0.502441 | missing-cloud-hardening-rule.go | starcoder |
package poly
// Intersects detects if a point intersects another polygon
func (p Point) Intersects(exterior Polygon, holes []Polygon) bool {
return p.Inside(exterior, holes)
}
// Intersects detects if a polygon intersects another polygon
func (shape Polygon) Intersects(exterior Polygon, holes []Polygon) bool {
retu... | vendor/github.com/tidwall/tile38/geojson/poly/intersects.go | 0.781247 | 0.692444 | intersects.go | starcoder |
package builders
import (
"go/ast"
"go/token"
)
// BinaryOp returns binary expression with given token.
func BinaryOp(x ast.Expr, tok token.Token, y ast.Expr) *ast.BinaryExpr {
return &ast.BinaryExpr{
X: x,
Op: tok,
Y: y,
}
}
// Arithmetic
// Add returns x + y expression.
func Add(x, y ast.Expr) *ast.Bi... | binary_op.go | 0.872524 | 0.716467 | binary_op.go | starcoder |
package gen
type floatConstantValuesSequence struct {
v float64
}
func NewFloatConstantValuesSequence(v float64) FloatValuesSequence {
return &floatConstantValuesSequence{
v: v,
}
}
func (g *floatConstantValuesSequence) Reset() {
}
func (g *floatConstantValuesSequence) Write(vs []float64) {
for i := 0; i < l... | vend/db/pkg/data/gen/values.gen.go | 0.667256 | 0.52074 | values.gen.go | starcoder |
package easyga
import (
"math/rand"
"sync"
)
// Rand is a pointer to the rand which can be changed outside
var Rand *rand.Rand
// GeneticAlgorithm is a struct that contains everything of genetic algorithm.
type GeneticAlgorithm struct {
Parameters GeneticAlgorithmParameters
Functions GeneticAlgorithmFunctions
... | ga.go | 0.66356 | 0.424472 | ga.go | starcoder |
package funk
import (
"reflect"
)
// Reduce takes a collection and reduces it to a single value using a reduction
// function (or a valid symbol) and an accumulator value.
func Reduce(arr, reduceFunc, acc interface{}) float64 {
arrValue := redirectValue(reflect.ValueOf(arr))
if !IsIteratee(arrValue.Interface()) {... | reduce.go | 0.675551 | 0.507263 | reduce.go | starcoder |
package network
import (
"bufio"
"encoding/csv"
"io"
"neuraldeep/utils"
"os"
"strconv"
)
const (
sizeLine = 1 + 784 // label + image pixels
)
// LoadData mixes <NAME>'s load_data() and load_data_wrapper() functions into one through the use of the `Input` object.
// Another difference is that we aren't actuall... | network/loader.go | 0.606032 | 0.475484 | loader.go | starcoder |
package main
import (
"github.com/go-gl/mathgl/mgl32"
"math"
)
const (
MouseSensitivity = 0.7
)
type Camera struct {
xAngle float32
zAngle float32
cameraPosition mgl32.Vec3
windowHandler *WindowHandler
}
func NewCamera(windowHandler *WindowHandler) *Camera {
return &Camera{
xAngle: ... | src/camera.go | 0.730674 | 0.468 | camera.go | starcoder |
package table
import (
"fmt"
"sort"
)
type sortDirection int
const (
sortDirectionAsc sortDirection = iota
sortDirectionDesc
)
type sortColumn struct {
columnKey string
direction sortDirection
}
// SortByAsc sets the main sorting column to the given key, in ascending order.
// If a previous sort was used, it... | table/sort.go | 0.749729 | 0.405331 | sort.go | starcoder |
package main
import (
// "fmt"
ui "github.com/gizak/termui"
"io/ioutil"
"strconv"
)
// Block
type Block struct {
TermBlock *ui.Block
Color ui.Attribute
Breakable int
Focused bool
}
func (b *Block) SetPosition(x, y int) {
b.TermBlock.X = x
b.TermBlock.Y = y
}
func (b *B... | main.go | 0.602646 | 0.408454 | main.go | starcoder |
package primitives
import (
"github.com/alexandreLamarre/Golang-Ray-Tracing-Renderer/pkg/algebra"
"github.com/alexandreLamarre/Golang-Ray-Tracing-Renderer/pkg/canvas"
"math"
)
//Sphere Data type for a 3D sphere
type Sphere struct {
parent Shape
origin *algebra.Vector
radius float64
transform *algebra.... | pkg/geometry/primitives/sphere.go | 0.854415 | 0.528229 | sphere.go | starcoder |
package sparse
import (
"math"
"github.com/gonum/floats"
"gonum.org/v1/gonum/mat"
)
// Cholesky shadows the gonum mat.Cholesly type
type Cholesky struct {
// internal representation is CSR in lower triangular form
chol *CSR
// some operations use a columnar version
cholc *CSC
cond float64
}
// Dims of the... | cholesky.go | 0.699049 | 0.460471 | cholesky.go | starcoder |
package cucumberexpressions
import (
"fmt"
"reflect"
"regexp"
"strings"
)
var escapeRegexp = regexp.MustCompile(`([\\^\[({$.|?*+})\]])`)
type CucumberExpression struct {
source string
parameterTypes []*ParameterType
treeRegexp *TreeRegexp
parameterTypeRegistry *ParameterTypeR... | cucumber-expressions/go/cucumber_expression.go | 0.636805 | 0.428712 | cucumber_expression.go | starcoder |
package graph
import (
"fmt"
"strings"
"github.com/gonum/graph/concrete"
)
// FilterPackages receives a graph and a set of packagePrefixes contained within the graph.
// Returns a new graph with the sub-tree for each node matching the packagePrefix collapsed
// into just that node. Relationships among packagePref... | kubernetes-model/vendor/github.com/openshift/origin/tools/depcheck/pkg/graph/filter.go | 0.723895 | 0.427038 | filter.go | starcoder |
package timetogo
import (
"fmt"
"time"
"github.com/dsoprea/go-logging"
"github.com/google/flatbuffers/go"
"github.com/dsoprea/time-to-go/protocol/ttgstream"
)
var (
streamLogger1 = log.NewLogger("timetogo.stream_protocol_1")
)
// StreamIndexedSequenceInfo1 briefly describes all series.
type StreamIndexedSequ... | stream_protocol_1.go | 0.727685 | 0.434881 | stream_protocol_1.go | starcoder |
package expression
import (
"errors"
"fmt"
"reflect"
"strconv"
)
type parseError struct {
error
offset int
tokenOffset int
}
type parser struct {
input scanner
mode ParseMode
types FieldTypeMap
// current token
token token
tokenOffset int
tokenText string
}
func (p *parser) error(msg s... | pkg/expression/parser.go | 0.584271 | 0.419707 | parser.go | starcoder |
package fauxgl
import (
"math"
"github.com/fogleman/simplify"
)
type Mesh struct {
Triangles []*Triangle
Lines []*Line
box *Box
}
func NewEmptyMesh() *Mesh {
return &Mesh{}
}
func NewMesh(triangles []*Triangle, lines []*Line) *Mesh {
return &Mesh{triangles, lines, nil}
}
func NewTriangleMesh(tria... | mesh.go | 0.738198 | 0.609175 | mesh.go | starcoder |
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed und... | test/e2e/cli.go | 0.667798 | 0.577555 | cli.go | starcoder |
package feistel
import (
"bytes"
"encoding/binary"
"io"
)
type cbc struct{}
// CBC contains the Encrypt and Decrypt functions using the CBC algorithm
var CBC cbc
// EncryptReader reads data from an reader and writes the encrypted data to the writer
func (cbc) EncryptReader(r io.Reader, w io.Writer, rounds int, k... | cbc.go | 0.6137 | 0.435181 | cbc.go | starcoder |
package blackbox
import (
"github.com/pkg/errors"
)
const (
// PredictorZero returns the value unmodified
PredictorZero = 0
// PredictorPrevious return the value substracted from the interframe
PredictorPrevious = 1
// PredictorStraightLine assumes that the slope between the current measurement and the previo... | src/blackbox/predictor.go | 0.854763 | 0.758018 | predictor.go | starcoder |
package pegomock
import (
"reflect"
)
func EqBool(value bool) bool {
RegisterMatcher(&EqMatcher{Value: value})
return false
}
func NotEqBool(value bool) bool {
RegisterMatcher(&NotEqMatcher{Value: value})
return false
}
func AnyBool() bool {
RegisterMatcher(NewAnyMatcher(reflect.TypeOf(false)))
return false
... | matcher_factories.go | 0.770551 | 0.524273 | matcher_factories.go | starcoder |
package ztable
import (
"errors"
"fmt"
"math"
"runtime"
"strconv"
"gonum.org/v1/gonum/integrate/quad"
)
// ZTable is the core z-score table component
type ZTable struct {
// list of unexported fields
zScoreMap map[string]int
leafNodes []*LeafNode
rootNode *Node
}
// Options is a config for the NewZTable ... | ztable.go | 0.662796 | 0.487002 | ztable.go | starcoder |
package inertia
import (
pr "github.com/StStep/go-test-simulation/internal/physics/prop"
fl "gonum.org/v1/gonum/floats"
)
type Inertia struct {
Prop *pr.Prop // Physics properties to use with math
curVelocity [2]float64 // Represents current velocity vector
cmdVelocity [2]float64 // Represents commanded... | internal/physics/inertia/inertia.go | 0.703448 | 0.6922 | inertia.go | starcoder |
package vm
import (
"time"
"github.com/runner-mei/errors"
)
func NewArithmeticError(op, left, right string) error {
return errors.New("cloudn't '" + left + "' " + op + " '" + right + "'")
}
func PlusFunc(left, right func(Context) (Value, error)) func(Context) (Value, error) {
return func(ctx Context) (Value, er... | vm/plus.go | 0.759047 | 0.527438 | plus.go | starcoder |
package strings
// Calculating edit distance between strings of length m and n is O(mn).
// In our case we also don't want distance against the full query string,
// we only want it against the "best" substring.
// The function GetBestMatchPositions below finds the "best" candidate
// substrings in time O(m+n). "Best... | strings/best_match_positions.go | 0.687735 | 0.676119 | best_match_positions.go | starcoder |
package mathutil
import (
"sort"
)
// SliceInt represets a slice of integers and provides functions on that slice.
type SliceInt struct {
Elements []int
Stats SliceIntStats
}
// NewSliceInt creates and returns an empty SliceInt struct.
func NewSliceInt() SliceInt {
sint := SliceInt{Elements: []int{}}
return ... | math/mathutil/sliceint.go | 0.837753 | 0.522568 | sliceint.go | starcoder |
package trinary
import (
"math"
"strings"
. "github.com/iotaledger/iota.go/consts"
"github.com/pkg/errors"
)
var (
// TryteToTritsLUT is a Look-up-table for Trytes to Trits conversion.
TryteToTritsLUT = [][]int8{
{0, 0, 0}, {1, 0, 0}, {-1, 1, 0}, {0, 1, 0},
{1, 1, 0}, {-1, -1, 1}, {0, -1, 1}, {1, -1, 1},
... | trinary/trinary.go | 0.648244 | 0.434461 | trinary.go | starcoder |
package levenshtein
import (
"fmt"
)
// stateLimit is the maximum number of states allowed.
var stateLimit = 10000
// StateLimit is the maximum number of states allowed.
func StateLimit() int {
return stateLimit
}
// SetStateLimit sets the maximum number of states allowed.
func SetStateLimit(v int) {
stateLimit... | levenshtein/levenshtein.go | 0.753557 | 0.447521 | levenshtein.go | starcoder |
package lamda
// MapPredicate function
type MapPredicate func(interface{}) interface{}
// MapStringPredicate function
type MapStringPredicate func(string) string
// MapBytePredicate function
type MapBytePredicate func(byte) byte
// MapIntPredicate function
type MapIntPredicate func(int) int
// MapInt16Predicate fu... | lamda/map.go | 0.736116 | 0.405419 | map.go | starcoder |
package mpl3115a2
import (
"encoding/binary"
"errors"
"time"
i2c "github.com/d2r2/go-i2c"
)
// Register map
const (
// Alias for DR_STATUS or F_STATUS
STATUS = 0x00
// 20-bit realtime pressure sample
OUT_PRES_MSB_CSB_LSB = 0x01
OUT_PRES_BYTES = 3
// 12-bit realtime temperature sample
OUT_TEMP_MSB... | mpl3115a2.go | 0.525856 | 0.408631 | mpl3115a2.go | starcoder |
package main
import (
"math"
"github.com/unixpickle/model3d/model3d"
)
const (
StarThickness = 1.0
StarPointRadius = 2.0
StarRingRadius = 0.2
StarHolderRadius = 0.4
StarHolderLength = 2.0
StarHolderThickness = 0.05
StarHolderOffset = 0.4
StarNumPoints = 6
)
func CreateStarSolid() model3d.Sol... | examples/decoration/tree_ornament/star.go | 0.750187 | 0.430207 | star.go | starcoder |
package git
import (
"errors"
"strconv"
"strings"
"github.com/github/git-sizer/counts"
)
// Tree represents a Git tree object.
type Tree struct {
data string
}
// ParseTree parses the tree object whose contents are contained in
// `data`. `oid` is currently unused.
func ParseTree(oid OID, data []byte) (*Tree, ... | git/tree.go | 0.84075 | 0.458167 | tree.go | starcoder |
package cartesiantree
import (
"fmt"
"math/rand"
)
// CTree ...
type CTree struct {
x uint32
y float32
left *CTree
right *CTree
init bool
}
// NewCartesianTree ...
func NewCartesianTree() *CTree {
t := &CTree{}
t.init = false
return t
}
func newCartesianTree(x uint32, y float32, left *CTree, right *C... | cartesiantree/cartesiantree.go | 0.586286 | 0.523116 | cartesiantree.go | starcoder |
package internal
import (
"fmt"
"math"
)
type grotskyNumber float64
func applyOpToNums(op func(x, y float64) interface{}, arguments ...interface{}) (interface{}, error) {
x := arguments[0].(grotskyNumber)
y, ok := arguments[1].(grotskyNumber)
if !ok {
return nil, errExpectedNumber
}
return op(float64(x), fl... | internal/grotskyNumber.go | 0.68721 | 0.421254 | grotskyNumber.go | starcoder |
package main
import (
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"math/big"
"os"
"strconv"
"strings"
"gitlab.com/NebulousLabs/Sia/encoding"
"gitlab.com/NebulousLabs/Sia/types"
"gitlab.com/NebulousLabs/errors"
)
var (
// errUnableToParseSize is returned when the input is unable to be parsed
// i... | cmd/siac/parse.go | 0.532911 | 0.4953 | parse.go | starcoder |
package num
import "math"
// NormalizeAngle takes an angle in radians and scales it to [-2PI,2PI].
func NormalizeAngle(theta float64) float64 {
if -2*math.Pi <= theta && theta <= 2*math.Pi {
return theta
}
f := theta / (2 * math.Pi)
if f < 0 {
return 2 * math.Pi * (f - math.Ceil(f))
}
return 2 * math.Pi * (... | num/interpolate.go | 0.899652 | 0.806396 | interpolate.go | starcoder |
package hyperloglog
import (
"errors"
"hash"
"hash/fnv"
"math"
)
// HyperLogLog probabilistic data struct for cardinality estimation.
type HyperLogLog struct {
registers []uint8 // registers bucket
m uint // number of registers
b uint32 // number of bits to find registers bucket... | pkg/hyperloglog/hyperloglog.go | 0.77806 | 0.433622 | hyperloglog.go | starcoder |
package memmetrics
import (
"math"
"sort"
"time"
)
// SplitRatios provides simple anomaly detection for requests latencies.
// it splits values into good or bad category based on the threshold and the median value.
// If all values are not far from the median, it will return all values in 'good' set.
// Precision ... | vendor/github.com/vulcand/oxy/memmetrics/anomaly.go | 0.730866 | 0.597461 | anomaly.go | starcoder |
package cast
import "strconv"
// AsFloat64 to convert as a float64
func AsFloat64(v interface{}) (float64, bool) {
switch d := indirect(v).(type) {
case bool:
if d {
return 1, true
}
return 0, true
case int:
return float64(d), true
case int64:
return float64(d), true
case int32:
return float64(d),... | float.go | 0.693369 | 0.504028 | float.go | starcoder |
package main
import "chaincode/errors"
// TrainingTask is a node of a ComputeDAG. It represents a training task
// (i.e. a Traintuple, a CompositeTraintuple or an Aggregatetuple)
type TrainingTask struct {
ID string
InModelsIDs []string
InputIndex int
Depth int
TaskType AssetType
}
// Compute... | chaincode/compute_plan_dag.go | 0.554953 | 0.598576 | compute_plan_dag.go | starcoder |
package unbounded
import (
"github.com/cnotch/algo/container/queue"
)
// Value 树存储的值类型
type Value = interface{}
// Tree 分支无限制的有根树
type Tree struct {
// 双亲树
parent *Tree
// 左孩子
leftChild *Tree
// 右兄弟
rightBrother *Tree
// 树节点存储的值
Value Value
}
// New 实例化 Tree
func New(v Value) *Tree {
return &Tree{Value: ... | container/tree/unbounded/tree.go | 0.558327 | 0.410047 | tree.go | starcoder |
package scanner
import (
"regexp"
"strings"
)
// Token is the structure containing a scanned token.
type Token struct {
Data string
}
// IsComment returns if the token is a comment.
func (t *Token) IsComment() bool {
return strings.HasPrefix(t.Data, "#")
}
// IsString returns if the current token begins a strin... | scanner/token.go | 0.798226 | 0.586464 | token.go | starcoder |
package indicators
import (
"math"
"github.com/dellosaneil/stocktracking-backend/util"
)
func RelativeStrengthIndex(prices []float64, period int) []float64 {
var rsi []float64
priceChange := calculatePriceChange(prices)
averageGains, averageLosses := getAverages(priceChange, period)
rs := (averageGains[0] / av... | indicators/RelativeStrengthIndex.go | 0.701509 | 0.561034 | RelativeStrengthIndex.go | starcoder |
package movers
import (
"math"
"github.com/wieku/danser-go/beatmap/objects"
"github.com/wieku/danser-go/settings"
"github.com/wieku/danser-go/bmath"
"github.com/wieku/danser-go/bmath/curves"
)
type AngleOffsetMover struct {
lastAngle float64
lastPoint bmath.Vector2d
bz *curve... | dance/movers/angleoffset.go | 0.646014 | 0.488527 | angleoffset.go | starcoder |
package trace
import (
"fmt"
"math"
"math/rand"
"reflect"
"strconv"
"github.com/Bredgren/gotracer/trace/options"
"github.com/Bredgren/gotracer/trace/ray"
"github.com/Bredgren/gotracer/trace/vec"
"github.com/go-gl/mathgl/mgl64"
)
// Camera is a viewpoint into a scene and is able to generate Camera rays.
type... | trace/camera.go | 0.818628 | 0.487246 | camera.go | starcoder |
package oak
import (
"github.com/oakmound/oak/v4/alg/intgeom"
"github.com/oakmound/oak/v4/event"
)
type Viewport struct {
Position intgeom.Point2
Bounds intgeom.Rect2
BoundsEnforced bool
}
// ShiftViewport shifts the viewport by x,y
func (w *Window) ShiftViewport(delta intgeom.Point2) {
w.SetView... | viewport.go | 0.739422 | 0.424591 | viewport.go | starcoder |
package duration
import (
"fmt"
"math"
"os"
"sort"
"github.com/kshedden/statmodel/statmodel"
)
// SurvfuncRight uses the method of Kaplan and Meier to estimate the
// survival distribution based on (possibly) right censored data. The
// caller must set Data and TimeVar before calling the Fit method.
// StatusV... | duration/survfunc.go | 0.640861 | 0.531574 | survfunc.go | starcoder |
package synthesizer
import (
"errors"
)
// LookupOscillator is an oscillator that's more gentle on your CPU
// By performing a table lookup to generate the required waveform..
type LookupOscillator struct {
Oscillator
Table *Gtable
SizeOverSr float64 // convenience variable for calculations
}
// NewLookupOs... | synthesizer/lookuposcil.go | 0.784649 | 0.471771 | lookuposcil.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// SimulationReportOverview
type SimulationReportOverview struct {
// Stores additional data not described in the OpenAPI description found when deserializing... | models/simulation_report_overview.go | 0.674479 | 0.55923 | simulation_report_overview.go | starcoder |
package day20
import (
"strings"
"github.com/chigley/advent2020"
)
type Picture struct {
// We keep state on what the tiles look like _and_ their IDs. Tile IDs alone
// aren't sufficient because they can't tell us which translations were
// performed.
tiles [][]Tile
tileIDs [][]int
// Width/height measure... | day20/picture.go | 0.620966 | 0.479321 | picture.go | starcoder |
package strftime
import (
"bytes"
"fmt"
"io"
"regexp"
"time"
)
const (
WEEK = time.Hour * 24 * 7
)
type FormatFunc func(t time.Time) string
func weekNumberFormatter(t time.Time) string {
start := time.Date(t.Year(), time.January, 1, 23, 0, 0, 0, time.UTC)
week := 0
for start.Before(t) {
week += 1
start... | vendor/github.com/hhkbp2/go-strftime/strftime.go | 0.610105 | 0.478224 | strftime.go | starcoder |
package gotest
import "reflect"
type Assert interface {
ShouldBeEqualTo(expected interface{})
ShouldNotBeEqualTo(expected interface{})
ShouldBeTrue()
ShouldBeFalse()
ShouldBeNil()
ShouldNotBeNil()
}
type assert struct {
objectName string
actual interface{}
s *scenario
}
// ShouldBeEqualTo chec... | assert.go | 0.682679 | 0.648355 | assert.go | starcoder |
package matcher
import (
"github.com/iNamik/go_container/stack"
"github.com/iNamik/go_lexer"
)
type Matcher interface {
// MatchZeroOrOneBytes consumes the next rune if it matches, always returning true
MatchZeroOrOneBytes([]byte) MatcherOperator
// MatchZeroOrOneRunes consumes the next rune if it matches, alw... | matcher.go | 0.613352 | 0.494812 | matcher.go | starcoder |
package data
type Data struct {
data map[string][]string
}
func New() *Data {
return &Data{
data: make(map[string][]string),
}
}
// Keys returns all data names
// Don't rely on it's order!
func (d *Data) Keys() []string {
keys := []string{}
for k := range d.data {
keys = append(keys, k)
}
return keys
}
f... | Godeps/_workspace/src/github.com/mattes/go-collect/data/data.go | 0.659076 | 0.455441 | data.go | starcoder |
package vial
import (
"sync"
"strconv"
"strings"
"github.com/google/uuid"
)
var once sync.Once
var pathParamMatcherMutex = new(sync.RWMutex)
var pathParamMatchers = map[string]*PathParamMatcher{}
// PathParamCoercer is a function which takes a raw path param string value and
// converts it to the e... | path_param_matcher.go | 0.708918 | 0.44083 | path_param_matcher.go | starcoder |
package useful
import (
"io/ioutil"
"strconv"
"strings"
)
// Min : returns minimum of integers a and b
func Min(a, b int) int {
if a < b {
return a
}
return b
}
// Max : returns maximum of integers a and b
func Max(a, b int) int {
if a > b {
return a
}
return b
}
// Abs : returns absolute value of inte... | useful/useful.go | 0.765067 | 0.407392 | useful.go | starcoder |
package aoc2021
import (
"fmt"
"strings"
"github.com/simonski/aoc/utils"
)
/*
--- Day 6: Lanternfish ---
The sea floor is getting steeper. Maybe the sleigh keys got carried this way?
A massive school of glowing lanternfish swims past. They must spawn quickly to reach such large numbers - maybe exponentially quic... | app/aoc2021/aoc2021_06.go | 0.61878 | 0.636918 | aoc2021_06.go | starcoder |
package types
import (
"github.com/antihax/optional"
"time"
)
type IngestBudget struct {
// Creation timestamp in UTC in [RFC3339](https://tools.ietf.org/html/rfc3339) format.
CreatedAt time.Time `json:"createdAt"`
CreatedByUser *UserInfo `json:"createdByUser"`
// Last modification timestamp in UTC in [RFC3... | service/cip/types/ingest_budget_v1_types.go | 0.776114 | 0.408159 | ingest_budget_v1_types.go | starcoder |
package gosmonaut
import (
"math"
"sort"
)
// binaryNodeEntityMap uses a binary search table for storing
// entites. It is well suited in this case since we only have to sort it once
// between the reads and writes. Also we avoid the memory overhead of storing
// the IDs twice and instead just read them from the s... | binary_entity_map.go | 0.678966 | 0.477981 | binary_entity_map.go | starcoder |
package schemer
import (
"fmt"
"reflect"
"strconv"
"time"
"github.com/BrobridgeOrg/schemer/types"
)
func getStandardValue(data interface{}) interface{} {
v := reflect.ValueOf(data)
switch v.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return v.Int()
case reflect.... | convert.go | 0.533641 | 0.437042 | convert.go | starcoder |
package arithmetic
import (
"errors"
"fmt"
"gopkg.in/guregu/null.v3"
"math"
"math/rand"
"time"
)
type IntSlice []int
type ISlice []interface{}
// IsPrime determines whether a given number is prime (P31).
func IsPrime(number int) bool {
upperDivisor := int(math.Sqrt(float64(number))) + 1
for divisor := 2; div... | Golang/pkg/arithmetic/arithmetic.go | 0.708112 | 0.450541 | arithmetic.go | starcoder |
package cache
import (
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/snowflake/v2"
"golang.org/x/exp/slices"
)
// PolicyNone returns a policy that will never cache anything.
func PolicyNone[T any](_ T) bool { return false }
// PolicyAll returns a policy that will cache all entities.
func PolicyAll[T an... | cache/cache_policy.go | 0.782247 | 0.402245 | cache_policy.go | starcoder |
package data
import (
"bytes"
"encoding/json"
"fmt"
"time"
)
// Array is an array of Values. It can be assigned to Value interface.
type Array []Value
// Type returns TypeID of Array. It's always TypeArray.
func (a Array) Type() TypeID {
return TypeArray
}
func (a Array) asBool() (bool, error) {
return false,... | data/array.go | 0.661814 | 0.409221 | array.go | starcoder |
package main
func main() {
}
/**
* 双端队列 结构 队头、队尾均可入队
*/
type MyCircularDeque struct {
front, rear *node
len, cap int
}
//节点 value 前后指针
type node struct {
value int
pre, next *node
}
/** Initialize your data structure here. Set the size of the deque to be k. */
func Constructor(k int) MyCircularDeque ... | Week 1/id_090/LeetCode_641_090.go | 0.582135 | 0.435841 | LeetCode_641_090.go | starcoder |
package vehicle
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
"github.com/mitchellh/hashstructure"
)
// List contains vehicles that were found during parsing.
type List map[uint64]Vehicle
// RegCountry represents a country of registration for a vehicle.
type RegCountry int
// List of allowed regi... | vehicle/vehicle.go | 0.78572 | 0.429489 | vehicle.go | starcoder |
// Package jtypes (golint)
package jtypes
import (
"reflect"
)
// Resolve (golint)
func Resolve(v reflect.Value) reflect.Value {
for {
switch v.Kind() {
case reflect.Interface, reflect.Ptr:
if !v.IsNil() {
v = v.Elem()
break
}
fallthrough
default:
return v
}
}
}
// IsBool (golint)
fun... | jtypes/funcs.go | 0.611614 | 0.458531 | funcs.go | starcoder |
package types
import (
"fmt"
"github.com/ethereum/go-ethereum/common/hexutil"
)
// SfcConfig defines the current SFC contract configuration.
type SfcConfig struct {
// minValidatorStake is the minimal amount of tokens required
// to register a validator account with the default self stake.
MinValidatorStake hexu... | internal/types/sfc_config.go | 0.687105 | 0.432363 | sfc_config.go | starcoder |
package hdrimage
import (
"encoding/binary"
"fmt"
"image"
"image/color"
"io"
"github.com/DexterLB/traytor/hdrcolour"
)
// Image is a stuct which will display images via its 2D colour array, wich represents the screen
type Image struct {
Pixels [][]hdrcolour.Colour
Width, Height int
Divisor int
... | hdrimage/image.go | 0.754101 | 0.417153 | image.go | starcoder |
package day14
import (
"fmt"
"regexp"
"strconv"
"strings"
)
var (
MaskInstruction = regexp.MustCompile(`^mask = ([X01]+$)`)
MemoryInstruction = regexp.MustCompile(`^mem\[(\d+)\] = (\d+)$`)
)
type BitMask interface {
// Applies the bitmap to the instruction and stores the result in the memory
apply(*Instruc... | day14/day14.go | 0.632503 | 0.41117 | day14.go | starcoder |
package hsl
// RGBtoHSL : Convert RGB to HSL
// rgb values are 0-255
// h is between 0.0 - 360.0
// s & l values are 0.0 - 1.0
func RGBtoHSL(r, g, b uint8) (h, s, l float64) {
var rgb [3]float64
rgb[0] = float64(r) / 255.0
rgb[1] = float64(g) / 255.0
rgb[2] = float64(b) / 255.0
max := 0.0
for _, v := range rgb... | hsl/hsl.go | 0.664867 | 0.422981 | hsl.go | starcoder |
package evaluator
import (
"fmt"
"github.com/yuzuy/yoru/ast"
"github.com/yuzuy/yoru/object"
"github.com/yuzuy/yoru/token"
)
var (
Null = &object.Null{}
True = &object.Boolean{Value: true}
False = &object.Boolean{Value: false}
)
func Eval(node ast.Node, env *object.Environment) object.Object {
switch node ... | evaluator/evaluator.go | 0.569853 | 0.470858 | evaluator.go | starcoder |
package transport
const ( // types of encoding over the wire.
// EncodingNone place holder.
EncodingNone byte = 0x00
// EncodingProtobuf uses protobuf as coding format.
EncodingProtobuf byte = 0x10
)
const ( // types of compression over the wire.
// CompressionNone does not apply compression on the payload.
Co... | secondary/transport/transport_flags.go | 0.738103 | 0.444565 | transport_flags.go | starcoder |
// Package compact provides compact Merkle tree data structures.
package compact
import (
"bytes"
"encoding/base64"
"encoding/hex"
"fmt"
"math/bits"
log "github.com/golang/glog"
"github.com/google/trillian/merkle/hashers"
)
// RootHashMismatchError indicates a unexpected root hash value.
type RootHashMismatc... | merkle/compact/tree.go | 0.695545 | 0.706652 | tree.go | starcoder |
package bst
import "github.com/kgantsov/data_structures_and_algorithms/data_structures/queue"
type Node struct {
value int
left *Node
right *Node
}
func NewNode(value int) *Node {
node := new(Node)
node.value = value
return node
}
type BinarySearchTree struct {
root *Node
}
func NewBinarySearchTree() *Bi... | data_structures/bst/bst.go | 0.69451 | 0.446676 | bst.go | starcoder |
package dynamic
import (
"fmt"
"math"
"github.com/rasaford/algorithms/internal/helper"
)
// CutRod takes a list of prices for various lengths of rods and returns
// the maximum achievable price for a rod of length n if all cuts are free.
// The prices table has the length of the rod as an index into the array and... | dynamic/rodCutting.go | 0.680454 | 0.498291 | rodCutting.go | starcoder |
package questions
import (
"container/list"
"fmt"
"math"
"math/bits"
"math/rand"
"sort"
"strconv"
"strings"
)
// QuestionOne performs addition without using arithmetic operators
func QuestionOne(x, y int64) int64 {
/*
No arithmetic, so binary operations required
addition:
0 + 0 = 00
0 + 1 = 01
... | exercises/questions/questions.go | 0.645567 | 0.431644 | questions.go | starcoder |
package glinkedlist
import "fmt"
//Stack tracks the linked list head and tail
type Stack struct {
Head *Node
Tail *Node
Count int
Debug bool
}
// Node is a linked list item
type Node struct {
Data string
Pointer *Node
}
// Pop takes the top node from the linked list and returns
func (s *Stack) Pop() Node {... | gLinkedList.go | 0.555194 | 0.418162 | gLinkedList.go | starcoder |
// Given a (singly) linked list with head node root, write a function to split the linked list into k consecutive linked list "parts".
// The length of each part should be as equal as possible: no two parts should have a size differing by more than 1. This may lead to some parts being null.
// The parts should be in o... | 0725/code.go | 0.764452 | 0.713619 | code.go | starcoder |
package systems
import (
"fmt"
gc "github.com/x-hgg-x/space-invaders-go/lib/components"
"github.com/x-hgg-x/space-invaders-go/lib/resources"
ecs "github.com/x-hgg-x/goecs/v2"
ec "github.com/x-hgg-x/goecsengine/components"
"github.com/x-hgg-x/goecsengine/utils"
w "github.com/x-hgg-x/goecsengine/world"
)
// Co... | lib/systems/collision.go | 0.615203 | 0.409575 | collision.go | starcoder |
package ts
// ArrayPkt implements Pkt interface and represents array of bytes that
// contains one MPEG-TS packet.
type ArrayPkt [PktLen]byte
// Slice returns refference to the content of p as SlicePkt
func (p *ArrayPkt) Slice() SlicePkt {
return SlicePkt(p[:])
}
func (p *ArrayPkt) Bytes() []byte {
return p[:]
}
... | ts/arraypkt.go | 0.685107 | 0.612715 | arraypkt.go | starcoder |
package geojson
import (
"encoding/json"
"reflect"
"github.com/ctessum/geom"
)
func pointCoordinates(point geom.Point) []float64 {
return []float64{point.X, point.Y}
}
func pointsCoordinates(points []geom.Point) [][]float64 {
coordinates := make([][]float64, len(points))
for i, point := range points {
coord... | encoding/geojson/encode.go | 0.665193 | 0.543227 | encode.go | starcoder |
package ioutil
import (
"io"
)
// A DataInput provides helpers for reading bytes from a binary stream and interprets the data for any primitive Go
// type. A DataInput is always tied to a specific endianness. A DataInput should not be considered thread safe.
// As soon as any error occurred, any call is a no-op and ... | datainput.go | 0.663996 | 0.748915 | datainput.go | starcoder |
package mvcc
import (
"github.com/jrife/flock/storage/kv"
"github.com/jrife/flock/storage/kv/keys"
)
// NamespaceView returns a view that will prefix
// all keys with ns
func NamespaceView(view View, ns []byte) View {
if len(ns) == 0 {
return view
}
return &namespacedView{MapReader: kv.NamespaceMapReader(view... | storage/mvcc/namespace.go | 0.720663 | 0.402627 | namespace.go | starcoder |
package export
import "github.com/prometheus/client_golang/prometheus"
// IngestionKafkaExporter contains all the Prometheus metrics that are possible to gather from the Jetty service
type IngestionKafkaExporter struct {
Lag *prometheus.GaugeVec `description:"total lag between the offsets consumed by the Kafka in... | pkg/export/ingestion_kafka.go | 0.841435 | 0.425784 | ingestion_kafka.go | starcoder |
package vector
// vector encapsulates a slice and provides the algorithms (push, pop, for_each, map...)
// that are missing from the slices
// it offers the method to reserve and shrink the memory it occupies, improving the
// performance
// note the Go type reference suggests: type Vector[T any] []T
// this looks sh... | pkg/vector/vector.go | 0.719186 | 0.604545 | vector.go | starcoder |
package amd64
import (
"errors"
)
// ============================================================================
// tree-arg instruction
// dst = a OP b
func (arch Amd64) Op3(asm *Asm, op Op3, a Arg, b Arg, dst Arg) *Asm {
arch.op3(asm, op, a, b, dst)
return asm
}
var op3KindError = errors.New("Amd64.op3: argum... | vendor/github.com/cosmos72/gomacro/jit/amd64/op3.go | 0.518059 | 0.425009 | op3.go | starcoder |
package govalidator
import (
"reflect"
"regexp"
"sort"
"sync"
)
// Validator is a wrapper for a validator function that returns bool and accepts string.
type Validator func(str string) bool
// CustomTypeValidator is a wrapper for validator functions that returns bool and accepts any type.
// The second parameter... | types.go | 0.698946 | 0.431944 | types.go | starcoder |
package csg
// Node is a node from a BSP tree
type Node struct {
plane *Plane
front *Node
back *Node
polygons []*Polygon
}
// NewNodeFromPolygons constructs a node from a slice of polygons
func NewNodeFromPolygons(p []*Polygon) *Node {
n := &Node{}
n.Build(p)
return n
}
// Clone will clone this node... | csg/node.go | 0.709724 | 0.445047 | node.go | starcoder |
package types
import (
"io"
"strconv"
"github.com/lyraproj/pcore/px"
)
type CallableType struct {
paramsType px.Type
returnType px.Type
blockType px.Type // Callable or Optional[Callable]
}
var CallableMetaType px.ObjectType
func init() {
CallableMetaType = newObjectType(`Pcore::CallableType`,
`Pcore::An... | types/callabletype.go | 0.580352 | 0.522872 | callabletype.go | starcoder |
package values
import (
"github.com/apache/arrow/go/v7/arrow/memory"
fluxarray "github.com/influxdata/flux/array"
"github.com/influxdata/flux/codes"
"github.com/influxdata/flux/internal/errors"
"github.com/influxdata/flux/semantic"
)
func vectorAdd(l, r Vector, mem memory.Allocator) (Value, error) {
switch l.E... | values/binary.gen.go | 0.717408 | 0.609234 | binary.gen.go | starcoder |
package cron
import "time"
// SpecCron specifies a duty cycle (to the second granularity), based on a
// traditional crontab specification. It is computed initially and stored as bit sets.
type SpecCron struct {
Second, Minute, Hour, Dom, Month, Dow uint64
}
// bounds provides a range of acceptable values (plus a m... | cron/spec.go | 0.601125 | 0.535888 | spec.go | starcoder |
package main
import "fmt"
type recommend struct {
Risk string `json:"risk,omitempty"`
Recommendation string `json:"recommendation,omitempty"`
}
func getRecommend(category, plugin string) recommend {
return recommendMap[fmt.Sprintf("%s/%s", category, plugin)]
}
// recommendMap maps risk and recommendati... | src/cloudsploit/recommend.go | 0.787196 | 0.446374 | recommend.go | starcoder |
MAix Go Bezel
https://www.sipeed.com
https://wiki.sipeed.com/en/maix/board/go.html
https://www.seeedstudio.com/Sipeed-MAix-GO-Suit-for-RISC-V-AI-IoT-p-2874.html
*/
//-----------------------------------------------------------------------------
package main
import . "github.com/deadsy/sdfx/sdf"
//-----------------... | examples/maixgo/main.go | 0.597843 | 0.492737 | main.go | starcoder |
package unittest
import (
"reflect"
"strconv"
"strings"
"code.gitea.io/gitea/models/db"
"github.com/stretchr/testify/assert"
"xorm.io/builder"
)
const (
// these const values are copied from `models` package to prevent from cycle-import
modelsUserTypeOrganization = 1
modelsRepoWatchModeDont = 2
models... | models/unittest/consistency.go | 0.639624 | 0.578329 | consistency.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.