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 models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// WorkforceIntegrationEncryption
type WorkforceIntegrationEncryption struct {
// Stores additional data not described in the OpenAPI description found when d... | models/workforce_integration_encryption.go | 0.706393 | 0.41253 | workforce_integration_encryption.go | starcoder |
package term
import (
"fmt"
"reflect"
)
// TransformSubexprs returns a Term with f() applied to each immediate
// subexpression.
func TransformSubexprs(t Term, f func(Term) Term) Term {
switch t := t.(type) {
case Universe, Builtin, Var, LocalVar, NaturalLit, DoubleLit, BoolLit,
IntegerLit:
return t
case Lam... | term/transform.go | 0.540196 | 0.576244 | transform.go | starcoder |
package iso20022
// Set of characteristics related to a cheque instruction, such as cheque type or cheque number.
type Cheque5 struct {
// Specifies the type of cheque to be issued by the first agent.
ChequeType *ChequeType2Code `xml:"ChqTp,omitempty"`
// Identifies the cheque number.
ChequeNumber *Max35Text `xm... | Cheque5.go | 0.76708 | 0.479321 | Cheque5.go | starcoder |
package redis
import (
"context"
"encoding/json"
"fmt"
"strconv"
"time"
"github.com/go-redis/redis/v7"
"github.com/benthosdev/benthos/v4/public/bloblang"
"github.com/benthosdev/benthos/v4/public/service"
)
func redisProcConfig() *service.ConfigSpec {
spec := service.NewConfigSpec().
Stable().
Summary(`... | internal/impl/redis/processor.go | 0.728072 | 0.6922 | processor.go | starcoder |
package structpbconv
import (
"fmt"
"reflect"
"strings"
"github.com/golang/protobuf/ptypes/struct"
)
// tagKey defines a structure tag name for ConvertStructPB.
const tagKey = "structpb"
// Convert converts a structpb.Struct object to a concrete object.
func Convert(src *structpb.Struct, dst interface{}) error... | pkg/structpbconv/structpbconv.go | 0.704872 | 0.444866 | structpbconv.go | starcoder |
package gah
import (
"image"
"image/color"
"image/draw"
"image/png"
"os"
)
// Vec2i is a simple 2D int vector
type Vec2i struct {
X, Y int
}
// Vec2f is a simple 2D float vector
type Vec2f struct {
X, Y float64
}
func fileExists(filename string) bool {
info, err := os.Stat(filename)
i... | util.go | 0.766992 | 0.414484 | util.go | starcoder |
package dpfilters
import (
"github.com/signalfx/golib/datapoint"
"github.com/signalfx/signalfx-agent/internal/core/common/dpmeta"
"github.com/signalfx/signalfx-agent/internal/utils/filter"
)
// DatapointFilter can be used to filter out datapoints
type DatapointFilter interface {
// Matches takes a datapoint and r... | internal/core/dpfilters/filter.go | 0.764628 | 0.42913 | filter.go | starcoder |
package assert
import (
"math"
"reflect"
"testing"
)
func True(t *testing.T, description string, actual interface{}) {
t.Helper()
Eq(t, description, actual, true)
}
func False(t *testing.T, description string, actual interface{}) {
t.Helper()
Eq(t, description, actual, false)
}
func Nil(t *testing.T, descrip... | assert/assert.go | 0.661595 | 0.557665 | assert.go | starcoder |
package conv
import (
"fmt"
"math/big"
"strings"
)
// BytesLe2Hex returns an hexadecimal string of a number stored in a
// little-endian order slice x.
func BytesLe2Hex(x []byte) string {
b := &strings.Builder{}
b.Grow(2*len(x) + 2)
fmt.Fprint(b, "0x")
if len(x) == 0 {
fmt.Fprint(b, "00")
}
for i := len(x)... | internal/conv/conv.go | 0.650911 | 0.475788 | conv.go | starcoder |
package check
import "fmt"
// MapStringBool is the type of a check function for a slice of strings. It
// takes a slice of strings as a parameter and returns an error or nil if
// there is no error
type MapStringBool func(v map[string]bool) error
// MapStringBoolStringCheck returns a check function that checks that ... | check/mapStringBool.go | 0.713032 | 0.554531 | mapStringBool.go | starcoder |
package bindgen
import (
"go/token"
"text/template"
"modernc.org/cc"
"modernc.org/xc"
)
// TypeKey is typically used as a representation of a C type that can be used as a key in a map
type TypeKey struct {
IsPointer bool
Kind cc.Kind
Name string
}
// ParamKey is a representtive of a param
type Par... | bindgen.go | 0.734976 | 0.414721 | bindgen.go | starcoder |
package main
import (
"context"
"math"
"runtime"
"golang.org/x/sync/errgroup"
)
const msgSmartCropNotSupported = "Smart crop is not supported by used version of libvips"
func extractMeta(img *vipsImage) (int, int, int, bool) {
width := img.Width()
height := img.Height()
angle := vipsAngleD0
flip := false
... | process.go | 0.721154 | 0.4436 | process.go | starcoder |
package ahrs
import "math"
const (
MahonyDefaultKp = 0.2
MahonyDefaultKi = 0.1
)
// Mahony instance
type Mahony struct {
twoKp, twoKi float64
integralFBx, integralFBy, integralFBz float64
SampleFreq float64
Quaternions [4]float64
}
// NewMahony initiates a Mahony struct
func NewMaho... | mahony.go | 0.746139 | 0.487368 | mahony.go | starcoder |
package steps
import (
"github.com/cucumber/godog"
"github.com/kiegroup/kogito-cloud-operator/test/smoke/framework"
)
// registerKogitoInfraSteps register all Kogito Infra steps existing
func registerKogitoInfraSteps(s *godog.Suite, data *Data) {
s.Step(`^Install Kogito Infra Infinispan$`, data.installKogitoInfra... | test/smoke/steps/kogitoinfra.go | 0.630116 | 0.62065 | kogitoinfra.go | starcoder |
package ell
import (
"math"
"math/rand"
"strconv"
. "github.com/boynton/ell/data"
)
// Zero is the Ell 0 value
var Zero = Integer(0)
// One is the Ell 1 value
var One = Integer(1)
// MinusOne is the Ell -1 value
var MinusOne = Integer(-1)
func Int(n int64) *Number {
return Integer(int(n))
}
// Round - retur... | number.go | 0.714528 | 0.445349 | number.go | starcoder |
package problems
import (
"math"
)
// Contains solutions for easy problems: https://leetcode.com/problemset/all/?difficulty=Easy
// https://leetcode.com/problems/hamming-distance/
// hammingDistance calculates the Hamming distance.
// The Hamming distance between two integers is the number of positions
// at which ... | problems/easy.go | 0.877674 | 0.444444 | easy.go | starcoder |
package eval
import "math"
type fn struct {
params int
usage string
special string
}
func test() {
math.Atanh(3)
}
var fnData = map[string]fn{
"cos": {1, `cos returns the cosin of the radian argument x.`,
`
Special cases are:
Cos(±Inf) = NaN
Cos(NaN) = NaN`},
"asin": {1, `asin returns the arcsine, in ... | ex_07.16-Expr_web_calculator/eval/fn.go | 0.808446 | 0.735903 | fn.go | starcoder |
package conv
import (
"image"
"image/color"
"log"
"math"
"sync"
)
const Pi_2 = math.Pi / 2.0
type Vec3fa struct {
X, Y, Z float64
}
type Vec3uc struct {
X, Y, Z uint32
}
func outImgToXYZ(i, j, face, edge int, inLen float64) *Vec3fa {
a := inLen*float64(i) - 1.0
b := inLen*float64(j) - 1.0
var res Vec3fa... | conv/convert.go | 0.682256 | 0.437223 | convert.go | starcoder |
package fitness_calculator
import (
"go-emas/pkg/solution"
"math"
)
// IFitnessCalculator is an interface for fitness calculators
type IFitnessCalculator interface {
CalculateFitness(solution solution.ISolution) int
}
// LinearFitnessCalculator represents linear function
type LinearFitnessCalculator struct {
}
/... | pkg/fitness_calculator/fitness_calculator.go | 0.794026 | 0.423935 | fitness_calculator.go | starcoder |
package iso20022
// Additional count which may be utilised for reconciliation.
type TransactionTotals6 struct {
// Sum number of all authorisation transactions.
Authorisation *Number `xml:"Authstn,omitempty"`
// Sum number of all reversed authorisation transactions.
AuthorisationReversal *Number `xml:"AuthstnRvs... | TransactionTotals6.go | 0.728941 | 0.422326 | TransactionTotals6.go | starcoder |
package coord
import (
"math"
)
const earthR = 6378137
func outOfChina(lat, lng float64) bool {
if lng < 72.004 || lng > 137.8347 {
return true
}
if lat < 0.8293 || lat > 55.8271 {
return true
}
return false
}
func transform(x, y float64) (lat, lng float64) {
xy := x * y
absX := math.Sqrt(math.Abs(x))
... | comm/coord/coord.go | 0.681621 | 0.482063 | coord.go | starcoder |
package generic
import (
"context"
"sync"
"time"
"github.com/OneOfOne/xxhash"
"github.com/benthosdev/benthos/v4/public/service"
)
func memCacheConfig() *service.ConfigSpec {
spec := service.NewConfigSpec().
Stable().
Summary(`Stores key/value pairs in a map held in memory. This cache is therefore reset ev... | internal/impl/generic/cache_memory.go | 0.724968 | 0.637525 | cache_memory.go | starcoder |
package main
type MerkleTree struct {
depth uint32
root *MerkleNode
}
type MerkleNode struct {
hash []byte
data []byte
left *MerkleNode
right *MerkleNode
}
func createNode(left, right *MerkleNode, data []byte) *MerkleNode {
node := MerkleNode{}
if left == nil && right == nil {
hash := generateArgon2Ha... | merkle.go | 0.553264 | 0.499329 | merkle.go | starcoder |
package pkg
import (
"strconv"
"time"
)
/**
File: structs.go
Description: All the structs needed to implement the C2 record
@author <NAME>
@date 5/16/18
*/
func ParseDateStrings(acTime time.Time) (string, string, string) {
lcMonth := acTime.Month().String()
lcDay := strconv.Itoa(acTime.Day())
lcYear :... | pkg/structs.go | 0.710929 | 0.46557 | structs.go | starcoder |
package factsphere
import (
"math/rand"
"github.com/jakevoytko/crbot/api"
"github.com/jakevoytko/crbot/log"
"github.com/jakevoytko/crbot/model"
)
// Executor prints a random ?factsphere command for the user.
type Executor struct {
}
// NewFactSphereExecutor works as advertised.
func NewFactSphereExecutor() *Exe... | feature/factsphere/factsphereexecutor.go | 0.672547 | 0.509215 | factsphereexecutor.go | starcoder |
package set
var exist = struct{}{}
// Set represents an unordered list of elements.
type Set struct {
m map[interface{}]struct{}
}
// New create and returns a set, optionally with the given elements.
func New(sl ...interface{}) *Set {
return NewFromSlice(sl)
}
// NewWithSize create and returns an initialized and ... | go/pkg/set/set.go | 0.848157 | 0.438124 | set.go | starcoder |
package plot
import (
"errors"
"fmt"
"image"
"image/color"
"image/png"
"io"
"math"
"os"
"golang.org/x/image/font"
"golang.org/x/image/font/basicfont"
"golang.org/x/image/math/fixed"
)
// Canvas is the basis for all other drawing
// primitives. Its only properties are a width,
// a height and a background ... | plot/primitives.go | 0.791982 | 0.453201 | primitives.go | starcoder |
package s4
import (
"crypto/rand"
"errors"
"github.com/ceriath/rsa-shamir-secret-sharing/gf256"
)
var usedXValues []byte
// Split splits a secret into n shares where the threshold k applies
func Split(secret []byte, k, n byte) ([]Share, error) {
usedXValues = make([]byte, 0)
if k > n {
return nil, errors.N... | s4/split.go | 0.762424 | 0.471771 | split.go | starcoder |
package trackball
import (
"math"
"github.com/go-gl/mathgl/mgl32"
)
var MIN_THETA = 0.000001
var MAX_THETA = math.Pi - MIN_THETA
// Trackball moves on a sphere around a target point with a specified radius.
type Trackball struct {
width int
height int
radius float32
theta float32
phi float32
Pos mg... | pkg/scene/camera/trackball/trackball.go | 0.86212 | 0.621455 | trackball.go | starcoder |
package any
// Or sets the Value to the default when not Ok and returns the Value.
// Otherwise, the original Value is returned and the default is ignored.
// This is useful for providing a default before using the underlying value.
func (v Value) Or(i interface{}) Value {
if !v.Ok() {
v.i = i
}
return v
}
// Bo... | or.go | 0.766119 | 0.402833 | or.go | starcoder |
<tutorial>
Match with device id example of using 51Degrees device detection. The example
shows how to:
<ol>
<li>Instantiate the 51Degrees device detection provider.
<p><pre class="prettyprint lang-go">
provider = FiftyOneDegreesPatternV3.NewProvider(dataFile)
</pre></p>
<li>Produce a match for a single device id
<p><pr... | MatchForDeviceId.go | 0.539954 | 0.552238 | MatchForDeviceId.go | starcoder |
package merkle
import (
"errors"
"math"
"github.com/chain/txvm/crypto/sha3"
"github.com/chain/txvm/crypto/sha3pool"
)
var (
leafPrefix = []byte{0x00}
interiorPrefix = []byte{0x01}
emptyStringHash = sha3.Sum256(nil)
)
// AuditHash stores the hash value and denotes which side of the concatenation
// oper... | slidechain/vendor/github.com/chain/txvm/protocol/merkle/merkle.go | 0.737253 | 0.417687 | merkle.go | starcoder |
package day8
import (
"fmt"
"math"
"strings"
"github.com/dschroep/advent-of-code/common"
)
// Converts `digit` to an integer by looking at `inputLine` (format "<input> | <output>").
// Returns -1 if parsing was not possible.
func toInt(digit string, inputLine string) int {
digitLength := len(digit)
// Sort ou... | 2021/day8/lvl2.go | 0.76074 | 0.548069 | lvl2.go | starcoder |
package ng
import (
"math"
)
// Vector is the base type of ng
type Vector []float64
// NewVector returns a vector with the given number of elements.
func NewVector(size int) Vector {
return make([]float64, size)
}
// Add sums each element of the given vector with the current vector and stores
// the resulting va... | vector.go | 0.872877 | 0.791378 | vector.go | starcoder |
package tilegraphics
import "image/color"
// Rectangle is a single rectangle drawn on the display that can be moved
// around.
type Rectangle struct {
parent *Layer // nil for the root
x1, y1, x2, y2 int16
color color.RGBA
}
// boundingBox returns the exact bounding box of the rectangle.
func (r ... | object-rectangle.go | 0.81538 | 0.645064 | object-rectangle.go | starcoder |
package sudogo
import (
"math/rand"
"golang.org/x/exp/constraints"
)
func removeAtIndex[T any](slice []T, index int) []T {
last := len(slice) - 1
if index >= 0 && index <= last {
slice[index] = slice[last]
slice = slice[:last]
}
return slice
}
func removeValue[T comparable](slice []T, value T) []T {
for ... | pkg/func.go | 0.613005 | 0.420124 | func.go | starcoder |
package color
import "image"
// Picker ...
type Picker interface {
Pick(image.Image, image.Rectangle) (r, g, b, a uint32)
}
// AverageColorPicker picks average color of given RectAngle area of src image.
type AverageColorPicker struct{}
// Pick of AverageColorPicker.
func (picker AverageColorPicker) Pick(src image... | color/picker.go | 0.830353 | 0.517693 | picker.go | starcoder |
package main
import (
"context"
"flag"
"fmt"
"github.com/cheggaaa/pb/v3"
"github.com/robinbraemer/imaget"
"os"
"regexp"
"strings"
"time"
)
const usageMessage = `usage: imaget -u URL [-d destination] [-t timeout] [-r regex] [-y] [-s] [-f]
Imaget is a convenient image tool for finding images on any http(s) we... | cmd/imaget.go | 0.588771 | 0.408395 | imaget.go | starcoder |
package ast
// Expression represents a Expression node.
type Expression struct {
AssignmentExpressions []*AssignmentExpression
}
// AssignmentExpression represents a AssignmentExpression node.
type AssignmentExpression struct {
ConditionalExpression *ConditionalExpression
YieldExpression *YieldExpression
... | internal/parser/ast/expression.go | 0.667473 | 0.531331 | expression.go | starcoder |
package simulation
import (
"fmt"
"math/rand"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/simapp/helpers"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/simulation"
node "github.com/sentinel-official/hub/x/node/simulation"
plan "github.com/sentinel-official/... | x/subscription/simulation/msgs.go | 0.553747 | 0.414425 | msgs.go | starcoder |
package analyser
import (
"fmt"
"github.com/sdcoffey/techan"
)
func makeMACD(isHist bool) func(series *techan.TimeSeries, a ...interface{}) (techan.Indicator, error) {
if isHist {
return func(series *techan.TimeSeries, a ...interface{}) (techan.Indicator, error) {
if len(a) != 3 {
return nil, newError(fm... | analyser/indicatorFuncs.go | 0.586878 | 0.416381 | indicatorFuncs.go | starcoder |
package datatype
import (
"fmt"
"github.com/shopspring/decimal"
"math/big"
"strconv"
)
var integerTypeSpec = newElementTypeSpec("integer")
type integerType struct {
PrimitiveType
value int32
}
type IntegerAccessor interface {
NumberAccessor
}
func IsInteger(accessor Accessor) bool {
dt := accessor.DataTyp... | datatype/integer_type.go | 0.707405 | 0.458531 | integer_type.go | starcoder |
package regression
import (
"github.com/gaillard/go-queue/queue"
"math"
)
//Regression represents a queue of past points. Use New() to initialize.
type Regression struct {
xSum, ySum, xxSum, xySum, yySum, xDelta float64
points *queue.Queue
lastSlopeCalc, las... | v1/regression.go | 0.83152 | 0.635039 | regression.go | starcoder |
package slice
import "fmt"
// Equal reports whether two slices are equal: the same length and all
// elements equal. If the lengths are different, Equal returns false.
// Otherwise, the elements are compared in index order, and the
// comparison stops at the first unequal pair.
// Floating point NaNs are not consider... | slice.go | 0.846197 | 0.57063 | slice.go | starcoder |
package op
import(
"fmt"
)
// Returns a == b and updates the State.
func (self *State)Eq(a,b any)bool{
self.IncOperations(self.coeff["=="]+self.off["=="])
var t string = fmt.Sprintf("%T", a)
switch t {
case "int": return a.(int)==b.(int)
case "int8": return a.(int8)==b.(int8)
case "int16": return ... | op/boolean_operators.go | 0.612078 | 0.617253 | boolean_operators.go | starcoder |
package main
import (
"fmt"
"unicode/utf8"
)
/*
A Go string is a read-only slice of bytes.
The language and the standard library treat strings specially - as containers of text encoded in UTF-8.
In other languages, strings are made of “characters”.
In Go, the concept of a character is called a rune - it’s an intege... | example/strings-and-runes.go | 0.584034 | 0.528533 | strings-and-runes.go | starcoder |
package mesh
import (
"github.com/adamcolton/geom/d3"
"github.com/adamcolton/geom/d3/affine"
"github.com/adamcolton/geom/d3/curve/line"
"github.com/adamcolton/geom/d3/solid"
)
// Extrusion creates a mesh by extruding the perimeter by transormations
type Extrusion struct {
cur []uint32
points *solid.PointSet
... | d3/solid/mesh/extrusion.go | 0.752468 | 0.530419 | extrusion.go | starcoder |
package css
import (
"fmt"
"strconv"
"strings"
)
// Parse an An+B notation at the current position in Tokenizer t.
// Returns the value for A and B on successful parse.
func parseNth(t Tokenizer) (int, int, error) {
var a, b int
var ok bool
err := fmt.Errorf("Invalid nth arguments at position %v", t.Position(... | css/nth_parser.go | 0.579757 | 0.502869 | nth_parser.go | starcoder |
package clusterdictionary
import (
"github.com/mattermost/mattermost-cloud/model"
"github.com/pkg/errors"
)
const (
// SizeAlefDev is the definition of a cluster supporting dev purposes.
SizeAlefDev = "SizeAlefDev"
// SizeAlef500 is the key representing a cluster supporting 500 users.
SizeAlef500 = "SizeAlef50... | clusterdictionary/size.go | 0.616359 | 0.430387 | size.go | starcoder |
package codegen
import (
"regexp"
"strings"
"github.com/pulumi/pulumi/pkg/v2/codegen/schema"
)
var (
// IMPORTANT! The following regexp's contain named capturing groups.
// It's the `?P<group_name>` where group_name can be any name.
// When changing the group names, be sure to change the reference to
// the ... | pkg/codegen/docs.go | 0.674587 | 0.701806 | docs.go | starcoder |
package zim
import (
"bytes"
"hash/fnv"
)
const defaultLimitEntries = 100
// EntryWithURL searches for the Directory Entry with the exact URL.
// If the Directory Entry was found, found is set to true and
// the returned position will be the position in the URL pointerlist.
// This can be used to iterate over the ... | entry_search.go | 0.535584 | 0.430447 | entry_search.go | starcoder |
package gen
import "fmt"
// Builder is assists in build a more complex Node.
type Builder struct {
stack []Node
starts []int
}
// Reset clears the the Builder of previous built nodes.
func (b *Builder) Reset() {
if 0 < cap(b.stack) && 0 < len(b.stack) {
b.stack = b.stack[:0]
b.starts = b.starts[:0]
} else ... | gen/builder.go | 0.569374 | 0.496948 | builder.go | starcoder |
package gojay
// AddSliceString unmarshals the next JSON array of strings to the given *[]string s
func (dec *Decoder) AddSliceString(s *[]string) error {
return dec.SliceString(s)
}
// SliceString unmarshals the next JSON array of strings to the given *[]string s
func (dec *Decoder) SliceString(s *[]string) error {... | vendor/github.com/francoispqt/gojay/decode_slice.go | 0.709019 | 0.413181 | decode_slice.go | starcoder |
package lt
import "math"
// rho(1) = 1 / K, d=1
// rho(d) = 1 / d*(d-1) d=2, 3, 4, ..., K
// :params K: number of source block
// :return list: rho array list
func GenRho(k uint64) []float64 {
rho_set := make([]float64, k)
for i := uint64(1); i <= k; i++ {
if i == 1 {
rho_set[i-1] = float64(1) / float64(k)
... | lt/RSD.go | 0.72487 | 0.468122 | RSD.go | starcoder |
package vm
const (
OpTypeLoadNil = iota + 1 // A A: register
OpTypeFillNil // AB A: start reg B: end reg [A,B)
OpTypeLoadBool // AB A: register B: 1 true 0 false
OpTypeLoadInt // A A: register Next instruction opcode is const unsigned int
OpTypeLoadCon... | Source/vm/OpCode.go | 0.664105 | 0.654087 | OpCode.go | starcoder |
package indices
import (
"log"
"github.com/monitoring-tools/prom-elasticsearch-exporter/elasticsearch"
"github.com/monitoring-tools/prom-elasticsearch-exporter/elasticsearch/model"
"github.com/monitoring-tools/prom-elasticsearch-exporter/metrics"
"github.com/prometheus/client_golang/prometheus"
)
var (
labelsI... | collector/indices/collector.go | 0.709321 | 0.411436 | collector.go | starcoder |
package op
import (
"github.com/m4gshm/gollections/c"
"github.com/m4gshm/gollections/check"
"github.com/m4gshm/gollections/it/impl/it"
"github.com/m4gshm/gollections/op"
)
//Map creates the Iterator that converts elements with a converter and returns them.
func Map[From, To any, IT c.Iterable[c.Iterator[From]]](e... | c/op/api.go | 0.80213 | 0.406921 | api.go | starcoder |
package criteria
import (
"fmt"
"github.com/viant/assertly"
"github.com/viant/toolbox"
"github.com/viant/toolbox/data"
)
//Criterion represent evaluation criterion
type Criterion struct {
*Predicate
LeftOperand interface{}
Operator string
RightOperand interface{}
}
func (c *Criterion) expandOperand(oppe... | model/criteria/criterion.go | 0.651355 | 0.456107 | criterion.go | starcoder |
// Package bits provides a mockable wrapper for math/bits.
package bits
import (
bits "math/bits"
)
var _ Interface = &Impl{}
var _ = bits.Add
type Interface interface {
Add(x uint, y uint, carry uint) (sum uint, carryOut uint)
Add32(x uint32, y uint32, carry uint32) (sum uint32, carryOut uint32)
Add64(x uint64... | math/bits/bits.go | 0.66888 | 0.477676 | bits.go | starcoder |
package number
import (
"math"
"math/big"
)
// SquareNumber returns the n-th square number.
// e.g. 1, 4, 9, 16, 25, ...
func SquareNumber(n int) int {
return n * n
}
// IsSquareNumber determines if a number is a square number.
func IsSquareNumber(n int) bool {
t := math.Sqrt(float64(n))
return t == math.Floor(... | number/number.go | 0.895531 | 0.469642 | number.go | starcoder |
package simplecsv
import (
"regexp"
"strings"
)
// FindInColumn returns a slice with the rownumbers where the "word" is in the columnPosition
// If the column is not valid it returns an empty slice and a second false value
func (s SimpleCsv) FindInColumn(columnPosition int, word string) ([]int, bool) {
var validC... | find.go | 0.78842 | 0.458046 | find.go | starcoder |
package kson
import (
"errors"
"encoding/json"
"reflect"
"strconv"
"log"
)
type TypeTransform struct {
data interface{}
err error
}
func NewTypeTransform(data interface{}) *TypeTransform {
return &TypeTransform{data: data}
}
func (t *TypeTransform)Interface() interface{} {
return t.data
}
//Bool guarant... | kson/transform.go | 0.667364 | 0.643805 | transform.go | starcoder |
package algebra
import (
"fmt"
"math"
)
type Matrix4 struct {
M00 MnFloat
M01 MnFloat
M02 MnFloat
M03 MnFloat
M10 MnFloat
M11 MnFloat
M12 MnFloat
M13 MnFloat
M20 MnFloat
M21 MnFloat
M22 MnFloat
M23 MnFloat
M30 MnFloat
M31 MnFloat
M32 MnFloat
M33 MnFloat
}
var IdentityMatrix4 = Matrix4{
M00: MnOne,... | algebra/matrix4.go | 0.697815 | 0.474449 | matrix4.go | starcoder |
package electreIII
import (
"fmt"
"github.com/Azbesciak/RealDecisionMaker/lib/utils"
"sort"
"strings"
)
type Matrix struct {
Size int
Data []float64
}
func NewMatrix(values *[][]float64) *Matrix {
size := len(*values)
data := make([]float64, size*size)
for i, v := range *values {
copy(data[i*size:(i+1)*si... | lib/logic/preference-func/electreIII/matrix.go | 0.606732 | 0.474509 | matrix.go | starcoder |
package confusion
import (
"github.com/emer/etable/etensor"
"github.com/emer/etable/simat"
"github.com/goki/gi/gi"
"github.com/goki/ki/ki"
"github.com/goki/ki/kit"
)
// Matrix computes the confusion matrix, with rows representing
// the ground truth correct class, and columns representing the
// actual answer p... | confusion/confusion.go | 0.67822 | 0.414306 | confusion.go | starcoder |
package envelope
import (
"log"
"github.com/steinarvk/abora/synth/interpolation"
"github.com/steinarvk/abora/synth/varying"
)
// Envelope represents the amplitude component of a waveform. It takes on
// values in [0,1]. It may or may not "end", i.e. reach zero permanently.
// Its argument is in seconds.
type Enve... | synth/envelope/envelope.go | 0.75183 | 0.555435 | envelope.go | starcoder |
package main
import (
"encoding/json"
"fmt"
"os"
"reflect"
)
// We’ll use these two structs to demonstrate encoding and decoding of custom types below.
type response1 struct {
Page int
Fruits []string
}
// Only exported fields will be encoded/decoded in JSON. Fields must start with capital letters to be export... | prac_code_content/pre/pre_go_example/e_json/json.go | 0.643553 | 0.405066 | json.go | starcoder |
package fixpoint
// Useful link:
// https://spin.atomicobject.com/2012/03/15/simple-fixed-point-math/
// Q16 is a Q7.16 fixed point integer type that has 16 bits of precision to the
// right of the fixed point. It is designed to be used as a more efficient
// replacement for unit vectors with some extra room to avoid... | fixpoint.go | 0.907492 | 0.562417 | fixpoint.go | starcoder |
This is an example in Linux password driver. It demonstrates how to implement
a device specific driver in Go, using framework components from the
translation engine.
Note: Drivers do not NEED to be written in Go. Any stand alone executable (
in any language) will work. That executable needs to run in the
forg... | cmd/drivers/linux/linux.go | 0.582135 | 0.405449 | linux.go | starcoder |
package point
import (
"github.com/gravestench/pho/geom"
)
// New creates a new point
func New(x, y float64) *Point {
return &Point{
Type: geom.Point,
X: x,
Y: y,
}
}
// Point defines a Point in 2D space, with an x and y component.
type Point struct {
Type geom.ShapeType
X, Y float64
}
// XY returns the ... | geom/point/point.go | 0.945462 | 0.817246 | point.go | starcoder |
package graph
import "bytes"
// Lines is a textual multi-line representation of the node graph.
func Lines(nodes []*Node) ([]string, error) {
if len(nodes) == 0 {
return []string{}, nil
}
g := &graph{
slots: [][]byte{nodes[0].ID},
nodes: nodes,
}
return g.table().lines()
}
// Node is a node (vertex) of ... | cli/graph/graph.go | 0.760028 | 0.460289 | graph.go | starcoder |
package transform
import (
"fmt"
"github.com/twpayne/go-geom"
)
// Compare compares two coordinates for equality and magnitude
type Compare interface {
IsEquals(x, y geom.Coord) bool
IsLess(x, y geom.Coord) bool
}
type tree struct {
left *tree
value geom.Coord
right *tree
}
// TreeSet sorts the coordinates... | vendor/github.com/whosonfirst/go-whosonfirst-static/vendor/github.com/whosonfirst/go-whosonfirst-readwrite-sqlite/vendor/github.com/whosonfirst/go-whosonfirst-sqlite-features/vendor/github.com/twpayne/go-geom/transform/tree_set.go | 0.872279 | 0.502747 | tree_set.go | starcoder |
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// A little test program for rational arithmetics.
// Computes a Hilbert matrix, its inverse, multiplies them
// and verifies that the product is the identity ... | test/hilbert.go | 0.761716 | 0.46393 | hilbert.go | starcoder |
package assertions
import (
"fmt"
"reflect"
"strings"
)
// ShouldStartWith receives exactly 2 string parameters and ensures that the first starts with the second.
func ShouldStartWith(actual interface{}, expected ...interface{}) string {
if fail := need(1, expected); fail != success {
return fail
}
value, va... | Godeps/_workspace/src/github.com/smartystreets/goconvey/convey/assertions/strings.go | 0.761804 | 0.60054 | strings.go | starcoder |
Package indexer provides tools to define, use, and update state indexers.
State service
The state service stores gateway state as keyed blobs.
Examples
- IMSI -> directory record blob
- HWID -> gateway status blob
Since state values are stored as arbitrary serialized blobs, the state
service has no semanti... | orc8r/cloud/go/services/state/indexer/doc.go | 0.655887 | 0.669421 | doc.go | starcoder |
package processor
import (
"fmt"
"time"
"github.com/Jeffail/benthos/v3/internal/bloblang/field"
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/internal/interop"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message"
"github.com/Jeffail/benthos/v3/lib/... | lib/processor/group_by_value.go | 0.727685 | 0.579817 | group_by_value.go | starcoder |
package lcio
import (
"bytes"
"fmt"
"strings"
"go-hep.org/x/hep/sio"
)
// RecParticleContainer is a collection of RecParticles.
type RecParticleContainer struct {
Flags Flags
Params Params
Parts []RecParticle
}
type RecParticle struct {
Type int32
P [3]float32 // momentum (Px,PyPz)... | lcio/recparticle.go | 0.534612 | 0.409457 | recparticle.go | starcoder |
package gol
// Rules:
// Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
// Any live cell with two or three live neighbours lives on to the next generation.
// Any live cell with more than three live neighbours dies, as if by overpopulation.
// Any dead cell with exactly three ... | gol.go | 0.691602 | 0.430925 | gol.go | starcoder |
package iso20022
// Key elements used to refer the original transaction.
type OriginalTransactionReference16 struct {
// Amount of money moved between the instructing agent and the instructed agent.
InterbankSettlementAmount *ActiveOrHistoricCurrencyAndAmount `xml:"IntrBkSttlmAmt,omitempty"`
// Amount of money to... | OriginalTransactionReference16.go | 0.783947 | 0.456652 | OriginalTransactionReference16.go | starcoder |
This is an unoptimized version based on the description in RFC 3713.
References:
http://en.wikipedia.org/wiki/Camellia_%28cipher%29
https://info.isl.ntt.co.jp/crypt/eng/camellia/
*/
package camellia
import (
"crypto/cipher"
"encoding/binary"
"math/bits"
"strconv"
)
const BlockSize = 16
type KeySize... | vendor/github.com/dgryski/go-camellia/camellia.go | 0.76533 | 0.511107 | camellia.go | starcoder |
package function
import (
"fmt"
"strconv"
"time"
"github.com/lestrrat-go/strftime"
"github.com/liquidata-inc/go-mysql-server/sql"
"github.com/liquidata-inc/go-mysql-server/sql/expression"
)
func panicIfErr(err error) {
if err != nil {
panic(err)
}
}
func monthNum(t time.Time) string {
return strconv.For... | sql/expression/function/date_format.go | 0.671578 | 0.424591 | date_format.go | starcoder |
package spacecurves
// Morton2DEncode encodes a 2D x,y pair into a single value along
// a Z-order curve of the specified number of bits.
func Morton2DEncode(bits, x, y uint) uint {
var answer uint
s := uint(1)
for i := uint(0); i < bits; i++ {
answer |= (x & s) << i
answer |= (y & s) << (i + 1)
s <<= 1
}
r... | spacecurves/morton.go | 0.844409 | 0.614018 | morton.go | starcoder |
package day5
import (
"fmt"
"strings"
)
/*
You come across a field of hydrothermal vents on the ocean floor! These vents
constantly produce large, opaque clouds, so it would be best to avoid them if
possible.
They tend to form in lines; the submarine helpfully produces a list of nearby
lines of vents (your puzzle ... | day5/part1.go | 0.739234 | 0.482795 | part1.go | starcoder |
package stripe
import (
"context"
"github.com/stripe/stripe-go"
"github.com/turbot/steampipe-plugin-sdk/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/plugin"
"github.com/turbot/steampipe-plugin-sdk/plugin/transform"
)
func tableStripePlan(ctx context.Context) *plugin.Table {
return &plugin.Table{
Name:... | stripe/table_stripe_plan.go | 0.715325 | 0.420659 | table_stripe_plan.go | starcoder |
package primitives
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"github.com/prysmaticlabs/go-ssz"
"github.com/phoreproject/synapse/beacon/config"
"github.com/phoreproject/synapse/bls"
"github.com/phoreproject/synapse/chainhash"
)
// ValidateAttestation checks if the attestation is valid.
func (s *State)... | primitives/blocktransition.go | 0.722625 | 0.455017 | blocktransition.go | starcoder |
// Package area provides functions working with image areas.
package area
import (
"fmt"
"image"
"github.com/mum4k/termdash/internal/numbers"
)
// Size returns the size of the provided area.
func Size(area image.Rectangle) image.Point {
return image.Point{
area.Dx(),
area.Dy(),
}
}
// FromSize returns the... | internal/area/area.go | 0.895374 | 0.756627 | area.go | starcoder |
package messages
import (
util "github.com/IBM/ibmcloud-volume-interface/lib/utils"
)
// messagesEn ...
var messagesEn = map[string]util.Message{
"AuthenticationFailed": {
Code: AuthenticationFailed,
Description: "Failed to authenticate the user.",
Type: util.Unauthenticated,
RC: 400,... | common/messages/messages_en.go | 0.512205 | 0.439386 | messages_en.go | starcoder |
package main
import (
"math"
"sort"
)
type Place struct {
Name string
Latitude float64
Longitude float64
Level int32
}
const RadiansToDegrees = 57.2957795
const DegreesToKm = math.Pi * 6371.0 / 180.0
const RadiansToKm = RadiansToDegrees * DegreesToKm
func (p Place) Distance(point Place) float64 {
... | tools/stationxml/place.go | 0.740925 | 0.594051 | place.go | starcoder |
package data
import "fmt"
const (
MISMATCHED_INDENTATION = "Mismatched indentation."
MODULE_NAME = `Module names should be composed of identifiers started with a lower case character and separated by dots.
They also cannot contain special characters like '?' or '!'.`
MODULE_DEFINITION = `Expected file to begin w... | data/errors.go | 0.866359 | 0.481393 | errors.go | starcoder |
package capi
const (
manifests = `---
apiVersion: v1
kind: Namespace
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: cluster-api-system
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: clusters.cluster.k8s.io
spec:
group: cluster.... | pkg/capi/constants.go | 0.871448 | 0.4474 | constants.go | starcoder |
package model
import (
"fmt"
"math/big"
"strings"
"github.com/hashicorp/hcl/v2"
"github.com/hashicorp/hcl/v2/hclsyntax"
"github.com/pulumi/pulumi/pkg/v3/codegen/hcl2/syntax"
"github.com/zclconf/go-cty/cty"
)
// TupleType represents values that are a sequence of independently-typed elements.
type TupleType st... | pkg/codegen/hcl2/model/type_tuple.go | 0.697506 | 0.450541 | type_tuple.go | starcoder |
// Package primitiveset is a container for a set of primitives (i.e. implementations of cryptographic
// primitives offered by Tink). It provides also additional properties for the primitives
// it holds. In particular, one of the primitives in the set can be distinguished as
// "the primary" one.
package primitiveset... | go/primitiveset/primitiveset.go | 0.808408 | 0.475666 | primitiveset.go | starcoder |
package goment
import (
"regexp"
)
var inclusivityRegex = regexp.MustCompile("^[\\[\\(]{1}[\\]\\)]{1}$")
// IsBefore will check if a Goment is before another Goment.
func (g *Goment) IsBefore(args ...interface{}) bool {
var err error
var input *Goment
numArgs := len(args)
if numArgs == 0 {
input, err = New()... | compare.go | 0.593963 | 0.435481 | compare.go | starcoder |
package throttle
import (
"sync/atomic"
"time"
)
//------------------------------------------------------------------------------
// Type is a throttle of retries to avoid endless busy loops when a message
// fails to reach its destination.
type Type struct {
// unthrottledRetries is the number of concecutive re... | lib/util/throttle/type.go | 0.741112 | 0.436622 | type.go | starcoder |
package matcher
import (
"github.com/mhoc/xtern-matcher/model"
)
func Simple(students model.Students, companies model.Companies) model.Matches {
var matches model.Matches
// The core of the matching algorithm works by company rank; starting with rank 0, going until
// rank n, finding as many matches at each rank... | matcher/matcher_simple.go | 0.577138 | 0.408277 | matcher_simple.go | starcoder |
package log
import "strconv"
/*
Copyright 2019 <NAME> <<EMAIL>>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required b... | vendor/github.com/brunotm/log/encoder.go | 0.669096 | 0.401131 | encoder.go | starcoder |
package search
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// Acronym
type Acronym struct {
SearchAnswer
// What the acronym stands for.
standsFor *string
// State of the acronym. Possible values are: publ... | models/search/acronym.go | 0.656108 | 0.451871 | acronym.go | starcoder |
package constraint
import (
"github.com/g3n/engine/math32"
"github.com/g3n/engine/experimental/physics/equation"
)
// ConeTwist constraint.
type ConeTwist struct {
PointToPoint
axisA *math32.Vector3 // Rotation axis, defined locally in bodyA.
axisB *math32.Vector3 // Rotation axis, defined locally in ... | experimental/physics/constraint/conetwist.go | 0.860765 | 0.508483 | conetwist.go | starcoder |
// Package elliptic implements elliptic curve primitives.
package elliptic
import (
"crypto/rand"
"io"
"math/big"
"sync"
"github.com/svkirillov/cryptopals-go/helpers"
)
// A Curve represents a short-form Weierstrass curve y^2 = x^3 + a*x + b.
type Curve interface {
// Params returns the parameters for the cur... | elliptic/elliptic.go | 0.857649 | 0.634515 | elliptic.go | starcoder |
package tuple
import (
"golang.org/x/exp/constraints"
)
// OrderedComparisonResult represents the result of a tuple ordered comparison.
// OrderedComparisonResult == 0 represents that the tuples are equal.
// OrderedComparisonResult < 0 represent that the host tuple is less than the guest tuple.
// OrderedComparison... | comparison.go | 0.898941 | 0.511412 | comparison.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.