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 jwt
import (
"github.com/urfave/cli"
)
// Command returns the cli.Command for jwt and related subcommands.
func Command() cli.Command {
return cli.Command{
Name: "jwt",
Usage: "sign and verify data using JSON Web Tokens (JWT)",
UsageText: "step crypto jwt <subcommand> [arguments] [global-flag... | command/crypto/jwt/jwt.go | 0.823257 | 0.469946 | jwt.go | starcoder |
package blackscholes
import (
"math"
"github.com/pkg/errors"
)
type OptionType rune
const (
Call = OptionType('c')
Put = OptionType('p')
Straddle = OptionType('s')
)
const InvSqrt2PI float64 = 1.0 / math.Sqrt2 / math.SqrtPi
var (
ErrNegPremium = errors.New("Negative option premium")
ErrNegP... | blackscholes.go | 0.753739 | 0.40869 | blackscholes.go | starcoder |
package collection
import (
"github.com/goal-web/contracts"
"github.com/goal-web/supports/utils"
)
func (this *Collection) Pluck(key string) contracts.Fields {
fields := contracts.Fields{}
for index, data := range this.mapData {
var name, ok = data[key].(string)
if _, exists := fields[name]; ok && !exists {
... | operate.go | 0.515132 | 0.402598 | operate.go | starcoder |
package statsd
import (
"math"
"math/rand"
"sort"
)
const defaultPercentileLimit = 1000
// // RunningStats calculates a running mean, variance, standard deviation,
// // lower bound, upper bound, count, and can calculate estimated percentiles.
// // It is based on the incremental algorithm described here:
// // ... | plugins/inputs/statsd/running_stats.go | 0.765243 | 0.549882 | running_stats.go | starcoder |
package accountmgmtclient
import (
"encoding/json"
"time"
)
// SummaryVector struct for SummaryVector
type SummaryVector struct {
Time *time.Time `json:"time,omitempty"`
Value *float64 `json:"value,omitempty"`
}
// NewSummaryVector instantiates a new SummaryVector object
// This constructor will assign default ... | accountmgmt/apiv1/client/model_summary_vector.go | 0.859546 | 0.560734 | model_summary_vector.go | starcoder |
package util
import (
"fmt"
"reflect"
"github.com/kr/pretty"
)
// IsString reports whether value is a string type.
func IsString(value interface{}) bool {
return reflect.TypeOf(value).Kind() == reflect.String
}
// IsPtr reports whether value is a ptr type.
func IsPtr(value interface{}) bool {
return reflect.T... | pkg/util/reflect.go | 0.758913 | 0.568775 | reflect.go | starcoder |
package position
import (
"strconv"
"strings"
"github.com/scancel/go-deribit/v3/models"
)
// Position is almost the same struct as in v3/models/position.go
type Position struct {
// Average price of trades that built this position
// Required: true
AveragePrice float64
// Only for options, average price in ... | v3/structures/position/position.go | 0.562417 | 0.423339 | position.go | starcoder |
package main
import (
"image"
"image/draw"
"log"
"github.com/mewkiz/pkg/imgutil"
"github.com/mewmew/pgg/grid"
"github.com/mewmew/pgg/tileset"
"github.com/mewmew/pgg/view"
)
func init() {
// Specify the width and height of grid cells.
grid.CellWidth = 48
grid.CellHeight = 48
}
func main() {
err := world()... | cmd/world/world.go | 0.635109 | 0.429071 | world.go | starcoder |
package cap1xxx
import (
"errors"
"periph.io/x/conn/v3/gpio"
)
// SamplingTime determines the time to make a single sample.
type SamplingTime uint8
// Valid SamplingTime values.
const (
S320us SamplingTime = 0
S640us SamplingTime = 1
// S1_28ms represents 1.28ms sampling time, which is the default.
S1_28ms S... | cap1xxx/cap1xxx_options.go | 0.65379 | 0.400163 | cap1xxx_options.go | starcoder |
package zkbpp
import (
"math/big"
lr "github.com/ldsec/lattigo/ring"
)
//================================================================
//Gate functions at user's disposal
//================================================================
//MpcAdd adds *big.Int x to *big.Int y and returns the result
func (c *Ci... | CRISP_go/zkbpp/circuit_gates.go | 0.776538 | 0.473414 | circuit_gates.go | starcoder |
package fan1
import "fmt"
const (
Table string = "table"
Ceiling string = "ceiling"
)
type Fan1 struct {
speed int // 1 through 5
kind string // "table", "ceiling"
color string
}
// First, we define an option type. It is a function that takes one argument, the Foo (Fan1) we are operating on.
type option ... | src/fan1/fan.go | 0.739516 | 0.40028 | fan.go | starcoder |
package arg
import (
"errors"
"fmt"
"reflect"
"strconv"
)
type Argument struct {
// common fields
Type ArgType
Value string
// named only fields
Key string
// indexed only fields
Positon int
}
type expectedArg struct {
Type ArgType
ScalarType reflect.Value
Offset int
Keys []string
Values ... | arg.go | 0.52902 | 0.450178 | arg.go | starcoder |
package gollection
func ArrayStackOf[T any](elements ...T) ArrayStack[T] {
var size = len(elements)
var stack = MakeArrayStack[T](size)
copy(stack.inner.elements, elements)
stack.inner.size = size
return stack
}
func MakeArrayStack[T any](capacity int) ArrayStack[T] {
if capacity < defaultElementsSize {
capac... | array_stack.go | 0.64131 | 0.495728 | array_stack.go | starcoder |
package parser
import (
"errors"
"github.com/Callidon/joseki/rdf"
)
// tokenURI represent a RDF URI
type tokenURI struct {
value string
}
// newTokenURI creates a new tokenURI
func newTokenURI(value string) *tokenURI {
return &tokenURI{value}
}
// Interpret evaluate the token & produce an action.
// In the cas... | parser/baseTokens.go | 0.825238 | 0.514827 | baseTokens.go | starcoder |
GoAniGiffy is a utility for converting a set of alphabetically sorted images such as video frames
grabbed from VLC or MPlayer into an animated GIF with options to Crop, Resize, Rotate & Flip the
images prior to creating the GIF
GoAniGiffy performs image operations in the order of cropping, scaling, rotating & flipping... | goanigiffy.go | 0.673192 | 0.569733 | goanigiffy.go | starcoder |
package main
import (
"fmt"
"strconv"
"bytes"
"os"
)
// Spiral is a square, 2D slice containing the numbers within the range of a particular number
// squared organized in a spiral fashion.
type Spiral [][]int
// NewSpiral returns a pointer to a Spiral made with the specified number.
func NewSpiral(... | 320-spiral_ascension/main.go | 0.829319 | 0.55917 | main.go | starcoder |
package math32
// Vector2 is a 2D vector/point with X and Y components.
type Vector2 struct {
X float32
Y float32
}
// NewVector2 creates and returns a pointer to a new Vector2 with
// the specified x and y components
func NewVector2(x, y float32) *Vector2 {
return &Vector2{X: x, Y: y}
}
// NewVec2 creates and ... | math32/vector2.go | 0.95033 | 0.850033 | vector2.go | starcoder |
package orderedmap
import "fmt"
// OrderedMap class
type OrderedMap struct {
table map[interface{}]*node
root *node
}
// NewOrderedMap creates an empty OrderedMap
func NewOrderedMap() *OrderedMap {
root := newNode(nil, nil, nil, nil) // sentinel Node
root.Next, root.Prev = root, root
om := &OrderedMap{
tabl... | orderedmap.go | 0.721939 | 0.474205 | orderedmap.go | starcoder |
package main
import (
"fmt"
"math"
"time"
)
// Vector
// ---
type Vector struct {
x, y, z float64
}
func (a Vector) Add(b Vector) Vector {
return Vector{a.x + b.x, a.y + b.y, a.z + b.z}
}
func (a Vector) Sub(b Vector) Vector {
return Vector{a.x - b.x, a.y - b.y, a.z - b.z}
}
func (a Vector) Mul(b Vector) Ve... | go/naive1.go | 0.677367 | 0.548069 | naive1.go | starcoder |
package gm
import (
"testing"
)
// VerifyNamed generates a file name based on current test name and
// the 'name' argument and compares its contents in git index (i.e.
// staged or committed if the changes are staged for the file) to
// that of of 'data' argument. The test will fail if the data
// differs. In this c... | tests/gm/gm.go | 0.511717 | 0.423339 | gm.go | starcoder |
package nn
import (
"github.com/sudachen/go-ml/fu"
"github.com/sudachen/go-ml/model"
"github.com/sudachen/go-ml/tables"
"github.com/sudachen/go-zorros/zorros"
"reflect"
)
type ModelMapFunction func(network *Network, features []string, predicts string) model.MemorizeMap
func DefaultModelMap(network *Network, fea... | nn/train.go | 0.651244 | 0.469277 | train.go | starcoder |
package plan
import (
"math"
"github.com/insionng/yougam/libraries/pingcap/tidb/ast"
)
// Plan is a description of an execution flow.
// It is created from ast.Node first, then optimized by optimizer,
// then used by executor to create a Cursor which executes the statement.
type Plan interface {
// Fields return... | libraries/pingcap/tidb/optimizer/plan/plan.go | 0.737631 | 0.421076 | plan.go | starcoder |
package lcs
import (
"fmt"
)
// Myers represents an implementation of Myer's longest common subsequence
// and shortest edit script algorithm as as documented in:
// An O(ND) Difference Algorithm and Its Variations, 1986.
type Myers struct {
a, b interface{}
na, nb int
slicer func(v interface{}, from, to int32... | algo/lcs/myers.go | 0.617167 | 0.442877 | myers.go | starcoder |
package values
import (
"reflect"
"github.com/ppapapetrou76/go-testing/types"
)
// MapValue is a struct that holds a string map value
type MapValue struct {
value interface{}
}
// Value returns the actual value of the map
func (s MapValue) Value() interface{} {
return s.value
}
// IsEqualTo returns true if the... | internal/pkg/values/map_value.go | 0.882535 | 0.579222 | map_value.go | starcoder |
// Package matrix can be used to wrap a DataFrame such that it implements the Matrix
// interface found in various external packages such as gonum.
package matrix
import (
"strconv"
"github.com/padchin/dataframe-go"
)
// Matrix replicates gonum/mat Matrix interface.
type Matrix interface {
// Dims returns the di... | math/matrix/matrix.go | 0.860252 | 0.703269 | matrix.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// RoleAssignment
type RoleAssignment struct {
Entity
// Description of the Role Assignment.
description *string
// The display or friendly name o... | models/role_assignment.go | 0.640748 | 0.422505 | role_assignment.go | starcoder |
package physical
import (
"math"
"github.com/tidepool-org/platform/data"
"github.com/tidepool-org/platform/structure"
)
const (
DistanceFeetPerMile = 5280.0
DistanceKilometersPerMile = 1.609344
DistanceMetersPerMile = 1609.344
DistanceUnitsFeet = "feet"
DistanceUnitsKilo... | data/types/activity/physical/distance.go | 0.812421 | 0.441854 | distance.go | starcoder |
package coefficient
// Pairing notes the multiplier and the powers applied to a oldformula term.
type Pairing struct {
PowerN int
PowerM int
NegateMultiplier bool
}
// GenerateCoefficientSets creates a list of locked coefficient sets (powers and multipliers)
// based on a given list of relatio... | entities/formula/coefficient/coefficientPair.go | 0.716318 | 0.527682 | coefficientPair.go | starcoder |
package cthramp
import "fmt"
// Range holds value minimum and value maximum (range) and provides the similar
// functions as a module.
type Range struct {
VMin, VMax float64
}
// AsFloat returns red, green, blue values each as float64 in range [0..1].
func (r *Range) AsFloat(val float64) (float64, float64, float64)... | cthramp.go | 0.864654 | 0.556882 | cthramp.go | starcoder |
package components
import (
"github.com/b4tman/caldav-go/icalendar/values"
"github.com/b4tman/caldav-go/utils"
"time"
)
type Event struct {
// defines the persistent, globally unique identifier for the calendar component.
UID string `ical:",required"`
// indicates the date/time that the instance of the iCalen... | icalendar/components/event.go | 0.863952 | 0.569314 | event.go | starcoder |
package mines
import (
"fmt"
"math/rand"
"strconv"
"time"
)
const (
// String to be marked for the mined cell.
Mine = "*"
// String to be marked for the Empty cell.
Empty = " "
)
// Generate board based on the input count configuration.
func GenerateBoard(rows int, columns int, mines int) [][]string {
board... | mines/minesweeper.go | 0.636805 | 0.409221 | minesweeper.go | starcoder |
package main
// Astar algorithm
type Astar struct {
graph *graph
source int
target int
hFn func(nd1, nd2 int) float32 // heuristic
frontier map[int]graphEdge // search frontier
gcost map[int]float32 // cost to some node
fcost map[int]float32 // cost to target. fcost = gcost + hcost (heuristic)
s... | astar.go | 0.703244 | 0.401365 | astar.go | starcoder |
package fieldpath
import (
"fmt"
"strconv"
"strings"
"unicode/utf8"
"github.com/crossplane/crossplane-runtime/pkg/errors"
)
// A SegmentType within a field path; either a field within an object, or an
// index within an array.
type SegmentType int
// Segment types.
const (
_ SegmentType = iota
SegmentField
... | pkg/fieldpath/fieldpath.go | 0.690037 | 0.45423 | fieldpath.go | starcoder |
package path
import (
"github.com/loki-os/go-ethernet-ip/bufferx"
"github.com/loki-os/go-ethernet-ip/types"
)
type SegmentType types.USInt
const (
SegmentTypePort SegmentType = 0 << 5
SegmentTypeLogical SegmentType = 1 << 5
SegmentTypeNetwork SegmentType = 2 << 5
SegmentTypeSymbolic SegmentType = 3 <... | path/path.go | 0.536313 | 0.522872 | path.go | starcoder |
package store
// Both the S3 and BlackPearl interfaces have a need to cache remote data and
// state in memory. This file implements a few kinds of caches.
import (
"sync"
"time"
)
// head is the structure stored in a sizecache.
type head struct {
expire time.Time
size int64 // size of item. 0 = ?, -1 = doesn'... | store/cache.go | 0.586641 | 0.417984 | cache.go | starcoder |
package hibe
import (
"crypto/rand"
"io"
"math/big"
"vuvuzela.io/crypto/bn256"
)
// Params represents the system parameters for a hierarchy.
type Params struct {
G *bn256.G2
G1 *bn256.G2
G2 *bn256.G1
G3 *bn256.G1
H []*bn256.G1
// Some cached state
Pairing *bn256.GT
}
// MasterKey represents the key fo... | core.go | 0.810404 | 0.486697 | core.go | starcoder |
package utility
import (
"reflect"
"strconv"
"strings"
"time"
)
type ReflectHelper struct {
mTargetValue reflect.Value
mTargetInterface interface{}
}
func NewReflectHelper(targetInterface interface{}) *ReflectHelper {
var ret ReflectHelper
ret.mTargetValue = reflect.Indirect(reflect.ValueOf(targetInterf... | ReflectHelper.go | 0.588061 | 0.479382 | ReflectHelper.go | starcoder |
package gunstructured
import (
"fmt"
"reflect"
"github.com/totherme/unstructured"
)
// DataTypeMatcher is a gomega matcher which tests if a given value represents
// json data of a given type.
type DataTypeMatcher struct {
typ string
}
// BeAnObject returns a gomega matcher which tests if a given value represen... | gunstructured/unstructured_type_matcher.go | 0.81582 | 0.691673 | unstructured_type_matcher.go | starcoder |
package telemetry
import (
"fmt"
"github.com/prometheus/client_golang/prometheus"
)
// Counter tracks how many times something is happening.
type Counter interface {
// Inc increments the counter with the given tags value.
Inc(tagsValue ...string)
// Add adds the given value to the counter with the given tags ... | pkg/telemetry/counter.go | 0.701406 | 0.400955 | counter.go | starcoder |
package painter
import (
"image"
"math"
"fyne.io/fyne/v2/canvas"
"github.com/srwiley/rasterx"
"golang.org/x/image/math/fixed"
)
// DrawCircle rasterizes the given circle object into an image.
// The bounds of the output image will be increased by vectorPad to allow for stroke overflow at the edges.
// The scal... | vendor/fyne.io/fyne/v2/internal/painter/draw.go | 0.792865 | 0.594875 | draw.go | starcoder |
package expression
import (
"bytes"
"github.com/dolthub/go-mysql-server/sql"
)
// CaseBranch is a single branch of a case expression.
type CaseBranch struct {
Cond sql.Expression
Value sql.Expression
}
// Case is an expression that returns the value of one of its branches when a
// condition is met.
type Case... | sql/expression/case.go | 0.667906 | 0.453806 | case.go | starcoder |
package histogramvec
import (
"sync"
"github.com/giantswarm/exporterkit/histogram"
"github.com/giantswarm/microerror"
)
type Config struct {
// BucketLimits is the upper limit of each bucket used when creating new internal Histograms.
// See https://godoc.org/github.com/prometheus/client_golang/prometheus#Histo... | vendor/github.com/giantswarm/exporterkit/histogramvec/histogramvec.go | 0.797793 | 0.428771 | histogramvec.go | starcoder |
package dataset
import (
"net/url"
"github.com/reearth/reearth-backend/pkg/value"
)
type LatLng = value.LatLng
type LatLngHeight = value.LatLngHeight
type Coordinates = value.Coordinates
type Rect = value.Rect
type Polygon = value.Polygon
type ValueType value.Type
var (
ValueTypeUnknown = ValueType(value.T... | pkg/dataset/value.go | 0.661267 | 0.514339 | value.go | starcoder |
package texture
import (
"github.com/g3n/engine/geometry"
"github.com/g3n/engine/gls"
"github.com/g3n/engine/graphic"
"github.com/g3n/engine/light"
"github.com/g3n/engine/material"
"github.com/g3n/engine/math32"
"github.com/g3n/engine/texture"
"github.com/g3n/engine/util/helper"
"github.com/g3n/g3nd/app"
"ma... | demos/texture/sphere.go | 0.639286 | 0.426262 | sphere.go | starcoder |
package duplo
import (
"github.com/nfnt/resize"
"image"
"math"
"math/rand"
"vincit.fi/image-sorter/duplo/haar"
)
// Hash represents the visual hash of an image.
type Hash struct {
haar.Matrix
// Thresholds contains the coefficient threholds. If you discard all
// coefficients with abs(coef) < threshold, you ... | duplo/hash.go | 0.829285 | 0.418519 | hash.go | starcoder |
package blockchain
import "fmt"
// BalanceSheet represents the data representation to maintain address balances.
type BalanceSheet map[string]uint
// newBalanceSheet constructs a new balance sheet for use.
func newBalanceSheet() BalanceSheet {
return make(BalanceSheet)
}
// replace updates the balance sheet for a ... | foundation/blockchain/balances.go | 0.850282 | 0.42668 | balances.go | starcoder |
package metric
type SparseCategoricalAccuracy struct {
Name string
Confidence float64
Average bool
Precision int
total float64
count float64
}
func (m *SparseCategoricalAccuracy) Init() {
if m.Precision == 0 {
m.Precision = 4
}
}
func (m *SparseCategoricalAccuracy) Reset() {
m.total = ... | metric/accuracy.go | 0.843831 | 0.409339 | accuracy.go | starcoder |
package main
import (
"fmt"
"github.com/sajari/regression"
"gonum.org/v1/gonum/floats"
)
type Model struct {
paths []string
observations []observation
regression *regression.Regression
hasTrained bool
}
type Coefficient struct {
Path string
Coefficient float64
}
type observation struct {
... | model.go | 0.807612 | 0.46478 | model.go | starcoder |
package bloom
import (
"math"
"github.com/markuskont/probstruct/pkg/hasher"
"github.com/markuskont/probstruct/pkg/util"
)
// Filter is bitvector of length m elements
// items will be hashed to integers with k non-cryptographic functions
// boolean values in corresponding positions will be flipped
type Filter stru... | pkg/bloom/bloom.go | 0.738952 | 0.534248 | bloom.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// OutlookGeoCoordinates
type OutlookGeoCoordinates struct {
// The accuracy of the latitude and longitude. As an example, the accuracy can be measured in mete... | models/microsoft/graph/outlook_geo_coordinates.go | 0.761272 | 0.506225 | outlook_geo_coordinates.go | starcoder |
package node
import (
"fmt"
"github.com/hslam/code"
)
// SetCommand represents a set command.
type SetCommand struct {
Key string
Value string
}
// Size returns the size of the buffer required to represent the data when encoded.
func (d *SetCommand) Size() int {
var size uint64
size += 11 + uint64(len(d.Key... | node/node.pb.go | 0.659515 | 0.40928 | node.pb.go | starcoder |
package block
import (
"github.com/df-mc/dragonfly/dragonfly/block/model"
"github.com/df-mc/dragonfly/dragonfly/item"
"github.com/df-mc/dragonfly/dragonfly/world"
"github.com/go-gl/mathgl/mgl64"
)
// Cake is an edible block.
type Cake struct {
noNBT
transparent
// Bites is the amount of bites taken out of the... | dragonfly/block/cake.go | 0.64131 | 0.405655 | cake.go | starcoder |
package properties
// GetExpression returns the Expression field if it's non-nil, zero value otherwise.
func (m *MultiDimensional) GetExpression() string {
if m == nil || m.Expression == nil {
return ""
}
return *m.Expression
}
// GetIndex returns the Index field if it's non-nil, zero value otherwise.
func (m *... | lottie/properties/properties-accessors.go | 0.859354 | 0.490175 | properties-accessors.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTMSketchPoint158AllOf struct for BTMSketchPoint158AllOf
type BTMSketchPoint158AllOf struct {
BtType *string `json:"btType,omitempty"`
IsUserPoint *bool `json:"isUserPoint,omitempty"`
X *float64 `json:"x,omitempty"`
Y *float64 `json:"y,omitempty"`
}
// NewBTMSketchP... | onshape/model_btm_sketch_point_158_all_of.go | 0.721939 | 0.432782 | model_btm_sketch_point_158_all_of.go | starcoder |
package datastore //nolint:dupl // it's cleaner to keep each type separate, even with duplication
import (
"encoding/binary"
"math"
"github.com/hexbee-net/errors"
"github.com/hexbee-net/parquet/parquet"
)
const sizeDouble = 8
type DoubleStore struct {
valueStore
min float64
max float64
}
// NewDoubleStore c... | datastore/double.go | 0.747432 | 0.408572 | double.go | starcoder |
package cryptoapis
import (
"encoding/json"
)
// AddressCoinsTransactionConfirmedDataItem Defines an `item` as one result.
type AddressCoinsTransactionConfirmedDataItem struct {
// Represents the specific blockchain protocol name, e.g. Ethereum, Bitcoin, etc.
Blockchain string `json:"blockchain"`
// Represents t... | model_address_coins_transaction_confirmed_data_item.go | 0.844922 | 0.420005 | model_address_coins_transaction_confirmed_data_item.go | starcoder |
package checksum
import (
"errors"
"strconv"
)
var multiplicationTable = map[int]map[int]int{
0: {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9},
1: {0: 1, 1: 2, 2: 3, 3: 4, 4: 0, 5: 6, 6: 7, 7: 8, 8: 9, 9: 5},
2: {0: 2, 1: 3, 2: 4, 3: 0, 4: 1, 5: 7, 6: 8, 7: 9, 8: 5, 9: 6},
3: {0: 3, 1: 4, 2: 0, 3... | verhoeff.go | 0.746509 | 0.729399 | verhoeff.go | starcoder |
package base
import (
"fmt"
)
// Feature types are very thin (no memory footprint) wrappers over actual data with some useful methods.
// Instead of defining the features in the metadata for a tuple/collection,
// we will put a very thin wrapper around every piece of data.
type Feature interface {
Value() inte... | base/features.go | 0.8156 | 0.514461 | features.go | starcoder |
// Package primitive contains types similar to Go primitives for BSON types can do not have direct
// Go primitive representations.
package primitive
import (
"bytes"
"fmt"
"github.com/mongodb/mongo-go-driver/bson/objectid"
)
// Binary represents a BSON binary value.
type Binary struct {
Subtype byte
Data [... | vendor/github.com/mongodb/mongo-go-driver/bson/primitive/primitive.go | 0.842215 | 0.480662 | primitive.go | starcoder |
package model
// Implementations represent a repository of information about users and their associated Preferences for items.
type DataModel interface {
// Add a particular preference for a user.
AddPreference(p Preference)
// Get user's preferences, ordered by item id
GetUserPreferences(userId uint6... | cf/model/interface.go | 0.819316 | 0.569075 | interface.go | starcoder |
package lm
import "math"
type Quat [4]float64
func QuatIdentity() (r Quat) {
r[0] = 0
r[1] = 0
r[2] = 0
r[3] = 1.0
return r
}
func (q Quat) Add(b Quat) (r Quat) {
for i := 0; i < 4; i++ {
r[i] = q[i] + b[i]
}
return r
}
func (q Quat) Sub(b Quat) (r Quat) {
for i := 0; i < 4; i++ {
r[i] = q[i] - b[i]
... | quat.go | 0.575111 | 0.526038 | quat.go | starcoder |
package game
import (
"math"
"github.com/go-gl/mathgl/mgl32"
)
// Movable is a movable Thing. eg. Monsters
type Movable struct {
*DoomThing
speed float32
collisionCB func(me *DoomThing, to mgl32.Vec2) mgl32.Vec2
}
// NewMovable creates a new movable thing
func NewMovable(x, y, angle float32, sprite strin... | game/movable.go | 0.684897 | 0.536313 | movable.go | starcoder |
package cmd
const version = "2.3.1"
const releaseNotes = `------------------------------------------------------------------------------|
| Version | Description |
|-----------|-----------------------------------------------------------------|
| 2.3.1 | Allow ... | cmd/version.go | 0.629205 | 0.416797 | version.go | starcoder |
package main
import (
"encoding/json"
"fmt"
"math/bits"
"os"
)
/*
* RegisterSet represents a subset of all registers. Each register is
* associated to a bit in the uint64. If the bit is 1, the register belongs
* to the RegisterSet and if it's 0 the register doesn't belong to the set.
* Using this representati... | cftool/main.go | 0.700485 | 0.481941 | main.go | starcoder |
package assert
import (
"fmt"
"strings"
"testing"
)
// test represents the functions to be used by Assertion.
type test interface {
Helper()
Error(...interface{})
}
// Assertion is a wrapper around testing.T.
type Assertion struct {
t test
}
// NewAssertion constructs and returns the wrapper.
func NewAssertio... | assert/assertion.go | 0.777511 | 0.616416 | assertion.go | starcoder |
package expr
import (
"fmt"
"hash/crc32"
"math"
"math/rand"
"reflect"
"strings"
)
const kEpsilon = 1e-7
type Env map[Var]interface{}
type runtimePanic string
func EvalBool(expr Expr, env Env) (value bool, err error) {
defer func() {
switch x := recover().(type) {
case nil:
// no panic
case runtimeP... | app/service/live/zeus/expr/eval.go | 0.557604 | 0.451629 | eval.go | starcoder |
package jptime
import "time"
// A JpTime represents an instant in japanese time.
type JpTime struct {
time.Time
}
// NewJpTime returns JpTime.
func NewJpTime(t time.Time) JpTime {
return JpTime{t.In(time.FixedZone("Asia/Tokyo", 9*60*60))}
}
var chineseNumerals = [...]rune{
'〇',
'一',
'二',
'三',
'四',
'五',
'六'... | jptime.go | 0.606149 | 0.419648 | jptime.go | starcoder |
package smoothspline
import (
"fmt"
"github.com/helloworldpark/gonaturalspline/bspline"
"gonum.org/v1/gonum/mat"
)
type SmoothSolver struct {
bSpline bspline.BSpline
bRegressionMat *mat.Dense
bSolvedMat *mat.Dense
bPenaltyMat *mat.Dense // scale by lambda at calculation
lambda float64
}... | smoothspline/smoothSolver.go | 0.642657 | 0.414543 | smoothSolver.go | starcoder |
package activityrings
import (
"image/color"
"io"
"math"
"github.com/fogleman/gg"
"github.com/lucasb-eyer/go-colorful"
)
// ActivityType is a type that represents one of the rings
type ActivityType int
const (
// Stand is the activity type for the Apple Watch stand goal
Stand ActivityType = iota
// Exercise... | activity-rings.go | 0.60288 | 0.434911 | activity-rings.go | starcoder |
package trisnake
import (
"fmt"
tl "github.com/JoelOtter/termloop"
tb "github.com/nsf/termbox-go"
)
var counterSnake = 10
var counterArena = 10
// Tick listens for a keypress and then returns a direction for the snake.
func (snake *Snake) Tick(event tl.Event) {
// Checks if the event is a keyevent.
if event.Ty... | game/keyinput.go | 0.625896 | 0.40157 | keyinput.go | starcoder |
package gomeasure
import (
"fmt"
"time"
)
// Stats holds the cumulative statistics for an action. All recorded samples for
// that action contribute to the stats figures. Once captures a set of stats
// will not be updated by the action is represents.
type Stats struct {
// Action is the name of the action the st... | stats.go | 0.747432 | 0.432303 | stats.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// EntitlementManagement
type EntitlementManagement struct {
Entity
// Approval stages for assignment requests.
accessPackageAssignmentApprovals []App... | models/entitlement_management.go | 0.617628 | 0.479199 | entitlement_management.go | starcoder |
package cryptoapis
import (
"encoding/json"
)
// ListTransactionsByBlockHeightRI struct for ListTransactionsByBlockHeightRI
type ListTransactionsByBlockHeightRI struct {
// Represents the index position of the transaction in the specific block.
Index int32 `json:"index"`
// Represents the hash of the block where... | model_list_transactions_by_block_height_ri.go | 0.87456 | 0.424651 | model_list_transactions_by_block_height_ri.go | starcoder |
package slice
import (
"container/heap"
"fmt"
"sort"
)
// SliceInt type
type SliceInt []int
// Set sets all element to c
func (slice SliceInt) Set(c int) {
for i := 0; i < len(slice); i++ {
slice[i] = c
}
}
// SortAsc sort ascending
func (slice SliceInt) SortAsc() {
sort.Sort(slice)
}
// SortDesc sort des... | datastructures/slice/gen-slice.go | 0.787196 | 0.400163 | gen-slice.go | starcoder |
package scanner
import (
"bytes"
)
// FindKey accepts a JSON object and returns the value associated with the key specified
func FindKey(in []byte, pos int, k []byte) ([]byte, error) {
// The start variable will be available to hold our start position for each type
// we scan through. Same for the end. And depth i... | pkg/json/ndjson/tools/jsonv1/scanner/find_key.go | 0.733165 | 0.599632 | find_key.go | starcoder |
package logging
import (
"fmt"
"io"
"strings"
)
// BreakpointLogger contains data gathered during the Knuth-Plass algorithm.
type BreakpointLogger struct {
AdjustmentRatiosTable *Table
LineDemeritsTable *Table
TotalDemeritsTable *Table
}
// NewBreakpointLogger returns a new initialized BreakpointLogger.... | pkg/knuthplass/logging/logging.go | 0.641535 | 0.450359 | logging.go | starcoder |
package interpolate
// Interpolator is a 1D interpolator. These interpolators all use caching, so
// they are not thread safe.
type Interpolator interface {
// Eval evaluates the interpolator at x.
Eval(x float64) float64
// EvalAll evaluates a sequeunce of values and returns the result. An
// optional output arra... | math/interpolate/interpolator.go | 0.78968 | 0.518912 | interpolator.go | starcoder |
package main
import (
"github.com/katydid/katydid/gen"
)
const compareStr = `
type {{.Type}}{{.CName}} struct {
V1 {{.CType}}
V2 {{.CType}}
}
func (this *{{.Type}}{{.CName}}) Eval() bool {
{{if .Eval}}{{.Eval}}{{else}}return this.V1.Eval() {{.Operator}} this.V2.Eval(){{end}}
}
func init() {
Register("{{.Name}... | funcs/funcs-gen/main.go | 0.539226 | 0.415521 | main.go | starcoder |
package main
// O(nm.8^s + ws) time | O(nm + ws) space
// where N is the width of the board, M is the height of the board
// where W is the number of words, S is the length of the longest word
func BoggleBoard(board [][]rune, words []string) []string {
trie := Trie{children: map[rune]Trie{}}
for _, word := range wor... | src/graphs/hard/boggle-board/go/recursive-trie.go | 0.575469 | 0.407982 | recursive-trie.go | starcoder |
package assertions
import (
"fmt"
"reflect"
)
// ShouldHaveSameTypeAs receives exactly two parameters and compares their underlying types for equality.
func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string {
if fail := need(1, expected); fail != success {
return fail
}
first := reflect... | vendor/github.com/smartystreets/assertions/type.go | 0.797123 | 0.637722 | type.go | starcoder |
package appkit
// #include "text_table.h"
import "C"
import (
"unsafe"
"github.com/hsiafan/cocoa/coregraphics"
"github.com/hsiafan/cocoa/foundation"
"github.com/hsiafan/cocoa/objc"
)
type TextBlock interface {
objc.Object
SetValue_Type_ForDimension(val coregraphics.Float, _type TextBlockValueType, dimension Te... | appkit/text_table.go | 0.610221 | 0.575767 | text_table.go | starcoder |
package CronScheduler
import (
"BUtils"
"time"
)
type Scheduler struct {
//Debug bool
Min string
Hour string
DayM string
DayW string
Month string
MinInt []int
HourInt []int
DayMInt []int
DayWInt []int
MonthInt []int
}
func New() *Scheduler {
return &Scheduler{
Min: "*",
Hour: "*",
... | bratok/src/Config/CronScheduler/CronScheduler.go | 0.530723 | 0.467514 | CronScheduler.go | starcoder |
package smetrics
// BytePair structs hold a pair of bytes
type BytePair struct {
firstByte byte
secondByte byte
}
//DefaultSubstitutionWeights holds weights for common misidentifications of
// letters and numbers taken from https://www.ismp.org/resources/misidentification-alphanumeric-symbols
var DefaultSubstituti... | wagner-fischer.go | 0.649023 | 0.459319 | wagner-fischer.go | starcoder |
Package featureflag implements simple feature-flagging.
Feature flags can become an anti-pattern if abused.
We should try to use them for two use-cases:
- `Preview` feature flags enable a piece of functionality we haven't yet fully baked. The user needs to 'opt-in'.
We expect these flags to be removed at some time. ... | pkg/featureflag/types.go | 0.748168 | 0.608361 | types.go | starcoder |
package wm
// DatacubeParams represent common parameters for requesting model run data
type DatacubeParams struct {
DataID string `json:"data_id"`
RunID string `json:"run_id"`
Feature string `json:"feature"`
Resolution string `json:"resolution"`
TemporalAggFunc string `json:"tempor... | pkg/wm/maas.go | 0.783285 | 0.445952 | maas.go | starcoder |
package countrymaam
import (
"bytes"
"encoding/gob"
"io"
"github.com/ar90n/countrymaam/number"
)
type Index[T number.Number, U any] interface {
Add(feature []T, item U)
Search(feature []T, n uint, maxCandidates uint) ([]Candidate[U], error)
Build() error
HasIndex() bool
Save(reader io.Writer) error
}
type ... | countrymaam.go | 0.551332 | 0.434041 | countrymaam.go | starcoder |
package msf
import (
"errors"
"fmt"
"math"
"sort"
"strconv"
)
type Splice struct {
Drive int
Length float32
}
type Ping struct {
Length float32
Extrusion float32
}
type Algorithm struct {
Ingoing int
Outgoing int
HeatFactor float32
CompressionFactor float32
Co... | msf/msf.go | 0.784236 | 0.453383 | msf.go | starcoder |
package writer
import pub "github.com/whisperverse/activitystream"
// Accept
func Accept(actor Object, object Object) Object {
return NewObject().
Type(pub.ActivityTypeAccept).
Actor(actor).
Object(object)
}
// Add
func Add(actor Object, object Object, target Object) Object {
return NewObject().
Type(pub.A... | writer/activities.go | 0.514888 | 0.477676 | activities.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// InferenceData
type InferenceData struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for seri... | models/inference_data.go | 0.806129 | 0.469277 | inference_data.go | starcoder |
package scramPkg
import (
"encoding/csv"
"fmt"
"log"
"math"
"os"
"path/filepath"
"strconv"
)
//CompareNoSplitCounts takes and alignment map and returns a map with the ref_header as key and the
//mean_se (mean and standard error) of aligned reads for that ref seq as value. Read counts are NOT split by the numb... | compare.go | 0.53777 | 0.447641 | compare.go | starcoder |
package cpe
type Relation int
const (
Disjoint = Relation(iota)
Equal
Subset
Superset
Undefined
)
// CheckDisjoint implements CPE_DISJOINT. Returns true if the set-theoretic reration between the names is DISJOINT.
func CheckDisjoint(src, trg *Item) bool {
type obj struct {
src Attribute
trg Attribute
}
... | matching.go | 0.694821 | 0.408159 | matching.go | starcoder |
package compact
import (
"github.com/dnovikoff/tempai-core/tile"
)
// Not more than 4 tiles per type by implementation
type Instances []PackedMasks
const (
instancesBits = 64
instancesInts = 4
tilesPerPack = 9
)
const _ = uint(tilesPerPack*instancesInts*4 - tile.InstanceCount)
func AllInstancesFromTo(from, to... | compact/instances.go | 0.505371 | 0.568835 | instances.go | starcoder |
package humanize
import (
"fmt"
"log"
"strings"
"time"
)
// Duration takes a `time.Duration` and converts it to the nearest-second string output
// Example output: 01:59:59
func Duration(duration time.Duration) string {
// Truncate away any non-second data
duration = duration.Truncate(1 * time.Second)
var hou... | pkg/humanize/date.go | 0.87637 | 0.535584 | date.go | starcoder |
package stats
import (
"math"
"math/rand"
)
// NormalDist is a normal (Gaussian) distribution with mean Mu and
// standard deviation Sigma.
type NormalDist struct {
Mu, Sigma float64
}
// StdNormal is the standard normal distribution (Mu = 0, Sigma = 1)
var StdNormal = NormalDist{0, 1}
// 1/sqrt(2 * pi)
const in... | stats/normaldist.go | 0.720467 | 0.598957 | normaldist.go | starcoder |
package synchronizer
import (
"math"
"time"
"github.com/relab/hotstuff/consensus"
)
// ViewDuration determines the duration of a view.
// The view synchronizer uses this interface to set its timeouts.
type ViewDuration interface {
// Duration returns the duration that the next view should last.
Duration() time.... | synchronizer/viewduration.go | 0.855202 | 0.418162 | viewduration.go | starcoder |
package api
import (
"time"
)
// Time is a wrapper around time.Time which supports correct
// marshaling to YAML and JSON. Wrappers are provided for many
// of the factory methods that the time package offers.
type Time struct {
time.Time
}
// Date returns the Time corresponding to the supplied parameters
// by w... | pkg/api/time.go | 0.829008 | 0.524943 | time.go | starcoder |
package dltree
import (
"bytes"
"math"
"strconv"
)
// A DomainLabel represents content of a label.
type DomainLabel []byte
// GetFirstLabelSize returns size in bytes needed to store first label of given domain name as a DomainLabel. Additionally the function returns position right after the label in given string ... | dltree/domain_label.go | 0.643329 | 0.478712 | domain_label.go | starcoder |
package main
import (
"math"
"github.com/go-gl/gl/v2.1/gl"
)
const (
// gridMargin controls the distance between grid points.
gridMargin = 30
// gridDestructionForce controls the amount of ripple created from entity
// destruction.
gridDestructionForce = 50
// gridMoveForce controls the amount of ripple crea... | grid.go | 0.668339 | 0.407451 | grid.go | starcoder |
package iso8601
import (
core "github.com/elimity-com/abnf/core"
"github.com/elimity-com/abnf/operators"
)
// date = datespec-full / datespec-year / datespec-month / datespec-mday / datespec-week / datespec-wday / datespec-yday
func Date(s []byte) operators.Alternatives {
return operators.Alts(
"date",
Datesp... | iso8601/date.go | 0.6488 | 0.538194 | date.go | starcoder |
package main
import "fmt"
type FullAdder func(circuit *Circuit, a, b, c, d string) (sum, carry string)
type HalfAdder func(circuit *Circuit, b, c, d string) (sum, carry string)
func FullAdderA1(circuit *Circuit, a, b, c, d string) (sum, carry string) {
circuit.AddGateCCNot(a, b, d)
circuit.AddGateCNot(b, a)
circ... | multiplier.go | 0.693265 | 0.407098 | multiplier.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.