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 parser
import (
"github.com/z-micro/ddl-parser/gen"
)
const (
_ int = iota
LongVarBinary
LongVarChar
GeometryCollection
GeomCollection
LineString
MultiLineString
MultiPoint
MultiPolygon
Point
Polygon
Json
Geometry
Enum
Set
Bit
Time
Timestamp
DateTime
Binary
VarBinary
Blob
Year
Decimal... | parser/datatype_visitor.go | 0.658966 | 0.417182 | datatype_visitor.go | starcoder |
package plaid
import (
"encoding/json"
"time"
)
// TransactionAllOf struct for TransactionAllOf
type TransactionAllOf struct {
// The channel used to make a payment. `online:` transactions that took place online. `in store:` transactions that were made at a physical location. `other:` transactions that relate t... | plaid/model_transaction_all_of.go | 0.86592 | 0.513303 | model_transaction_all_of.go | starcoder |
package views
import (
"github.com/zyedidia/tcell"
)
// BoxLayout is a container Widget that lays out its child widgets in
// either a horizontal row or a vertical column.
type BoxLayout struct {
view View
orient Orientation
style tcell.Style // backing style
cells []*boxLayoutCell
width int
height ... | views/boxlayout.go | 0.585338 | 0.409044 | boxlayout.go | starcoder |
package hamt32
import (
"fmt"
"hash/fnv"
"strconv"
"strings"
"github.com/pkg/errors"
)
// HashVal sets the numberer of bits of the hash value by being an alias to
// uint32 and establishes a type we can hang methods, like Index(), off of.
type HashVal uint32
// CalcHash deterministically calculates a randomize... | hamt32/hashval.go | 0.730386 | 0.441613 | hashval.go | starcoder |
package primitives
import (
"errors"
"github.com/phoreproject/synapse/pb"
)
// ProposerSlashing is a slashing request for a proposal violation.
type ProposerSlashing struct {
ProposerIndex uint32
ProposalData1 ProposalSignedData
ProposalSignature1 [48]byte
ProposalData2 ProposalSignedData
Propo... | primitives/slashings.go | 0.712332 | 0.412353 | slashings.go | starcoder |
package data
import "strings"
// TypeKind is the kind of a type.
type TypeKind int
const (
// IntType is an int
IntType TypeKind = iota
// StringType is a string
StringType
// BoolType is a bool
BoolType
// JSValueType is js.Value
JSValueType
// NamedType is any named type that is not an int, a string or a ... | data/types.go | 0.506347 | 0.432423 | types.go | starcoder |
package playgo
import (
"fmt"
)
// TreeNode is the definition for a binary tree type
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
// TreeHeight returns the maximum height of the btree
func TreeHeight(r *TreeNode) int {
if r == nil {
return 0
}
hl, hr := 0, 0
if r.Left != nil {
hl =... | tree/invertBtree.go | 0.770465 | 0.433981 | invertBtree.go | starcoder |
package metrics
import (
"github.com/prometheus/client_golang/prometheus"
)
// Counter is a Metric that represents a single numerical value that only ever
// goes up.
type Counter interface {
// Inc increments the counter by 1. Use Add to increment it by arbitrary
// non-negative values.
Inc()
// Add adds the g... | metrics/types.go | 0.778018 | 0.400661 | types.go | starcoder |
package fp
// MergeIntPtr takes two inputs: map[int]int and map[int]int and merge two maps and returns a new map[int]int.
func MergeIntPtr(map1, map2 map[*int]*int) map[*int]*int {
if map1 == nil && map2 == nil {
return map[*int]*int{}
}
newMap := make(map[*int]*int)
if map1 == nil {
for k, v := range map2 {... | fp/mergeptr.go | 0.656988 | 0.580709 | mergeptr.go | starcoder |
Bushing for the Box Joint Jig
https://woodgears.ca/box_joint/jig.html
*/
//-----------------------------------------------------------------------------
package main
import . "github.com/deadsy/sdfx/sdf"
//-----------------------------------------------------------------------------
// center hole
const ch_d = 0... | examples/bjj/main.go | 0.677687 | 0.411466 | main.go | starcoder |
package expression
import (
"fmt"
"math"
)
type binaryExpression struct {
first Expression
second Expression
calcFunc func(float64, float64) (float64, error)
format string
}
func (exp binaryExpression) Calculate(vals SymbolValues) (float64, error) {
var err error
firstValue, err := exp.first.Calculate... | binary_expr.go | 0.820901 | 0.549399 | binary_expr.go | starcoder |
package crds
const PolicyCRD = `
{
"group": "kyverno.io",
"names": {
"kind": "Policy",
"listKind": "PolicyList",
"plural": "policies",
"shortNames": [
"pol"
],
"singular": "policy"
},
"scope": "Namespaced",
"versions": [
{
"additionalPrinterColumns": [
{
"jsonPath": ".spec.backgrou... | pkg/kyverno/crds/policy_crd.go | 0.779993 | 0.513546 | policy_crd.go | starcoder |
package dataframe
import (
"fmt"
)
type RowIterator struct {
FloatBatching
df *DataFrame
rowOffset int
dfIndex int
subInds []int
}
// Float32Iterator is a structure to iterate over a dataframe one row at a time.
// The rows provided to the user will be slices of float32.
// Float32Iterator c... | dataframe/row_iterators.go | 0.761361 | 0.540803 | row_iterators.go | starcoder |
package level
// BlockPuzzleState describes the state of a block puzzle.
type BlockPuzzleState struct {
width int
height int
data []byte
}
// NewBlockPuzzleState returns a new instance of a block puzzle state modifier.
// The returned instance works with the passed data slice directly.
func NewBlockPuzzleState(... | ss1/content/archive/level/BlockPuzzleState.go | 0.845879 | 0.478468 | BlockPuzzleState.go | starcoder |
package azure
type ClassicVMSize struct {
MemoryInMB int
NumberOfCores int
StorageSize int
MaxNic int
}
var CLASSIC_VM_SIZES = map[string]ClassicVMSize{
"ExtraSmall": {MemoryInMB: 786, NumberOfCores: 1, StorageSize: 20, MaxNic: 1},
"Small": {MemoryInMB: 1.75 * 1024, NumberOfCores: 1,... | pkg/multicloud/azure/classic_instancesize.go | 0.556882 | 0.452596 | classic_instancesize.go | starcoder |
package embd
// I2CBus interface is used to interact with the I2C bus.
type I2CBus interface {
// ReadByte reads a byte from the given address.
ReadByte(addr byte) (value byte, err error)
// ReadBytes reads a slice of bytes from the given address.
ReadBytes(addr byte, num int) (value []byte, err error)
// WriteB... | i2c.go | 0.666062 | 0.473718 | i2c.go | starcoder |
package iris
import (
"crossvalidation"
"sync"
)
// Irises represents the set of all iris data.
type Irises []Datum
// Iterate allows looping over the Irises.
func (is Irises) Iterate() <-chan interface{} {
c := make(chan interface{})
go func() {
for _, i := range []Datum(is) {
c <- i
}
close(c)
}()
r... | src/iris/data.go | 0.749729 | 0.598459 | data.go | starcoder |
package muse
import "fmt"
// Group is a collection of timeseries keeping track of all labeled timeseries,
// All timeseries must be unique regarding their label value pairs
type Group struct {
Name string
n int // length of each timeseries in the group
index map[string][]string // map... | group.go | 0.779364 | 0.498474 | group.go | starcoder |
package underscore
import (
"reflect"
"sort"
)
type sortQuery struct {
keysRV reflect.Value
valuesRV reflect.Value
compareRV reflect.Value
}
func (this sortQuery) Len() int {
if this.keysRV.IsValid() {
return this.keysRV.Len()
}
return 0;
}
func (this sortQuery) Swap(i, j int) {
temp := this.keysRV.Inde... | vendor/github.com/ahl5esoft/golang-underscore/sort.go | 0.52074 | 0.467332 | sort.go | starcoder |
package main
var schemas = `
{
"API": {
"createDevice": {
"description": "Create one or more parking meter device. One argument, a JSON encoded event.",
"properties": {
"args": {
"description": "args are JSON encoded strings",
... | contracts/industry/parkingmeter/mbedParkingMeter.0.6/schemas.go | 0.826607 | 0.538498 | schemas.go | starcoder |
package gogo
import (
"sort"
"gonum.org/v1/gonum/graph/formats/rdf"
)
// Query represents a step in a graph query.
type Query struct {
g *Graph
terms []rdf.Term
}
// Query returns a query of the receiver starting from the given nodes.
// Queries may not be mixed between distinct graphs.
func (g *Graph) Query(... | query.go | 0.730674 | 0.488771 | query.go | starcoder |
package goparse
var (
// Lexical error codes and their strings
lexErrors = map[string]string{
"stringne": "A string cannot be empty",
"stringesc": `A string escape can must be \\, \t, \n, \', or \"`,
"rangene": "A range cannot be empty",
}
// Lexical analyzer table, where each row is compressed into a ma... | lexer_table.go | 0.501221 | 0.49408 | lexer_table.go | starcoder |
package order
import (
"sort"
"strings"
"golang.org/x/exp/constraints"
"github.com/mariomac/gostream/item"
)
// Comparator function compares its two arguments for order. Returns a negative
// integer, zero, or a positive integer as the first argument is less than,
// equal to, or greater than the second.
type C... | order/order.go | 0.821796 | 0.442094 | order.go | starcoder |
package manager
type ResourceManager interface {
/**
* Creates a {@code Namespace} resource with some preset attributes.
* <p>
* A namespace wraps the OMS resources in an abstract concept that makes it appear to the users within the namespace
* that they have their own isolated instance of the global OMS resource... | openmessaging/manager/resource_manager.go | 0.925124 | 0.513546 | resource_manager.go | starcoder |
package resp
import (
"fmt"
"strconv"
)
const (
crByte = byte('\r')
nlByte = byte('\n')
whitespaceByte = byte(' ')
stringStartByte = byte('+')
integerStartByte = byte(':')
bulkStringStartByte = byte('$')
arrayStartByte = byte('*')
errorStartByte = byte('-')
)
... | resp/parsers.go | 0.672654 | 0.476336 | parsers.go | starcoder |
package main
import (
"fmt"
"log"
"math"
"github.com/unixpickle/model3d/model2d"
"github.com/unixpickle/model3d/model3d"
"github.com/unixpickle/model3d/render3d"
"github.com/unixpickle/model3d/toolbox3d"
)
const (
Thickness = 0.15
PartSpacing = 0.01
EtchInset = 0.05
AxleRadius = 0.15
HolderRadius ... | examples/toys/fidget_spinner/main.go | 0.586168 | 0.407392 | main.go | starcoder |
package dsp
import (
"fmt"
"github.com/brettbuddin/musictheory"
)
// Valuer is the wrapper interface around the Value method; which is used in obtaining the constant value
type Valuer interface {
Float64() float64
}
// Float64 is a wrapper for float64 that implements Valuer
type Float64 float64
// Float64 retur... | dsp/values.go | 0.897634 | 0.580352 | values.go | starcoder |
package main
import (
"bufio"
"flag"
"fmt"
"math/rand"
"os"
"strconv"
"strings"
)
const (
clear marker = iota
opaque marker = iota + 10 // +10 so we can use 1-9 as bomb markers
bomb
)
type marker byte
func (m marker) String() string {
switch m {
case opaque:
return "."
case bomb:
return "B"
case ... | main.go | 0.568895 | 0.439807 | main.go | starcoder |
package sema
import "github.com/onflow/cadence/runtime/ast"
type CheckCastVisitor struct {
exprInferredType Type
targetType Type
}
var _ ast.ExpressionVisitor = &CheckCastVisitor{}
func (d *CheckCastVisitor) IsRedundantCast(expr ast.Expression, exprInferredType, targetType Type) bool {
prevInferredType := ... | runtime/sema/check_cast_visitor.go | 0.72526 | 0.455622 | check_cast_visitor.go | starcoder |
package gabor
import (
"math"
"github.com/emer/etable/etable"
"github.com/emer/etable/etensor"
"github.com/goki/mat32"
)
// gabor.Filter specifies a gabor filter function,
// i.e., a 2d Gaussian envelope times a sinusoidal plane wave.
// By default it produces 2 phase asymmetric edge detector filters.
type Filte... | gabor/gabor.go | 0.681833 | 0.524395 | gabor.go | starcoder |
package math3D
import (
"fmt"
)
type Matrix struct {
Data [][]float64
}
func NewMatrix(row []float64) *Matrix {
ret := new(Matrix)
ret.AddRow(row)
return ret
}
func (m *Matrix) AddRow(row []float64) *Matrix {
m.Data = append(m.Data, row)
return m
}
func (m *Matrix) At(row, col int) float64 {
return m.Data[... | math3D/matrix.go | 0.685739 | 0.46035 | matrix.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// WorkbookRangeView
type WorkbookRangeView struct {
Entity
// Represents the cell addresses
cellAddresses *Json;
// Returns the number of visible ... | models/microsoft/graph/workbook_range_view.go | 0.744471 | 0.476945 | workbook_range_view.go | starcoder |
package observability
import (
"time"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
)
// Pool metrics:
// 1. Connections taken
// 2. Connections closed
// 3. Connections usetime -- how long is a connection used until it is closed, discarded or returned
// 4. Connections reused
// ... | internal/observability/observability.go | 0.573201 | 0.50177 | observability.go | starcoder |
package btrank
import "github.com/algao1/basically"
// A SGraph is an undirected graph, representing the sentences within a document.
// The nodes represent individual sentences, and edges represent the connection
// between sentences.
type SGraph struct {
Nodes []*basically.Sentence
Edges [][]float64
}
// BiasedT... | btrank/btrank.go | 0.825625 | 0.604136 | btrank.go | starcoder |
package main
import (
"fmt"
"math"
"github.com/ByteArena/box2d"
"github.com/wdevore/RangerGo/api"
"github.com/wdevore/RangerGo/engine/maths"
"github.com/wdevore/RangerGo/engine/nodes/custom"
"github.com/wdevore/RangerGo/engine/rendering"
)
// QuadBoxComponent is a bunch of boxes.
type QuadBoxComponent struct ... | examples/physics/basics/fixture_properties/quadbox_component.go | 0.646795 | 0.450601 | quadbox_component.go | starcoder |
package generator
import (
"fmt"
"image"
"image/jpeg"
"math"
"os"
"runtime"
"sync"
"github.com/saesh/mandelbrot/pkg/colors"
)
// Coordinate holds real number 'Re', imaginary number 'Im' and corresponding pixel index
type Coordinate struct {
Re float64
Im float64
index int
}
// Mandelbrot defines th... | pkg/generator/mandelbrot.go | 0.669096 | 0.45847 | mandelbrot.go | starcoder |
package mph
import "sort"
// A Table is an immutable hash table that provides constant-time lookups of key
// indices using a minimal perfect hash.
type Table struct {
keys []string
level0 []uint32 // power of 2 size
level0Mask int // len(Level0) - 1
level1 []uint32 // power of 2 size >= len(ke... | mph.go | 0.60964 | 0.414366 | mph.go | starcoder |
package plaid
import (
"encoding/json"
)
// TransferAuthorization TransferAuthorization contains the authorization decision for a proposed transfer
type TransferAuthorization struct {
// Plaid’s unique identifier for a transfer authorization.
Id string `json:"id"`
// The datetime representing when the authorizat... | plaid/model_transfer_authorization.go | 0.753376 | 0.593786 | model_transfer_authorization.go | starcoder |
package sliceutil
import (
"strconv"
"strings"
)
// Atoi initializes an array of int from a string of int separated by a character
func Atoi(content string, separator string) []int {
lines := strings.Split(content, separator)
sliceOfInts := make([]int, len(lines))
for i, instruction := range lines {
sliceOfInt... | sliceutil/sliceutil.go | 0.827445 | 0.471892 | sliceutil.go | starcoder |
package types
import (
"bytes"
"sort"
"strings"
)
type operator uint8
const (
operatorEq operator = iota + 1
operatorGt
operatorGte
operatorLt
operatorLte
)
func (op operator) String() string {
switch op {
case operatorEq:
return "="
case operatorGt:
return ">"
case operatorGte:
return ">="
case ... | types/compare.go | 0.733547 | 0.478955 | compare.go | starcoder |
package clip
import (
"github.com/tidwall/geojson"
"github.com/tidwall/geojson/geometry"
)
// Clip clips the contents of a geojson object and return
func Clip(
obj geojson.Object, clipper geojson.Object, opts *geometry.IndexOptions,
) (clipped geojson.Object) {
switch obj := obj.(type) {
case *geojson.Point:
r... | internal/clip/clip.go | 0.691393 | 0.438966 | clip.go | starcoder |
package rf
import (
"fmt"
r "reflect"
)
/*
Ensures that the type has the required kind or panics with a descriptive error.
Returns the same type, allowing shorter code.
*/
func ValidateTypeKind(typ r.Type, exp r.Kind) r.Type {
act := TypeKind(typ)
if exp != act {
panic(Err{
`validating type kind`,
fmt.Er... | rf_validate.go | 0.832169 | 0.577049 | rf_validate.go | starcoder |
package check
import "fmt"
// Int64Slice is the type of a check function for a slice of int64's. It
// takes a slice of int64's and returns an error or nil if the check passes
type Int64Slice func(v []int64) error
// Int64SliceNoDups checks that the list contains no duplicates
func Int64SliceNoDups(v []int64) error ... | check/int64slice.go | 0.678966 | 0.512327 | int64slice.go | starcoder |
package generic
func IsEmpty(value interface{}) bool {
switch val := value.(type) {
case uint:
return val == 0
case uint8:
return val == 0
case uint16:
return val == 0
case uint32:
return val == 0
case uint64:
return val == 0
case int:
return val == 0
case int8:
return val == 0
case int16:
re... | generic/primitives.go | 0.514644 | 0.465266 | primitives.go | starcoder |
package pythonmixing
import (
"math"
"strings"
"github.com/kiteco/kiteco/kite-go/lang/python/pythoncompletions"
"github.com/kiteco/kiteco/kite-go/lang/python/pythonkeyword"
"github.com/kiteco/kiteco/kite-golib/kitectx"
)
// CompType defines enum to represent which model the completion is from
type CompType int
... | kite-exp/old-mixing-model/pythonmixing/features.go | 0.693888 | 0.513851 | features.go | starcoder |
Package speedtest is a client for the speedtest.net bandwidth measuring service.
This package is not affiliated, connected, or associated with speedtest.net in
any way. For information about speedtest.net, visit: http://www.speedtest.net/
This package is hosted on GitHub: http://www.github.com/johnsto/speedtest
This... | doc.go | 0.85022 | 0.712232 | doc.go | starcoder |
package xbits
// Many of the loops in this file are of the form
// for i := 0; i < len(z) && i < len(x) && i < len(y); i++
// i < len(z) is the real condition.
// However, checking i < len(x) && i < len(y) as well is faster than
// having the compiler do a bounds check in the body of the loop;
// remarkably it is e... | xbits/arith.go | 0.560493 | 0.548915 | arith.go | starcoder |
package gen
import (
"math/rand"
"time"
)
/*
Times
*/
// Time is a generator for Time values.
type Time interface {
Gen() time.Time
}
// StaticTime generates a static Time.
func StaticTime(t time.Time) Time {
return TimeFunc(func() time.Time { return t })
}
// NormalTime generates a Time from a normal distribu... | pkg/gen/time.go | 0.885365 | 0.646572 | time.go | starcoder |
package blend
import (
"image"
stdcolor "image/color"
"image/draw"
)
// porter/duff compositing modes
var (
Clear draw.Drawer = clear{}
Copy draw.Drawer = copy{}
Dest draw.Drawer = dest{}
SrcOver draw.Drawer = srcOver{}
DestOver draw.Drawer = destOver{}
SrcIn draw.Drawer = srcIn{}
DestIn d... | blend/zporterduffs.go | 0.662796 | 0.408926 | zporterduffs.go | starcoder |
// Package systestkeys defines trusted assertions and keys to use in tests.
package systestkeys
import (
"fmt"
"github.com/snapcore/snapd/asserts"
)
const (
TestRootPrivKey = `-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: GnuPG v1
<KEY>
-----END PGP PRIVATE KEY BLOCK-----
`
encodedTestRootAccount = `type: acc... | vendor/github.com/snapcore/snapd/asserts/systestkeys/trusted.go | 0.500732 | 0.430626 | trusted.go | starcoder |
package gates
var builtInFunctions = map[string]Function{
"bool": FunctionFunc(func(fc FunctionCall) Value {
var v Bool
if NewArgumentScanner(fc).Scan(&v) != nil {
return False
}
return v
}),
"int": FunctionFunc(func(fc FunctionCall) Value {
var v Int
if NewArgumentScanner(fc).Scan(&v) != nil {
r... | global.go | 0.527073 | 0.472562 | global.go | starcoder |
package exp
import (
"errors"
"strconv"
"github.com/Miha-ha/exp/parse"
)
// The Exp interface represents a tree node. There are several implementations
// of the interface in this package, but one may define custom Exp's as long as
// they implement the Eval function.
type Exp interface {
Eval(Params) bool
}
//... | exp.go | 0.717408 | 0.465266 | exp.go | starcoder |
package include
import "strings"
// Exampledagbasic created with astro dev init
var Exampledagbasic = strings.TrimSpace(`
import json
from datetime import datetime, timedelta
from airflow.decorators import dag, task # DAG and task decorators for interfacing with the TaskFlow API
@dag(
# This defines how often ... | airflow/include/basicexampledag.go | 0.622574 | 0.623234 | basicexampledag.go | starcoder |
package wonsz
import "unicode"
// camelCaseToDashedLowered converts text from
// camelCase naming convention (begin new words with capital letter except first word)
// to kebab-case naming convention (separate words with dashes).
func camelCaseToDashedLowered(text string) string {
return camelCaseToSeparatorsLowered... | names_conversion.go | 0.708414 | 0.400632 | names_conversion.go | starcoder |
package scene
import (
"github.com/eriklupander/rt/internal/pkg/config"
"github.com/eriklupander/rt/internal/pkg/mat"
"math"
)
func DoF() *Scene {
camera := mat.NewCamera(config.Cfg.Width, config.Cfg.Height, math.Pi/3)
viewTransform := mat.ViewTransform(mat.NewPoint(-1, 0.5, -3), mat.NewPoint(0, 0.5, 0), mat.New... | scene/dof.go | 0.526586 | 0.508422 | dof.go | starcoder |
package example
import (
"fmt"
"sort"
"strconv"
"time"
)
type test struct {
ID string
Description string
}
func countLoop() {
// General for loop comprised of the init statement (optional), condition expression and post statement (optional). This counts 10 times.
sum := 0
for i := 0; i < 10; i++ {
... | chase/internal/pkg/example/loops.go | 0.582254 | 0.42668 | loops.go | starcoder |
package sketchy
import (
"github.com/tdewolff/canvas"
)
type KDTree struct {
point *IndexPoint
region Rect
left *KDTree
right *KDTree
}
func NewKDTree(r Rect) *KDTree {
return &KDTree{
point: nil,
region: r,
left: nil,
right: nil,
}
}
func NewKDTreeWithPoint(p IndexPoint, r Rect) *KDTree {
r... | kdtree.go | 0.727685 | 0.427755 | kdtree.go | starcoder |
package api
import (
"encoding/json"
"time"
)
// CellLocation struct for CellLocation
type CellLocation struct {
// Average signal strength from all observations for the cell network. This is an integer value, in dBm.
AvgStrength *int32 `json:"avg_strength,omitempty"`
// Timestamp of the time when this record w... | openapi/api/model_cell_location.go | 0.855157 | 0.448607 | model_cell_location.go | starcoder |
package spatial
import (
"log"
"github.com/pmezard/gogeos/geos"
)
func (p Polygon) clipToBBox(b BBox) []Geom {
gpoly := p.geos()
if gpoly == nil {
return nil
}
var bboxLine = make([]geos.Coord, 0, 4)
for _, pt := range NewLinesFromSegments(BBoxBorders(b.SW, b.NE))[0] {
bboxLine = append(bboxLine, geos.N... | lib/spatial/clip_geos.go | 0.571886 | 0.400925 | clip_geos.go | starcoder |
package apimodel
import (
"errors"
"fmt"
"github.com/alexandre-normand/glukit/app/util"
"time"
)
const (
CALIBRATION_READ_TAG = "CalibrationRead"
)
// CalibrationRead represents a CGM read (not to be confused with a MeterRead which is a calibration value from an external
// meter
type CalibrationRead struct {
... | app/apimodel/calibration.go | 0.801548 | 0.522872 | calibration.go | starcoder |
package bandrng
import (
"math"
)
// safeAdd performs the addition operation on two uint64 integers, but panics if overflow.
func safeAdd(a, b uint64) uint64 {
if math.MaxUint64-a < b {
panic("bandrng::safeAdd: overflow addition")
}
return a + b
}
// ChooseOne randomly picks an index between 0 and len(weights)... | chain/pkg/bandrng/sampling.go | 0.747524 | 0.485966 | sampling.go | starcoder |
package machinestate
import (
"fmt"
"strings"
)
// State defines the Machines state
type State int
const (
// Unknown is a state that needs to be resolved manually
Unknown State = iota
// NotInitialzed defines a state where the machine instance does not exists
// and was not built once. It's waits to be initi... | go/src/koding/kites/kloud/machinestate/machinestate.go | 0.629775 | 0.541773 | machinestate.go | starcoder |
package holiday
import (
"encoding/json"
"log"
"time"
"github.com/marcelblijleven/holiday/easter"
)
type holiday struct {
Name string `json:"name"`
Date time.Time `json:"date"`
Official bool `json:"official"`
}
func newHoliday(name string, date time.Time, official bool) holiday {
return holi... | holiday.go | 0.679604 | 0.411702 | holiday.go | starcoder |
package gf2p16
import "github.com/akalin/gopar/gf2"
// T is an element of GF(2^16).
type T uint16
// Plus returns the sum of t and u as elements of GF(2^16), which is
// just the bitwise xor of the two.
func (t T) Plus(u T) T {
return t ^ u
}
// Minus returns the difference of t and u as elements of GF(2^16),
// w... | gf2p16/t.go | 0.597138 | 0.549882 | t.go | starcoder |
package matcher
import (
"github.com/cube2222/octosql/physical"
)
// NodeMatcher is used to match nodes on various predicates.
type NodeMatcher interface {
// Match tries to match a node filling the match. Returns true on success.
Match(match *Match, node physical.Node) bool
}
// AnyNodeMatcher matches any node.
... | physical/matcher/node.go | 0.664867 | 0.432483 | node.go | starcoder |
package check
import (
"errors"
"fmt"
"reflect"
"time"
)
func equal(x, y interface{}) bool {
return reflect.DeepEqual(x, y)
}
func isEmpty(x interface{}) bool {
if x == nil {
return true
}
v := reflect.ValueOf(x)
switch v.Kind() {
case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.Str... | reflect.go | 0.727879 | 0.477067 | reflect.go | starcoder |
package log
import (
"fmt"
"os"
"github.com/fatih/color"
)
// Infof print an info with a colored prefix.
// Errorln formats according to a format specifier and writes to standard output.
// It returns the number of bytes written and any write error encountered.
func Infof(format string, a ...interface{}) (n int, ... | backend/log/log.go | 0.64512 | 0.420243 | log.go | starcoder |
package proxy
import (
"context"
"errors"
"fmt"
"github.com/milvus-io/milvus/internal/log"
"github.com/milvus-io/milvus/internal/proto/commonpb"
"github.com/milvus-io/milvus/internal/proto/milvuspb"
"github.com/milvus-io/milvus/internal/proto/schemapb"
"github.com/milvus-io/milvus/internal/util/distance"
"gi... | internal/proxy/task_calc_distance.go | 0.602179 | 0.423518 | task_calc_distance.go | starcoder |
package store
import (
"fmt"
)
// Chunks tracks a sequence of persisted chunk files.
type Chunks struct {
PathPrefix, FileSuffix string
// ChunkSizeBytes is the size of each chunk file.
ChunkSizeBytes int
// Chunks is a sequence of append-only chunk files. An example
// usage is to hold the underlying key/va... | store/chunk.go | 0.673943 | 0.438064 | chunk.go | starcoder |
package unityai
type NavMeshObstacleShape int32
const (
kObstacleShapeCapsule NavMeshObstacleShape = iota
kObstacleShapeBox
)
type NavMeshCarveShape struct {
shape NavMeshObstacleShape // NavMeshObstacleShape
center Vector3f
extents Vector3f
xAxis Vector3f
yAxis Vector3f
zAxis Vector3f
bounds MinM... | nav_mesh_carve_types.go | 0.841923 | 0.494995 | nav_mesh_carve_types.go | starcoder |
package docs
import "github.com/swaggo/swag"
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"... | docs/docs.go | 0.545286 | 0.410166 | docs.go | starcoder |
// Package naming provides methods to parse and build compound names for variables types,
// functions, classes or other structures in source code.
package naming
import (
"strings"
"unicode"
)
const (
kebab = '-'
snake = '_'
space = ' '
blank = ""
)
// Fields splits the string s around each instance of one o... | naming.go | 0.744378 | 0.476458 | naming.go | starcoder |
package program
import (
"fmt"
"strings"
)
type stdFunction struct {
cFunc string
includeHeader string
functionBody string
dependPackages []string
dependFuncStd []string
}
func init() {
source := `
//---
// fmax returns the larger of its arguments: either x or y.
// c function : double fmax(dou... | program/cstd.go | 0.511961 | 0.408513 | cstd.go | starcoder |
package minass
import (
"fmt"
"io"
"reflect"
"runtime"
"strings"
"time"
)
// assertion contains the basic properties common to value and functional
// assertions.
type assertion struct {
t testingT
invert bool
prefix string
}
// testingT describes the behavior we require from the default testing librar... | minass.go | 0.653901 | 0.451992 | minass.go | starcoder |
package launchpad
import (
"errors"
"fmt"
"gitlab.com/gomidi/midi"
"strings"
)
// Launchpad represents a device with an input and output MIDI stream.
type Launchpad interface {
// ListenToHits listens the input stream for hits.
// It will return an error if listening initialisation failed.
ListenToHits() (<-c... | launchpad.go | 0.712932 | 0.434101 | launchpad.go | starcoder |
package ioman
import (
"container/ring"
"time"
)
const _boxcarRatio float64 = 0.1 //division of of sample rate
const _breathInFlowThreshold = 5
const _breathOutFlowThreshold = 0
type calcStore struct {
flowAverageTotal float64
flowAverageN uint64
}
type bufferStore struct {
flowMovingAverage float64
flowR... | ioman/controller.go | 0.748812 | 0.425187 | controller.go | starcoder |
package curve
import "github.com/oasisprotocol/curve25519-voi/curve/scalar"
func edwardsMultiscalarMulStraus(out *EdwardsPoint, scalars []*scalar.Scalar, points []*EdwardsPoint) *EdwardsPoint {
switch supportsVectorizedEdwards {
case true:
return edwardsMultiscalarMulStrausVector(out, scalars, points)
default:
... | curve/scalar_mul_straus.go | 0.583203 | 0.489503 | scalar_mul_straus.go | starcoder |
package game
import (
"fmt"
"time"
)
// Point represents a coordinate on the grid of the game
type Point struct {
X, Y int
}
type cell bool
func (c cell) String() string {
if c {
return "[0]"
}
return "[ ]"
}
// Game holds the game's logic and the grid of cells where the game takes place
type Game struct {... | game/game.go | 0.817137 | 0.641689 | game.go | starcoder |
package graph
import (
"sort"
)
type Vertex int
// Edge describes the edge of a weighted graph
type Edge struct {
Start Vertex
End Vertex
Weight int
}
// DisjointSetUnionElement describes what an element of DSU looks like
type DisjointSetUnionElement struct {
Parent Vertex
Rank int
}
// DisjointSetUni... | graph/kruskal.go | 0.830903 | 0.643777 | kruskal.go | starcoder |
Package geo is a library package that provide utilities to process calculations on geographical points, hashes & boundaries.
Brief
The package has a few features that might be handy, including:
- Geo-point latlng normalization.
- Geo-point 8 decimal places precision handling.
- Measuring the distance between two give... | doc.go | 0.9339 | 0.827131 | doc.go | starcoder |
package merge
import "reflect"
func Interface(data ...interface{}) reflect.Value {
if len(data) == 0 {
return reflect.Value{}
}
firstRecordV, ok := data[0].(reflect.Value)
if !ok {
firstRecordV = reflect.ValueOf(data[0])
}
if firstRecordV.Type().Kind() == reflect.Ptr {
firstRecordV = firstRecordV.Elem()
... | helper/merge/merge.go | 0.513181 | 0.403626 | merge.go | starcoder |
package gap
import (
"fmt"
"runtime"
"time"
"github.com/stiganik/gap/combination"
"github.com/stiganik/gap/selection"
"github.com/stiganik/gap/solution"
// Statically import all selection and combination algorithms to make
// them register themselves at runtime.
_ "github.com/stiganik/gap/combination/all"
... | gap.go | 0.625781 | 0.505798 | gap.go | starcoder |
package ast
//BuiltInFunctionName returns the full function name for the given builtin symbol.
//The function returns an empty string when the symbol is not a known builtin symbol.
func BuiltInFunctionName(symbol string) string {
switch symbol {
case "==":
return "eq"
case "!=":
return "ne"
case "<":
return... | relapse/ast/builtin.go | 0.703855 | 0.551332 | builtin.go | starcoder |
package model
import "fmt"
// KeyphraseType enumerates the types of keyphrase.
type KeyphraseType int
const (
// KeyphraseTypeNone represents text that is not a keyphrase.
KeyphraseTypeNone KeyphraseType = iota
// KeyphraseTypeBlue represents a blue keyphrase.
KeyphraseTypeBlue
// KeyphraseTypeGreen represent... | model/record.go | 0.652463 | 0.425009 | record.go | starcoder |
package daemon
import (
"log"
"math"
"time"
"github.com/larsth/go-gpsfix"
"github.com/larsth/go-rmsggpsbinmsg"
"github.com/larsth/rmsggpsd-gpspipe/cache"
"github.com/larsth/rmsggpsd-gpspipe/errors"
)
/*
calcBearing is a function that calculates the _inital_ bearing
from point p1(lat1, lon1) to point p2(lat2, ... | daemon/bearing.go | 0.53048 | 0.437824 | bearing.go | starcoder |
package model
import (
"bytes"
"encoding/gob"
"github.com/therfoo/therfoo/metrics"
"github.com/therfoo/therfoo/optimizers"
"github.com/therfoo/therfoo/tensor"
"io/ioutil"
"math/rand"
"os"
"sync"
"time"
)
type Model struct {
accurate func(yTrue, yEstimate *tensor.Vector) bool
lossFunction func(yTrue, y... | model/model.go | 0.677367 | 0.475179 | model.go | starcoder |
package golife
import (
"fmt"
"math/rand"
"github.com/gdamore/tcell"
)
// CellState represents the state of a cell
// 0 is dead and 1 is alive
type CellState int
const (
dead CellState = iota
alive
)
// Board represents the game board
type Board struct {
Game *Game
Grid [][]CellState
Dimension
}
// newBoa... | board.go | 0.664431 | 0.438785 | board.go | starcoder |
package guetzli_patapon
// Returns true if and only if x has a zero byte, i.e. one of
// x & 0xff, x & 0xff00, ..., x & 0xff00000000000000 is zero.
func HasZeroByte(x uint64) bool {
return ((x - 0x0101010101010101) & ^x & 0x8080808080808080) != 0;
}
// Handles the packing of bits into output bytes.
type BitWriter s... | jpeg_bit_writer.go | 0.756537 | 0.529872 | jpeg_bit_writer.go | starcoder |
package main
import (
"fmt"
"log"
"net/http"
)
type data struct {
host string
path string
}
type test struct {
name string
args data
expected string
fallback bool
status int
comment string
}
var tests = []test{
{
name: "Redirect a path record without specified v=",
args: data{
host: "n... | e2e/path/main.go | 0.505127 | 0.514156 | main.go | starcoder |
package httpref
// WellKnownPorts is the list of all known IANA reserved ports
var WellKnownPorts = References{
{
Name: "Well Known Ports",
IsTitle: true,
Summary: "The port numbers in the range from 0 to 1023 (0 to 2^10 − 1)",
Description: `The port numbers in the range from 0 to 1023 (0 to 210 − 1) are t... | well-known-ports.go | 0.802168 | 0.553686 | well-known-ports.go | starcoder |
package main
import (
"math"
)
type Texture interface {
ApplyAtHit(ii *IntersectionInfo)
}
type Pattern interface {
Transformable
Texture
PatternAt(point Tuple) Color
ColorAt(object Patternable, point Tuple) Color
}
type LocalPatternAt func(point Tuple) Color
type BasicPattern struct {
Transformer
LocalPa... | pattern.go | 0.85984 | 0.546133 | pattern.go | starcoder |
package pricecalculator
import (
ec "github.com/mjah/price-calculator/server/errors"
)
// PriceCalculator stores the price, costs, and fees
type PriceCalculator struct {
SellPrice float64 `json:"sell_price"`
FreeDeliveryPrice float64 `json:"free_delivery_price"`
Cost float64 `json:"cost"`
Fe... | server/pricecalculator/pricecalculator.go | 0.839504 | 0.433921 | pricecalculator.go | starcoder |
package element
func (e Element) AriaAtomic() (string, error) {
return e.GetAttributeString("ariaAtomic")
}
func (e Element) SetAriaAtomic(value string) error {
return e.SetAttributeString("ariaAtomic", value)
}
func (e Element) AriaAutoComplete() (string, error) {
return e.GetAttributeString("ariaAutoComplet... | element/accessibility.go | 0.761627 | 0.625038 | accessibility.go | starcoder |
package lshtree
import (
"errors"
"github.com/justinfargnoli/lshforest/pkg/hash"
)
// Trie is a prefix tree which uses a Element.hash, a []Bit, to determine the
// elements prefix
type Trie struct {
root *Node
}
// NewTrie constructs an empty Trie
func NewTrie() Trie {
return Trie{}
}
// Preorder performs a pre... | pkg/lshtree/trie.go | 0.71423 | 0.476092 | trie.go | starcoder |
package parser
import (
"regexp"
"strconv"
"strings"
)
var nDashDigitRe = regexp.MustCompile("^n(-[0-9]+)$")
// Parse `<An+B> <http://dev.w3.org/csswg/css-syntax-3/#anb>`_,
// as found in `:nth-child()
// <http://dev.w3.org/csswg/selectors/#nth-child-pseudo>`
// and related Selector pseudo-classes.
// Although ti... | css/parser/nth.go | 0.636127 | 0.419232 | nth.go | starcoder |
// Animation inspired by http://blog.golang.org/concurrency-is-not-parallelism.
// Gopher logo by <NAME>. The design is licensed under the Creative Commons 3.0 Attributions license.
// For more details see http://blog.golang.org/gopher.
package main
import (
"math/rand"
"strings"
"time"
"github.com/gopherjs/gop... | gopherjs/gophers/gophers.go | 0.531453 | 0.409929 | gophers.go | starcoder |
package main
import (
"fmt"
"log"
"math"
"runtime"
"time"
)
var (
epsilon = 32
)
func SetMemUsage(x int, y int, a float64, b float64, c float64, d float64, e float64, f float64, g float64, h float64) *[][]int8 {
var overall [][]int8
var i uint
mem := getMemoryUsage(x, y, a, b, c, d, e, f, g, h)
for ; i < ... | metrics.go | 0.552298 | 0.474327 | metrics.go | starcoder |
package telemetry
import (
"context"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
)
var (
// HistogramBounds defines a unified bucket boundaries for all histogram typed time metrics in Open Match
HistogramBounds = []float64{0, 50, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 2... | internal/telemetry/metrics.go | 0.717111 | 0.422743 | metrics.go | starcoder |
package jaeger
import (
"time"
"github.com/welcome112s/jaeger-client-go/log"
)
// SamplerOption is a function that sets some option on the sampler
type SamplerOption func(options *samplerOptions)
// SamplerOptions is a factory for all available SamplerOption's.
var SamplerOptions SamplerOptionsFactory
// Sample... | sampler_remote_options.go | 0.617513 | 0.44059 | sampler_remote_options.go | starcoder |
package schema
import "github.com/elimity-com/scim/optional"
// BinaryParams are the parameters used to create a simple attribute with a data type of "binary".
// The attribute value MUST be base64 encoded. In JSON representation, the encoded values are represented as a JSON string.
// A binary is case exact and has ... | schema/simple.go | 0.817538 | 0.520923 | simple.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.