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 input
import (
"github.com/Jeffail/benthos/v3/internal/docs"
"github.com/Jeffail/benthos/v3/lib/input/reader"
"github.com/Jeffail/benthos/v3/lib/log"
"github.com/Jeffail/benthos/v3/lib/message/batch"
"github.com/Jeffail/benthos/v3/lib/metrics"
"github.com/Jeffail/benthos/v3/lib/types"
"github.com/Jeffai... | lib/input/kinesis.go | 0.672439 | 0.456713 | kinesis.go | starcoder |
package encoding
// writeBigEndian writes x into buf as a big-endian n-byte
// integer. If the buffer is too small, a panic will ensue.
func writeBigEndian(buf []byte, x uint64, n int) {
for i := 1; i <= n; i++ {
buf[i-1] = byte(x >> uint(8*(n-i)))
}
}
// readBigEndian reads buf as a big-endian integer and retur... | util/encoding/varint.go | 0.63023 | 0.514888 | varint.go | starcoder |
package plausible
// TimeseriesQuery represents an API query for time series information over a period of time.
// In an aggregate query, the Metrics field is mandatory, all the others are optional.
type TimeseriesQuery struct {
// Period to consider for the time series query.
// The result will include results over... | plausible/timeseries_query.go | 0.914715 | 0.569972 | timeseries_query.go | starcoder |
package lm
import (
"errors"
"fmt"
"log"
"github.com/alldroll/rbtree"
"github.com/suggest-go/suggest/pkg/utils"
)
// NGramVectorBuilder is an entity that responses for building NGramVector
type NGramVectorBuilder interface {
// Put adds the given sequence of nGrams and count to model
Put(nGrams []WordID, coun... | pkg/lm/ngram_vector_builder.go | 0.656988 | 0.499451 | ngram_vector_builder.go | starcoder |
package htest
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"strings"
"sync"
"testing"
"github.com/fatih/color"
)
const lineWidth = 40
// ResponseAsserter is responsible for making assertions based on the expected and the actual value returned from httptest.ResponseRecorder
type Res... | vendor/github.com/celrenheit/htest/response_asserter.go | 0.623606 | 0.406833 | response_asserter.go | starcoder |
package main
import (
"bufio"
"fmt"
"log"
"math"
"os"
"sort"
"strconv"
"time"
)
type point struct {
x, y int
}
func (p point) add(d point) point {
return point{p.x + d.x, p.y + d.y}
}
func (p *point) isValid(w, h int) bool {
return p.x >= 0 && p.y >= 0 && p.x < w && p.y < h
}
func (p *point) distance(o ... | day10/p2/main.go | 0.608129 | 0.433622 | main.go | starcoder |
package missing_vault_isolation
import (
"github.com/threagile/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "missing-vault-isolation",
Title: "Missing Vault Isolation",
Description: "Ativos de cofre altamente confidenciais e seus armazenamentos de dados devem ser i... | risks/built-in/missing-vault-isolation/missing-vault-isolation-rule.go | 0.523177 | 0.503357 | missing-vault-isolation-rule.go | starcoder |
package kv
import (
"fmt"
"reflect"
"github.com/Ch1f/otel/api/kv/value"
)
// KeyValue holds a key and value pair.
type KeyValue struct {
Key Key
Value value.Value
}
// Bool creates a new key-value pair with a passed name and a bool
// value.
func Bool(k string, v bool) KeyValue {
return Key(k).Bool(v)
}
/... | api/kv/kv.go | 0.770378 | 0.547585 | kv.go | starcoder |
package formats
// Used for codes in the AMADEUS code tables. Code Length is one alphanumeric character.
// pattern = "[0-9A-Z]"
type AMA_EDICodesetType_Length1 string
// Used for codes in the AMADEUS code tables. Code Length is three alphanumeric characters.
// pattern = "[0-9A-Z]{1,3}"
type AMA_EDICodesetType_Lengt... | structs/formats/types.go | 0.636805 | 0.452778 | types.go | starcoder |
package types
import (
"fmt"
"reflect"
structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/google/cel-go/common/types/ref"
"github.com/google/cel-go/common/types/traits"
)
// baseMap is a reflection based map implementation designed to handle a variety of map-like types.
type baseMap struct {
valu... | common/types/map.go | 0.686685 | 0.42656 | map.go | starcoder |
package hole
import (
"math/rand"
"strings"
)
var (
notes = [12][2]string{
{"C", "B♯"},
{"C♯", "D♭"},
{"D", "D"},
{"D♯", "E♭"},
{"E", "F♭"},
{"F", "E♯"},
{"F♯", "G♭"},
{"G", "G"},
{"G♯", "A♭"},
{"A", "A"},
{"A♯", "B♭"},
{"B", "C♭"},
}
triadTypes = [4]string{
"°", "m", "", "+",
}
triad... | hole/musical-chords.go | 0.526343 | 0.453201 | musical-chords.go | starcoder |
package ckks
import (
"math"
)
// ChebyshevInterpolation is a struct storing the coefficients, degree and range of a Chebyshev interpolation polynomial.
type ChebyshevInterpolation struct {
coeffs map[uint64]complex128
degree uint64
a complex128
b complex128
}
// Approximate computes a Chebyshev appro... | ckks/chebyshev_interpolation.go | 0.79166 | 0.576184 | chebyshev_interpolation.go | starcoder |
package dtls
import (
"encoding/binary"
)
/*
The TLS Record Layer which handles all data transport.
The record layer is assumed to sit directly on top of some
reliable transport such as TCP. The record layer can carry four types of content:
1. Handshake messages—used for algorithm negotiation and key establishm... | pkg/dtls/record_layer.go | 0.680879 | 0.44354 | record_layer.go | starcoder |
package particles
import (
"image/color"
"github.com/gremour/grue"
)
// ParticleData contains set of particle parameters.
type ParticleData struct {
Pos grue.Vec
Size grue.Vec
Color color.Color
}
// Particle describes particle.
type Particle struct {
Initial ParticleData
Current ParticleData
Image stri... | particles/particles.go | 0.643329 | 0.417331 | particles.go | starcoder |
package expect
import (
"fmt"
"path"
"reflect"
"runtime"
"strings"
"testing"
)
func New(t *testing.T) func(target interface{}) *expectation {
return (&expector{T: t}).expect
}
type expector struct {
T *testing.T
}
func (e *expector) expect(target interface{}) *expectation {
return &expectation{T: e.T, targ... | expect/expect.go | 0.673299 | 0.567577 | expect.go | starcoder |
package list
type node struct {
next *node
values []interface{}
}
var maxChunkSize int = 8
var midOfChunk int = maxChunkSize / 2
func newNode(next *node) *node {
return &node{next, make([]interface{}, 0, maxChunkSize)}
}
func (n *node) isFull() bool {
return len(n.values) >= maxChunkSize
}
type Iterator stru... | list/unrolled.go | 0.528777 | 0.47171 | unrolled.go | starcoder |
package ui
import (
"encoding/binary"
"math"
"time"
"gioui.org/ui/f32"
"gioui.org/ui/internal/ops"
)
// Config represents the essential configuration for
// updating and drawing a user interface.
type Config interface {
// Now returns the current animation time.
Now() time.Time
// Px converts a Value to pix... | ui/ui.go | 0.586523 | 0.426501 | ui.go | starcoder |
package render
import (
"blockexchange/core"
"sort"
"github.com/fogleman/gg"
)
type Block struct {
X int
Y int
Z int
Color *Color
Order int
}
type PartRenderer struct {
Mapblock *core.ParsedSchemaPart
Colormapping map[string]*Color
NodeIDStringMapping map[int]string
Blocks ... | render/renderer_part.go | 0.646125 | 0.408395 | renderer_part.go | starcoder |
package backoff
import (
"math"
"time"
)
// Algorithm defines a function that calculates a time.Duration based on
// the given retry attempt number.
type Algorithm func(attempt uint) time.Duration
// Incremental creates a Algorithm that increments the initial duration
// by the given increment for each attempt.
fu... | backoff/backoff.go | 0.844665 | 0.642951 | backoff.go | starcoder |
package osc
import (
"encoding/json"
)
// HealthCheck Information about the health check configuration.
type HealthCheck struct {
// The number of seconds between two pings (between `5` and `600` both included).
CheckInterval int32 `json:"CheckInterval"`
// The number of consecutive successful pings before consi... | v2/model_health_check.go | 0.780746 | 0.499329 | model_health_check.go | starcoder |
package plan
import (
"github.com/liquidata-inc/go-mysql-server/sql"
"github.com/liquidata-inc/go-mysql-server/sql/expression"
)
// TransformUp applies a transformation function to the given tree from the
// bottom up.
func TransformUp(node sql.Node, f sql.TransformNodeFunc) (sql.Node, error) {
if o, ok := node.(s... | sql/plan/transform.go | 0.628635 | 0.490785 | transform.go | starcoder |
package matchers
import (
"fmt"
"reflect"
"regexp"
"strings"
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/types"
)
func ContainLines(expected ...interface{}) types.GomegaMatcher {
return &containLinesMatcher{
expected: expected,
}
}
type containLinesMatcher struct {
expected []interface{}
}
f... | vendor/github.com/cloudfoundry/switchblade/matchers/contain_lines.go | 0.705988 | 0.407304 | contain_lines.go | starcoder |
package main
import (
"math"
"math/rand"
)
type (
Individual struct {
genome Genome
location Coord
birthPlace Coord
age uint16
wasBlocked bool // will be true if this individual was not able to do an action last step because it was blocked
brain *NeuralNet
}
// Actions encodes the ... | src/individual.go | 0.753013 | 0.439687 | individual.go | starcoder |
package validator
// MessageMap is a map of string, that can be used as error message for ValidateStruct function.
var MessageMap = map[string]string{
"accepted": "The :attribute must be accepted.",
"activeUrl": "The :attribute is not a valid URL.",
"after": "The :attribute must be a... | message.go | 0.641535 | 0.667866 | message.go | starcoder |
package mbr
import (
"bytes"
"encoding/binary"
"io"
"strconv"
"github.com/masahiro331/go-vmdk-parser/pkg/disk/types"
"golang.org/x/xerrors"
)
const (
SIGNATURE = 0xAA55
Sector = 512
)
/*
# Master Boot Record Spec
https://uefi.org/sites/default/files/resources/UEFI%20Spec%202.8B%20May%202020.pdf
p. 112
Ma... | pkg/disk/mbr/mbr.go | 0.621656 | 0.435421 | mbr.go | starcoder |
package dep
import (
"fmt"
"io/ioutil"
"github.com/chewxy/lingo"
"github.com/chewxy/lingo/treebank"
)
// Performance is a tuple that holds performance information from a training session
type Performance struct {
Iter int // which training iteration is this?
UAS float64 // Unlabelled Attachment Score
LAS... | dep/evaluation.go | 0.682891 | 0.455622 | evaluation.go | starcoder |
package bincode
import (
"encoding/binary"
"math"
"reflect"
)
type Decoder interface {
Decode(bz []byte, data interface{})
}
type decoder struct {
order binary.ByteOrder
buf []byte
offset int // next read offset in data
}
func NewDecoder() Decoder {
return &decoder{}
}
func (d *decoder) Decode(bz []byt... | solana/bincode/decode.go | 0.511473 | 0.427815 | decode.go | starcoder |
package main
import (
"fmt"
"github.com/codingbeard/cberrors"
"github.com/codingbeard/cberrors/iowriterprovider"
"github.com/codingbeard/cblog"
"github.com/codingbeard/tfkg/callback"
"github.com/codingbeard/tfkg/data"
"github.com/codingbeard/tfkg/layer"
"github.com/codingbeard/tfkg/metric"
"github.com/codingb... | examples/multiple_inputs/main.go | 0.580709 | 0.417628 | main.go | starcoder |
package measurements
import "fmt"
const DegreeSign = "°"
type TemperatureUnit int32
const (
Celsius TemperatureUnit = iota
Fahrenheit
Kelvin
)
var TemperatureUnitTypeName = map[TemperatureUnit]string{
Celsius: "C",
Fahrenheit: "F",
Kelvin: "K",
}
var TemperatureUnitTypeValue = map[string]TemperatureU... | temperature.go | 0.843348 | 0.441071 | temperature.go | starcoder |
package callrecords
import (
i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e "time"
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// MediaStream
type MediaStream struct {
// Stores additional data not descr... | models/callrecords/media_stream.go | 0.781414 | 0.587026 | media_stream.go | starcoder |
package props
import (
"github.com/rs/zerolog/log"
)
// Enumeration is a type to store different encoding schemes of an enumeration.
type Enumeration struct {
// JSON encodes the enumeration as a string.
JSON string
// Binary encodes the enumeration as a uint8.
Binary uint8
}
// Health is the known health of a ... | pkg/props/manager_type.go | 0.553264 | 0.441673 | manager_type.go | starcoder |
package main
import (
"bufio"
"bytes"
"fmt"
"os"
"runtime"
"sort"
)
// seqString is a sequence of nucleotides as a string: "ACGT..."
type seqString string
// seqChars is a sequence of nucleotides as chars: 'A', 'C', 'G', 'T'...
type seqChars []byte
// seqBits is a sequence of nucleotides as ... | knucleotide/knucleotide.go-3.go | 0.614625 | 0.426859 | knucleotide.go-3.go | starcoder |
package login
import (
"context"
"testing"
"github.com/ory/x/assertx"
"github.com/ory/kratos/ui/container"
"github.com/bxcodec/faker/v3"
"github.com/gofrs/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/ory/kratos/selfservice/flow"
"github.com/ory/kratos/x"
)... | selfservice/flow/login/persistence.go | 0.502686 | 0.634388 | persistence.go | starcoder |
package luhn
// Utility functions for generating valid luhn strings and validating against the Luhn algorithm
import (
"math/rand"
"strconv"
"strings"
"time"
)
// Valid returns a boolean indicating if the argument was valid according to the Luhn algorithm.
func Valid(luhnString string) bool {
checksumMod := cal... | luhn.go | 0.830594 | 0.50116 | luhn.go | starcoder |
package astilibav
import (
"github.com/asticode/go-astikit"
"github.com/asticode/goav/avutil"
)
// FrameRestamper represents an object capable of restamping frames
type FrameRestamper interface {
Restamp(f *avutil.Frame)
}
type frameRestamperWithValue struct {
lastValue *int64
}
func newFrameRestamperWithValue(... | libav/frame_restamper.go | 0.713731 | 0.411466 | frame_restamper.go | starcoder |
package iterator
import "github.com/tsingson/gonum/graph"
// OrderedLines implements the graph.Lines and graph.LineSlicer interfaces.
// The iteration order of OrderedLines is the order of lines passed to
// NewLineIterator.
type OrderedLines struct {
idx int
lines []graph.Line
}
// NewOrderedLines returns an O... | graph/iterator/lines.go | 0.829768 | 0.412412 | lines.go | starcoder |
package linear
import (
"fmt"
"math"
"time"
"github.com/m3db/m3/src/query/executor/transform"
)
const (
// DayOfMonthType returns the day of the month for each of the given times in UTC.
// Returned values are from 1 to 31.
DayOfMonthType = "day_of_month"
// DayOfWeekType returns the day of the week for ea... | src/query/functions/linear/datetime.go | 0.812198 | 0.783782 | datetime.go | starcoder |
package semt
import (
"encoding/xml"
"github.com/fairxio/finance-messaging/iso20022"
)
type Document04100102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:semt.041.001.02 Document"`
Message *SecuritiesBalanceTransparencyReportV02 `xml:"SctiesBalTrnsprncyRpt"`
}
fu... | iso20022/semt/SecuritiesBalanceTransparencyReportV02.go | 0.678007 | 0.438064 | SecuritiesBalanceTransparencyReportV02.go | starcoder |
package to
import "github.com/MaxSlyugrov/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE d MMMM y", Long: "d MMMM y", Medium: "d MMM y", Short: "d/M/yy"},
Time: cldr.CalendarDateFormat{Full: "h:mm:ss a zzzz", Long: "h:mm:ss a z", Medium: "h:mm... | resources/locales/to/calendar.go | 0.516352 | 0.430925 | calendar.go | starcoder |
// Test concurrency primitives: power series.
package ps
// ===========================================================================
// Specific power series
/*
--- https://en.wikipedia.org/wiki/Formal_power_series
1 / (1-x) <=> a(n) = 1
1 / (1+x) <=> a(n) = (-1)^n
x / (1-x)^2 <=> a(n) = n
--- e^x
U := a0 a1 a... | series.go | 0.81457 | 0.640017 | series.go | starcoder |
package try
/*
Simplifies control flow by panicking on non-nil errors. Should be used in
conjunction with `Rec`.
If the error doesn't already have a stacktrace, adds one
via "github.com/pkg/errors". Stacktraces are essential for such exception-like
control flow. Without them, debugging would be incredibly tedious.
*/... | try_to.go | 0.717111 | 0.565959 | try_to.go | starcoder |
package numerology
import (
"strconv"
"time"
)
// Days of the week values for use in date searches. Values are similar to time.Weekday.
const (
Sunday = iota
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
)
// DateNumerology stores required information to calculate the numerological values
// of dates.
... | numerology/calculateDates.go | 0.76869 | 0.599544 | calculateDates.go | starcoder |
package iso20022
// Specifies rates.
type CorporateActionRate46 struct {
// Cash dividend amount per equity before deductions or allowances have been made.
GrossDividendRate []*GrossDividendRateFormat10Choice `xml:"GrssDvddRate,omitempty"`
// Cash dividend amount per equity after deductions or allowances have bee... | CorporateActionRate46.go | 0.842086 | 0.608158 | CorporateActionRate46.go | starcoder |
package engine
import (
"fmt"
. "github.com/tsatke/lua/internal/engine/value"
)
func (e *Engine) cmpEqual(left, right Value) ([]Value, error) {
if left.Type() == TypeTable && right.Type() == TypeTable {
if left == right {
// primitive equal check
return values(True), nil
}
// use metamethod if availab... | internal/engine/compare.go | 0.669853 | 0.543954 | compare.go | starcoder |
package pso
import (
"log"
"math"
"math/rand"
G "gorgonia.org/gorgonia"
T "gorgonia.org/tensor"
)
//Data x
type Data struct {
Input []float64
Output []float64
}
type particle struct {
feats int
n *nn
velocities []float64
bestErrorLoss float64
bestLocalPosition... | pso/particle.go | 0.553988 | 0.487063 | particle.go | starcoder |
package set
// Of[T] a set of elements of type T.
// The zero value of Of is not safe for use.
// Create one with New instead.
type Of[T comparable] map[T]struct{}
// New produces a new set containing the given values.
func New[T comparable](vals ...T) Of[T] {
s := Of[T](make(map[T]struct{}))
for _, val := range va... | set.go | 0.73307 | 0.65062 | set.go | starcoder |
package dfl
import (
"fmt"
"reflect"
"strings"
"github.com/pkg/errors"
"github.com/spatialcurrent/go-reader-writer/pkg/io"
"github.com/spatialcurrent/go-try-get/pkg/gtg"
)
func parseExtractPath(path string) (int, int, int, int, error) {
index_questionmark := -1
index_period := -1
index_start := -1
index... | pkg/dfl/Extract.go | 0.535584 | 0.416678 | Extract.go | starcoder |
package gotween
import (
"errors"
"math"
)
var version string = "0.0.1"
// EasingFunc defines a common interface that most of the easing functions
// conform to. The few that don't can be easily wrapped as required so that
// they match the interface.
type EasingFunc func(float64) (float64, error)
// GetPointOnLi... | gotween.go | 0.81571 | 0.603143 | gotween.go | starcoder |
package pinapi
import (
"encoding/json"
)
// SpecialsFixturesEvent Optional event asscoaited with the special.
type SpecialsFixturesEvent struct {
// Event Id
Id *int `json:"id,omitempty"`
// The period of the match. For example in soccer 0 (Game), 1 (1st Half) & 2 (2nd Half)
PeriodNumber *int `json:"periodNumbe... | pinapi/model_specials_fixtures_event.go | 0.828696 | 0.466906 | model_specials_fixtures_event.go | starcoder |
package imageutil
import (
"image"
"image/color"
)
// ImageReader implements the same methods as the standard image interface.
type ImageReader interface {
At(x, y int) color.Color
Bounds() image.Rectangle
ColorModel() color.Model
}
// ImageWriter implements a method for setting colors at individual
// coordina... | imageutil.go | 0.871584 | 0.57678 | imageutil.go | starcoder |
package astar
import (
"fmt"
"math"
)
// TableEntry is a row in the A* table.
type TableEntry struct {
Node *Tile
// Distance from start.
G *float64
// Heuristic distance from end.
H float64
// For tracking the path to how we got here.
PreviousVertex *Tile
}
// F is the A* distance function - g() + h().
fun... | graph.go | 0.783658 | 0.509154 | graph.go | starcoder |
import "fmt"
func BinSearch(nums []int, target int, low int, high int) int {
if low > high {
return -1
}
mid := low + (high-low)/2
//fmt.Println(low, mid,high, nums[low],nums[mid],nums[high], target)
if nums[mid] < target {
return BinSearch(nums, target, mid+1, high)
}
if nums[mid] > target {
return BinSe... | submissions/0033.Search_in_Rotated_Array.go | 0.539954 | 0.480357 | 0033.Search_in_Rotated_Array.go | starcoder |
package scaling
import (
"knative.dev/serving/pkg/metrics"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
)
var (
desiredPodCountM = stats.Int64(
"desired_pods",
"Number of pods autoscaler wants to allocate",
stats.UnitDimensionless)
excessBurstCapacityM = stats.Float64(
"excess_burst_capacity",... | pkg/autoscaler/scaling/metrics.go | 0.660501 | 0.412944 | metrics.go | starcoder |
package gremlingo
type Lambda struct {
Script string
Language string
}
// GraphTraversal stores a Traversal.
type GraphTraversal struct {
*Traversal
}
// NewGraphTraversal make a new GraphTraversal.
func NewGraphTraversal(graph *Graph, traversalStrategies *TraversalStrategies, bytecode *bytecode, remote *Driver... | gremlin-go/driver/graphTraversal.go | 0.901948 | 0.50354 | graphTraversal.go | starcoder |
package three
import "math"
// NewMatrix3 :
func NewMatrix3() *Matrix3 {
elements := [9]float64{
1, 0, 0,
0, 1, 0,
0, 0, 1,
}
return &Matrix3{elements}
}
// Matrix3 :
type Matrix3 struct {
Elements [9]float64
}
// Set :
func (m Matrix3) Set(n11, n12, n13, n21, n22, n23, n31, n32, n33 float64) *Matrix3 {
... | server/three/matrix3.go | 0.655115 | 0.625953 | matrix3.go | starcoder |
package compare
import (
"bytes"
"encoding/gob"
"encoding/json"
"errors"
"fmt"
"reflect"
"regexp"
"strconv"
"strings"
)
var (
ErrInvalidMatchType = errors.New("invalid match type")
ErrValueNotANumber = errors.New("value is not a number")
)
// MatchType defines the type of match to be performed.
type Matc... | match.go | 0.61173 | 0.703942 | match.go | starcoder |
// Package caesar provides interface to encrypt and decrypt Caesar cipher.
package caesar
import (
"bytes"
"fmt"
"io"
)
var (
// Classical bounds of the cipher.
alphabet = []int{'a', 'z', 'A', 'Z'}
// Printable ASCII as bounds.
printable = []int{' ', '~'}
)
// ROT13 rotates by 13 places. It's the most famous... | caesar/caesar.go | 0.834204 | 0.507446 | caesar.go | starcoder |
Package event implements the events that cause transitions between FSA states.
* Unicode classes: number, letter, upcase, lowcase, space
* Ranges: any, anyof, not
* CharLit
*/
package event
import (
"fmt"
"os"
"sort"
"unicode"
"github.com/goccmack/gogll/ast"
"github.com/goccmack/gogll/lex/item"
"github.com/go... | lex/items/event/event.go | 0.672762 | 0.441131 | event.go | starcoder |
package xrandr
// Rotation values.
const (
RotationNormal Rotation = iota
RotationLeft
RotationInverted
RotationRight
)
// Rotation represents the rotation status of a CRTC, which is sent to an output.
type Rotation int
// String returns this Rotation as a string, ready for use with the xrandr command.
func (r R... | xrandr/types.go | 0.841956 | 0.48688 | types.go | starcoder |
package gocommon
import (
"math"
"strconv"
)
// Rotli - Rotate left int
func Rotli(value int, count uint) int {
return (value << count) | (value >> (strconv.IntSize - count))
}
// Rotlu - Rotate left uint
func Rotlu(value uint, count uint) uint {
return (value << count) | (value >> (strconv.IntSize - count))
}
... | mathutil.go | 0.826537 | 0.513363 | mathutil.go | starcoder |
package models
import (
i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization"
)
// Reminder
type Reminder struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization ... | models/reminder.go | 0.604165 | 0.466299 | reminder.go | starcoder |
package compare
import (
"fmt"
"reflect"
"github.com/golang/protobuf/proto"
)
// Action is the optional return value type of functions passes to
// Register and Custom.Register.
type Action int
const (
// Done is returned by custom comparison functions when the two objects
// require no further comparisons.
... | core/data/compare/custom.go | 0.69233 | 0.414247 | custom.go | starcoder |
package cy
import "github.com/rannoch/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE, d MMMM y", Long: "d MMMM y", Medium: "d MMM y", Short: "dd/MM/yy"},
Time: cldr.CalendarDateFormat{Full: "HH:mm:ss zzzz", Long: "HH:mm:ss z", Medium: "HH:mm:s... | resources/locales/cy/calendar.go | 0.512449 | 0.446555 | calendar.go | starcoder |
package arc
import (
"context"
"time"
"chromiumos/tast/local/arc"
"chromiumos/tast/local/bundles/cros/arc/motioninput"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/ash"
"chromiumos/tast/local/chrome/uiauto/mouse"
"chromiumos/tast/local/coords"
"chromiumos/tast/testing"
"chromiumos/tast/test... | src/chromiumos/tast/local/bundles/cros/arc/mouse_input.go | 0.560614 | 0.413418 | mouse_input.go | starcoder |
Common 3D shapes.
*/
//-----------------------------------------------------------------------------
package sdf
import (
"errors"
"fmt"
"math"
)
//-----------------------------------------------------------------------------
// CounterBoredHole3D returns the SDF3 for a counterbored hole.
func CounterBoredHole... | sdf/shapes3.go | 0.89526 | 0.458591 | shapes3.go | starcoder |
package ckks
import (
"math/bits"
)
// PowerOf2 computes op^(2^logPow2), consuming logPow2 levels, and returns the result on opOut. Providing an evaluation
// key is necessary when logPow2 > 1.
func (eval *evaluator) PowerOf2(op *Ciphertext, logPow2 int, opOut *Ciphertext) {
if logPow2 == 0 {
if op != opOut {
... | ckks/algorithms.go | 0.676834 | 0.403508 | algorithms.go | starcoder |
package utils
// reference: https://github.com/mohae/deepcopy
import (
"bytes"
"encoding/gob"
"encoding/json"
"reflect"
)
func deepCopy(dst, src reflect.Value) {
switch src.Kind() {
case reflect.Interface:
value := src.Elem()
if !value.IsValid() {
return
}
newValue := reflect.New(value.Type()).Elem()... | utils/clone.go | 0.582847 | 0.403302 | clone.go | starcoder |
package generate_sp
import (
"fmt"
"github.com/swamp/assembler/lib/assembler_sp"
decorated "github.com/swamp/compiler/src/decorated/expression"
dectype "github.com/swamp/compiler/src/decorated/types"
"github.com/swamp/opcodes/instruction_sp"
opcode_sp_type "github.com/swamp/opcodes/type"
)
func booleanToBinary... | src/generate_sp/binary_operator.go | 0.642769 | 0.446615 | binary_operator.go | starcoder |
package util
import (
"bytes"
"image"
"image/color"
"image/draw"
"image/png"
"os"
"path/filepath"
"strconv"
"github.com/anthonynsimon/bild/blend"
"github.com/lucasb-eyer/go-colorful"
)
var outfitColors = []string{
"FFFFFF", "FFD4BF", "FFE9BF", "FFFFBF", "E9FFBF", "D4FFBF",
"BFFFBF", "BFFFD4", "BFFFE9", "... | app/util/outfit.go | 0.514156 | 0.435902 | outfit.go | starcoder |
package inverted
import (
"bytes"
"encoding/binary"
"fmt"
"math"
"github.com/pkg/errors"
)
// LexicographicallySortableFloat64 transforms a conversion to a
// lexicographically sortable byte slice. In general, for lexicographical
// sorting big endian notatino is required. Additionally the sign needs to be
//... | adapters/repos/db/inverted/serialization.go | 0.727395 | 0.406243 | serialization.go | starcoder |
package rendering
import (
"github.com/llgcode/draw2d"
"github.com/llgcode/draw2d/draw2dimg"
"github.com/samlecuyer/ecumene/geom"
"github.com/samlecuyer/ecumene/mapping"
"github.com/samlecuyer/ecumene/query"
"github.com/samlecuyer/ecumene/util"
"code.google.com/p/sadbox/color"
"image"
"image/draw"
"log"
"m... | rendering/renderer.go | 0.645008 | 0.404831 | renderer.go | starcoder |
package chron
import (
"time"
"github.com/dustinevan/chron/dura"
"fmt"
"reflect"
"database/sql/driver"
"strings"
)
type Milli struct {
time.Time
}
func NewMilli(year int, month time.Month, day, hour, min, sec, milli int) Milli {
return Milli{time.Date(year, month, day, hour, min, sec, milli*1000000, time.UT... | milli.go | 0.65379 | 0.461077 | milli.go | starcoder |
package ConcurrentSkipList
import (
"errors"
"math"
"sync/atomic"
"github.com/OneOfOne/xxhash"
)
// Comes from redis's implementation.
// Also you can see more detail in <NAME>'s paper <Skip Lists: A Probabilistic Alternative to Balanced Trees>.
// The paper is in ftp://ftp.cs.umd.edu/pub/skipLists/skiplists.pdf... | concurrentSkipList.go | 0.692642 | 0.445891 | concurrentSkipList.go | starcoder |
package viql
import (
"fmt"
"io"
)
const qlHelpText = `
VIQL - The VimInfo Query Language
Viql is a simple boolean query language for selecting VimInfo records
as created by examining a Vim swapfile with 'toolman.org/file/viminfo'.
Query statements are boolean expressions composed of declarations or
comparisons c... | viql/help.go | 0.762513 | 0.508361 | help.go | starcoder |
package generator
// Generate integers resembling a hotspot distribution where x% of operations
// access y% of data items. The parameters specify the bounds for the numbers,
// the percentage of the interval which comprises the hot set and
// the percentage of operations that access the hot set. Numbers of the host s... | generator/hotspot_integer_generator.go | 0.894881 | 0.495484 | hotspot_integer_generator.go | starcoder |
package common
import "math"
// 定义相关辅助函数与数据类型
// 守恒性通量类型
type Flux struct {
Density float64 // rho
MomX float64 // rho*u
MomY float64 // rho*v
Energy float64 // rho*E
}
type PrimtiveFlux struct {
Density float64
VelocityX float64
VelocityY float64
Pressure float64
}
// 对流通量对象
type ConvectiveFlux s... | Common/Flux.go | 0.671255 | 0.584657 | Flux.go | starcoder |
package graphproc
//Vertex : graph vertex type
type Vertex struct {
Name string
Prev []*Edge
Next []*Edge
Vstage *Stage
joined int
forked int
produced int
}
//Edge : graph edge type
type Edge struct {
//In *Vertex
Out *Vertex
Epayload *Payload
Estate *State
}
//Graph : graph t... | graphproc/graph.go | 0.518546 | 0.47859 | graph.go | starcoder |
package colorful
import (
"fmt"
"math"
"math/rand"
)
// The algorithm works in L*a*b* color space and converts to RGB in the end.
// L* in [0..1], a* and b* in [-1..1]
type SoftPaletteSettings struct {
// A function which can be used to restrict the allowed color-space.
CheckColor func(c ColorLab) bool
... | soft_palettegen.go | 0.849784 | 0.598518 | soft_palettegen.go | starcoder |
package testutils
import (
"github.com/stretchr/testify/require"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
const (
messageExpectedToBeNotRequired = "Expected %s to be not required"
messageExpectedToBeRequired = "Expected %s to be required"
messageExpectedToBeComputed = "Exp... | testutils/terraform-schema-asserts.go | 0.736401 | 0.62986 | terraform-schema-asserts.go | starcoder |
package lbpCalc
import (
"image"
"github.com/bejohi/golbp/model"
)
var pixelNeighboursY = []int{-1,-1,-1,0,1,1,1,0}
var pixelNeighboursX = []int{-1,0,1,1,1,0,-1,-1}
// createUniformMatrix creates a 2d binary matrix for the given uniform struct.
// A 'true' in a cell means, that the pixel lbp pattern matches one of... | lbpCalc/lbpCalculator.go | 0.677581 | 0.46132 | lbpCalculator.go | starcoder |
package main
import (
"bufio"
"fmt"
"image"
"image/color"
"image/png"
"math/cmplx"
"os"
)
/*
just take a point called z in the complex plane
let z1 be z^2 plus z
and z2 is z1^2 plus z
and z3 is z2^2 plus z
and if the series of z's should always stay
close to z and never trend away
that point is in the m... | src/mandelbarf/mandelbarf.go | 0.628977 | 0.448547 | mandelbarf.go | starcoder |
package design
import (
. "goa.design/goa/v3/dsl"
)
var _ = Service("codeset", func() {
Description("The codeset service performs operations on Codesets.")
// Method describes a service method (endpoint)
Method("list", func() {
Description("Retrieve information about Codesets registered in FuseML.")
// Paylo... | design/codeset.go | 0.617397 | 0.415017 | codeset.go | starcoder |
package azuremonitorexporter
// Contains code common to both trace and metrics exporters
import (
"strconv"
"time"
"github.com/microsoft/ApplicationInsights-Go/appinsights/contracts"
"go.opentelemetry.io/collector/consumer/pdata"
"go.opentelemetry.io/collector/translator/conventions"
tracetranslator "go.opente... | exporter/azuremonitorexporter/metric_to_envelopes.go | 0.641198 | 0.462898 | metric_to_envelopes.go | starcoder |
package charvol
import (
"fmt"
"github.com/zellyn/adventofcode/charmap"
"github.com/zellyn/adventofcode/geom"
)
// V is a map of geom.Vec3 to rune.
type V map[geom.Vec3]rune
// V4 is a map of geom.Vec4 to rune.
type V4 map[geom.Vec4]rune
// MinMax returns a geom.Vec3 for minimum coordinates, and one for maximum... | charvol/charvol.go | 0.810816 | 0.425665 | charvol.go | starcoder |
package lit
import (
"fmt"
"reflect"
"xelf.org/xelf/cor"
"xelf.org/xelf/knd"
"xelf.org/xelf/typ"
)
// Reg is a registry context for type references, reflected types and proxies. Many functions and
// container literals have an optional registry to aid in value conversion and construction.
type Reg struct {
ref... | lit/reg.go | 0.607663 | 0.425307 | reg.go | starcoder |
package dendrolog
import (
"fmt"
"regexp"
"strings"
"testing"
)
type trieTree struct {
value string
left *trieTree
middle *trieTree
right *trieTree
}
func (trie *trieTree) setChildren(left string, middle string, right string) (leftTree *trieTree, middleTree *trieTree, rightTree *trieTree) {
if left != "... | testUtils.go | 0.594198 | 0.431225 | testUtils.go | starcoder |
package task
const ProtocolV1 = "1"
const ProtocolV1_1 = "1.1"
const ProtocolV2 = "2"
const HydroStartBlockNumberV1 = 6885289
const HydroExchangeAddressV1 = "0x2cB4B49C0d6E9db2164d94Ce48853BF77C4D883E"
const HydroMatchTopicV1 = "0xdcc6682c66bde605a9e21caeb0cb8f1f6fbd5bbfb2250c3b8d1f43bb9b06df3f"
const HydroExchangeAB... | task/contract.go | 0.516839 | 0.417271 | contract.go | starcoder |
package pgkebab
import (
"encoding/json"
"fmt"
"strconv"
"time"
)
// Row holds a single record
type Row struct {
tuple map[string]interface{}
}
// Ready returns true if the tuple contains at least one filled column
func (r Row) Ready() bool {
return len(r.tuple) > 0
}
// Columns returns an string array filled... | row.go | 0.796925 | 0.468487 | row.go | starcoder |
package soyutil;
import (
"bytes"
"math"
"math/rand"
"strconv"
"strings"
)
type Lener interface {
Len() int
}
func Conditional(cond bool, iftrue SoyData, iffalse SoyData) SoyData {
if cond {
return iftrue
}
return iffalse
}
func InsertWordBreaks(value string, maxCharsBetweenWordBreaks int) st... | go/src/closure/template/soyutil/utils.go | 0.681515 | 0.511961 | utils.go | starcoder |
package expect
import (
"testing"
)
// Fault is an expectation that always results in an error
type Fault struct {
*testing.T
err error
}
// Faulty returns a new Fault
func Faulty(t *testing.T, err error) Expectation {
return &Fault{t, err}
}
// To returns the current expectation
func (f *Fault) To() Expectati... | expect/fault.go | 0.820757 | 0.462048 | fault.go | starcoder |
package codecs
// H264Payloader payloads H264 packets
type H264Payloader struct{}
const (
fuaHeaderSize = 2
)
func emitNalus(nals []byte, emit func([]byte)) {
nextInd := func(nalu []byte, start int) (indStart int, indLen int) {
zeroCount := 0
for i, b := range nalu[start:] {
if b == 0 {
zeroCount++
... | pkg/rtp/codecs/h264_packet.go | 0.538741 | 0.442335 | h264_packet.go | starcoder |
package cubicSpline
import (
"github.com/helloworldpark/gonaturalspline/knot"
"gonum.org/v1/gonum/mat"
)
// CubicSpline Univariate function
type CubicSpline func(float64) float64
// NaturalCubicSplines Reference from:
// p.141-156, <NAME> et. al., The Elements of Statistical Learning
type NaturalCubicSplines struc... | cubicSpline/cubicSpline.go | 0.790692 | 0.581214 | cubicSpline.go | starcoder |
package simpleio
import (
"fmt"
"log"
"math/big"
"strconv"
"strings"
)
// BytesToInt a function that converts a byte slice and return a number, type int.
func BytesToInt(b []byte) int {
answer, err := strconv.Atoi(string(b))
StdError(err)
return answer
}
// StringToInt is a function that converts a string an... | simpleio/parse.go | 0.728169 | 0.545104 | parse.go | starcoder |
package maps
import (
"golang.org/x/exp/constraints"
. "github.com/noxer/nox/dot"
"github.com/noxer/nox/slice"
"github.com/noxer/nox/tuple"
)
// Keys returns an unsorted slice of the keys of m.
func Keys[K comparable, V any](m map[K]V) []K {
keys := make([]K, 0, len(m))
for k := range m {
keys = append(keys,... | maps/maps.go | 0.818047 | 0.433322 | maps.go | starcoder |
package quality
import (
"github.com/biogo/biogo/alphabet"
"github.com/biogo/biogo/seq"
)
// A slice of quality scores that satisfies the alphabet.Slice interface.
type Qsolexas []alphabet.Qsolexa
func (q Qsolexas) Make(len, cap int) alphabet.Slice { return make(Qsolexas, len, cap) }
func (q Qsolexas) Len() in... | seq/quality/solexa.go | 0.798894 | 0.420362 | solexa.go | starcoder |
package pops
import (
"time"
"sort"
)
type Periods struct {
ps []Period
}
func NewPeriods(periods []Period) Periods {
this := Periods{}
this.ps = append([]Period{}, periods...)
return this
}
func NewPeriodsWithSingleTimeRange(startIncl, endExcl time.Time) (periods Periods, err error) {
period, err := NewPeri... | pops/periods.go | 0.691289 | 0.502563 | periods.go | starcoder |
package validator
import (
"reflect"
"regexp"
"strconv"
)
var (
fixedLengthRegex = regexp.MustCompile(`^string\((\d+)\)$`)
variableLengthRegex = regexp.MustCompile(`^string\((\d+), ?(\d+)\)$`)
)
// StringType makes the types beloz available in the aicra configuration:
// - "string" considers any string valid... | validator/string.go | 0.698124 | 0.528533 | string.go | starcoder |
package mparser
import (
"bytes"
"encoding/xml"
"log"
"github.com/gomarkdown/markdown/ast"
"github.com/mmarkdown/mmark/mast"
"github.com/mmarkdown/mmark/mast/reference"
)
// CitationToBibliography walks the AST and gets all the citations on HTML blocks and groups them into
// normative and informative referenc... | vendor/github.com/mmarkdown/mmark/mparser/bibliography.go | 0.52074 | 0.461199 | bibliography.go | starcoder |
package app
import "github.com/timshannon/townsourced/data"
// Help is a help document entry
type Help struct {
Key data.Key `json:"key"`
Title string `json:"title"`
Document string `json:"document"`
}
// HelpGet Retrieves a help document
func HelpGet(key data.Key) (*Help, error) {
return &Help{
K... | app/help.go | 0.599251 | 0.497253 | help.go | starcoder |
package state
import (
"fmt"
"go-snake-ai/direction"
"go-snake-ai/tile"
"math/rand"
)
// NewState returns a State that has been initialised with empty tiles
func NewState(tileNumX int, tileNumY int) *State {
changed := make([]*tile.Vector, 0)
tiles := make([][]tile.Type, tileNumY)
for y := 0; y < tileNumY; y++... | state/state.go | 0.628749 | 0.519826 | state.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.