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 godata
import "sort"
type FloatSeries struct {
data []float64
}
func NewFloatSeries(data ...float64) FloatSeries {
return FloatSeries{data: data}
}
func (f FloatSeries) Append(elements ...float64) FloatSeries {
changed := f.Clone()
changed.data = append(changed.data, elements...)
return f
}
func (f Fl... | floatseries.go | 0.780244 | 0.520009 | floatseries.go | starcoder |
package f64
import (
"context"
"log"
)
// DenseMatrix a dense matrix
type DenseMatrix struct {
c int // number of rows in the sparse matrix
r int // number of columns in the sparse matrix
data [][]float64
}
// NewDenseMatrix returns a DenseMatrix
func NewDenseMatrix(r, c int) *DenseMatrix {
return newMa... | f64/denseMatrix.go | 0.849472 | 0.631367 | denseMatrix.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTMSketchPoint158 struct for BTMSketchPoint158
type BTMSketchPoint158 struct {
BTMSketchGeomEntity5
BtType *string `json:"btType,omitempty"`
IsUserPoint *bool `json:"isUserPoint,omitempty"`
X *float64 `json:"x,omitempty"`
Y *float64 `json:"y,omitempty"`
}
// NewBTM... | onshape/model_btm_sketch_point_158.go | 0.72487 | 0.473109 | model_btm_sketch_point_158.go | starcoder |
// lint:file-ignore S1001 // want "Disabling of linter must have an annotation associated with it. Please visit https://transcom.github.io/mymove-docs/docs/dev/contributing/code-analysis/Guide-to-Static-Analysis-Annotations-for-Disabled-Linters"
//RA Summary: [linter] - [linter type code] - [Linter summary] // want "... | testdata/src/ato/staticcheck.go | 0.61057 | 0.492188 | staticcheck.go | starcoder |
package assign
import (
"reflect"
)
// Source represents any value which can be assigned to a Go value.
type Source interface {
// Kind is the reflection based kind of the type.
Kind() reflect.Kind
// Elem is the contained value of the pointer or interface.
Elem() Source
// FieldByName retrieves the field value... | source.go | 0.713731 | 0.407982 | source.go | starcoder |
package yelp
// A SearchResult is returned from the Search API. It includes
// the region, the total number of results, and a list of matching businesses.
// The business objects returned by this query are shallow - they will not include
// deep results such as reviews.
type SearchResult struct {
Region Re... | vendor/github.com/JustinBeckwith/go-yelp/yelp/business.go | 0.694406 | 0.455017 | business.go | starcoder |
package core
import (
"github.com/nuberu/engine/event"
"github.com/nuberu/engine/math"
)
const (
defaultMatrixAutoUpdate bool = true
)
var (
object3IdGenerator = new(IdGenerator)
)
type CameraObject interface {
IsCamera() bool
}
type Object3 struct {
id Id
Name string
... | core/object3.go | 0.729327 | 0.449574 | object3.go | starcoder |
package math32
// Line3 represents a 3D line segment defined by a start and an end point.
type Line3 struct {
start Vector3
end Vector3
}
// NewLine3 creates and returns a pointer to a new Line3 with the
// specified start and end points.
func NewLine3(start, end *Vector3) *Line3 {
l := new(Line3)
l.Set(start... | math32/line3.go | 0.915231 | 0.707758 | line3.go | starcoder |
package vulpes
import (
"math"
"sort"
)
const (
// LOSS means the game is over and the current player has lost the game.
LOSS = iota
// TIE means the game is over and ended in a tie.
TIE
// WIN means the game is over and the current player has won the game.
WIN
// UNFINISHED means the game is not yet over.
... | vulpes.go | 0.562898 | 0.416915 | vulpes.go | starcoder |
package values
import (
"reflect"
"sort"
)
// SliceValue is a struct that holds a string slice value.
type SliceValue struct {
value interface{}
}
// IsEqualTo returns true if the value is equal to the expected value, else false.
func (s SliceValue) IsEqualTo(expected interface{}) bool {
if !IsSlice(expected) ||... | internal/pkg/values/slice_value.go | 0.846387 | 0.631694 | slice_value.go | starcoder |
package synth
import (
"math"
)
// Form holds the 6 parameters needed to for the superformula to
// create supershapes. Form uses the the superformula to generate
// points in both 2D and 3D. See:
// https://en.wikipedia.org/wiki/Superformula
// http://paulbourke.net/geometry/supershape/
type Form struct {
M... | synth/form.go | 0.879147 | 0.673217 | form.go | starcoder |
package internal
import (
"time"
"github.com/influxdata/telegraf"
)
type Measurement struct {
Name string
Fields map[string]interface{}
Tags map[string]string
T []time.Time
}
// StoreAccumulator store in memory all value pushed by AddFields, AddGauge...
// All type (fields, gague, counter) are proces... | inputs/internal/store_accumulator.go | 0.709523 | 0.431405 | store_accumulator.go | starcoder |
package distance
import (
"errors"
"math"
)
// DistMetric returns a function for calculating the distance between two vectors.
// Any entries that are zero in both vectors are ignored and vectors must be equal
// length. Default metric is euclidean.
func DistMetric(metric string) func(x []float64, y []float64) (dis... | distance/distmetric.go | 0.74055 | 0.624122 | distmetric.go | starcoder |
package accumulator
import (
"context"
"sync"
"time"
)
// Accumulator stores data on an interval and allows you to access it.
type Accumulator struct {
ctx context.Context
sync.RWMutex
Label string // used to identify the owner of an accumulator.
Samples []*Sample
acc int64
total int64 // total numbe... | pkg/accumulator/accumulator.go | 0.826362 | 0.413714 | accumulator.go | starcoder |
package bimap
import "sync"
// BiMap is a bi-directional hashmap that is thread safe and supports immutability
type BiMap struct {
s sync.RWMutex
immutable bool
forward map[interface{}]interface{}
inverse map[interface{}]interface{}
}
// NewBiMap returns a an empty, mutable, biMap
func NewBiMap() *Bi... | bimap.go | 0.757346 | 0.508788 | bimap.go | starcoder |
package circuit
import "github.com/heustis/tsp-solver-go/model"
// CompletedCircuit provides a no-op represenatation of a circuit, for use once an algorithm completes its computation.
// This allows for circuits with large memory requirements or circular references to be deleted without deleting the best computed cir... | circuit/completed.go | 0.892234 | 0.640397 | completed.go | starcoder |
package scene
import (
"math"
"sync"
"github.com/carlosroman/aun-otra-ray-tracer/go/internal/object"
"github.com/carlosroman/aun-otra-ray-tracer/go/internal/ray"
)
func NewCamera(hSize, vSize int, from, to, vup ray.Vector) (c Camera, err error) {
return newCamera(hSize, vSize, math.Pi/2, ray.ViewTransform(from,... | go/internal/scene/camera.go | 0.813905 | 0.484136 | camera.go | starcoder |
package gorm
import (
"crypto/sha1"
"fmt"
"reflect"
"regexp"
"strconv"
"strings"
"time"
"unicode/utf8"
)
type oracle struct {
commonDialect
}
func init() {
RegisterDialect("oci8", &oracle{})
}
func (oracle) GetName() string {
return "oci8"
}
func (oracle) Quote(key strin... | dialects_oracle_oci8.go | 0.540924 | 0.412057 | dialects_oracle_oci8.go | starcoder |
package miner
import (
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/util/math"
"github.com/filecoin-project/specs-actors/actors/util/smoothi... | actors/builtin/miner/monies.go | 0.637144 | 0.412619 | monies.go | starcoder |
package merge
type Interface interface {
Merge(dst interface{}, src interface{}) (interface{}, bool)
}
type detectType uint
const (
noneType detectType = iota
mapType
arrayType
)
type JSONMerge struct{}
func NewJSONMerge() Interface {
return &JSONMerge{}
}
func (m *JSONMerge) Merge(dst interface{}, src inter... | internal/merge/merge.go | 0.584745 | 0.411998 | merge.go | starcoder |
package config
import (
"log"
"github.com/iotexproject/iotex-core/blockchain/genesis"
)
// Codename for height upgrades
const (
Pacific = iota
Aleutian
Bering
Cook
Dardanelles
Daytona
Easter
Fairbank
)
type (
// HeightName is codename for height upgrades
HeightName int
// HeightUpgrade lists heights ... | config/heightupgrade.go | 0.678859 | 0.405566 | heightupgrade.go | starcoder |
package binson
import (
"fmt"
)
// Returns a new empty binson array.
func NewBinsonArray() *BinsonArray {
a := BinsonArray([]field{})
return &a
}
// Return length of binson array.
func (a *BinsonArray) Size() int{
return len(*a);
}
// Removes a given field if it exists.
func (a *BinsonArray) Remove(... | binson_array.go | 0.669637 | 0.442576 | binson_array.go | starcoder |
package types
import (
"io"
"reflect"
"github.com/lyraproj/pcore/px"
)
type NotUndefType struct {
typ px.Type
}
var NotUndefMetaType px.ObjectType
func init() {
NotUndefMetaType = newObjectType(`Pcore::NotUndefType`,
`Pcore::AnyType {
attributes => {
type => {
type => Optional[Type],
value... | types/notundeftype.go | 0.570092 | 0.423577 | notundeftype.go | starcoder |
package vector
import (
"fmt"
"math"
"github.com/downflux/go-geometry/epsilon"
)
type D int
const (
// AXIS_X is a common alias for the first dimension.
AXIS_X D = iota
// AXIS_Y is a common alias for the second dimension.
AXIS_Y
// AXIS_Z is a common alias for the third dimension.
AXIS_Z
// AXIS_W is ... | nd/vector/vector.go | 0.843766 | 0.515071 | vector.go | starcoder |
package egc
// Det2x2 -- computes the determinant of a 2x2 matrix.
func Det2x2(a [2][2]QQ) QQ {
m01 := a[0][0].Mul(a[1][1]).Sub(a[1][0].Mul(a[0][1]))
return m01
}
// Det3x3 -- computes the determinant of a 3x3 matrix.
func Det3x3(a [3][3]QQ) QQ {
m01 := a[0][0].Mul(a[1][1]).Sub(a[1][0].Mul(a[0][1]))
m02 := a[0][... | dets.go | 0.684159 | 0.571109 | dets.go | starcoder |
package htm
import (
"fmt"
"azul3d.org/lmath.v1"
)
// Tree represents a node contained with an HTM.
type Tree struct {
Index int
Level int
Indices [3]int
Children [4]int
Parent int
}
func (t Tree) Empty() bool {
return t.Level == 0
}
func (t Tree) Equals(x Tree) bool {
return t.Index == x.Index &... | htm.go | 0.737442 | 0.588505 | htm.go | starcoder |
Coding Exercise #1
Using a composite literal declare and initialize a slice of type string with 3 elements.
Iterate over the slice and print each element in the slice and its index.
Are you stuck? Do you want to see the solution for this exercise? Click https://play.golang.org/p/CRPEvm-A31h.
Coding Exercise #2
Th... | more_code/coding_tasks/slices/tasks.go | 0.872944 | 0.69653 | tasks.go | starcoder |
package ast
import (
"os"
"github.com/fabulousduck/smol/errors"
"github.com/fabulousduck/smol/lexer"
)
//Expression contains nodes in RPN form
type Expression struct {
Tokens []lexer.Token
}
func createExpression(nodes []lexer.Token) Expression {
expression := Expression{Tokens: nodes}
return expression
}
//... | ast/expression.go | 0.704668 | 0.464659 | expression.go | starcoder |
package apimodel
import (
"errors"
"fmt"
"github.com/alexandre-normand/glukit/app/util"
"time"
)
const (
GLUCOSE_READ_TAG = "GlucoseRead"
// Units
MMOL_PER_L = "mmolPerL"
MG_PER_DL = "mgPerDL"
UNKNOWN_GLUCOSE_MEASUREMENT_UNIT = "Unknown"
)
type GlucoseUnit strin... | app/apimodel/glucoseread.go | 0.732113 | 0.400808 | glucoseread.go | starcoder |
package parse
import (
"fmt"
"github.com/orange-lang/orange/pkg/ast"
"github.com/orange-lang/orange/pkg/lexer"
"github.com/orange-lang/orange/pkg/token"
)
type parser struct {
stream lexer.LexemeStream
}
// Parse takes a lexeme stream and returns an AST. Consumes the entire
// lexeme stream, and returns a list... | pkg/parse/parser.go | 0.705684 | 0.400515 | parser.go | starcoder |
package lm
import "errors"
// WordCount is a count of a corresponding path
type WordCount = uint32
// TrieIterator is a callback that is called for each path of the given trie
type TrieIterator = func(path Sentence, count WordCount) error
// CountTrie represents a data structure for counting ngrams.
type CountTrie ... | pkg/lm/count_trie.go | 0.770896 | 0.566738 | count_trie.go | starcoder |
package blockchain
import (
"bytes"
"crypto/sha256"
"encoding/gob"
"encoding/hex"
"encoding/json"
"github.com/samuelvl/blockchain-lab/pkg/pow"
)
// Difficulty of the hashcash algorithm to compute the nonce. The closer to 256,
// the harder to find a nonce.
const Difficulty uint = 16
// Block represents the si... | pkg/blockchain/block.go | 0.832373 | 0.405478 | block.go | starcoder |
package main
import "fmt"
/*
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You may assume no duplicates in the array.
Example 1:
Input: [1,3,5,6], 5
Output: 2
Example 2:
Input: [1,3,5,6], 2
Output: 1
Examp... | Programs/035Search Insert Position/035Search Insert Position.go | 0.568176 | 0.656032 | 035Search Insert Position.go | starcoder |
// This file implements operations in Rq, a univariate quotient polynomial
// ring over GF(q) with modulus x^761 + 4590*x + 4590. It is a port of the
// public domain, C reference implementation.
package rq
import (
"github.com/companyzero/sntrup4591761/rq/modq"
"github.com/companyzero/sntrup4591761/rq/vector"
)
... | rq/rq.go | 0.733165 | 0.44089 | rq.go | starcoder |
package wow
// ScoreCalculator contains methods for calculating a character's score related to specific
// properties of a character.
type ScoreCalculator interface {
Calculate(Character) int
}
// -- Aggregate score calculator.
// AggregateScoreCalculator ties together other score calculators and provides a single ... | step2/modules/wow/score-calculator.go | 0.825062 | 0.560914 | score-calculator.go | starcoder |
package special
import "github.com/aegoroff/godatastruct/rbtree"
// maxTree represents Red-black search binary tree
// that stores only limited size of max possible values
type maxTree struct {
// tree contains underlying Red-black search binary tree
tree rbtree.RbTree
size int64
}
func (t *maxTree) Root() *rbtre... | rbtree/special/fixed_tree.go | 0.827096 | 0.439687 | fixed_tree.go | starcoder |
package redis
import (
"plutus/vault"
)
// RefreshUserToGroups refreshes the User to Group and the Group to User mappings in the database
func (c *Client) RefreshUserToGroups(data *vault.Data) error {
namespace := data.Namespace
c.deleteAllWithAnyPrefixes(namespace, PrefixUsrToVgr, PrefixVgrToUsr)
groups := dat... | redis/refresh.go | 0.679391 | 0.429908 | refresh.go | starcoder |
package api
import (
. "github.com/gocircuit/circuit/gocircuit.org/render"
)
func RenderNamePage() string {
return RenderHtml("Using name servers", Render(nameBody, nil))
}
const nameBody = `
<h2>Using name servers</h2>
<p>Name server elements are an easy way of creating and configuring
lightweight DNS server d... | gocircuit.org/api/name.go | 0.653348 | 0.571557 | name.go | starcoder |
package prefix_sums
/*
A DNA sequence can be represented as a string consisting of the letters A, C, G and T, which correspond to the types
of successive nucleotides in the sequence. Each nucleotide has an impact factor, which is an integer. Nucleotides of
types A, C, G and T have impact factors of 1, 2, 3 and 4, resp... | prefix-sums/GenomicRangeQuery.go | 0.86053 | 0.967349 | GenomicRangeQuery.go | starcoder |
package ride
func selectFunctionsByName(v int, enableInvocation bool) (func(string) (rideFunction, bool), error) {
switch v {
case 1, 2:
return functionsV2, nil
case 3:
return functionsV3, nil
case 4:
return functionsV4, nil
case 5:
if enableInvocation {
return functionsV5, nil
}
return expressionF... | pkg/ride/selectors.go | 0.560734 | 0.579906 | selectors.go | starcoder |
package tegola
// IsPointEqual will check to see if the two tegola points are equal.
func IsPointEqual(p1, p2 Point) bool {
if p1 == nil || p2 == nil {
return p1 == p2
}
return p1.X() == p2.X() && p1.Y() == p2.Y()
}
// IsPoint3Equal will check to see if the two 3d tegola points are equal.
func IsPoint3Equal(p1, ... | isequal.go | 0.749821 | 0.810704 | isequal.go | starcoder |
package streams
// GetPipelineQueryParams represents valid query parameters for the GetPipeline operation
// For convenience GetPipelineQueryParams can be formed in a single statement, for example:
// `v := GetPipelineQueryParams{}.SetVersion(...)`
type GetPipelineQueryParams struct {
// Version : version
Versio... | services/streams/param_generated.go | 0.897662 | 0.530115 | param_generated.go | starcoder |
package routing
import (
"fmt"
"net"
"strings"
"github.com/scionproto/scion/go/lib/addr"
)
// singleIAMatcher matches other ISD-AS numbers based on a single ISD-AS.
type singleIAMatcher struct {
IA addr.IA
}
// Match matches the input ISD-AS if both the ISD and the AS number are the same
// as the one of the ... | go/pkg/gateway/routing/matchers.go | 0.646237 | 0.506408 | matchers.go | starcoder |
package palindrome
func multiplier(n int) int {
// Calculate 10^n efficiently
f := 10
m := 1
if n < 0 {
return -1
}
for n > 0 {
if n & 1 != 0 {
m *= f
}
f *= f
n >>= 1
}
return m
}
func Construct(l, m, x, c int) int {
if x == 0 {
x = multiplier(c)
}
if m >= 0 {
// Construct a palindrom... | gen.go | 0.669313 | 0.510192 | gen.go | starcoder |
package search
import (
"github.com/christat/search"
"time"
"github.com/christat/gost/queue"
"sort"
)
// Beam implements Beam Search.
// On each execution step, the most promising set of descendants (i.e. with the lowest Heuristic value) are enqueued, discarding the others (hence not keeping them in the queue).
/... | informed/beam.go | 0.731442 | 0.428652 | beam.go | starcoder |
package array
import (
"fmt"
"errors"
"reflect"
"github.com/golodash/structure/internal"
)
type (
Array[T any] struct {
Values []*T
size int
functions map[string]any
}
)
func New[T any](functions map[string]any) (*Array[T], error) {
a := &Array[T]{
Values: []*T{},
size: 0,
functions: map[string]a... | array/array.go | 0.590661 | 0.53127 | array.go | starcoder |
package tachymeter
import (
"math"
"sort"
"sync/atomic"
)
// Calc summarizes Tachymeter sample data and returns it in the form of a *Metrics.
func (m *Tachymeter) Calc() *Metrics {
metrics := &Metrics{}
if atomic.LoadUint64(&m.count) == 0 {
return metrics
}
m.Lock()
metrics.Samples = int(math.Min(float64(... | plugins/data/collection/stats/tachymeter/snapshot.go | 0.762778 | 0.467818 | snapshot.go | starcoder |
package mlpack
/*
#cgo CFLAGS: -I./capi -Wall
#cgo LDFLAGS: -L. -lmlpack_go_gmm_train
#include <capi/gmm_train.h>
#include <stdlib.h>
*/
import "C"
import "gonum.org/v1/gonum/mat"
type GmmTrainOptionalParam struct {
DiagonalCovariance bool
InputModel *gmm
KmeansMaxIterations int
MaxIterations int
... | gmm_train.go | 0.732018 | 0.458106 | gmm_train.go | starcoder |
package draw
import (
"fmt"
"math"
"regexp"
"strings"
"github.com/Alquimista/eyecandy/utils"
)
type Filter func(m string) string
type Shape struct {
draw string
}
// M Draw Move
func (d Shape) M(x, y int) *Shape {
d.draw += fmt.Sprintf(`m %d %d `, x, y)
return &d
}
// N Draw Move (no closing)
func (d Shap... | draw/draw.go | 0.729134 | 0.464537 | draw.go | starcoder |
package euler
import (
"fmt"
"math"
)
const gravity = 9.8
type Ref struct {
// Relative Height [m]
Z float64
// Relative Pressure [Pa]
P float64
}
func New(r Ref, f Fluid) *Model {
p := Pipe{z: r.Z}
m := Model{pipes: []Pipe{p}, fluid: f, startP: r.P}
return &m
}
type Model struct {
startP float64
pipes ... | model.go | 0.782787 | 0.412708 | model.go | starcoder |
package geom
import (
"bufio"
"bytes"
"fmt"
"io"
"strconv"
"strings"
)
const Empty = "EMPTY"
func NewGeometryFromWKT(wkt string) (*Geometry, error) {
d := &WKT{}
return d.Decode(wkt)
}
func (x *Geometry) FromWKT(wkt string) error {
if x != nil {
g, err := NewGeometryFromW... | go/pkg/mojo/geom/wkt.go | 0.78838 | 0.419588 | wkt.go | starcoder |
package trie
import "strings"
// Digitizer
type Digitizer interface {
// Base returns the base for the Digitizer.
Base() int
// IsPrefixFree returns true if and only if the Digitizer guarantees that no element is a prefix of another.
IsPrefixFree() bool
// NumDigitsOf returns the number of digi... | trie/digitizer.go | 0.859472 | 0.638117 | digitizer.go | starcoder |
package types
import "github.com/antihax/optional"
type Baselines struct {
// The average daily amount of continuous logs this child org is expected to ingest, in GB.
ContinuousIngest int64 `json:"continuousIngest,omitempty"`
// The average daily amount of frequent logs this child org is expected to ingest, in GB.... | service/cip/types/organization_types.go | 0.723016 | 0.563138 | organization_types.go | starcoder |
package data
import (
"encoding/binary"
"math"
"math/big"
"reflect"
"unsafe"
"github.com/factset/go-drill/internal/rpc/proto/common"
"github.com/factset/go-drill/internal/rpc/proto/exec/shared"
"google.golang.org/protobuf/proto"
)
//go:generate go run ../cmd/tmpl -data numeric.tmpldata vector_numeric.gen.go.... | internal/data/data_vector.go | 0.572723 | 0.581184 | data_vector.go | starcoder |
package onshape
import (
"encoding/json"
)
// BTExportTessellatedEdgesBody890AllOf struct for BTExportTessellatedEdgesBody890AllOf
type BTExportTessellatedEdgesBody890AllOf struct {
BtType *string `json:"btType,omitempty"`
Edges *[]BTExportTessellatedEdgesEdge1364 `json:"edges,omitempty"`
}
// NewBTExportTessella... | onshape/model_bt_export_tessellated_edges_body_890_all_of.go | 0.652131 | 0.533884 | model_bt_export_tessellated_edges_body_890_all_of.go | starcoder |
package main
import (
"log"
)
/**
题目:https://leetcode-cn.com/problems/longest-consecutive-sequence/
最长连续序列
给定一个未排序的整数数组 nums ,找出数字连续的最长序列(不要求序列元素在原数组中连续)的长度。
请你设计并实现时间复杂度为O(n) 的算法解决此问题。
示例 1:
输入:nums = [100,4,200,1,3,2]
输出:4
解释:最长数字连续序列是 [1, 2, 3, 4]。它的长度为 4。
示例 2:
输入:nums = [0,3,7,2,5,8,4,6,0,1]
输出:9
提示:
0 ... | datastruct/hash/leetcodeQuestion/longestConsecutive/longestConsecutive.go | 0.520984 | 0.516413 | longestConsecutive.go | starcoder |
package testing
import (
"testing"
)
const (
notEqual = "assertion failed\ngot :\t>[\t%v\t]<\nwant :\t>[\t%v\t]<"
)
func assert(t *testing.T, method func() bool,
context string, args ...interface{}) {
t.Helper()
if !method() {
if len(args) > 0 {
t.Errorf(context, args...)
} else {
t.Errorf(context)
... | testing/assert.go | 0.531939 | 0.765922 | assert.go | starcoder |
package couchdb
//--------------------
// DESIGN
//--------------------
// Design provides convenient access to a design document.
type Design interface {
// ID returns the ID of the design.
ID() string
// Language returns the language for views and shows.
Language() string
// Language sets the language for v... | couchdb/design.go | 0.725357 | 0.448004 | design.go | starcoder |
package iso20022
// Execution of a redemption order.
type RedemptionExecution5 struct {
// Unique and unambiguous identifier for an order, as assigned by the instructing party.
OrderReference *Max35Text `xml:"OrdrRef"`
// Unique and unambiguous investor's identification of an order. This reference can typically b... | RedemptionExecution5.go | 0.820757 | 0.481332 | RedemptionExecution5.go | starcoder |
package component
import (
"github.com/juan-medina/goecs"
"reflect"
)
// Bullet is a component for our bullets
type Bullet struct{}
// Block is a component for a map blocks
type Block struct {
C, R int
ClearOn float32
Text *goecs.Entity
}
// FloatText is a component for a floating text
type FloatText str... | game/component/components.go | 0.531209 | 0.497864 | components.go | starcoder |
package kindergarten
import (
"fmt"
"sort"
"strings"
)
// plants maps the diagram plant code to a plant name.
var plants = map[rune]string{
'C': "clover",
'G': "grass",
'R': "radishes",
'V': "violets",
}
// Garden represents the garden containing students' plants.
type Garden struct {
studentRowPosition map[... | go/exercism/go/kindergarten-garden/kindergarten_garden.go | 0.671794 | 0.403449 | kindergarten_garden.go | starcoder |
package exploits
import (
"git.gobies.org/goby/goscanner/goutils"
)
func init() {
expJson := `{
"Name": "Elasticsearch Remote Code Execution CVE-2015-1427",
"Description": "The Groovy script engine before Elasticsearch 1.3.8 and the Groovy script engine in 1.4.x before 1.4.3 allow remote attackers to bypass the... | 2015/CVE-2015-1427/poc/goby/Elasticsearch_Remote_Code_Execution_CVE_2015_1427.go | 0.553747 | 0.435241 | Elasticsearch_Remote_Code_Execution_CVE_2015_1427.go | starcoder |
package binvox
import (
"fmt"
"log"
"strings"
gl "github.com/fogleman/fauxgl"
)
const (
g0 neighborBitMap = 1 << iota // Classical Marching Cubes grid points
g1
g2
g3
g4
g5
g6
g7
)
var (
verbose = false
)
type neighborBitMap byte
type manifoldMap map[Key]neighborBitMap
func (b *BinVOX) ManifoldMesh(... | binvox/manifold.go | 0.662906 | 0.533944 | manifold.go | starcoder |
package httpexpect
import (
"fmt"
)
type JSONArrayType = []interface{}
type JSONArray struct {
expectation *Expectation
path string
value []interface{}
}
func (a *JSONArray) Len() *JSONNumber {
return &JSONNumber{
expectation: a.expectation,
path: fmt.Sprintf("%s.$len", a.path),
value: flo... | httpexpect/json_array.go | 0.620507 | 0.542742 | json_array.go | starcoder |
package civ
import (
"fmt"
"strconv"
)
type Table struct {
header Row
// Maximum length of each columns data including both header
// and contents
maxLen []int
// A list of column number that is disabled to display
disabledCols []int
// Table contents excluding header
contents []Row
// View setting, st... | table.go | 0.673406 | 0.41739 | table.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// SkillProficiency
type SkillProficiency struct {
ItemFacet
// Contains categories a user has associated with the skill (for example, personal, professio... | models/skill_proficiency.go | 0.590543 | 0.414721 | skill_proficiency.go | starcoder |
package gift
import (
"image"
"image/color"
"image/draw"
)
type pixel struct {
r, g, b, a float32
}
type imageType int
const (
itGeneric imageType = iota
itNRGBA
itNRGBA64
itRGBA
itRGBA64
itYCbCr
itGray
itGray16
itPaletted
)
type pixelGetter struct {
it imageType
bounds image.Rectangle
imag... | vendor/github.com/disintegration/gift/pixels.go | 0.611614 | 0.459197 | pixels.go | starcoder |
package orbit
import (
"fmt"
)
type OrbitParameter struct {
MU *float64 // G*M earth MU
CentralBodyRadius *float64 // // earth radius
// Apogee defines furthest point to the central body
Apogee *float64 // km
// Perigee defines closest point to the central body
Perigee *float64 // km
// Se... | server/mathf/orbit/orbit-parameter.go | 0.747984 | 0.627552 | orbit-parameter.go | starcoder |
package keras2go
import "math"
/**
* 1D (temporal) Padding.
*
* :param output: tensor to store padded output data.
* :param input: tensor to pad.
* :param fill: value to fill in padded areas.
* :param pad: Array[2] of how many rows to pad. Order is {before dim 1, after dim 1}.
*/
func k2c_pad1d(output *K2c_tensor, i... | convolution_layers.go | 0.862439 | 0.70864 | convolution_layers.go | starcoder |
package geometry
import (
"math"
)
const (
curveRecursionLimit = 32
)
// Bezier cubic curve defined by 2 control points
// the first and last point defined respectivly the start and the end of the curve
type CubicCurve [4]Vector
// Subdivide the curve into 2 CubicCurve that is equivalent
func (c CubicCurve) Subdi... | geometry/curve.go | 0.758153 | 0.526099 | curve.go | starcoder |
package vecmath
import (
"fmt"
"math"
"github.com/etic4/vecmath/maths"
)
//Vec2 Représente un vecteur 2D
type Vec2 struct {
X float64
Y float64
}
//NewVector crée un nouveau vecteur
func NewVector(x, y float64) Vec2 {
return Vec2{x, y}
}
//FromPolar retourne un vecteur à partir de coordonées polaires
// para... | vecmath.go | 0.748904 | 0.713881 | vecmath.go | starcoder |
package gofa
// Vector/Matrix Library
// 1. Initialization (4)
// Operations involving p-vectors and r-matrices (3)
/*
Zp Zero a p-vector.
Returned:
p [3]float64 zero p-vector
*/
func Zp(p *[3]float64) {
p[0] = 0.0
p[1] = 0.0
p[2] = 0.0
}
/*
Zr Initialize an r-matrix to the null matrix.
Retur... | vml.go | 0.722037 | 0.612136 | vml.go | starcoder |
package ast
import (
"github.com/lyraproj/goni/goni/state"
"github.com/lyraproj/goni/util"
)
type stateNode struct {
abstractNode
state state.Type
}
func (s *stateNode) AppendTo(w *util.Indenter) {
w.NewLine()
w.Append(`state: `)
s.state.AppendString(w)
}
func (s *stateNode) StateType() state.Type {
return ... | ast/statenode.go | 0.576542 | 0.458046 | statenode.go | starcoder |
package math3d32
import "fmt"
type Matrix3 []float32
func MakeMatrix3V(v []float32, rowMajor bool) Matrix3 {
if rowMajor {
// transform the data to OpenGl format
return Matrix3{v[0], v[3], v[6], v[1], v[4], v[7], v[2], v[5], v[8]}[:]
}
return Matrix3{v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8]}[:]
}
... | math3d32/matrix3.go | 0.751375 | 0.530662 | matrix3.go | starcoder |
package terminal
import (
"context"
"github.com/searKing/golang/go/error/exception"
"github.com/searKing/golang/go/util/class"
"github.com/searKing/golang/go/util/optional"
"github.com/searKing/golang/go/util/spliterator"
)
/**
* An operation in a stream pipeline that takes a stream as input and produces
* a... | go/container/stream/op/terminal/op.go | 0.860677 | 0.431704 | op.go | starcoder |
package btree
import "github.com/xtmono/gods/containers"
func assertIteratorImplementation() {
var _ containers.ReverseIteratorWithKey = (*Iterator)(nil)
}
// Iterator holding the iterator's state
type Iterator struct {
tree *Tree
node *Node
entry *Entry
position position
}
type position byte
cons... | trees/btree/iterator.go | 0.755096 | 0.431045 | iterator.go | starcoder |
package validation
import (
validation "github.com/Randyshu2018/fabric/core/handlers/validation/api"
)
// State defines interaction with the world state
type State interface {
// GetStateMultipleKeys gets the values for multiple keys in a single call
GetStateMultipleKeys(namespace string, keys []string) ([][]byte,... | core/handlers/validation/api/state/state.go | 0.594787 | 0.521837 | state.go | starcoder |
// Package run implements a custom change that applies to a sequence
// of array elements.
package run
import (
"github.com/dotchain/dot/changes"
"github.com/dotchain/dot/refs"
)
// Run implements a custom change type which applies a provided
// inner change to a run of items in an array. This is particularly
// ... | changes/run/run.go | 0.794505 | 0.490724 | run.go | starcoder |
package peplos
import (
"fmt"
"github.com/gocql/gocql"
"github.com/maraino/go-mock"
)
func metadata(s *gocql.Session, keyspace string) (*gocql.KeyspaceMetadata, error) {
var m, err = s.KeyspaceMetadata(keyspace)
if err != nil {
return nil, err
}
if !m.DurableWrites && m.Name == keyspace && m.StrategyClass... | session.go | 0.732687 | 0.403273 | session.go | starcoder |
package maps
import (
"bufio"
"bytes"
"image"
"image/draw"
"image/jpeg"
"image/png"
"io/ioutil"
"os"
"github.com/JayBusch/go-mapbox/lib/base"
)
// LocationToTileID converts a lat/lon location into a tile ID
func LocationToTileID(loc base.Location, level uint64) (uint64, uint64) {
return MercatorLocationToT... | lib/maps/util.go | 0.746231 | 0.459501 | util.go | starcoder |
package query
import (
"database/sql"
"fmt"
"strings"
)
// SelectStrings executes a statement which must yield rows with a single string
// column. It returns the list of column values.
func SelectStrings(tx *sql.Tx, query string, args ...any) ([]string, error) {
values := []string{}
scan := func(rows *sql.Rows)... | lxd/db/query/slices.go | 0.70069 | 0.508666 | slices.go | starcoder |
package st3
// A sum type which can have 3 different types.
type SumType3[T0, T1, T2 any] struct {
which uint8
val0 T0
val1 T1
val2 T2
}
// Creates a new SumType3 containing a value of type T0.
func New0[T0, T1, T2 any](value T0) SumType3[T0, T1, T2] {
return SumType3[T0, T1, T2]{
which: 0,
... | st3/sumtype3.go | 0.571049 | 0.447702 | sumtype3.go | starcoder |
package client
import (
"path/filepath"
gover "github.com/mcuadros/go-version"
. "github.com/vtomar10/devicedetector/parser"
)
// Known browsers mapped to their internal short codes
var availableBrowsers = map[string]string{
`1B`: `115 Browser`,
`2B`: `2345 Browser`,
`36`: `360 Phone Browser`,
`3B`: `360 Bro... | parser/client/browser.go | 0.602412 | 0.671821 | browser.go | starcoder |
package ray
import "math"
// Cube is a canonical cube, centered of origin, of side 2 (-1 to +1)
type Cube struct {
Transform
Surface
name string
}
// NewCube instantiate a new cube
func NewCube() *Cube {
return &Cube{
Transform: IDTransform,
Surface: DefaultSurface,
}
}
// SetName ...
func (c *Cube) SetN... | cube.go | 0.821939 | 0.488344 | cube.go | starcoder |
package tpe
import (
"math"
"math/rand"
"sort"
"sync"
"github.com/c-bata/goptuna"
"github.com/c-bata/goptuna/internal/random"
"gonum.org/v1/gonum/floats"
)
const eps = 1e-12
// FuncGamma is a type of gamma function.
type FuncGamma func(int) int
// FuncWeights is a type of weights function.
type FuncWeights ... | tpe/sampler.go | 0.696475 | 0.409752 | sampler.go | starcoder |
package geometry
func (triangle *Triangle) GetNormal() Vector {
if Magnitude(triangle.Normal) > 0 {
return triangle.Normal
}
edge1 := CreateVector(triangle.Vertex1, triangle.Vertex0)
edge2 := CreateVector(triangle.Vertex2, triangle.Vertex0)
normal := CrossProduct(edge1, edge2)
return normal
}
func getLinePoi... | pkg/geometry/triangle.go | 0.829492 | 0.808332 | triangle.go | starcoder |
package chart
import (
"image"
"image/png"
"io"
"math"
"github.com/golang/freetype/truetype"
"github.com/liuxhu/go-chart/v2/drawing"
)
// PNG returns a new png/raster renderer.
func PNG(width, height int) (Renderer, error) {
i := image.NewRGBA(image.Rect(0, 0, width, height))
gc, err := drawing.NewRasterGrap... | raster_renderer.go | 0.857007 | 0.420778 | raster_renderer.go | starcoder |
package db
import (
"fmt"
"sort"
sq "github.com/Masterminds/squirrel"
"github.com/paydex-core/paydex-go/support/errors"
)
// Row adds a new row to the batch. All rows must have exactly the same columns
// (map keys). Otherwise, error will be returned. Please note that rows are not
// added one by one but in batc... | support/db/batch_insert_builder.go | 0.682256 | 0.411229 | batch_insert_builder.go | starcoder |
package sub
import (
"fmt"
)
type BenchmarkType uint
const (
BenchmarkTypeTypeUndefined BenchmarkType = 0
BenchmarkTypeEqual BenchmarkType = 1
BenchmarkTypeGT BenchmarkType = 2
BenchmarkTypeGTE BenchmarkType = 3
BenchmarkTypeLT BenchmarkType = 4
BenchmarkTypeLTE ... | be/ent/schema/sub/rule_condition.go | 0.505615 | 0.472379 | rule_condition.go | starcoder |
package datadog
import (
"encoding/json"
"fmt"
)
// LogsIndexesOrder Object containing the ordered list of log index names.
type LogsIndexesOrder struct {
// Array of strings identifying by their name(s) the index(es) of your organization. Logs are tested against the query filter of each index one by one, followi... | api/v1/datadog/model_logs_indexes_order.go | 0.615435 | 0.435781 | model_logs_indexes_order.go | starcoder |
package tile
import (
"fmt"
"io"
"log"
"strconv"
"strings"
"github.com/cshabsin/advent/common/readinp"
)
// Map is the structure of a set of tiles.
type Map struct {
tiles map[int]*Tile
edgeMap map[int][]int
}
// Rotate rotates the given tile n times counterclockwise.
func (tm *Map) Rotate(tileNum, rotate... | 2020/tile/tile.go | 0.708313 | 0.438966 | tile.go | starcoder |
package rbt
type BinaryTree struct {
Root *BinaryTreeNode
}
func NewBinaryTree() *BinaryTree {
return &BinaryTree{}
}
func (t *BinaryTree) Insert(key Comparable, v interface{}) (ret bool) {
ret = true
node := NewBinaryTreeNode(key, v)
cur := t.Root
if cur == nil {
t.Root = node
return
}
var parent *Bina... | binary_tree.go | 0.569134 | 0.458227 | binary_tree.go | starcoder |
package internal
/*
This module can represent a Timeline History file which can be retrieved from Postgres using the TIMELINEHISTORY SQL command.
A Timeline History file belongs to a timeline (which also will be the last Row in the file), and contains multiple rows.
Each row describes at what LSN that timeline came to... | internal/timeline_history.go | 0.735547 | 0.446676 | timeline_history.go | starcoder |
package main
import (
"fmt"
"log"
"net/http"
"os"
"os/exec"
"strings"
"time"
"github.com/leekchan/timeutil"
"gopkg.in/alecthomas/kingpin.v2"
)
var (
serversArg = kingpin.Flag("server", "server to use for synchronization, multiple values possible").Short('s').Default("pool.ntp.org", "ntp.org").URLList... | main.go | 0.501221 | 0.403126 | main.go | starcoder |
package main
import "fmt"
type Number interface {
int64 | float64
}
type Custom interface {
Method()
}
type SomeType struct {
Field string
}
func (st SomeType) Method() {
fmt.Println(st.Field)
}
func main() {
// Initialize a map for the integer values
ints := map[string]int64{
"first": 34,
"second": 12... | go/interfaces/type_constraints/intro/main.go | 0.758511 | 0.427994 | main.go | starcoder |
package kparams
import (
"strconv"
)
const (
// NA defines absent parameter's value
NA = "na"
)
// Value defines the container for parameter values
type Value interface{}
// Type defines kernel event parameter type
type Type uint16
// Hex is the type alias for hexadecimal values
type Hex string
// NewHex creat... | pkg/kevent/kparams/types.go | 0.744749 | 0.405861 | types.go | starcoder |
package cryptoapis
import (
"encoding/json"
)
// ListUnspentTransactionOutputsByAddressRI struct for ListUnspentTransactionOutputsByAddressRI
type ListUnspentTransactionOutputsByAddressRI struct {
// Represents the index position of the transaction in the block.
Index int32 `json:"index"`
// Represents the time ... | model_list_unspent_transaction_outputs_by_address_ri.go | 0.820397 | 0.442275 | model_list_unspent_transaction_outputs_by_address_ri.go | starcoder |
package iterator
import (
"fmt"
"github.com/Spi1y/tsp-solver/solver2/types"
)
// Iterator is a calculator used to determine the following values:
// - nodes left to visit (based on currently traveled path)
// - rows and columns used to calculate distance lower estimate (based on the path and the next node)
type It... | solver3/iterator/iterator.go | 0.695235 | 0.659494 | iterator.go | starcoder |
package report
import (
"bytes"
"encoding/gob"
"encoding/json"
"math"
"time"
"github.com/mndrix/ps"
)
// Metrics is a string->metric map.
type Metrics map[string]Metric
// Merge merges two sets maps into a fresh set, performing set-union merges as
// appropriate.
func (m Metrics) Merge(other Metrics) Metrics ... | report/metrics.go | 0.845113 | 0.410284 | metrics.go | starcoder |
package path
import (
"github.com/weworksandbox/lingo"
"github.com/weworksandbox/lingo/expr"
"github.com/weworksandbox/lingo/expr/operator"
"github.com/weworksandbox/lingo/expr/set"
"github.com/weworksandbox/lingo/sql"
)
func NewFloat64WithAlias(e lingo.Table, name, alias string) Float64 {
return Float64{
en... | expr/path/float64.go | 0.700997 | 0.44342 | float64.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.