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 stegjpeg
import (
"io"
)
// maxCodeLength is the maximum (inclusive) number of bits in a Huffman code.
const maxCodeLength = 16
// maxNCodes is the maximum (inclusive) number of codes in a Huffman tree.
const maxNCodes = 256
// lutSize is the log-2 size of the Huffman decoder's look-up table.
const lutSiz... | stegjpeg/huffman.go | 0.554832 | 0.441372 | huffman.go | starcoder |
package http2
import (
"golang.org/x/net/http2"
"github.com/summerwind/h2spec/config"
"github.com/summerwind/h2spec/spec"
)
func Ping() *spec.TestGroup {
tg := NewTestGroup("6.7", "PING")
// Receivers of a PING frame that does not include an ACK flag MUST
// send a PING frame with the ACK flag set in response... | http2/6_7_ping.go | 0.546254 | 0.400749 | 6_7_ping.go | starcoder |
package handlers
//nolint: gofmt
//nolint: lll
//nolint: funlen
func spec() string {
return `
{
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"https"
],
"swagger": "2.0",
"info": {
"description": "All the information needed to talk to the API.\n\n... | cmd/mailchain/internal/http/handlers/openapi.go | 0.524638 | 0.434101 | openapi.go | starcoder |
package pure
import (
"context"
"fmt"
"github.com/benthosdev/benthos/v4/internal/bloblang/mapping"
"github.com/benthosdev/benthos/v4/internal/bloblang/parser"
"github.com/benthosdev/benthos/v4/internal/bundle"
"github.com/benthosdev/benthos/v4/internal/component/processor"
"github.com/benthosdev/benthos/v4/int... | internal/impl/pure/processor_bloblang.go | 0.77193 | 0.636254 | processor_bloblang.go | starcoder |
package processor
import (
"fmt"
"strings"
"time"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffail/benthos/v3/lib/util/text"
"github.com/Jeffail/benthos/v3/lib/x/docs"
"github.com/opentracing/opentracing-go"
)
/... | lib/processor/metadata.go | 0.783988 | 0.716491 | metadata.go | starcoder |
package iso20022
// Identification of a security by its symbol.
type SecurityIdentification3 struct {
// International Securities Identification Number (ISIN). A numbering system designed by the United Nation's International Organisation for Standardisation (ISO). The ISIN is composed of a 2-character prefix repres... | SecurityIdentification3.go | 0.76074 | 0.585605 | SecurityIdentification3.go | starcoder |
package poly
import (
"math"
"strings"
)
// For reference: https://www.sigmaaldrich.com/technical-documents/articles/biology/oligos-melting-temp.html
// thermodynamics stores enthalpy (dH, kcal/mol) and entropy (dS, cal/mol-K) values for nucleotide pairs
type thermodynamics struct{ H, S float64 }
/***************... | primers.go | 0.696062 | 0.524699 | primers.go | starcoder |
package ldap_injection
import (
"github.com/damianmcgrath/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "ldap-injection",
Title: "LDAP-Injection",
Description: "When an LDAP server is accessed LDAP-Injection risks might arise. " +
"The risk rating depends on the ... | risks/built-in/ldap-injection/ldap-injection-rule.go | 0.683102 | 0.474936 | ldap-injection-rule.go | starcoder |
package summarize
import (
"math"
)
// FleschKincaid computes the Flesch–Kincaid grade level
// (https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests).
func (d *Document) FleschKincaid() float64 {
x := 0.39 * d.NumWords / d.NumSentences
y := 11.8 * d.NumSyllables / d.NumWords
return x + y - 15.5... | summarize/readability.go | 0.841207 | 0.55935 | readability.go | starcoder |
package types
import (
"fmt"
"strings"
)
type Coin struct {
Denom string `json:"denom"`
Amount int64 `json:"amount"`
}
func (coin Coin) String() string {
return fmt.Sprintf("(%v %v)",
coin.Denom, coin.Amount)
}
//----------------------------------------
type Coins []Coin
// Must be sorted, and not have 0... | types/coin.go | 0.631935 | 0.510008 | coin.go | starcoder |
package gohome
import (
"github.com/PucklaMotzer09/mathgl/mgl32"
)
// Returns wether two Polygons are intersecting
func AreIntersecting(p1, p2 *PolygonMath2D) bool {
vertices1 := *p1
vertices2 := *p2
relativeVecs1, relativeVecs2 := make([]mgl32.Vec2, len(vertices1)), make([]mgl32.Vec2, len(vertices2))
var j in... | src/gohome/seperatingaxis.go | 0.642545 | 0.502197 | seperatingaxis.go | starcoder |
package main
// Unit testing is an important part of writing principled Go programs.
// The testing package provides the tool we need to write unit tests and the go test command runs tests.
// For the sake of demonstration, this code is in package main, but it could be any package. Testing code typically
// lives in ... | 01_Go_by_Example/65_Testing.go | 0.578686 | 0.661807 | 65_Testing.go | starcoder |
package indicators
import (
"github.com/dellosaneil/stocktracking-backend/model"
"github.com/dellosaneil/stocktracking-backend/util"
)
func StochasticOscillator(prices []model.PriceModel, fastKPeriod int, slowKPeriod int, slowDPeriod int) []model.StochasticOscillator {
var stochastic []model.StochasticOscillator
... | indicators/StochasticOscillator.go | 0.661158 | 0.429908 | StochasticOscillator.go | starcoder |
package farm
func uoH(x, y, mul uint64, r uint) uint64 {
a := (x ^ y) * mul
a ^= (a >> 47)
b := (y ^ a) * mul
return rotate64(b, r) * mul
}
func Hash64WithSeeds(s []byte, seed0, seed1 uint64) uint64 {
slen := len(s)
if slen <= 64 {
return naHash64WithSeeds(s, seed0, seed1)
}
// For strings over 64 bytes we... | vendor/github.com/dgryski/go-farm/farmhashuo.go | 0.666605 | 0.462291 | farmhashuo.go | starcoder |
package hsluv
import (
"fmt"
"math"
"strconv"
"strings"
)
func HsluvToHex(h, s, l float64) (string) {
return convRgbHex(convHsluvRgb(h, s, l))
}
func HsluvToRGB(h, s, l float64) (float64, float64, float64) {
return convHsluvRgb(h, s, l)
}
func HsluvFromHex(hex string) (float64, float64, floa... | vendor/github.com/hsluv/hsluv-go/hsluv.go | 0.848753 | 0.542984 | hsluv.go | starcoder |
package reflectx
import (
"errors"
"reflect"
)
type valueType int
const (
structType valueType = 1
basicType valueType = 2
sliceType valueType = 3
otherType valueType = 4
)
type Column struct {
Name string
Value interface{}
}
var convertType = map[reflect.Kind]valueType{
reflect.Invalid: otherTy... | reflectx/reflect.go | 0.51562 | 0.466724 | reflect.go | starcoder |
Package taskhawk is a replacement for celery that works on AWS SQS/SNS, while keeping things pretty simple and
straightforward. Any unbound function can be converted into a TaskHawk task.
For inter-service messaging, see Hedwig: https://godoc.org/github.com/cloudchacho/hedwig-go/hedwig.
Provisioning
Taskhawk works o... | doc.go | 0.693369 | 0.4133 | doc.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// AttendanceRecord
type AttendanceRecord struct {
Entity
// List of time periods between joining and leaving a meeting.
attendanceIntervals []Attenda... | models/attendance_record.go | 0.589953 | 0.504394 | attendance_record.go | starcoder |
package azure
type ClassicVMSize struct {
MemoryInMB int
NumberOfCores int
StorageSize int
MaxNic int
}
var CLASSIC_VM_SIZES = map[string]ClassicVMSize{
"ExtraSmall": {MemoryInMB: 786, NumberOfCores: 1, StorageSize: 20, MaxNic: 1},
"Small": {MemoryInMB: 1.75 * 1024, NumberOfCores: 1,... | pkg/multicloud/azure/classic_instancesize.go | 0.556882 | 0.452596 | classic_instancesize.go | starcoder |
package util
import (
"bytes"
"encoding/binary"
"encoding/hex"
"encoding/json"
"fmt"
"math/big"
"strconv"
"strings"
"github.com/asaskevich/govalidator"
"github.com/make-os/kit/util/identifier"
"github.com/shopspring/decimal"
"github.com/spf13/cast"
)
// Constants
const (
Length32 = 32
Length64 = 64
)
... | util/custom_types.go | 0.792544 | 0.429788 | custom_types.go | starcoder |
package reldate
import (
"errors"
"strings"
"time"
)
const (
// The standard format for dates I find convient
YYYYMMDD = "2006-01-02"
// Version of this package
Version = "v0.0.2"
)
// finds the end of the month value (e.g. 28, 29, 30, 31)
func EndOfMonth(t1 time.Time) string {
location := t1.Location()
yea... | plugins/data/transform/datatools/reldate/reldate.go | 0.574872 | 0.587026 | reldate.go | starcoder |
package v1
func (VM) SwaggerDoc() map[string]string {
return map[string]string{
"": "VM is *the* VM Definition. It represents a virtual machine in the runtime environment of kubernetes.",
"spec": "VM Spec contains the VM specification.",
"status": "Status is the high level overview of how the VM is doi... | pkg/api/v1/types_swagger_generated.go | 0.852844 | 0.564158 | types_swagger_generated.go | starcoder |
package xpath
import (
"math"
"github.com/santhosh-tekuri/dom"
)
// Expr is interface used to represent a specific type of xpath expression.
type Expr interface {
// Returns returns the DataType of the value that this expression evaluates to.
Returns() DataType
// Eval evaluates against the given context and ... | expr.go | 0.807954 | 0.494568 | expr.go | starcoder |
package encoder
import (
`encoding`
`encoding/json`
`reflect`
`unsafe`
`github.com/bytedance/sonic/internal/native`
`github.com/bytedance/sonic/internal/rt`
)
/** Encoder Primitives **/
var _QuoteTab = [256]string {
'\x00' : `\u0000`,
'\x01' : `\u0001`,
'\x02' : `\u0002`,
'\x... | vendor/github.com/bytedance/sonic/encoder/primitives.go | 0.74512 | 0.433981 | primitives.go | starcoder |
package list
// Create makes a slice of the given length with each item set to value.
func Create[T any](length int, value T) []T {
output := make([]T, length)
for i := range output {
output[i] = value
}
return output
}
// Create2D makes a two dimensional slice of the given lengths with each item set to value.
... | list/create.go | 0.798305 | 0.703817 | create.go | starcoder |
package irs
import (
"log"
"math"
"time"
)
func roundTo(n float64, decimals uint32) float64 {
// 반올림
return math.Round(n*math.Pow(10, float64(decimals))) / math.Pow(10, float64(decimals))
}
func days(date1 time.Time, date2 time.Time) float64 {
// 날짜 간 일수 계산
return date2.Sub(date1).Hours() / 24
}
func isEOM(e... | engine/utils.go | 0.536313 | 0.563258 | utils.go | starcoder |
package main
import "github.com/forestgiant/eff"
const (
defaultState = 0
xState = 1
fillState = 2
incorrectState = 3
)
type square struct {
eff.Shape
state int
point eff.Point
mouseOver bool
leftDown bool
rightDown bool
selected bool
onSelect func(int, int)
... | square.go | 0.507812 | 0.406243 | square.go | starcoder |
package assert
import (
"github.com/guillermo/terminal/area"
"github.com/guillermo/terminal/char"
"testing"
)
// TArea is a testing Area
type TArea struct {
area.Area
T *testing.T
}
// SetChar is a shorthand to set a specific Char
func (a *TArea) SetChar(Row, Col int, ch string) {
a.Set(Row, Col, &char.Char{Va... | assert/area.go | 0.598899 | 0.474936 | area.go | starcoder |
package main
import (
"fmt"
"io/ioutil"
"math"
"os"
"strconv"
"strings"
)
const halfPi float64 = math.Pi / 2.0
// Round float64 to the nearest int.
// Works for positive and negative numbers and zero.
// Examples:
// round(0.4) -> 0.0
// round(0.5) -> 1.0
// round(-0.4) -> 0.0
// round(-0.5) -> -1.0
// roun... | go/day1/day1.go | 0.772702 | 0.493592 | day1.go | starcoder |
package providers
import (
"encoding/json"
"fmt"
"log"
"github.com/StackExchange/dnscontrol/models"
)
//Registrar is an interface for a domain registrar. It can return a list of needed corrections to be applied in the future.
type Registrar interface {
GetRegistrarCorrections(dc *models.DomainConfig) ([]*models... | providers/providers.go | 0.565539 | 0.419113 | providers.go | starcoder |
package iso20022
// Choice of identifiers for a clearing system member, as assigned by the clearing system. In some clearing systems, the accounts of the clearing system members are also assigned an identifier.
type ClearingSystemMemberIdentification2Choice struct {
// (United States) Clearing House Interbank Paymen... | ClearingSystemMemberIdentification2Choice.go | 0.709221 | 0.490358 | ClearingSystemMemberIdentification2Choice.go | starcoder |
package gokql
import (
"strconv"
"time"
)
type typeHandler interface {
convert(value string) (result interface{}, err error)
equal(left interface{}, right interface{}) bool
greater(left interface{}, right interface{}) bool
less(left interface{}, right interface{}) bool
greaterOrEqual(left interface{}, right in... | type_handler.go | 0.718496 | 0.494995 | type_handler.go | starcoder |
package spellingbee
import "time"
// Puzzle represents a spelling bee puzzle. The puzzle is comprised of a
// circular grid of 6 letters around a single letter. The goal is to use the
// letters to make words that all use the center letter and have length 4 or
// greater. Letters may be reused.
type Puzzle struct ... | api/spellingbee/puzzle.go | 0.797162 | 0.508056 | puzzle.go | starcoder |
package typeinfo
import (
"context"
"fmt"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/dolt/go/store/geometry"
"github.com/dolthub/dolt/go/store/types"
)
// This is a dolt implementation of the MySQL type Point, thus most of the functionality
// within is directly reliant on the go-mysql-serve... | go/libraries/doltcore/schema/typeinfo/point.go | 0.592784 | 0.433382 | point.go | starcoder |
package challenge
import (
"strings"
"github.com/codemicro/adventOfCode/lib/aocgo"
)
type node struct {
isSmall bool
name string
}
func newNode(x string) *node {
return &node{
isSmall: x == strings.ToLower(x),
name: x,
}
}
type graph struct {
nodes map[string]*node
edges map[*node][]*node
}
func... | challenges/2021/12-passagePathing/go/challenge.go | 0.571049 | 0.47591 | challenge.go | starcoder |
package score
import (
"fmt"
"math"
"strings"
"time"
)
const (
layout = "2006-01-02T15:04:05"
)
func NewResults(scores ...*Score) *Results {
r := &Results{
testNames: make([]string, 0),
scores: make(map[string]*Score),
}
for _, sc := range scores {
r.addScore(sc)
}
r.Scores = r.toScoreSlice()
ret... | kit/score/results.go | 0.743913 | 0.404213 | results.go | starcoder |
package cppn
import (
"errors"
"math"
"github.com/yaricom/goESHyperNEAT/hyperneat"
"github.com/yaricom/goNEAT/neat/network"
"github.com/yaricom/goNEAT/neat/utils"
)
// Represents substrate holding configuration of ANN with weights produced by CPPN. According to HyperNEAT method
// the ANN neurons are encoded as... | cppn/substrate.go | 0.763924 | 0.532547 | substrate.go | starcoder |
package util
import (
"math"
"strconv"
)
func Sigmoid(x float64)(y float64) {
y = 1 / (1 + math.Exp(-1 * x))
return y
}
func UnSigmoid(x float64) float64 {
x = x * 0.99 + 0.01
y := math.Log(x / (1 - x))
return y
}
func Signum(x float64) float64 {
ret := 0.0
if x > 0{
ret = 1.0
} else if(x < 0) {
ret =... | vendor/github.com/xlvector/hector/util/math_util.go | 0.741393 | 0.400984 | math_util.go | starcoder |
package day8
var data = `rect 1x1
rotate row y=0 by 6
rect 1x1
rotate row y=0 by 3
rect 1x1
rotate row y=0 by 5
rect 1x1
rotate row y=0 by 4
rect 2x1
rotate row y=0 by 5
rect 2x1
rotate row y=0 by 2
rect 1x1
rotate row y=0 by 5
rect 4x1
rotate row y=0 by 2
rect 1x1
rotate row y=0 by 3
rect 1x1
rotate row y=0 by 3
rect... | 2016/day8/data.go | 0.629661 | 0.749018 | data.go | starcoder |
package datastructure
// Set is a data container, like slice, but element of set is not duplicate
type Set[T comparable] map[T]bool
// NewSet return a instance of set
func NewSet[T comparable](values ...T) Set[T] {
set := make(Set[T])
set.Add(values...)
return set
}
// Add value to set
func (s Set[T]) Add(values ... | datastructure/set/set.go | 0.787646 | 0.430686 | set.go | starcoder |
package cubelib
import (
// "fmt"
"github.com/mortdeus/mathgl"
gl "github.com/remogatto/opengles2"
"math"
)
type Camera struct {
X, Y, Z float32
}
type World struct {
// Size of the rendering viewport
Width, Height int
camera Camera
objects []*Cube
view, projection mathgl.Mat4f
project... | cube/cubelib/world.go | 0.757615 | 0.465873 | world.go | starcoder |
package jbtracer
import (
"fmt"
"math"
"strings"
)
type Canvas struct {
Width, Height int
Grid [][]*Color
}
type PPM []string
// NewCanvas returns a new canvas of width, height with an
// initialized grid of pixels
func NewCanvas(width, height int) *Canvas {
c := &Canvas{Width: width, Height: height}... | canvas.go | 0.737725 | 0.419232 | canvas.go | starcoder |
package main
import (
"github.com/go-gl/gl/all-core/gl"
)
type Renderer struct {
vao uint32
vbo uint32
vertices []float32
}
const MaxVertices = 100000
func newRenderer() *Renderer {
renderer := &Renderer {}
gl.GenVertexArrays(1, &renderer.vao)
gl.GenBuffers(1, &renderer.vbo)
gl.BindVertexArray(renderer.va... | renderer.go | 0.603114 | 0.401365 | renderer.go | starcoder |
package tester
import (
"regexp"
"strings"
"github.com/pladdy/cabby"
"github.com/pladdy/stones"
log "github.com/sirupsen/logrus"
)
// CompareAPIRoot compares two APIRoots
func CompareAPIRoot(result, expected cabby.APIRoot) bool {
passed := true
if result.Path != expected.Path {
log.Error("Got:", result.Pat... | tester/compare.go | 0.553747 | 0.568775 | compare.go | starcoder |
package functions
import (
"crypto/rand"
"encoding/hex"
"regexp"
"strings"
"github.com/jexia/semaphore/v2/pkg/broker"
"github.com/jexia/semaphore/v2/pkg/broker/logger"
"github.com/jexia/semaphore/v2/pkg/references"
"github.com/jexia/semaphore/v2/pkg/specs"
"go.uber.org/zap"
)
// Custom represents a collecti... | pkg/functions/functions.go | 0.708918 | 0.483648 | functions.go | starcoder |
package scenery
import (
"fmt"
"math"
"github.com/go-gl/gl/v4.6-core/gl"
"github.com/go-gl/glfw/v3.3/glfw"
mgl "github.com/go-gl/mathgl/mgl32"
"github.com/xopoww/go-raytrace/app"
"github.com/xopoww/go-raytrace/glutils"
)
type Camera struct {
Position mgl.Vec3
Lookat mgl.Vec3
Up mgl.Vec3
FOV ... | scenery/camera.go | 0.555073 | 0.463748 | camera.go | starcoder |
package decisiontrees
import (
"fmt"
pb "github.com/ajtulloch/decisiontrees/protobufs"
"math/rand"
"sort"
)
// Examples is a slice of Example elements
type Examples []*pb.Example
func (e Examples) subsampleExamples(samplingRate float64) Examples {
for i := range e {
j := rand.Intn(i + 1)
e[i], e[j] = e[j], ... | examples.go | 0.832577 | 0.485661 | examples.go | starcoder |
package memory
import (
"bytes"
"encoding/binary"
"fmt"
"io"
"strconv"
)
var (
True = NewAddr(TypeBool, 1)
False = NewAddr(TypeBool, 0)
NoBytes = NewAddr(TypeBytes)
Nil = NewAddr(TypeNil)
)
type Addr struct {
typ Type
dat []byte
vec []Addr
}
func NewAddr(t Type, dat ...byte) Addr {
return Addr... | memory/addr.go | 0.553988 | 0.432243 | addr.go | starcoder |
package csv
import (
"fmt"
"github.com/sudachen/go-ml/fu"
"github.com/sudachen/go-ml/tables"
"math"
"reflect"
"strconv"
"time"
)
type resolver func() mapper
func (r resolver) As(n string) resolver {
return func() mapper {
m := r()
m.TableCol = n
return m
}
}
func Column(v string) resolver {
return f... | tables/csv/resolver.go | 0.546496 | 0.403714 | resolver.go | starcoder |
package sequence
import (
"log"
"math"
)
// Solve calculates the polynomial represented by the list of coeffs
// coeffs - polynomial coefficients
// a + b*x + c*x^2 ...
// x - a value to substitute
func Solve(coeffs []float64, x float64) float64 {
var sum float64
for i := range coeffs {
sum += coeffs[i]... | sequence/polynomial.go | 0.802478 | 0.492615 | polynomial.go | starcoder |
package common
import (
"math/big"
"math/rand"
"reflect"
)
const (
hashLength = 32
addressLength = 20
)
type (
Hash [hashLength]byte
Address [addressLength]byte
)
func BytesToHash(b []byte) Hash {
var h Hash
h.SetBytes(b)
return h
}
func StringToHash(s string) Hash { return BytesToHash([]byte(s)) }
... | common/types.go | 0.783492 | 0.461623 | types.go | starcoder |
package zloysql
import (
"database/sql"
"errors"
"math/big"
"github.com/shopspring/decimal"
)
var ErrorSqlDbIsNil error = errors.New("sql.DB is nil pointer")
type DialectSQL int
const (
MySQL DialectSQL = iota
MicrosoftSQL
PostgreSQL
)
type MaybeInt8 struct {
Value int8
Null bool
}
func (it MaybeInt8) ... | gen/common.go | 0.577019 | 0.446012 | common.go | starcoder |
package Challenge1
/*
Given a sequence originalSeq and an array of sequences, write a method to find if originalSeq can be uniquely reconstructed from the array of sequences.
Unique reconstruction means that we need to find if originalSeq is the only sequence such that all sequences in the array are subsequences of it... | Pattern16 - Topological Sort/Challenge1/solution.go | 0.800614 | 0.856692 | solution.go | starcoder |
package io
import (
"fmt"
"reflect"
"github.com/pkg/errors"
)
func isIterable(i interface{}) bool {
kind := reflect.TypeOf(i).Kind()
return kind == reflect.Array || kind == reflect.Slice
}
// CoerceColumnType replaces the data type of values in a column that has the specified name to the specified elementType
... | utils/io/coercecolumn.go | 0.716417 | 0.458046 | coercecolumn.go | starcoder |
package convert
import (
"reflect"
"time"
)
type TTypeConverter struct{}
var TypeConverter *TTypeConverter = &TTypeConverter{}
func (c *TTypeConverter) ToTypeCode(value interface{}) TypeCode {
return ToTypeCode(value)
}
func (c *TTypeConverter) ToNullableType(typ TypeCode, value interface{}) interface{} {
retu... | convert/TypeConverter.go | 0.645567 | 0.49585 | TypeConverter.go | starcoder |
package transaction
import (
"math/big"
"github.com/ethereum/go-ethereum/rlp"
)
// MaxCoinSupply returns max available coin supply
func MaxCoinSupply() *big.Int {
return big.NewInt(0).Exp(big.NewInt(10), big.NewInt(15+18), nil)
}
// CreateTokenData is a Data of Transaction for creation of a token (non-reserve co... | transaction/token.go | 0.866613 | 0.441372 | token.go | starcoder |
package gobless
import "github.com/gdamore/tcell"
type Color int32
const (
ColorBlack = Color(tcell.ColorBlack)
ColorMaroon = Color(tcell.ColorMaroon)
ColorGreen = Color(tcell.ColorGreen)
ColorOlive = Color(tcell.ColorOlive)
ColorNavy = ... | color.go | 0.701304 | 0.483709 | color.go | starcoder |
package config
// Default returns the default colorscheme for the given type (light or dark).
func Default(colorschemeType ColorschemeType) Config {
return Config{
Stylesheet: defaultStylesheet(colorschemeType),
Categories: []Category{
{Fg: "#000000", Bg: "#cccccc", Name: "default"},
{Fg: "#000000", Bg: "#f... | src/config/default.go | 0.689201 | 0.423458 | default.go | starcoder |
package resources
import (
"fmt"
"github.com/go-gl/gl/v4.1-core/gl"
"github.com/Ariemeth/quantum-pulse/components"
)
const (
// ComponentTypeShader represents a shaders components type.
ComponentTypeShader = "shader"
// CameraUniform is the expected name of view matrix uniform in the shader.
CameraUniform = ... | resources/shader.go | 0.768386 | 0.680859 | shader.go | starcoder |
package funk
import (
"fmt"
"reflect"
)
func equal(expectedOrPredicate interface{}, optionalIsMap ...bool) func(keyValueIfMap, actualValue reflect.Value) bool {
isMap := append(optionalIsMap, false)[0]
if IsFunction(expectedOrPredicate) {
inTypes := []reflect.Type{nil}; if isMap {
inTypes = append(inTypes, ... | vendor/github.com/thoas/go-funk/utils.go | 0.711832 | 0.476397 | utils.go | starcoder |
package astcopy
import (
"go/ast"
)
// Node returns x node deep copy.
// Copy of nil argument is nil.
func Node(x ast.Node) ast.Node {
return copyNode(x)
}
// NodeList returns xs node slice deep copy.
// Copy of nil argument is nil.
func NodeList(xs []ast.Node) []ast.Node {
if xs == nil {
return nil
}
cp := m... | vendor/github.com/go-toolsmith/astcopy/astcopy.go | 0.700383 | 0.423041 | astcopy.go | starcoder |
package record
import (
"testing"
"github.com/go-spring/spring-core/redis"
"github.com/go-spring/spring-core/redis/testcases"
"github.com/go-spring/spring-core/redis/testdata"
)
func ZAdd(t *testing.T, c redis.Client) {
RunCase(t, c, testcases.ZAdd, testdata.ZAdd)
}
func ZCard(t *testing.T, c redis.Client) {
... | spring/spring-core/redis/record/zset.go | 0.67971 | 0.562958 | zset.go | starcoder |
package box2d
import (
"math"
)
// Find the max separation between poly1 and poly2 using edge normals from poly1.
func FindMaxSeparation(edgeIndex *int, poly1 *PolygonShape, xf1 Transform, poly2 *PolygonShape, xf2 Transform) float64 {
count1 := poly1.Count
count2 := poly2.Count
n1s := poly1.Normals
v1s := poly1.... | pkg/box2d/collide_polygon.go | 0.729134 | 0.692233 | collide_polygon.go | starcoder |
package hexgrid
import "math"
// Point is a geometric point.
type Point struct {
X float64
Y float64
}
// Layout is a struct that holds layout parameters.
type Layout struct {
Orientation Orientation
Size Point // multiplication factor relative to the canonical hexagon, where the points are on a unit circ... | layout.go | 0.909246 | 0.563918 | layout.go | starcoder |
package tests
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
)
func TestCreateProject(t *testing.T) {
truncateAllTablesForTestingOnly()
ctx := context.Background()
client, conn := GetTestAdminServiceClient()
defer conn.Close()
req... | tests/project.go | 0.568296 | 0.400339 | project.go | starcoder |
package ssh
import "io"
// ServerShell contains the state for running a VT100 terminal that is capable
// of reading lines of input.
type ServerShell struct {
c Channel
prompt string
// line is the current line being entered.
line []byte
// pos is the logical position of the cursor in line
pos int
// c... | server_shell.go | 0.557966 | 0.470433 | server_shell.go | starcoder |
package fsm
import (
"os"
"fmt"
"strings"
)
// types of callback functions
type onBeforeTransitionCallback func(transition string)
type onAfterTransitionCallback func(transition string)
type onEnterStateCallback func(state string)
type onLeaveStateCallback func(state string)
// definition of a State
type State... | fsm/fsm.go | 0.763924 | 0.408513 | fsm.go | starcoder |
package run
import (
"fmt"
"os"
"strings"
"github.com/coinbase/step/machine"
"github.com/coinbase/step/machine/state"
"github.com/coinbase/step/utils/to"
)
// Output Dot Format For State Machine
// JSON prints a state machine as JSON
func Dot(stateMachine *machine.StateMachine, err error) {
if err != nil {
... | utils/run/dot.go | 0.547222 | 0.40204 | dot.go | starcoder |
package geojson
import (
"bytes"
"strconv"
"github.com/tidwall/tile38/geojson/geohash"
)
// Polygon is a geojson object with the type "Polygon"
type Polygon struct {
Coordinates [][]Position
BBox *BBox
}
func fillPolygon(coordinates [][]Position, bbox *BBox, err error) (Polygon, error) {
if err == nil ... | vendor/github.com/tidwall/tile38/geojson/polygon.go | 0.738292 | 0.504516 | polygon.go | starcoder |
package buffer
type FeedableBuffer struct {
Data []byte
minByteCount int
maxByteCount int
}
// API
func New(minByteCount, maxByteCount, initialCapacity int) *FeedableBuffer {
this := new(FeedableBuffer)
this.Init(minByteCount, maxByteCount, initialCapacity)
return this
}
func (this *FeedableBuffer) In... | internal/buffer/buffer.go | 0.772531 | 0.441673 | buffer.go | starcoder |
package main
import (
"fmt"
"log"
"math/rand"
"time"
"github.com/forestgiant/eff"
"github.com/forestgiant/eff/sdl"
)
const (
windowW = 800
windowH = 600
parentSize = 150
)
type colorMarquee struct {
eff.Shape
colors []*eff.Shape
}
func (c *colorMarquee) init(f eff.Font) {
c.SetRect(eff.Rect{
X:... | examples/clipping/main.go | 0.540924 | 0.406185 | main.go | starcoder |
package daemon
import (
"math"
"github.com/larsth/rmsggpsd-gpspipe/errors"
)
var ErrSameLocation = errors.New("The 2 coordinates is at the same location")
//atan2 is the arctangent 2 algoritm
/* See https://en.wikipedia.org/wiki/Atan2
Quote:
In a variety of computer languages, the function atan2 is the arctangent... | daemon/atan2.go | 0.744842 | 0.657552 | atan2.go | starcoder |
An implementation of the Version vector technique for distributed systems.
Basics
A Version vector is a set of key value pairs, where the key IDENTIFIES the Node
modifying the data item, and the value is the version. If a key value-pair with
a given key does not exist, 0 is the default value.
Requirements
Two Nod... | versionvector/versionvector.go | 0.634883 | 0.707708 | versionvector.go | starcoder |
package geometry
import (
"errors"
"fmt"
"github.com/skelterjohn/geom"
"github.com/tidwall/gjson"
"github.com/whosonfirst/go-whosonfirst-geojson-v2"
"github.com/whosonfirst/go-whosonfirst-geojson-v2/utils"
)
type Polygon struct {
geojson.Polygon
exterior geom.Polygon
interior []geom.Polygon
}
func (p Polygo... | vendor/github.com/whosonfirst/go-whosonfirst-geojson-v2/geometry/polygon.go | 0.727879 | 0.475118 | polygon.go | starcoder |
// Package math32 implements basic math functions which operate
// directly on float32 numbers without casting and contains
// types of common entities used in 3D Graphics such as vectors,
// matrices, quaternions and others.
package math32
import (
"math"
)
const Pi = math.Pi
const degreeToRadiansFactor = math.Pi ... | math32/math.go | 0.884782 | 0.849535 | math.go | starcoder |
package visualization
import (
"sort"
"sync"
"time"
"github.com/GaryBoone/GoStats/stats"
"github.com/cloudfoundry-incubator/auction/auctiontypes"
"github.com/cloudfoundry-incubator/rep"
"github.com/cloudfoundry/gunk/workpool"
)
type Report struct {
Cells map[string]rep.Client
NumAucti... | simulation/visualization/report.go | 0.612078 | 0.403802 | report.go | starcoder |
package f64
const BadLen = "floats: mismatched slice lengths"
func AddTo(dst, a, b []float64) []float64 {
n := len(dst)
if len(a) != n || len(b) != n {
panic(BadLen)
}
tail := n % 8
if n >= 8 {
add8(&dst[0], &a[0], &b[0], n-tail)
}
for i := n - tail; i < n; i++ {
dst[i] = a[i] + b[i]
}
return dst
}
f... | floats/f64/f64_asm.go | 0.550607 | 0.408454 | f64_asm.go | starcoder |
package bst
import (
"errors"
)
type Node struct {
Value string
Data string
Left *Node
Right *Node
}
// insert into node
func (n *Node) Insert(value, data string) error {
if n == nil {
return errors.New("Cannot insert a value into a nil tree")
}
switch {
case value == n.Value:
return nil
case value ... | Tree/Binary Search Tree/go/src/bst.go | 0.585338 | 0.654232 | bst.go | starcoder |
package dome9
import (
"fmt"
"strings"
)
// Description returns the Description parameter of the ticket
func (finding *Finding) String() (param string) {
return finding.getDescription()
}
// ID returns the VulnerabilityID parameter of the ticket
func (finding *Finding) ID() (param string) {
return finding.RuleHa... | finding_interface.go | 0.760295 | 0.449211 | finding_interface.go | starcoder |
package nn
import (
"encoding/json"
tsr "../tensor"
)
// ConvolutionLayer is a layer that performs convolutional filters on data.
type ConvolutionLayer struct {
inputShape LayerShape
outputShape LayerShape
inputs *tsr.Tensor
outputs *tsr.Tensor
Filters []*tsr.Tensor
Activation ActivationFuncti... | nn/convolutionLayer.go | 0.919863 | 0.689433 | convolutionLayer.go | starcoder |
package giopdf
import (
"image/color"
"gioui.org/f32"
"gioui.org/op"
"gioui.org/op/clip"
)
type graphicsState struct {
fillColor color.NRGBA
strokeColor color.NRGBA
lineWidth float32
lineCap int
lineJoin int
miterLimit float32
dashes []float32
dashPhase float32
font Font
font... | state.go | 0.776199 | 0.446676 | state.go | starcoder |
package costmodel
import (
"sort"
"time"
"github.com/kubecost/cost-model/pkg/kubecost"
)
// IntervalPoint describes a start or end of a window of time
// Currently, this used in PVC-pod relations to detect/calculate
// coefficients for PV cost when a PVC is shared between pods.
type IntervalPoint struct {
Time ... | pkg/costmodel/intervals.go | 0.820793 | 0.629903 | intervals.go | starcoder |
package mathtool
import (
"fmt"
"math"
)
// Orientation is used to represent orientation of two segment in an Enum style
type Orientation int
// possible orentation
const (
// COLINEAR is when two segment are colinear
COLINEAR Orientation = iota
// CLOCKWISE is when orientation of two segments are clockwise
CL... | internal/pkg/mathtool/vector.go | 0.851274 | 0.719002 | vector.go | starcoder |
// Copyright 2017 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.
package arm64asm
// Following functions are used as the predicator: canDecode of according instruction
// Refer to instFormat inside decode.go for more detail... | src/cmd/vendor/golang.org/x/arch/arm64/arm64asm/condition.go | 0.575111 | 0.410697 | condition.go | starcoder |
package math
import (
"math"
qspec "github.com/qiniu/goplus/exec.spec"
"github.com/qiniu/goplus/gop"
)
// func math.Abs(x float64) float64
func execAbs(_ int, p *gop.Context) {
args := p.GetArgs(1)
ret := math.Abs(args[0].(float64))
p.Ret(1, ret)
}
// func math.Acos(x float64) float64
func execAcos(_ int, p *... | lib/math/exports.go | 0.504639 | 0.400955 | exports.go | starcoder |
package benchmark
import (
"reflect"
"testing"
)
func isBoolConsumerCalibrated(supplier func() bool) bool {
return isCalibrated(reflect.Bool, reflect.Invalid, reflect.ValueOf(supplier).Pointer())
}
func isIntConsumerCalibrated(supplier func() int) bool {
return isCalibrated(reflect.Int, reflect.Invalid, reflect.... | common/benchmark/00_consumer.go | 0.722821 | 0.805556 | 00_consumer.go | starcoder |
package keeper
import (
"fmt"
"math"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
hardtypes "github.com/kava-labs/kava/x/hard/types"
"github.com/kava-labs/kava/x/incentive/types"
)
// AccumulateHardSupplyRewards updates the rewards accumulated for the input reward period
func (k Keeper) AccumulateHardSuppl... | x/incentive/keeper/rewards_supply.go | 0.73029 | 0.434521 | rewards_supply.go | starcoder |
package basal
import (
"encoding/binary"
"encoding/hex"
)
const zero = byte('0')
const one = byte('1')
var BytesArrNot16BitMultiple = NewError("[]byte len not is 16bit multiple")
var BytesArrNot32BitMultiple = NewError("[]byte len not is 32bit multiple")
var BytesArrNot64BitMultiple = NewError("[]byte len not is 6... | binary.go | 0.574872 | 0.463991 | binary.go | starcoder |
package funcs
//NewDouble dynamically creates and asserts the returning function is of type Double.
//This function is used by the compose library to compile functions together.
func (f *Maker) NewDouble(values ...interface{}) (Double, error) {
v, err := f.New(values...)
if err != nil {
return nil, err
}
return ... | relapse/funcs/newfunc.gen.go | 0.703651 | 0.496216 | newfunc.gen.go | starcoder |
package ana
import (
"fmt"
"image/color"
"log"
"time"
"go-hep.org/x/hep/hbook"
)
// Analysis maker type is the main object of the ana package.
// It contains all samples and variables on which
// to loop to produce and plot histograms. Several options
// can be specified to normalize and/or stack histograms,
//... | ana/maker.go | 0.568176 | 0.45532 | maker.go | starcoder |
package core
import (
"encoding/binary"
"github.com/pkg/errors"
)
type ParsedOpCode struct {
opValue byte
length int
data []byte
}
// isDisabled returns whether or not the opCode is disabled and thus is always
// bad to see in the instruction stream (even if turned off by a conditional).
func (parsedOpCode ... | core/parseopcode.go | 0.577734 | 0.425486 | parseopcode.go | starcoder |
package sequence
import "github.com/snowmerak/generics-for-go/v2/iterable"
// Sequence is a sequence structure based on iterable.
type Sequence[K comparable, V any] struct {
iter iterable.Iterable[K, V]
firstIndex int
currentIndex int
data map[K]V
keys []K
filters []func(K, V) bool
maps []func(K... | iterable/sequence/sequence.go | 0.733643 | 0.413951 | sequence.go | starcoder |
package spectral
import (
"clustering/gsl"
"clustering/math"
"clustering/sort"
"math"
)
func GaussianKernel(a cmath.IMatrix) cmath.IMatrix {
m := cmath.NewMatrix(a.DimN(), a.DimM())
for i := 0; i < a.DimN(); i++ {
for j := 0; j < a.DimM(); j++ {
m.Set(i, j, math.Exp(-math.Pow(a.At(i, j), 2)/math.Pow(Sigma,... | spectral/spectralClustering.go | 0.747247 | 0.54056 | spectralClustering.go | starcoder |
package banana
import (
"sort"
)
// Letter represents a tile character.
type Letter rune
const (
// noLetter is used in the absense of a valid letter to return.
noLetter = Letter(rune(0))
)
// String turns the letter into a string.
func (l Letter) String() string {
return string(l)
}
// Tiles represents a set ... | banana/tiles.go | 0.745213 | 0.516839 | tiles.go | starcoder |
package iso20022
// Set of elements used to provide information specific to the individual transaction(s) included in the message.
type CreditTransferTransactionInformation11 struct {
// Set of elements used to reference a payment instruction.
PaymentIdentification *PaymentIdentification3 `xml:"PmtId"`
// Set of ... | CreditTransferTransactionInformation11.go | 0.659076 | 0.636946 | CreditTransferTransactionInformation11.go | starcoder |
package cmd
import (
"log"
"github.com/spf13/cobra"
"github.com/ftl/si5351/pkg/si5351"
)
var oscFlags = struct {
drive int
intDiv bool
noInit bool
}{}
var oscCmd = &cobra.Command{
Use: "osc [freq0] [freq1] [freq2] [freq3] [freq4] [freq5]",
Short: "Output the given frequencies on the outputs CLK0-CLK5 us... | cmd/osc.go | 0.621426 | 0.412116 | osc.go | starcoder |
package gencellular
import (
"image"
"image/color"
"image/gif"
"math/rand"
"os"
)
// SeedFunc is the type of function used to initialize the simulation.
type SeedFunc func(cells [][]bool, w, h int)
// SeedDefault is the default init function used to initialize the simulation.
func SeedDefault(cells [][]bool, w,... | gencellular/gencellular.go | 0.648911 | 0.535584 | gencellular.go | starcoder |
// Package flexpolyline contains tools to encode and decode FlexPolylines
// This file defines the Decode() function
package flexpolyline
import (
"fmt"
)
// Decodes a Polyline from a string following the format specified in
// https://github.com/heremaps/flexible-polyline/blob/master/README.md
func Decode(polylin... | golang/flexpolyline/decode.go | 0.830422 | 0.440349 | decode.go | starcoder |
package rule
// Heuristic consist of (a number of) rules where each, if matches,
// identifes content as belonging to a programming language(s).
type Heuristic interface {
Matcher
Languages() []string
}
// Matcher checks if the data matches (number of) pattern.
// Every heuristic rule below implements this interfac... | vendor/github.com/go-enry/go-enry/v2/data/rule/rule.go | 0.829319 | 0.426441 | rule.go | starcoder |
package ilium
import "math/rand"
// An IndependentSampler is a Sampler which generates samples that are
// mutually independent.
type IndependentSampler struct{}
func MakeIndependentSampler(config map[string]interface{}) *IndependentSampler {
return &IndependentSampler{}
}
func (is *IndependentSampler) AllocateSam... | ilium/independent_sampler.go | 0.57344 | 0.496216 | independent_sampler.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.