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 fp6
const Mul = `
// Mul multiplies two numbers in {{.Fp6Name}}
func (z *{{.Fp6Name}}) Mul(x, y *{{.Fp6Name}}) *{{.Fp6Name}} {
// Algorithm 13 from https://eprint.iacr.org/2010/354.pdf
var rb0, b0, b1, b2, b3, b4 {{.Fp2Name}}
b0.Mul(&x.B0, &y.B0) // step 1
b1.Mul(&x.B1, &y.B1) // step 2
b2.Mul(&x.B2, &y.B... | internal/generators/template/tower/fp6/mul.go | 0.5564 | 0.614394 | mul.go | starcoder |
package akeebabackup
// Do note that the data is always returned unencrypted, no mater what the requested encapsulation was in your request.
type DownloadDirectRequestData struct {
BackupID int `json:"backup_id"` // The numeric ID of the backup record whose files you want to download
PartID int `json:"part_id"` ... | download_direct.go | 0.587352 | 0.414603 | download_direct.go | starcoder |
package types
type ColoringRule struct {
// Regex string to match queries to apply coloring to.
Scope string `json:"scope"`
// Function to aggregate one series into one single value.
SingleSeriesAggregateFunction string `json:"singleSeriesAggregateFunction"`
// Function to aggregate the aggregate values of multip... | service/cip/types/dashboard_types.go | 0.820146 | 0.435001 | dashboard_types.go | starcoder |
package model
import (
"github.com/juju/errors"
"github.com/newm4n/grool/context"
"github.com/newm4n/grool/pkg"
"reflect"
"time"
)
const (
TimeTypeString = "time.Time"
)
// Predicate holds the left and right Expression Atom graph. And apply comparisson operator from both
// expression atom result.
type Predica... | model/Predicate.go | 0.607663 | 0.459197 | Predicate.go | starcoder |
package schema
import (
"go/ast"
"go/token"
"go/types"
"github.com/bflad/tfproviderlint/helper/astutils"
"github.com/bflad/tfproviderlint/helper/terraformtype/diag"
)
// IsFuncTypeCRUDFunc returns true if the FuncType matches expected parameters and results types
func IsFuncTypeCRUDFunc(node ast.Node, info *typ... | vendor/github.com/bflad/tfproviderlint/helper/terraformtype/helper/schema/type_crudfunc.go | 0.621541 | 0.464355 | type_crudfunc.go | starcoder |
package interpreter
import (
"fmt"
"io"
"os"
"strings"
"github.com/benhoyt/littlelang/parser"
. "github.com/benhoyt/littlelang/tokenizer"
)
// Value is a littlelang runtime value (nil, bool, int, str, list, map, func).
type Value interface{}
// Config allows you to configure the interpreter's interaction with... | interpreter/interpreter.go | 0.566139 | 0.403567 | interpreter.go | starcoder |
package ast
// These are the available root node types. In JSON it will either be an
// object or an array at the base.
const (
ObjectRoot RootNodeType = iota
ArrayRoot
)
// RootNodeType is a type alias for an int
type RootNodeType int
// RootNode is what starts every parsed AST. There is a `Type` field so that
//... | pkg/ast/ast.go | 0.736021 | 0.681369 | ast.go | starcoder |
package strconvhelper
import (
"github.com/apaxa-io/mathhelper"
"strconv"
)
const defaultIntegerBase = 10
// Signed integers
// ParseInt interprets a string s in 10-base and returns the corresponding value i (int) and error.
func ParseInt(s string) (int, error) {
if valueInt64, err := strconv.ParseInt(s, default... | parseint.go | 0.78535 | 0.473109 | parseint.go | starcoder |
package evaluation
import (
"fmt"
)
// Number type for clause attribute evaluation
type Number float64
// NewNumber creates a Number instance with the object value
func NewNumber(value interface{}) (Number, error) {
num, ok := value.(float64)
if ok {
newNumber := Number(num)
return newNumber, nil
}
return 0... | number.go | 0.794026 | 0.429549 | number.go | starcoder |
package datadog
import (
"encoding/json"
"time"
)
// UsageNetworkFlowsHour Number of netflow events indexed for each hour for a given organization.
type UsageNetworkFlowsHour struct {
// The hour for the usage.
Hour *time.Time `json:"hour,omitempty"`
// Contains the number of netflow events indexed.
IndexedEve... | api/v1/datadog/model_usage_network_flows_hour.go | 0.720565 | 0.477493 | model_usage_network_flows_hour.go | starcoder |
package mft
import (
"bytes"
"encoding/binary"
"fmt"
"github.com/t9t/gomft/binutil"
"github.com/t9t/gomft/fragment"
"github.com/t9t/gomft/utf16"
)
var (
fileSignature = []byte{0x46, 0x49, 0x4c, 0x45}
)
const maxInt = int64(^uint(0) >> 1)
// A Record represents an MFT entry, excluding all technical data (suc... | mft/mft.go | 0.669529 | 0.434461 | mft.go | starcoder |
package dataframe
import "golang.org/x/text/encoding"
// DataBuilder is a helper structure to build dataframes.
// Use dataframe.DataBuilder{RawData: dataframe.EmptyRawData()} to initialize it
type DataBuilder struct {
RawData *RawData
}
// AddFloats adds a list of floats to the given float column.
// It returns a... | dataframe/builder.go | 0.835013 | 0.710314 | builder.go | starcoder |
package liblsdj
import (
"fmt"
)
const (
instrumentCount = 0x40 //! The amount of instruments in a song
instrumentByteCount = 16 //! The amount of bytes an instrument takes
instrumentNameLength = 5 //! The amount of bytes an instrument name takes
instrumentPulseLengthInfinit... | instrument.go | 0.600774 | 0.572603 | instrument.go | starcoder |
package ssot
import (
"crypto/ed25519"
"encoding/binary"
"github.com/frankbraun/codechain/util/base64"
"github.com/frankbraun/codechain/util/hex"
)
// SignedHeadV2 is a signed Codechain head ready for publication as a SSOT with
// DNS TXT records (version 2).
type SignedHeadV2 struct {
version uint8 // ... | ssot/ssot_v2.go | 0.713032 | 0.40486 | ssot_v2.go | starcoder |
package timex
import "time"
const (
Day = 24 * time.Hour
Week = 7 * Day
)
var (
DaysMonth = []int{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
DaysMonthLeap = []int{0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
NSec = int(time.Second - time.Nanosecond)
)
func AtBeginningOfDay(target ti... | timex.go | 0.706697 | 0.460653 | timex.go | starcoder |
package search
import "strings"
type Node struct {
key string
value int
left *Node
right *Node
}
type BST struct {
root *Node
count int
}
func (n *Node) GetNodeKey() string {
return n.key
}
func NewBST() *BST {
return &BST{nil, 0}
}
func (bst *BST) Insert(key string, value int) {
bst.count++
bst.root... | binarySearchTree.go | 0.57678 | 0.409634 | binarySearchTree.go | starcoder |
package step
/* In order to make the parser work properly
---in a concurrent fashion we'll need to add
---a skip stack that you'll get back to when
---some of the points are missing
---something like:
-Skip: list of definitions that are impossible to parse
for now
-Missing: list of definitions that are missing
--compl... | step/parse.go | 0.508544 | 0.575677 | parse.go | starcoder |
package main
import (
"errors"
"log"
"os"
"strings"
)
type Rate struct {
value []bool
}
func main() {
// Read the input file. It contains a list of binary numbers
structuredInput, err := getStructFromInput("day3/input.txt")
if err != nil {
log.Fatal(err)
}
// Part 1: multiply the gamma rate by the epsil... | day3/main.go | 0.52829 | 0.503662 | main.go | starcoder |
SPEC Benchmark Specification
Go
1.0: General
1.1: Classification
Go is a cpu-bound integer benchmark. It is an example of the use of
artificial intelligence in game playing.
1.2: Description
Go plays the game of go against itself. The benchmark is stripped
down version of a succe... | benchmarks/deputytests/spec95/go/DESCR.go | 0.751466 | 0.571408 | DESCR.go | starcoder |
package breeze
import (
"encoding/binary"
"io"
)
// Buffer is A variable-sized buffer of bytes with Read and Write methods.
// Buffer is not thread safe for multi goroutine operation.
type Buffer struct {
buf []byte // contents are the bytes buf[0 : wpos] in write, are the bytes buf[rpos: len(buf)] in read
rp... | breezeBuffer.go | 0.502686 | 0.601564 | breezeBuffer.go | starcoder |
package main
import (
"math"
)
func connectEdgesToBoundary(currentNode *node, boundingBox boundingBox, dcel *doublyConnectedEdgeList) {
// Each internal node left in the beachline represents a half infinite edge
// Need to connect each of these to the bounding box
if currentNode.breakpoint != nil {
// Steps:
... | boundingbox.go | 0.711531 | 0.692024 | boundingbox.go | starcoder |
package csg
import (
"runtime"
"sync"
)
//IPolygonSplitter is an interface for a specific implementation of a polygon splitter
type IPolygonSplitter interface {
//SplitPolygons splits the polygons into various slices based upon their orientation to the specified plane
SplitPolygons(plane *Plane, polygons []*Polyg... | csg/polygonsplitter.go | 0.657868 | 0.49762 | polygonsplitter.go | starcoder |
// Package kgobject contains helper methods to construct common api KGObject instances
package kgobject
import (
"time"
"github.com/ebay/beam/api"
)
// AString returns a new KGObject instance containing the supplied string and language ID.
func AString(s string, langID uint64) api.KGObject {
return api.KGObject{... | src/github.com/ebay/beam/msg/kgobject/make.go | 0.857306 | 0.598107 | make.go | starcoder |
package main
type BinaryTree struct {
Value int
Left *BinaryTree
Right *BinaryTree
}
// O(n) time | O(n) space - where N is the number of nodes in the tree
func FindNodesDistanceK(tree *BinaryTree, target int, k int) []int {
nodesToParents := map[int]*BinaryTree{}
populateNodesToParents(tree, nodesToParents, ni... | src/binary-trees/hard/find-distance-k-nodes/go/bfs.go | 0.738103 | 0.454835 | bfs.go | starcoder |
package types
import (
"errors"
"github.com/prysmaticlabs/prysm/shared/bytesutil"
)
// DetectionKind defines an enum type that
// gives us information on the type of slashable offense
// found when analyzing validator min-max spans.
type DetectionKind uint8
const (
// DoubleVote denotes a slashable offense in wh... | .docker/Prysm/prysm-spike/slasher/detection/attestations/types/types.go | 0.723798 | 0.42662 | types.go | starcoder |
package interval
import (
"fmt"
"time"
)
type (
// Float64Range represents a range of numbers of type float64.
Float64Range struct {
Min *float64
Max *float64
}
// Int32Range represents a range of numbers of type int32.
Int32Range struct {
Min *int32
Max *int32
}
// TimeRange represents a range of ... | interval/range.go | 0.829837 | 0.434101 | range.go | starcoder |
package iso20022
// Parameters applied to the settlement of a security transfer.
type Transfer21 struct {
// Unique and unambiguous identifier for a transfer instruction, as assigned by the instructing party.
TransferReference *Max35Text `xml:"TrfRef"`
// Unique and unambiguous investor's identification of a tran... | Transfer21.go | 0.791378 | 0.46557 | Transfer21.go | starcoder |
// hlclock provides functions for Hybrid Logical Clocks.
package hlclock
import (
"encoding/json"
"fmt"
)
// Now implementation provides the current wall clock time.
type SysClock interface {
Now() int64
}
// HTimestamp contains the timestamp information.
type HTimestamp struct {
timestamp int64
counter uint... | hlclock/hlclock.go | 0.620162 | 0.554893 | hlclock.go | starcoder |
package finance
import (
"sort"
"time"
)
// Transactions is a collection of type Transaction
type Transactions []Transaction
// StartingBalance calculates the correct starting balance by iterating over
// each transaction and identify if it belongs to a different account.
// If it does, than the starting balance i... | finance/transactions.go | 0.804444 | 0.414129 | transactions.go | starcoder |
package util
import (
"strconv"
"strings"
"time"
)
func GetCurrentTime() time.Time {
return time.Now().UTC()
}
func GetTimeStamp() int64 {
return time.Now().UTC().Unix()
}
func GetMSTimeStamp() int64 {
return time.Now().UTC().UnixNano() / int64(time.Millisecond)
}
func GetSecTimeStamp() int64 {
return time.... | pkg/util/time.go | 0.540681 | 0.402216 | time.go | starcoder |
package util
import (
"math"
)
var (
deg2rad = math.Pi / 180 // degrees to radian conversion
rad2deg = 180 / math.Pi // radians to degrees conversion
earthRadius = 6371.01 // Earth's radius in km
maxLat = math.Pi / 2 // 90 degrees
minLat = -maxLat // -90 degrees
maxLon... | util/geolocation.go | 0.836087 | 0.567877 | geolocation.go | starcoder |
package mysql
import (
"math"
"strings"
)
// ToDataType returns a MySQL DataType based on the given data name.
func ToDataType(s string) DataType {
return DataType(strings.ToLower(s))
}
// DataType represents a MySQL data type.
type DataType string
// List of supported MySQL data types.
const (
Bit Data... | internal/mysql/data_type.go | 0.692642 | 0.622345 | data_type.go | starcoder |
package search
// ListEventsSummaryQueryParams represents valid query parameters for the ListEventsSummary operation
// For convenience ListEventsSummaryQueryParams can be formed in a single statement, for example:
// `v := ListEventsSummaryQueryParams{}.SetCount(...).SetEarliest(...).SetField(...).SetLatest(...).... | services/search/param_generated.go | 0.949 | 0.629063 | param_generated.go | starcoder |
package ansi
import (
"fmt"
)
// Color256 represents an `xterm-256color` ANSI color code.
type Color256 int
// For W3C color list, see:
// - https://jonasjacek.github.io/colors/
// - https://en.wikipedia.org/wiki/X11_color_names#Clashes_between_web_and_X11_colors_in_the_CSS_color_scheme
const (
// Color256Black i... | ansi/color256.go | 0.916154 | 0.734822 | color256.go | starcoder |
package temporal
import "time"
// MinuteStart will return the starting time of the minute for the given time.Time object
func MinuteStart(t time.Time) time.Time {
y, m, d := t.Date()
return time.Date(y, m, d, t.Hour(), t.Minute(), 0, 0, t.Location())
}
// MinuteFinish will return the final time of the ... | bounds.go | 0.589835 | 0.50177 | bounds.go | starcoder |
package color
import (
"github.com/lucasb-eyer/go-colorful"
)
// NativeColorspace describes the native color space of a convertible color.
type NativeColorspace uint8
const (
// HueSat the color is represented as Hue and saturation of the sRGB colorspace.
HueSat NativeColorspace = 0
// XYY the color is represent... | capabilities/color/color.go | 0.86813 | 0.555073 | color.go | starcoder |
package query
import (
"bytes"
"strconv"
)
type Operand struct {
e Expression
}
func (o Operand) Expand(s Starter, i int) (string, []interface{}, error) {
return Expand(o.e, false, s, i)
}
func E2O(e Expression) Operand {
switch o := e.(type) {
case Operand:
return o
case *Operand:
return *o
}
return ... | query/o.go | 0.642993 | 0.595316 | o.go | starcoder |
package eval
import (
"fmt"
"github.com/hscells/trecresults"
"math"
)
// MaximumLikelihoodEvaluator is similar to ResidualEvaluator, except that the
// proportion of the residual that should be labelled relevant is computed as
// a maximum likelihood probability. That is, the number of unjudged documents
// that s... | eval/mle.go | 0.827932 | 0.478407 | mle.go | starcoder |
package steering
import (
"fmt"
"math/rand"
)
func Seek(s Steerer, target Vector) Vector {
desired_velocity := target.Minus(s.Position()).Normalize().Mult(s.MaxSpeed())
return desired_velocity.Minus(s.Velocity())
}
func Flee(s Steerer, target Vector) Vector {
desired_velocity := target.Minus(s.Position()).Norma... | steering.go | 0.758242 | 0.493714 | steering.go | starcoder |
package web3
type Service interface {
// Returns the version of the current client
Web3ClientVersion() (*Web3ClientVersionResult, error)
// Hashes data using the Keccak-256 algorithm
Web3Sha3(*Web3Sha3Params) (*Web3Sha3Result, error)
// Determines if this client is listening for new network connections.
NetListe... | rpc/web3/types.go | 0.824214 | 0.413773 | types.go | starcoder |
package tensor
import (
"math"
"reflect"
"github.com/pkg/errors"
)
/* MaskedEqual */
// MaskedEqual sets the mask to true where the corresponding data is equal to val
// Any values must be the same type as the tensor
func (t *Dense) MaskedEqual(val1 interface{}) (err error) {
if !t.IsMasked() {
t.makeMask(... | dense_maskcmp_methods.go | 0.537041 | 0.517388 | dense_maskcmp_methods.go | starcoder |
package lsb
import (
"encoding/binary"
"image"
"image/color"
)
// Hide writes data into copy of src using LSB (least significant bit) method.
// It includes 32 bit length value in data before payload
func Hide(src image.Image, data []byte) image.Image {
bounds := src.Bounds()
out := image.NewRGBA(bounds)
var cu... | lsb/lsb.go | 0.550124 | 0.461623 | lsb.go | starcoder |
package calendar
import (
"fmt"
"time"
"go.uber.org/zap"
)
//Calendar ..
type Calendar struct {
ID int64 `json:"id,omitempty"`
Name string `json:"name"`
Description string `json:"description"`
Periods []Period `json:"periods"`
UnionCalendarIDs []int64 `json:"un... | internals/calendar/calendar.go | 0.75183 | 0.462959 | calendar.go | starcoder |
package codec
import (
"encoding/binary"
"github.com/juju/errors"
)
const signMask uint64 = 0x8000000000000000
func encodeIntToCmpUint(v int64) uint64 {
u := uint64(v)
if u&signMask > 0 {
u &= ^signMask
} else {
u |= signMask
}
return u
}
func decodeCmpUintToInt(u uint64) int64 {
if u&signMask > 0 {
... | vendor/github.com/pingcap/tidb/util/codec/number.go | 0.849924 | 0.470372 | number.go | starcoder |
package groups
import (
"crypto/dsa"
"crypto/rand"
"fmt"
"math/big"
"github.com/xlab-si/emmy/crypto/common"
)
// SchnorrGroup is a cyclic group in modular arithmetic. It holds P = Q * R + 1 for some R.
// The actual value R is never used (although a random element from this group could be computed
// by a^R for... | crypto/groups/schnorr.go | 0.72594 | 0.412116 | schnorr.go | starcoder |
package common
import (
"fmt"
"math"
"math/rand"
"reflect"
"testing"
)
// Swap two array values given their indices.
func Swap(v interface{}, i, j int) {
switch a := v.(type) {
case []int:
SwapInt(a, i, j)
case []string:
SwapString(a, i, j)
}
}
// SwapInt two array values given their indices.
func SwapI... | common/utils.go | 0.703448 | 0.463505 | utils.go | starcoder |
package layers
import (
"encoding/binary"
"fmt"
"github.com/tsg/gopacket"
"hash/crc32"
)
// SCTP contains information on the top level of an SCTP packet.
type SCTP struct {
BaseLayer
SrcPort, DstPort SCTPPort
VerificationTag uint32
Checksum uint32
sPort, dPort []byte
}
// LayerType returns gop... | vendor/github.com/tsg/gopacket/layers/sctp.go | 0.746971 | 0.443841 | sctp.go | starcoder |
package dilithium
import (
"golang.org/x/crypto/sha3"
)
//reduce32 maps a to the [-Q, Q] domain
func reduce32(a int32) int32 {
t := (a + (1 << 22)) >> 23
t = a - t*q
return t
}
//addQ maps a to a "positive" representation in constant time
func addQ(a int32) int32 {
a += (a >> 31) & q
return a
}
//freeze maps ... | crystals-dilithium/internal.go | 0.713731 | 0.510863 | internal.go | starcoder |
package function
import (
"fmt"
"time"
"gopkg.in/src-d/go-mysql-server.v0/sql"
"gopkg.in/src-d/go-mysql-server.v0/sql/expression"
)
func getDatePart(
ctx *sql.Context,
u expression.UnaryExpression,
row sql.Row,
f func(interface{}) interface{},
) (interface{}, error) {
val, err := u.Child.Eval(ctx, row)
if ... | sql/expression/function/time.go | 0.765681 | 0.456531 | time.go | starcoder |
package sbdb
import "github.com/ovn-org/libovsdb/model"
type (
LogicalFlowPipeline = string
)
var (
LogicalFlowPipelineIngress LogicalFlowPipeline = "ingress"
LogicalFlowPipelineEgress LogicalFlowPipeline = "egress"
)
// LogicalFlow defines an object in Logical_Flow table
type LogicalFlow struct {
UUID ... | go-controller/pkg/sbdb/logical_flow.go | 0.544801 | 0.477189 | logical_flow.go | starcoder |
package convert
import "github.com/yyf330/kit/metrics"
type counterHistogram struct {
c metrics.Counter
}
// NewCounterAsHistogram returns a Histogram that actually writes the
// value on an underlying Counter
func NewCounterAsHistogram(c metrics.Counter) metrics.Histogram {
return counterHistogram{c}
}
// With i... | util/metrics/internal/convert/convert.go | 0.927618 | 0.58673 | convert.go | starcoder |
package widgets
import (
"fmt"
"github.com/bcicen/tcolors/state"
"github.com/bcicen/tcolors/styles"
"github.com/gdamore/tcell"
)
const (
padPalette = true
palettePadding = 2
)
type PaletteBox struct {
width int
boxWidth int
boxHeight int
xStretch int
pst tcell.Style // pointer style
stat... | widgets/palette.go | 0.622574 | 0.41182 | palette.go | starcoder |
package main
import (
"fmt"
)
type TreeNode struct {
data int
left *TreeNode
right *TreeNode
}
type BinarySearchTree struct {
root *TreeNode
}
func (tree *BinarySearchTree) add(data int) {
if tree.root == nil {
tree.root = &TreeNode{data: data, left: nil, right: nil}
} else {
add(tree.root, data)
}
}
... | data-structures/Tree/BinarySearchTree/go/BinarySearchTree.go | 0.603698 | 0.62581 | BinarySearchTree.go | starcoder |
package observations
import (
"context"
"fmt"
"image"
"github.com/zeebo/rothko/draw"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)
const (
padding = 2
)
// Measured represents a measured observations axis.
type Measured struct {
// Width is the width in pixels of the observation axis
Width i... | draw/observations/obs.go | 0.885204 | 0.484624 | obs.go | starcoder |
package types
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// NewMinter returns a new Minter object with the given inflation and annual
// provisions values.
func NewMinter(inflation, annualProvisions sdk.Dec, phase, startPhaseBlock uint64) Minter {
return Minter{
Inflation: inflation,
Ann... | x/mint/types/minter.go | 0.791459 | 0.409398 | minter.go | starcoder |
package slice
import (
"fmt"
"math/rand"
)
// IndexOfInt64 gets the index of an int64 element in an int64 slice
func IndexOfInt64(x []int64, y int64) int {
for i, v := range x {
if v == y {
return i
}
}
return -1
}
// ContainsInt64 checks whether an int64 element is in an int64 slice
func ContainsInt64(x... | slice/int64.go | 0.730194 | 0.522263 | int64.go | starcoder |
package constraint
import (
"github.com/leapar/engine/experimental/physics/equation"
"github.com/leapar/engine/math32"
)
// Lock constraint.
// Removes all degrees of freedom between the bodies.
type Lock struct {
PointToPoint
rotEq1 *equation.Rotational
rotEq2 *equation.Rotational
rotEq3 *equation.Rotational
... | experimental/physics/constraint/lock.go | 0.821689 | 0.578299 | lock.go | starcoder |
package racesimulator
// ITimePoint is the interface that wraps the underlying TimePoint related methods.
// This helps form consistency with derivative structures.
type ITimePoint interface {
// Name is the name of the timepoint which denotes where the timepoint resides. TimePointName is a simple
// wrapper over st... | source/backend/racesimulator/timepoint.go | 0.804021 | 0.668053 | timepoint.go | starcoder |
package iso20022
// Nature of the amount and currency on a document referred to in the remittance section, typically either the original amount due/payable or the amount actually remitted for the referenced document.
type RemittanceAmount2 struct {
// Amount specified is the exact amount due and payable to the credi... | RemittanceAmount2.go | 0.759939 | 0.565659 | RemittanceAmount2.go | starcoder |
package pefisa
const registerPefisa = `
## Authorization:Bearer {{.Authentication.AuthorizationToken}}
## Content-Type:application/json
{
"idBeneficiario": {{.Agreement.AgreementNumber}},
"carteira": {{.Agreement.Wallet}},
"nossoNumero": "{{padLeft (toString .Title.OurNumber) "0" 10}}",
"seuNumero": "{... | pefisa/request.go | 0.623262 | 0.406921 | request.go | starcoder |
package expr
import (
"fmt"
"strings"
)
type lexeme string
const (
add lexeme = "+"
subtract lexeme = "-"
multiply lexeme = "*"
divide lexeme = "/"
openBracket lexeme = "("
closeBracket lexeme = ")"
eof lexeme = "."
)
/*
node represents a node of an expression parse tree... | pkg/expr/parser.go | 0.698329 | 0.490053 | parser.go | starcoder |
package main
import (
"fmt"
"strconv"
"strings"
"time"
)
// Period defines a time period
type Period struct {
Start time.Time
End time.Time
}
func (p *Period) String() string {
return fmt.Sprintf("%s to %s", p.Start.Format("2006-01-02"), p.End.Format("2006-01-02"))
}
// Match returns true if t falls within... | period.go | 0.848533 | 0.505371 | period.go | starcoder |
package gendata
func BuildBitManipulation() string {
return `
func gbRLA(cpu *Core) {
c := (cpu.Registers.A >> 7) > 0
f := uint8(0)
if cpu.Registers.GetCarry() {
f = 1
}
cpu.Registers.A = (cpu.Registers.A << 1) | f
cpu.Registers.SetCarry(c)
cpu.Registers.SetZero(false)
cpu.R... | cpu/generator/gendata/bitManipulation.go | 0.633637 | 0.567158 | bitManipulation.go | starcoder |
package copit
import (
"database/sql"
"errors"
"reflect"
)
// Copy copy things
func Copy(toValue interface{}, fromValue interface{}) (err error) {
var (
from = indirect(reflect.ValueOf(fromValue))
to = indirect(reflect.ValueOf(toValue))
)
if !to.CanAddr() {
return errors.New("copy to value is unaddress... | copit.go | 0.529507 | 0.424472 | copit.go | starcoder |
package matrix
import (
"fmt"
"math/rand"
"time"
)
// New creates a new empty matrix of a given size.
func New(rows, cols int) Matrix {
assertValidSize(rows, cols)
return createWithData(rows, cols, make([]float64, rows*cols))
}
// NewSquare creates an empty square matrix of a given size.
func NewSquare(size int... | constructors.go | 0.843541 | 0.767516 | constructors.go | starcoder |
package dynamodb
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/guregu/dynamo"
)
type (
// Query : Request to get one or more items in a table.
Query interface {
// Range : Specifies the range key (a.k.a. sort key) or keys to get.
Range(name string, op dynamo.Operator, values ...interface{}) Query
// ... | query.go | 0.776538 | 0.4133 | query.go | starcoder |
package main
/*
WARNING: Until issue #67 is done, this is a copy from HW2.
*/
import (
"fmt"
"math"
"math/rand"
"time"
"github.com/ChristopherRabotin/smd"
"github.com/gonum/floats"
"github.com/gonum/matrix/mat64"
"github.com/gonum/stat/distmv"
)
const (
r2d = 180 / math.Pi
d2r = 1 / r2d
)
// Station defi... | examples/statOD/hwmain/station.go | 0.578686 | 0.527986 | station.go | starcoder |
package Example
import (
flatbuffers "github.com/google/flatbuffers/go"
)
type Vec3T struct {
X float32
Y float32
Z float32
Test1 float64
Test2 Color
Test3 *TestT
}
func (t *Vec3T) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
if t == nil {
return 0
}
return CreateVec3(builder, t.X, t.Y, t.Z... | tests/MyGame/Example/Vec3.go | 0.883129 | 0.442215 | Vec3.go | starcoder |
package dfl
import (
"strings"
"github.com/pkg/errors"
)
// TernaryOperator is a DFL Node that represents the ternary operator of a condition, true value, and false value.
type TernaryOperator struct {
Left Node
True Node
False Node
}
func (to TernaryOperator) Dfl(quotes []string, pretty bool, tabs int) str... | pkg/dfl/TernaryOperator.go | 0.714628 | 0.485051 | TernaryOperator.go | starcoder |
package checksum
import (
"sort"
"strconv"
"strings"
)
// GetSmallest returns the smallest value of a row of numbers
func GetSmallest(content string) int {
smallestValue := 999999
values := strings.Split(content, " ")
for _, valueChar := range values {
value, err := strconv.Atoi(string(valueChar))
// fmt.Pr... | checksum/checksum.go | 0.700075 | 0.42668 | checksum.go | starcoder |
package discovery
import (
"math"
"math/rand"
"sync"
"time"
)
type BackoffFactory func() BackoffStrategy
// BackoffStrategy describes how backoff will be implemented. BackoffStratgies are stateful.
type BackoffStrategy interface {
// Delay calculates how long the next backoff duration should be, given the prior... | vendor/github.com/libp2p/go-libp2p-discovery/backoff.go | 0.805441 | 0.450541 | backoff.go | starcoder |
package x2j
import (
"strings"
"github.com/clbanning/mxj"
)
//----------------------------- find all paths to a key --------------------------------
// Want eventually to extract shortest path and call GetValuesAtKeyPath()
// This will get all the possible paths. These can be scanned for len(path) and sequence.
... | plugins/data/parser/json/mxj/head/x2j-wrapper/x2j_findPath.go | 0.586286 | 0.495239 | x2j_findPath.go | starcoder |
package ls
import (
"sort"
"github.com/bserdar/digraph"
)
// Edge represents a graph edge
type Edge interface {
digraph.Edge
GetLabelStr() string
// Clone returns a new edge that is a copy of this one but
// unconnected to any nodes
Clone() Edge
GetProperties() map[string]*PropertyValue
GetCompiledData... | pkg/ls/edge.go | 0.76145 | 0.465448 | edge.go | starcoder |
package grid
import (
"fmt"
"github.com/johnfercher/taleslab/pkg/taleslab/taleslabdomain/taleslabconsts"
"github.com/johnfercher/taleslab/pkg/taleslab/taleslabdomain/taleslabentities"
"math/rand"
"time"
)
func GenerateElementGrid(x, y int, defaultElement taleslabentities.Element) [][]taleslabentities.Element {
... | pkg/grid/helpers.go | 0.520496 | 0.418816 | helpers.go | starcoder |
package scalar
import (
"encoding/base64"
"reflect"
"strconv"
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/language/ast"
)
func coerceFloat32(value interface{}) interface{} {
switch value := value.(type) {
case bool:
if value == true {
return float32(1)
}
return float32(0)
case *bo... | runtime/scalar/types.go | 0.675551 | 0.410431 | types.go | starcoder |
package gglm
import (
"fmt"
"math"
)
var _ Swizzle4 = &Vec4{}
var _ fmt.Stringer = &Vec4{}
type Vec4 struct {
Data [4]float32
}
func (v *Vec4) X() float32 {
return v.Data[0]
}
func (v *Vec4) Y() float32 {
return v.Data[1]
}
func (v *Vec4) Z() float32 {
return v.Data[2]
}
func (v *Vec4) W() float32 {
retur... | gglm/vec4.go | 0.798423 | 0.439747 | vec4.go | starcoder |
package conway
// Location is an x, y coordinate
type Location struct {
X int
Y int
}
// Cell is a structure to containe the state of a location (alive or dead) and a count of it's living neighbours
type Cell struct {
State bool
Rc int8
}
// Field is a structure containing all data needed to represent the Lif... | pkg/conway/conway.go | 0.634204 | 0.53437 | conway.go | starcoder |
package main
import (
"math"
)
type twod_Vector struct {
X float64
Y float64
}
func (v twod_Vector) Add(b twod_Vector) twod_Vector {
return twod_Vector{
X: v.X + b.X,
Y: v.Y + b.Y,
}
}
func (v twod_Vector) Sub(b twod_Vector) twod_Vector {
return twod_Vector{
X: v.X - b.X,
Y: v.Y - b.Y,
}
}
func (v t... | source/twod.go | 0.63114 | 0.523786 | twod.go | starcoder |
// Package queueimpl3 implements an unbounded, dynamically growing FIFO queue.
// Internally, queue store the values in fixed sized slices that are linked using a singly linked list.
// This implementation tests the queue performance when controlling the length and current positions in
// the slices using the builtin ... | queueimpl3/queueimpl3.go | 0.88981 | 0.567637 | queueimpl3.go | starcoder |
package core
import (
"fmt"
"strings"
"github.com/philandstuff/dhall-golang/v6/term"
)
func (naturalBuild) Call(x Value) Value {
var succ Value = lambda{
Label: "x",
Domain: Natural,
Fn: func(x Value) Value {
if n, ok := x.(NaturalLit); ok {
return NaturalLit(n + 1)
}
return oper{OpCode: term... | core/builtins.go | 0.567577 | 0.566738 | builtins.go | starcoder |
package main
const input = `
forward 4
down 8
down 1
forward 6
forward 7
down 7
forward 3
forward 5
up 9
down 1
forward 5
down 8
forward 4
forward 5
down 5
down 1
forward 1
down 3
forward 5
forward 5
down 1
up 2
down 2
down 5
down 5
forward 3
forward 7
forward 5
forward 9
forward 8
down 4
down 6
up 5
down 1
forward 6
... | day2/input.go | 0.767298 | 0.552781 | input.go | starcoder |
package tuid
import (
"bytes"
"crypto/rand"
"errors"
"fmt"
"math/big"
"time"
)
// MinID is the first ID at 2000-01-01T00:00:00Z
const MinID = "5Hr02eJHAfTt1tTM"
// MaxID is the first ID at 2100-01-01T00:00:00Z
const MaxID = "MuklDY5bgW1s9Ev2"
// TUID is a Time-based Unique Identifier (e.g. 91Mq07yx9IxHCi5Y) t... | tuid.go | 0.666605 | 0.410993 | tuid.go | starcoder |
// Package day20 solves AoC 2019 day 20.
package day20
import (
"container/heap"
"unicode"
"github.com/fis/aoc/glue"
"github.com/fis/aoc/util"
)
func init() {
glue.RegisterSolver(2019, 20, glue.LevelSolver{Solver: solve, Empty: ' '})
}
func solve(level *util.Level) ([]string, error) {
dist := distances(level... | 2019/day20/day20.go | 0.640861 | 0.434641 | day20.go | starcoder |
package api
// PointI
// ToPoint2D converts to a Point2D.
func (p PointI) ToPoint2D() Point2D {
return Point2D{float32(p.X), float32(p.Y)}
}
// ToPoint2DCentered converts to a Point2D and adds 0.5 to X/Y to center inside that map cell.
func (p PointI) ToPoint2DCentered() Point2D {
return Point2D{float32(p.X) + 0.5... | api/points.go | 0.942135 | 0.793226 | points.go | starcoder |
package evaluator
import (
"regexp"
"github.com/shric/monkey/object"
"github.com/shric/monkey/token"
)
func evalInfixExpression(
tok token.Token,
left, right object.Object,
) object.Object {
switch {
case left.Type() == object.FLOAT_OBJ && right.Type() == object.INTEGER_OBJ:
return evalFloatIntegerInfixExpr... | evaluator/infix.go | 0.671255 | 0.544499 | infix.go | starcoder |
package filter
import "github.com/nerdynick/ccloud-go-sdk/telemetry/labels"
const (
//OpNot is a static def for NOT Operand
OpNot string = "NOT"
)
type UnaryFilter struct {
Op string `json:"op"`
SubFilter Filter `json:"filter"`
}
func (fil UnaryFilter) And(filters ...Filter) CompoundFilter {
return And(... | telemetry/query/filter/unary.go | 0.828696 | 0.427337 | unary.go | starcoder |
package iso20022
// Provides information on the status of a trade.
type TradeData9 struct {
// Reference to the unique system identification assigned to the trade by the central matching system.
MatchingSystemUniqueReference *Max35Text `xml:"MtchgSysUnqRef"`
// Reference to the unique matching identification assi... | TradeData9.go | 0.791982 | 0.449272 | TradeData9.go | starcoder |
package datablock
import (
"bytes"
"compress/gzip"
"github.com/mattetti/filebuffer"
log "github.com/sirupsen/logrus"
"io"
"io/ioutil"
"net/http"
"strconv"
"time"
)
// DataBlock represents a block of data that may be compressed
type DataBlock struct {
data []byte
compressed bool
length ... | vendor/github.com/xyproto/datablock/datablock.go | 0.616012 | 0.605566 | datablock.go | starcoder |
package types
import (
"fmt"
"math"
)
/*
EdgeKey is an always positive number that stores an edge's vertices as indices in a way that can be compared
An edge between vertices [4] and [0] will always be stored as [0,4], in the ascending order of the index values
*/
type EdgeKey uint64
func NewEdgeKey(verts [2]int) ... | types/elemental.go | 0.566738 | 0.695965 | elemental.go | starcoder |
package main
import (
"bytes"
"fmt"
"math"
"time"
"github.com/tkrajina/gpxgo/gpx"
)
const border = 0.05
// Map is used to translate track coordinates into SVG coordinate system for rendering.
type Map struct {
w, h int // widht, height in svg coordinates
lw, lh float64 // width, height in lat/lon degre... | map.go | 0.750736 | 0.505493 | map.go | starcoder |
package gfx
import (
"fmt"
"image/color"
"github.com/hajimehoshi/ebiten/v2"
)
// A FrameBuffer is a set of cells which contain color information.
type FrameBuffer struct {
pixels []byte
pixelsLength uint
Width uint
Height uint
}
// NewFrameBuffer returns a new frame buffer that contains a set of
// l... | pkg/gfx/framebuffer.go | 0.827236 | 0.631438 | framebuffer.go | starcoder |
package zgeo
import (
"math"
"github.com/torlangballe/zutil/zmath"
)
type Matrix struct {
A, B, C, D, Tx, Ty float64
}
var MatrixIdentity = Matrix{1, 0, 0, 1, 0, 0}
/*
func SM(w, h Num) *Matrix {
return &Matrix{sz.W, 0, 0, sz.H, 0, 0}
}
func TM(dx, dy Num) *Matrix {
return &Matrix{1, 0, 0, 1, dx, dy}
}
*/
f... | zgeo/matrix.go | 0.845751 | 0.574395 | matrix.go | starcoder |
package fptower
// Expt set z to x^t in E12 and return z
func (z *E12) Expt(x *E12) *E12 {
// const tAbsVal uint64 = 9586122913090633729
// tAbsVal in binary: 1000010100001000110000000000000000000000000000000000000000000001
// drop the low 46 bits (all 0 except the least significant bit): 100001010000100011 = 13622... | ecc/bls12-377/internal/fptower/e12_pairing.go | 0.589244 | 0.401805 | e12_pairing.go | starcoder |
package main
import (
"fmt"
"math/rand"
"time"
"github.com/qeedquan/go-media/math/f64"
)
func main() {
rand.Seed(time.Now().UnixNano())
ex1()
ex2()
}
// OpenGL and other rendering APIs expect
// coordinate system to be between [-1, 1]
// and we need to remap it to [0,W]x[0,H] at
// the end this is the standa... | math/linear_remap.go | 0.553988 | 0.455683 | linear_remap.go | starcoder |
package schedule
import "time"
// Schedule is the struct used to represent a set of retrievable time.Time structs.
type Schedule struct {
at []time.Time
crn *CronExpression
crnI *CronInstance
followingIndex int
}
// At creates a new schedule that produces the dates provided.
func At(at ...time.Time) *Schedul... | schedule.go | 0.604866 | 0.409457 | schedule.go | starcoder |
package mgl
import (
"bytes"
"fmt"
"math"
"text/tabwriter"
)
type Mat4 [16]float32
func Identity() Mat4 {
return Mat4{
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
}
}
// Pretty prints the matrix
func (m Mat4) String() string {
buf := new(bytes.Buffer)
w := tabwriter.NewWriter(buf, 4, 4, 1, ' ',... | mgl/mat4.go | 0.560614 | 0.549641 | mat4.go | starcoder |
package avltree
import (
"fmt"
"strconv"
"github.com/RedAFD/treeprint"
)
// AVL树(平衡二叉搜索树) AVL Tree
// Tree tree structure
type Tree struct {
root *Node
count uint
}
// Node tree node structure
type Node struct {
Key int
Value interface{}
Height uint
Left *Node
Right *Node
Parent *Node
}
// Len ... | DataStructures/AVLTree/AVLTree.go | 0.599251 | 0.44065 | AVLTree.go | starcoder |
package orderbook
import (
"github.com/emirpasic/gods/maps/treemap"
)
// OrderBook represents both bids (BUY) and asks (SELL).
// For each one it will hold a height balanced binary search tree.
// The order book is a tree in which the price are keys and the values are volumes.
type OrderBook struct {
bids *tr... | order_book.go | 0.760562 | 0.63141 | order_book.go | starcoder |
package main
import (
"image/color"
"math"
"time"
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
opensimplex "github.com/ojrac/opensimplex-go"
"golang.org/x/image/colornames"
)
// layerNoise creates noise from multiple layers of simplex noise.
// See https://cmaher.github.io/posts/working-with-... | procgen.go | 0.799794 | 0.461017 | procgen.go | starcoder |
package parse
import "unicode"
// This files represents the all of the states that there can possibly be
// within a field of a cron expression. This is a state machine, it does not
// validate the values of the items, only that the syntax of the cron statement
// field matches the grammar of a cron field.
func lexF... | internal/parse/states.go | 0.628521 | 0.558508 | states.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.