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 |
|---|---|---|---|---|---|
Variable: 3 step of visibility
----------------------------------
Global : available accrocess package. must be declear with capital letter.
Package : available inside package. must be declear with small letter outside of function
Block : available inside block/function. must be declear with small letter inside of func... | Practice/2_Variable.go | 0.612889 | 0.409162 | 2_Variable.go | starcoder |
package api
import (
. "github.com/gocircuit/circuit/gocircuit.org/render"
)
func RenderContainerPage() string {
figs := A{
"FigMkDkr": RenderFigurePngSvg("Docker elements are similar to processes.", "mkdkr", "600px"),
}
return RenderHtml("Using containers", Render(containerBody, figs))
}
const containerBody =... | gocircuit.org/api/container.go | 0.741674 | 0.461927 | container.go | starcoder |
package gotime
import (
"time"
)
// Equalizer abstracts the Gotime comparison functions
type Equalizer func(a, b time.Time) bool
// DateEquals determines whether the date portion of two Times are equal.
// This function considers two times with the same year and the same day
// of the year to be identical, ignoring... | equality.go | 0.87452 | 0.595934 | equality.go | starcoder |
package ses
import (
"fmt"
"net/http"
)
// Session decorates the user session data with additional fields.
type Session struct {
Data
IsNew bool
IsCookie bool
}
// Data is the user defined session data that is often coupled to a specific application and store.
type Data interface {
// ID returns the sessio... | ses/token.go | 0.720762 | 0.490602 | token.go | starcoder |
package core
const jwtAPIHelp = `
# NATS Account Server JWT API HELP
This document describes the various URL paths that encompass the HTTP API for working
with JWTs on the NATS Account Server
## GET /jwt/v1/help
Returns this page.
## GET /jwt/v1/operator
If the server is configured with an operator JWT path, thi... | server/core/jwthelp.go | 0.914625 | 0.466116 | jwthelp.go | starcoder |
package toml
import (
"fmt"
"strings"
"time"
)
// LocalDate represents a calendar day in no specific timezone.
type LocalDate struct {
Year int
Month int
Day int
}
// AsTime converts d into a specific time instance at midnight in zone.
func (d LocalDate) AsTime(zone *time.Location) time.Time {
return time.... | vendor/github.com/pelletier/go-toml/v2/localtime.go | 0.884819 | 0.408985 | localtime.go | starcoder |
package types
import (
"io"
"github.com/lyraproj/issue/issue"
"github.com/lyraproj/pcore/px"
)
type TypeReferenceType struct {
typeString string
}
var TypeReferenceMetaType px.ObjectType
func init() {
TypeReferenceMetaType = newObjectType(`Pcore::TypeReference`,
`Pcore::AnyType {
attributes => {
type_str... | types/typereferencetype.go | 0.615088 | 0.44071 | typereferencetype.go | starcoder |
package opt
// --- Bool --------------------------------------------------------------------
// Bool is an optional type that wraps a bool.
type Bool struct {
isSet bool
val bool
}
// MakeBool creates a new Bool with the specified value.
func MakeBool(v bool) Bool {
return Bool{isSet: true, val: v}
}
// IsSet... | opt_gen.go | 0.936241 | 0.636353 | opt_gen.go | starcoder |
package polygon
import (
"github.com/adamcolton/geom/d2"
"github.com/adamcolton/geom/d2/curve/line"
"github.com/adamcolton/geom/d2/shape/triangle"
)
// ConcavePolygon represents a Polygon with at least one concave angle.
type ConcavePolygon struct {
concave Polygon
regular Polygon
triangles [][2]*triangle.T... | d2/shape/polygon/concave.go | 0.892761 | 0.775095 | concave.go | starcoder |
package middleware
import (
"errors"
"fmt"
"reflect"
)
// ClearFieldByType clears all fields and nested fields in an object
// that have a specified type.
func ClearFieldByType(obj interface{}, t reflect.Type) error {
value := reflect.ValueOf(obj)
if value.Kind() != reflect.Ptr {
return fmt.Errorf("non-pointe... | middleware/reflect.go | 0.674265 | 0.501709 | reflect.go | starcoder |
package solve
import (
"sync"
gs "github.com/deanveloper/gridspech-go"
)
// SolveGoals will return a channel of solutions for all the goal tiles in g
func (g GridSolver) SolveGoals() <-chan gs.TileSet {
iter := make(chan gs.TileSet, 4)
go func() {
defer close(iter)
g.solveGoals(iter)
}()
return iter
}
... | solve/goals.go | 0.548432 | 0.426799 | goals.go | starcoder |
package spt
// http://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
import (
"encoding/gob"
"math"
)
func init() {
gob.Register(SDFCircle{})
gob.Register(SDFRectangle{})
gob.Register(SDFTriangle{})
gob.Register(SDFPolygon{})
gob.Register(SDFStadium{})
gob.Register(SDFParabola{})
gob.Regist... | sdf2.go | 0.638497 | 0.452596 | sdf2.go | starcoder |
package ts
import (
"math"
"time"
"github.com/m3db/m3/src/query/graphite/stats"
)
// A Datapoint is a single data value reported at a given time
type Datapoint struct {
Timestamp time.Time
Value float64
}
// ValueIsNaN returns true iff underlying value is NaN
func (d Datapoint) ValueIsNaN() bool { return ... | src/query/graphite/ts/datapoint.go | 0.751739 | 0.427755 | datapoint.go | starcoder |
package md3
type Frame struct {
name string
min Vec3
max Vec3
origin Vec3
radius float32
}
func (f *Frame) Name() string {
return f.name
}
func (f *Frame) Min() Vec3 {
return f.min
}
func (f *Frame) Max() Vec3 {
return f.max
}
func (f *Frame) Origin() Vec3 {
return f.origin
}
func (f *Frame) Radi... | md3/model.go | 0.78789 | 0.419053 | model.go | starcoder |
package detest
import (
"fmt"
"reflect"
"sort"
)
// MapComparer implements comparison of map values.
type MapComparer struct {
with func(*MapTester)
}
// Map takes a function which will be called to do further comparisons of the
// map's contents.
func (d *D) Map(with func(*MapTester)) MapComparer {
return MapC... | pkg/detest/map.go | 0.746878 | 0.561395 | map.go | starcoder |
package trees
import (
"fmt"
)
type TreeNode struct {
Left *TreeNode
Right *TreeNode
Val int
}
func Algos() {
fmt.Println("Minimum depth of BTree: ", findMinDepthOfBTree(nil))
fmt.Println("Maximum depth of BTree: ", findMaxDepthOfBTree(nil))
fmt.Println("Is Tree symmetrical? ", isTreeSymmetrical(nil))
fmt... | trees/algos.go | 0.558568 | 0.591841 | algos.go | starcoder |
package core
// ===========================================================================
// Fmap establishes Head as Endo-Functor F<Head>.
// If a == nil this is returned directly - f is not evaluated for nil.
// If f == nil the identity function is applied.
func (a Head) Fmap(f func(Head) Head) Head {
if f ... | core/fmap.go | 0.635449 | 0.426023 | fmap.go | starcoder |
package entity
import "github.com/lquesada/cavernal/lib/g3n/engine/math32"
// RelativeCylinder is a cylinder relative to a bigger entity, e.g. a sword that's carried.
type RelativeCylinder struct{
Ahead float32
Y float32
SimpleCylinder *SimpleCylinder
}
// SimpleCylinder is a bare abstract cylinder with a certain... | entity/colision.go | 0.771801 | 0.464962 | colision.go | starcoder |
package parser
import (
"github.com/serulian/compiler/compilercommon"
)
// Parse parses the given WebIDL source into a parse tree.
func Parse(moduleNode AstNode, builder NodeBuilder, source compilercommon.InputSource, input string) AstNode {
lexer := lex(source, input)
config := parserConfig{
ignoredTokenTypes:... | webidl/parser/parser_rules.go | 0.692954 | 0.400046 | parser_rules.go | starcoder |
package geomap
import "math"
// SECTION: Internal
func toDegrees(x float64) float64 {
return x * 180.0 / math.Pi
}
func toRadians(x float64) float64 {
return x * math.Pi / 180.0
}
func min(a int, b int) int {
if a < b {
return a
} else {
return b
}
}
func euclidDistance(disl DegreeDistance, lat1 float64,... | geomap.go | 0.861057 | 0.708364 | geomap.go | starcoder |
package codes
type Code struct {
Message string `yaml:"message"`
Description string `yaml:"description"`
}
var Codes = map[string]Code{
"100": {
Message: "Continue",
Description: "The server has received the request headers, and the client should proceed to send the request body.",
},
"101": {
Mess... | pkg/codes/codes.go | 0.568536 | 0.427397 | codes.go | starcoder |
package fpc
import "time"
// Parameters define the parameters of an FPC instance.
type Parameters struct {
// The lower bound liked percentage threshold at the first round. Also called 'a'.
FirstRoundLowerBoundThreshold float64
// The upper bound liked percentage threshold at the first round. Also called 'b'.
Fir... | packages/vote/fpc/parameters.go | 0.788298 | 0.520374 | parameters.go | starcoder |
package main
import (
"errors"
"fmt"
"strconv"
"strings"
)
var (
// ErrVertexExists is returned when adding a vertex with a label that already exists.
ErrVertexExists = errors.New("vertex already exists, try a different label")
// ErrEdgeExists is returned when adding a vertex with a label that already exists... | go/graph/graph.go | 0.608245 | 0.418043 | graph.go | starcoder |
package custom
import (
"sort"
"strings"
"github.com/grafana-tools/sdk"
)
// Option represents an option that can be used to configure a custom variable.
type Option func(constant *Custom)
// ValuesMap represent a "label" to "value" map of options for a custom variable.
type ValuesMap map[string]string
func (va... | variable/custom/custom.go | 0.779238 | 0.408808 | custom.go | starcoder |
package utils
import (
"fmt"
"time"
)
// get the current time full format
func GetCurrentTimeFullFormat() string {
return TimeFullFormat(time.Now())
}
// get the current time format to second
func GetCurrentTimeFormatToSecond() string {
return TimeFormatToSecond(time.Now())
}
// get the current time format to d... | time_utils.go | 0.716715 | 0.497192 | time_utils.go | starcoder |
package expr
import (
"fmt"
"github.com/lqiz/expr/node"
"go/ast"
"go/token"
"strings"
)
type BinaryBoolExpr struct{}
type BinaryStrExpr struct{}
type BinaryIntExpr struct{}
type CallExpr struct {
fn string // one of "in_array", "ver_compare"
args []ast.Expr
}
func (b BinaryBoolExpr) Invoke(x, y node.Valu... | function.go | 0.560253 | 0.456107 | function.go | starcoder |
package util
import (
"github.com/foxcapades/go-bytify/v0/bytify"
"github.com/foxcapades/tally-go/v1/tally"
)
func ClampF32(value float32) float32 {
if value < 0 {
return 0
} else if value > 1 {
return 1
} else {
return value
}
}
func TruncateF32(value float32, precision int) float32 {
mag := IPow(10, p... | v1/internal/util/float32.go | 0.673729 | 0.436922 | float32.go | starcoder |
package toms
import (
"github.com/dreading/gospecfunc/machine"
"github.com/dreading/gospecfunc/utils"
"math"
)
// TRAN02 calculates the transport integral of order 2
// ∫ 0 to x {t^2 exp(t)/[exp(t)-1]^2 } dt
// The code uses Chebyshev expansions with the coefficients
// given to 20 decimal places
func TRAN02(XVA... | integrals/internal/toms/transport.go | 0.564939 | 0.44734 | transport.go | starcoder |
package dosa
import (
"bytes"
"sort"
"strings"
"time"
"github.com/pkg/errors"
)
// Condition holds an operator and a value for a condition on a field.
type Condition struct {
Op Operator
Value FieldValue
}
// ColumnCondition represents the condition of each column
type ColumnCondition struct {
Name ... | range_conditions.go | 0.747339 | 0.414484 | range_conditions.go | starcoder |
package tipWifi
import (
"fmt"
)
// The Radio object represents a subset of the Device configuration related
// to the Radio, whether that is Wi-Fi or Other.
type Radio struct {
Band string `json:"band"` // "Specifies the wireless band to configure the radio for. Available radio devi... | radio.go | 0.776792 | 0.422266 | radio.go | starcoder |
package node
// Node Definition for a Node.
type Node struct {
Val int
Left *Node
Right *Node
Next *Node
}
// 根据前序遍历和中序遍历得出Node
func BuildTreePreIn(preorder []int, inorder []int) *Node {
return buildTreePreIn(preorder, inorder)
}
func buildTreePreIn(preorder []int, inorder []int) *Node {
if len(inorder) == ... | node/node.go | 0.566978 | 0.49408 | node.go | starcoder |
package methodchain
import (
"strings"
)
// MethodChainMapTest is template to generate itself for different combination of data type.
func MethodChainMapTest() string {
return `
func TestMap<FTYPE>MethodChain(t *testing.T) {
expectedSquareList := []<TYPE>{1, 4, 9}
squareList := Make<FTYPE>Slice([]<TYPE>{1, 2, 3}.... | internal/template/methodchain/methodchaintest.go | 0.608245 | 0.609088 | methodchaintest.go | starcoder |
package draw2dbase
import (
"github.com/elcamino/draw2d"
)
// Liner receive segment definition
type Liner interface {
// LineTo Draw a line from the current position to the point (x, y)
LineTo(x, y float64)
}
// Flattener receive segment definition
type Flattener interface {
// MoveTo Start a New line from the ... | draw2dbase/flattener.go | 0.574275 | 0.601389 | flattener.go | starcoder |
package demod
import (
"log"
"math"
"math/cmplx"
"github.com/ktye/fft"
)
func iqToComplex128(input []byte, output []complex128) {
i := 0
for idx := range output {
output[idx] = complex(float64(input[i]), float64(input[i+1]))
output[idx] /= 127.5
output[idx] -= (1 + 1i)
i += 2
}
}
// mult calculates p... | pkg/demod/demod.go | 0.607547 | 0.400691 | demod.go | starcoder |
Package p256 Encapsulates secP256k1 elliptic curve.
*/
package p256
import (
"bytes"
"crypto/sha256"
"errors"
"math/big"
"strconv"
"github.com/tap-group/tdsvc/util"
)
var (
CURVE = S256()
)
/*
Elliptic Curve Point struct.
*/
type P256 struct {
X, Y *big.Int
}
func CommitG1(x, r *big.Int, h *P256) (*P256, e... | crypto/p256/p256.go | 0.805211 | 0.462594 | p256.go | starcoder |
package iso20022
// Details of the closing of the securities financing transaction.
type SecuritiesFinancingTransactionDetails30 struct {
// Unambiguous identification of the underlying securities financing trade as assigned by the instructing party. The identification is common to all collateral pieces (one or many... | SecuritiesFinancingTransactionDetails30.go | 0.857604 | 0.421076 | SecuritiesFinancingTransactionDetails30.go | starcoder |
package index
import (
"fmt"
"sync"
"github.com/phoreproject/synapse/chainhash"
"github.com/phoreproject/synapse/primitives"
"github.com/prysmaticlabs/go-ssz"
)
// ShardBlockNode is a block node in the shard chain.
type ShardBlockNode struct {
Parent *ShardBlockNode
BlockHash chainhash.Hash
StateRoot chai... | shard/chain/index/index.go | 0.674479 | 0.40645 | index.go | starcoder |
package util
import (
"errors"
"fmt"
"log"
"math"
"time"
"github.com/cmoscofian/meliponto/src/context"
"github.com/cmoscofian/meliponto/src/util/constants"
)
var holidays []time.Time
var today time.Time
func init() {
ctx := context.Create()
for _, d := range ctx.Holidays {
day, err := time.Parse(constant... | src/util/datetime.go | 0.678327 | 0.427277 | datetime.go | starcoder |
package quadtree
import (
"fmt"
)
// Box defines an axis-aligned bounding box using the (x,y) value of the
// bottom, left corner along with the width and height of the box.
type Box struct {
x int
y int
width int
height int
}
func (b *Box) String() string {
return fmt.Sprintf("(%d, %d), (%d, %d)", ... | quadtree/box.go | 0.917242 | 0.506958 | box.go | starcoder |
package vcl
import (
. "github.com/ying32/govcl/vcl/api"
. "github.com/ying32/govcl/vcl/types"
"unsafe"
)
type TBevel struct {
IControl
instance uintptr
// 特殊情况下使用,主要应对Go的GC问题,与LCL没有太多关系。
ptr unsafe.Pointer
}
// CN: 创建一个新的对象。
// EN: Create a new object.
func NewBevel(owner IComponent) ... | vcl/bevel.go | 0.562177 | 0.41401 | bevel.go | starcoder |
package qrad
import (
"fmt"
"math/cmplx"
)
type Matrix struct {
Elements []Complex
Width, Height int
}
func NewMatrix() *Matrix {
return &Matrix{Elements: make([]Complex, 0), Width: 0, Height: 0}
}
func NewMatrixFromElements(elements [][]Complex) *Matrix {
c := &Matrix{}
c.Height = len(elements)
c.Width = ... | matrix.go | 0.735547 | 0.541469 | matrix.go | starcoder |
package pricing
import (
"fmt"
"strconv"
"go.uber.org/zap"
"github.com/transcom/mymove/pkg/models"
)
// parseDomesticLinehaulPrices: parser for 2a) Domestic Linehaul Prices
var parseDomesticLinehaulPrices processXlsxSheet = func(params ParamConfig, sheetIndex int, logger Logger) (interface{}, error) {
// XLSX ... | pkg/parser/pricing/parse_domestic_linehaul_prices.go | 0.516352 | 0.544559 | parse_domestic_linehaul_prices.go | starcoder |
// Package windowsiana provides support in converting date timezones from
// the non-standard windows timezone format into UTC. It also provides a function
// to return a timezone-aware date given a date string and an IANA timezone
// the date can then be used as a UTC date via the .UTC() function
package windowsiana
... | windowsiana.go | 0.510985 | 0.634345 | windowsiana.go | starcoder |
package wiremock
// Types of params matching.
const (
ParamEqualTo ParamMatchingStrategy = "equalTo"
ParamMatches ParamMatchingStrategy = "matches"
ParamContains ParamMatchingStrategy = "contains"
ParamEqualToXml ParamMatchingStrategy = "equalToXml"
ParamEqualToJson ParamMatchingSt... | matching.go | 0.810104 | 0.402686 | matching.go | starcoder |
package text
//diff proposes simple and naive functions to visualize differences between
//strings. It probably is only working to have some eyecandies when loking at
//test results or to support some command line interactions.
import (
"encoding/json"
"fmt"
"strings"
"unicode"
)
type diffType int
const (
isSa... | style/text/diff.go | 0.560493 | 0.45538 | diff.go | starcoder |
package data
import (
"context"
"net/url"
"strings"
errs "github.com/ONSdigital/dp-frontend-search-controller/apperrors"
"github.com/ONSdigital/log.go/log"
)
// Filter represents information of filters selected by user
type Filter struct {
Query []string `json:"query,omitempty"`
LocaliseKeyName []st... | data/filter.go | 0.634656 | 0.403655 | filter.go | starcoder |
package camera
import (
"github.com/go-gl/mathgl/mgl32"
"github.com/wieku/danser-go/app/settings"
"github.com/wieku/danser-go/framework/math/vector"
)
const OsuWidth = 512.0
const OsuHeight = 384.0
type Rectangle struct {
MinX, MinY, MaxX, MaxY float32
}
type Camera struct {
screenRect Rectangle
projec... | app/bmath/camera/camera.go | 0.793186 | 0.53777 | camera.go | starcoder |
package expression
import (
"fmt"
"regexp"
errors "gopkg.in/src-d/go-errors.v1"
"gopkg.in/src-d/go-mysql-server.v0/sql"
)
// Comparer implements a comparison expression.
type Comparer interface {
sql.Expression
Compare(ctx *sql.Context, row sql.Row) (int, error)
Left() sql.Expression
Right() sql.Expression
}... | vendor/gopkg.in/src-d/go-mysql-server.v0/sql/expression/comparison.go | 0.825906 | 0.468851 | comparison.go | starcoder |
package common
import "math"
type Matrix3 struct {
elements [9]float32 // COLUMN-MAJOR (just like WebGL)
}
func NewMatrix3() *Matrix3 {
mtx := Matrix3{elements: [9]float32{1, 0, 0, 0, 1, 0, 0, 0, 1}} // identity matrix
return &mtx
}
func (self *Matrix3) GetElements() *[9]float32 {
return &self.elements // refer... | common/matrix3.go | 0.739328 | 0.582283 | matrix3.go | starcoder |
package ns
/**
* Configuration for encryption key resource.
*/
type Nsencryptionkey struct {
/**
* Key name. This follows the same syntax rules as other expression entity names:
It must begin with an alpha character (A-Z or a-z) or an underscore (_).
The rest of the characters must be alpha, numeric (0-9) or un... | resource/config/ns/nsencryptionkey.go | 0.701406 | 0.609146 | nsencryptionkey.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"regexp"
)
var digitRegexp = regexp.MustCompile("[0-9]+")
// FindDigits find digits in file in a consistent way
func FindDigits(filename string) []byte {
b, _ := ioutil.ReadFile(filename)
b = digitRegexp.Find(b)
c := make([]byte, len(b))
c = append(c, b...)
return digi... | slices.go | 0.53437 | 0.406597 | slices.go | starcoder |
package slice
import (
"reflect"
"sort"
"time"
"github.com/jgbaldwinbrown/go-gg/generic"
)
// CanSort returns whether the value v can be sorted.
func CanSort(v interface{}) bool {
switch v.(type) {
case sort.Interface, []time.Time:
return true
}
return generic.CanOrderR(reflect.TypeOf(v).Elem().Kind())
}
... | generic/slice/sort.go | 0.832032 | 0.490846 | sort.go | starcoder |
package questions
import (
"fmt"
"strings"
track "github.com/OscarZhou/gotrack"
)
type ValidNumber struct {
Question
Track *track.Track
}
func (e *ValidNumber) Init() {
e.No = 65
e.Title = "Valid Number"
e.FullTitle = "Valid Number"
e.URL = "https://leetcode.com/problems/jewels-and-stones"
e.Level = Level... | questions/valid_number.go | 0.569972 | 0.405596 | valid_number.go | starcoder |
package gtasa
// See https://gtasa-savegame-editor.github.io/docs/#/block16
type Block16 struct {
ProgressMade float32 `gta:"index:0"`
MaxProgress float32 `gta:"index:4"`
DistanceTravelledByFoot float32 `gta:"index:12"`
DistanceTravelledByCar float32 `gta:"index:16"`
DistanceTravelledByMotorbike float32 `gta:"in... | gtasa/block16.go | 0.712532 | 0.499207 | block16.go | starcoder |
package trace
import (
"math"
"github.com/peterstace/grayt/xmath"
)
type grid struct {
minBound xmath.Vector
maxBound xmath.Vector
stride xmath.Vector
data []*link
resolution xmath.Triple
}
func newGrid(lambda float64, objs []object) *grid {
minBound, maxBound := bounds(objs)
boundDiff := maxBou... | trace/grid.go | 0.748904 | 0.559049 | grid.go | starcoder |
package types
type MetricDefinition struct {
// Name of the metric returning the timeseries.
Metric string `json:"metric,omitempty"`
// Metric dimensions / metadata related to each timeseries.
Dimensions map[string]string `json:"dimensions,omitempty"`
}
type MetricsQueryRequest struct {
// A list of metrics quer... | service/cip/types/metrics_query.go | 0.910406 | 0.488588 | metrics_query.go | starcoder |
// Package fleetspeak provides functionality for network sensors to communicate with the Emitto
// service via Fleetspeak.
package fleetspeak
import (
"math/rand"
"time"
"github.com/golang/protobuf/ptypes"
"github.com/google/fleetspeak/fleetspeak/src/client/channel"
"github.com/google/fleetspeak/fleetspeak/src/... | source/sensor/fleetspeak/fleetspeak.go | 0.720073 | 0.400339 | fleetspeak.go | starcoder |
package typedesc
import (
"fmt"
"go/types"
"reflect"
)
// TypeDesc describes types for generating code
type TypeDesc struct {
TypeString string
Underlying string
KindTuple
}
func (d *TypeDesc) IsType(t string) bool {
return d.TypeString == t || d.Underlying == t
}
func (d *TypeDesc) IsTime() bool {
return d... | gen/typedesc/typedesc.go | 0.604049 | 0.444203 | typedesc.go | starcoder |
package crm_extensions
import (
"encoding/json"
)
// CardObjectTypeBody struct for CardObjectTypeBody
type CardObjectTypeBody struct {
// A CRM object type where this card should be displayed.
Name string `json:"name"`
// An array of properties that should be sent to this card's target URL when the data fetch re... | generated/crm_extensions/model_card_object_type_body.go | 0.617628 | 0.412294 | model_card_object_type_body.go | starcoder |
package streamstats
import (
"fmt"
"math"
)
// MomentStats is a datastructure for computing the first four moments of a stream
type MomentStats struct {
n uint64
m1 float64
m2 float64
m3 float64
m4 float64
}
// NewMomentStats returns an empty MomentStats structure with no values
func NewMomentStats() *Moment... | momentstats.go | 0.901476 | 0.621168 | momentstats.go | starcoder |
package renderer
import (
"image"
"math"
"github.com/nightmarlin/murum/layout"
"github.com/nightmarlin/murum/provider"
)
// Renderer allows for murum image rendering
type Renderer interface {
// Render draws an image with the bounding rectangle rect filled with the pattern defined in the
// layout.L. Each L se... | renderer/renderer.go | 0.790975 | 0.511961 | renderer.go | starcoder |
package main
import (
"errors"
"os"
"time"
)
// Pin represents a single pin, which can be used either for reading or writing
type Pin struct {
Number uint
direction direction
f *os.File
}
// NewInput opens the given pin number for reading. The number provided should be the pin number known by the kernel
func... | watchdog/io.go | 0.812942 | 0.402979 | io.go | starcoder |
package aoc2020
import (
"fmt"
"strconv"
goutils "github.com/simonski/goutils"
)
/*
--- Part Two ---
For some reason, the sea port's computer system still can't communicate with your ferry's docking program. It must be using version 2 of the decoder chip!
A version 2 decoder chip doesn't modify the values being ... | app/aoc2020/aoc2020_14_part2.go | 0.607197 | 0.626895 | aoc2020_14_part2.go | starcoder |
package textile
import (
"image"
)
// Textile represents every cell in a display as a string that ideally renders
// as a single glyph. Like images and slices, the textile is a thin header
// that can share allocated memory with other textiles.
type Textile struct {
Strings []string
Stride int
Rect image.Rect... | textile/textile.go | 0.892557 | 0.648341 | textile.go | starcoder |
package graphql
import "github.com/vektah/gqlparser/v2/ast"
var __Schema = &ast.Definition{
Kind: ast.Object,
Description: "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscrip... | internal/graphql/introspection.go | 0.568416 | 0.643357 | introspection.go | starcoder |
package types
import (
"bytes"
"encoding/binary"
"encoding/hex"
"fmt"
"io"
"strings"
"github.com/apex/log"
)
const (
/** B-Tree Table of Contents Constants **/
BTREE_TOC_ENTRY_INCREMENT = 8
BTREE_TOC_ENTRY_MAX_UNUSED = (2 * BTREE_TOC_ENTRY_INCREMENT)
/** B-Tree Node Constants **/
BTREE_NODE_SIZE_DEFAUL... | types/btree.go | 0.582729 | 0.408395 | btree.go | starcoder |
package gorgonia
import (
"fmt"
"hash"
"log"
"math"
"github.com/chewxy/hm"
"github.com/chewxy/math32"
"gorgonia.org/tensor"
)
type Reduction uint
const (
ReductionMean Reduction = iota
ReductionSum
)
// CTCLoss - implements the ctc loss operation
// This is the implementation of the following paper: http... | op_ctc_loss.go | 0.728748 | 0.429968 | op_ctc_loss.go | starcoder |
package dht
import (
denet "github.com/hlandau/degoutils/net"
"github.com/hlandau/goutils/clock"
"time"
)
// DHT configuration.
type Config struct {
// IP address to listen on. If blank, a port is chosen randomly.
Address string `usage:"Address to bind on"`
// Number of peers that DHT will try to find for ever... | dht-config.go | 0.757705 | 0.414366 | dht-config.go | starcoder |
package live
import (
"encoding/binary"
"encoding/json"
"math"
"github.com/edwingeng/live/internal"
)
var (
Nil Data
)
type Data struct {
v interface{}
}
func (d Data) ToBool() bool {
return d.v.(*internal.Data).N == 1
}
func (d Data) ToInt() int {
return int(d.v.(*internal.Data).N)
}
func (d Data) ToInt... | data.go | 0.572006 | 0.502136 | data.go | starcoder |
package cmd
import "github.com/MakeNowJust/heredoc"
func mergeConflictHelp(name string) string {
helpTexts := map[string]string{
"*model.Bookmark": `Bookmarks are set for each publication (i.e. a Watchtower issue or a Bible translation)
and can be placed at ten different „slots“ (the colors you see in the app). ... | cmd/help.go | 0.64646 | 0.564459 | help.go | starcoder |
package als
import (
"errors"
"fmt"
"math"
"math/rand"
"sort"
"strconv"
. "github.com/skelterjohn/go.matrix"
)
var (
NA = math.NaN()
)
func errcheck(err error) {
if err != nil {
fmt.Printf("Error occured: %v", err)
}
}
// Create the W matrix for the ALS algorithm..
// Returns binary matrix indicating p... | plugins/data/learn/ml-filters-als/als.go | 0.661923 | 0.557905 | als.go | starcoder |
package main
import (
"github.com/kindermoumoute/adventofcode/pkg/execute"
)
var tests = execute.TestCases{
{
`light red bags contain 1 bright white bag, 2 muted yellow bags.
dark orange bags contain 3 bright white bags, 4 muted yellow bags.
bright white bags contain 1 shiny gold bag.
muted yellow bags contain 2 ... | 2020/day7/puzzle.go | 0.58676 | 0.70124 | puzzle.go | starcoder |
// Package lifecycle implements a simple helper object to make
// synchronization of worker goroutines a little less verbose.
package lifecycle
// Stdlib imports.
import (
"sync"
"time"
)
// Lifecycle provides a simple way to coordinate the lifecycle of
// worker goroutines that loop infinitely
type Lifecycl... | lib/lifecycle/lifecycle.go | 0.764979 | 0.401189 | lifecycle.go | starcoder |
package ast
import (
"fmt"
"strconv"
)
// Constants for different types
// of numbers
const (
IntType = iota
FloatType
)
// NumberValue is for any value that
// can stand in place of a number
// Current implementers:
// Number
// NumberSymbol
type NumberValue interface {
GetDataType() int
GetIntValue() i... | ast/number.go | 0.756537 | 0.452294 | number.go | starcoder |
package url
import (
"unicode"
"github.com/bits-and-blooms/bitset"
)
type PercentEncodeSet struct {
bs *bitset.BitSet
allBelow int32
}
func NewPercentEncodeSet(allBelow int32, bytes ...uint) *PercentEncodeSet {
p := &PercentEncodeSet{allBelow: allBelow, bs: bitset.New(0x7f)}
for _, b := range bytes {
... | url/codesets.go | 0.553023 | 0.526525 | codesets.go | starcoder |
package shapes
import (
"fmt"
"image"
"image/color"
"image/draw"
"image/jpeg"
"image/png"
"math"
"os"
"path/filepath"
"runtime"
"strings"
)
func clamp(minimum, x, maximum int) int {
switch {
case x < minimum:
return minimum
case x > maximum:
re... | src/shaper3/shapes/shapes.go | 0.878835 | 0.538377 | shapes.go | starcoder |
package messages
/*
This go file centralizes error log messages so we have them all in one place.
Although having the names of the consts as the error code (i.e CSPFK014E) and not as a descriptive name (i.e InvalidStoreType)
can reduce readability of the code that raises the error, we decided to do so for the foll... | pkg/log/messages/error_messages.go | 0.532425 | 0.529446 | error_messages.go | starcoder |
package main
import (
"fmt"
"reflect"
)
type Slicer interface {
EqualTo(i int, x interface{}) bool
Len() int
}
type IntSlice []int
func (slice IntSlice) EqualTo(i int, x interface{}) bool {
return slice[i] == x.(int)
}
func (slice IntSlice) Len() int { return len(slice) }
func IntIndexSlicer(i... | src/contains/contains.go | 0.828211 | 0.526586 | contains.go | starcoder |
package shp
import (
"github.com/cpmech/gosl/chk"
"github.com/cpmech/gosl/gm"
"github.com/cpmech/gosl/utl"
)
// GetShapeNurbs returns a shape structure based on NURBS
// Note: span are the local ids of control points in NURBS defining elements
// Note: FaceLocalVerts does not work for internal surfaces; only th... | shp/nurbs.go | 0.558086 | 0.465934 | nurbs.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTPStatementLoop277 struct for BTPStatementLoop277
type BTPStatementLoop277 struct {
BTPStatement269
BtType *string `json:"btType,omitempty"`
Body *BTPStatement269 `json:"body,omitempty"`
SpaceAfterLoopType *BTPSpace10 `json:"spaceAfterLoopType,omitempty"`
}
// NewB... | onshape/model_btp_statement_loop_277.go | 0.693369 | 0.441252 | model_btp_statement_loop_277.go | starcoder |
package colors
import (
"encoding/hex"
"github.com/jung-kurt/gofpdf"
)
const Red, Amber, Green, Blue, DarkBlue, Black, Gray, LightGray, MiddleLightGray, MoreLightGray, VeryLightGray, ExtremeLightGray, Pink, LightPink = "#CC0000", "#AF780E", "#008000", "#000080", "#000060", "#000000", "#444444", "#666666", "#999999"... | colors/colors.go | 0.747432 | 0.401629 | colors.go | starcoder |
package mingru
import (
"database/sql"
)
// GetLastInsertIDWithError checks a given error before calling GetLastInsertID.
func GetLastInsertIDWithError(result sql.Result, err error) (int64, error) {
if err != nil {
return 0, err
}
return result.LastInsertId()
}
// GetLastInsertIDUint64WithError checks a given ... | errors.go | 0.638835 | 0.416144 | errors.go | starcoder |
package setop
import (
"bytes"
"fmt"
"strings"
)
// RawSourceCreator is a function that takes the name of a raw skippable sortable set, and returns a Skipper interface.
type RawSourceCreator func(b []byte) Skipper
// SetOpResultIterator is something that handles the results of a SetExpression.
type SetOpResult... | setop/set_op.go | 0.705379 | 0.72227 | set_op.go | starcoder |
package eff
type shape interface {
Drawable
SetBackgroundColor(Color)
BackgroundColor() Color
Clear()
DrawPoint(Point, Color)
DrawPoints([]Point, Color)
DrawColorPoints([]Point, []Color)
DrawLine(Point, Point, Color)
DrawLines([]Point, Color)
StrokeRect(Rect, Color)
StrokeRects([]Rect, Color)
StrokeCo... | shape.go | 0.88565 | 0.716429 | shape.go | starcoder |
package vals
import (
"fmt"
"math"
"math/big"
"strconv"
"strings"
)
// Num is a stand-in type for int, *big.Int, *big.Rat or float64. This type
// doesn't offer type safety, but is useful as a marker.
type Num interface{}
// NumSlice is a stand-in type for []int, []*big.Int, []*big.Rat or []float64.
// This typ... | pkg/eval/vals/num.go | 0.594904 | 0.418994 | num.go | starcoder |
package atest
import (
"github.com/cadmean-ru/amphion/common/a"
"github.com/cadmean-ru/amphion/engine"
"testing"
)
var eng *engine.AmphionEngine
type TestingDelegate func(e *engine.AmphionEngine)
type SceneTestingDelegate func(e *engine.AmphionEngine, testScene, testObject *engine.SceneObject)
// RunEngineTest ... | atest/engineTest.go | 0.658198 | 0.41117 | engineTest.go | starcoder |
// +build !amd64 gccgo appengine nacl
package poly1305
import "encoding/binary"
const (
msgBlock = uint32(1 << 24)
finalBlock = uint32(0)
)
// Sum generates an authenticator for msg using a one-time key and returns the
// 16-byte result. Authenticating two different messages with the same key allows
// an atta... | gosnippet/vendor/github.com/aead/poly1305/poly1305_ref.go | 0.666497 | 0.442456 | poly1305_ref.go | starcoder |
package govaluate
import (
"fmt"
"math"
"strconv"
"strings"
"unicode"
)
// ExprNodePrinter is an output builder for ExprNode.
// Use AppendString or AppendNode from custom handlers to append to output.
type ExprNodePrinter struct {
nodeHandler func(ExprNode, *ExprNodePrinter) error
output strings.Builder
... | Print.go | 0.701611 | 0.49109 | Print.go | starcoder |
package geojson
import "github.com/mmadfox/geojson/geometry"
// SimplePoint ...
type SimplePoint struct {
geometry.Point
}
// NewSimplePoint returns a new SimplePoint object.
func NewSimplePoint(point geometry.Point) *SimplePoint {
return &SimplePoint{Point: point}
}
// ForEach ...
func (g *SimplePoint) ForEach(i... | simplepoint.go | 0.899652 | 0.744285 | simplepoint.go | starcoder |
package linear
import (
"fmt"
"spell"
"spell/scorer"
)
type vectorScore struct {
*scorer.Vector
score float64
}
type LearnProgress struct {
VectorSystemsCount int
Step int
BestScore int
RelaxingCount int
}
type Learner struct {
*scorer.Vectoriser
learnProgress LearnProgress
}... | spell/scorer/linear/stochastic_learner.go | 0.586996 | 0.527742 | stochastic_learner.go | starcoder |
package diceware
// loadDiceString returns a JSON string containing the diceware wordlist.
// this function is listed separately, because it is veeeeery long.
func loadDiceString() []byte {
return []byte(`{"11111": "abacus",
"11112": "abdomen",
"11113": "abdominal",
"11114": "abide",
"11115": "abiding",
"11116": "abi... | diceware_dicedbstring.go | 0.712432 | 0.433202 | diceware_dicedbstring.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// OnPremisesAgent
type OnPremisesAgent struct {
Entity
// List of onPremisesAgentGroups that an onPremisesAgent is assigned to. Read-only. Nullable.
... | models/on_premises_agent.go | 0.597373 | 0.432303 | on_premises_agent.go | starcoder |
package game
import (
"fmt"
"strconv"
)
// Board with Grid and Player
type Board struct {
Grid [][]int
Player int
SelectedCube Cube
}
// Coords x and y
type Coords struct {
X int
Y int
}
// Cube with Coords and value
type Cube struct {
Coords Coords
Value int
}
// GetBoardWithNoCubeSelected... | advisor-go/src/quixo/game/game.go | 0.594434 | 0.47792 | game.go | starcoder |
package genmai
import (
"database/sql"
"errors"
"fmt"
"strings"
"time"
)
// Dialect is an interface that the dialect of the database.
type Dialect interface {
// Name returns a name of the dialect.
// Return value must be same as the driver name.
Name() string
// Quote returns a quoted s.
// It is for a co... | dialect.go | 0.788665 | 0.407805 | dialect.go | starcoder |
package xorfilter
import (
"math"
)
// XorN offers a configurable false-positive probability
type XorN struct {
XorFilterCommon
// Bits in 9..32
Bits int
// Fingerprints should be serialized as keeping the low XorN.Bits of each entry
Fingerprints []uint32
}
// PopulateN creates an xor filter with tunable num... | xorN.go | 0.616705 | 0.485722 | xorN.go | starcoder |
package mino
import (
"sort"
)
// A Transform operates over a data source and calculates "some"
// value for it.
type Transform interface {
Transform(analyzer *Analyzer, data Collection) (result interface{}, err error)
}
type DataPoint struct {
Value float64
Weight float64
}
// Sorting function for data points... | types.go | 0.816113 | 0.544256 | types.go | starcoder |
// Package deque implements a deque using a circular array.
package deque
const (
initialQueueSize = 4
)
// T is the type of queues.
type T struct {
contents []interface{}
// Boundary cases.
// o If full, size==len and fx==bx
// o If empty, size==0 and fx==bx
// o On initialization, contents=nil, size==0, fx=... | x/ref/runtime/internal/lib/deque/deque.go | 0.625667 | 0.468243 | deque.go | starcoder |
package staticarray
import (
"github.com/influxdata/flux/array"
"github.com/influxdata/flux/memory"
"github.com/influxdata/flux/semantic"
)
type uints struct {
data []uint64
alloc *memory.Allocator
}
func UInt(data []uint64) array.UInt {
return &uints{data: data}
}
func (a *uints) Type() semantic.Type {
ret... | internal/staticarray/uint.go | 0.609292 | 0.474753 | uint.go | starcoder |
package functions
import (
"fmt"
"math"
"reflect"
"strconv"
"strings"
)
var FuncToString = Function{
Description: `Converts the given argument to a string.`,
Parameters: Parameters{{
Name: "in",
}},
}.MustWithFunc(func(in ...interface{}) string {
return fmt.Sprint(in)
})
var FuncParseInt = Function{
Desc... | template/functions/conversations.go | 0.750187 | 0.553747 | conversations.go | starcoder |
package digraph
// Index provides indexed access to all nodes and edges of an
// underlying graph. The index is lazily constructed to include all
// nodes and edges. Index is constructed by accessible nodes and
// edges, thus the underlying graph should not be modified.
type Index struct {
g *Graph
allNodes ... | index.go | 0.848314 | 0.697802 | index.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.