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 csvnewcol
import (
"errors"
"strings"
)
type csvReader interface {
Read() ([]string, error)
}
// Expression allows generating a new column given a row
type Expression interface {
evaluate([]string) string
}
type stringExpr struct {
str string
}
// Evaluate on StringExpr just returns its contained stri... | pkg/csvnewcol/csvnewcol.go | 0.764364 | 0.417509 | csvnewcol.go | starcoder |
package vmath
import (
"errors"
)
// MatStack4f represents a stack of 4x4 matrices.
type MatStack4f struct {
stack []Mat4f
}
// NewMatStack4f creates a new matrix stack containing only the identity matrix.
func NewMatStack4f() *MatStack4f {
mStack := &MatStack4f{
stack: make([]Mat4f, 1),
}
mStack.stack[0] = I... | matstack4f.go | 0.863046 | 0.538498 | matstack4f.go | starcoder |
package leetcode_go
/*
Given two sorted arrays nums1 and nums2 of size m and n respectively,
return the median of the two sorted arrays.
Follow up: The overall run time complexity should be O(log (m+n)).
Example 1:
Input: nums1 = [1,3], nums2 = [2]
Output: 2.00000
Explanation: merged array = [1,2,3] and median is 2... | 0004.MedianOfTwoSortedArrays.go | 0.837387 | 0.740714 | 0004.MedianOfTwoSortedArrays.go | starcoder |
package datastore
import (
"github.com/stretchr/testify/mock"
)
// MockDatastore represents the mocked object
type MockDatastore struct {
mock.Mock
}
// CreateSession implements the Datastore interface
func (m *MockDatastore) CreateSession() (string, error) {
arguments := m.Called()
return arguments.Get(0).(stri... | backend/pkg/datastore/datastore_mock.go | 0.833121 | 0.540075 | datastore_mock.go | starcoder |
package scanner
// stateT is the state after reading `t`.
func stateT(s *scanner, c byte) int {
if c == 'r' {
s.step = stateTr
return scanContinue
}
return s.error(c, "in literal true (expecting 'r')")
}
// stateTr is the state after reading `tr`.
func stateTr(s *scanner, c byte) int {
if c == 'u' {
s.step ... | scanner/state_keywords.go | 0.793426 | 0.498474 | state_keywords.go | starcoder |
// Package transform provides translations for opentelemetry-go concepts and
// structures to otlp structures.
package transform
import (
"errors"
commonpb "github.com/open-telemetry/opentelemetry-proto/gen/go/common/v1"
metricpb "github.com/open-telemetry/opentelemetry-proto/gen/go/metrics/v1"
"go.opentelemetr... | exporters/otlp/internal/transform/metric.go | 0.701815 | 0.420659 | metric.go | starcoder |
package webrtc
import (
"encoding/json"
"strings"
)
// SDPType describes the type of an SessionDescription.
type SDPType int
const (
// SDPTypeOffer indicates that a description MUST be treated as an SDP
// offer.
SDPTypeOffer SDPType = iota + 1
// SDPTypePranswer indicates that a description MUST be treated ... | sdptype.go | 0.526343 | 0.413832 | sdptype.go | starcoder |
package virustotal
import (
"context"
virustotal "github.com/VirusTotal/vt-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 tableVirusTotalDomain(ctx context.Context) *plugin.Table {
return ... | virustotal/table_virustotal_domain.go | 0.594551 | 0.430028 | table_virustotal_domain.go | starcoder |
package solution
/*
leetcode: https://leetcode.com/problems/implement-magic-dictionary/
*/
/*
We build a trie data structure.
When we search a word, for example: abc
We try to seach *bc, a*c, ab* and character at index * != character at index in searchword
==> we found the answer
Time complexity:
Construc... | lesson-15/trie/676-implement-magic-dictionary/solution.go | 0.810141 | 0.418875 | solution.go | starcoder |
package main
import (
"fmt"
"errors"
"strings"
"github.com/rolfschmidt/advent-of-code-2021/helper"
)
func main() {
fmt.Println("Part 1", Part1())
fmt.Println("Part 2", Part2())
}
func Part1() int {
return Run(false)
}
func Part2() int {
return Run(true)
}
func IntBetween(value int, ... | day22/main.go | 0.555194 | 0.458773 | main.go | starcoder |
package internal
import (
"fmt"
"sync"
"testing"
)
type Tree struct {
TreeNode
testsByID map[string]*TestCase
}
// NewTree returns a new Tree with the provided test cases.
func NewTree(testCases ...TestCase) Tree {
var tree Tree
for _, tc := range testCases {
tree.Insert(tc)
}
return tree
}
// DeepEqual ... | internal/tree.go | 0.70304 | 0.493164 | tree.go | starcoder |
package interpreter
import (
"fmt"
"image"
"reflect"
)
type Rect image.Rectangle
func (rc Rect) Compare(other Value) (Value, error) {
if r, ok := other.(Rect); ok {
if rc == r {
return Number(0), nil
}
}
return nil, nil
}
func (rc Rect) Add(other Value) (Value, error) {
return nil, fmt.Errorf("type mi... | internal/interpreter/rect.go | 0.823754 | 0.469824 | rect.go | starcoder |
package move
import (
"github.com/kemokemo/kuronan-dash/internal/view"
)
// NewKuronaVc returns a new VelocityController for Kurona.
func NewKuronaVc() *KuronaVc {
return &KuronaVc{
scrollV: &view.Vector{X: 0.0, Y: 0.0},
charaPosV: &view.Vector{X: 0.0, Y: 0.0},
charaDrawV: &view.Vector{X: 0.0, Y: 0.0},
... | internal/move/kurona_vc.go | 0.512937 | 0.416085 | kurona_vc.go | starcoder |
package main
import (
"math"
"sort"
. "github.com/9d77v/leetcode/pkg/algorithm/math"
. "github.com/9d77v/leetcode/pkg/algorithm/unionfind"
)
/*
题目:连接所有点的最小费用
给你一个points 数组,表示 2D 平面上的一些点,其中 points[i] = [xi, yi] 。
连接点 [xi, yi] 和点 [xj, yj] 的费用为它们之间的 曼哈顿距离 :|xi - xj| + |yi - yj| ,其中 |val| 表示 val 的绝对值。
请你返回将所有点连接的最... | internal/leetcode/1584.min-cost-to-connect-all-points/main.go | 0.529263 | 0.435061 | main.go | starcoder |
package wkt
import (
"errors"
"strconv"
"strings"
"github.com/paulmach/orb"
)
var (
// ErrNotWKT is returned when unmarshalling WKT and the data is not valid.
ErrNotWKT = errors.New("wkt: invalid data")
// ErrIncorrectGeometry is returned when unmarshalling WKT data into the wrong type.
// For example, unma... | vendor/github.com/paulmach/orb/encoding/wkt/unmarshal.go | 0.68637 | 0.430686 | unmarshal.go | starcoder |
package faststats
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
)
// RollingCounter uses a slice of buckets to keep track of counts of an event over time with a sliding window
type RollingCounter struct {
// The len(buckets) is constant and not mutable
// The values of the individual buckets are at... | v3/faststats/rolling_counter.go | 0.68637 | 0.424591 | rolling_counter.go | starcoder |
package webtest
import (
"bytes"
"context"
"io/ioutil"
"net/http"
"testing"
"time"
"github.com/stretchr/testify/require"
)
// HandlerForTest implement the function signature used to check the req/resp
type HandlerForTest = func(t *testing.T, resp *http.Response)
const (
_notEqualHeader = `assertion failed f... | webtest/web.go | 0.622918 | 0.459743 | web.go | starcoder |
package subnetmath
import (
"bytes"
"math"
"math/big"
"net"
"sync"
)
type Buffer struct {
mtx *sync.Mutex
bigIntAlpha *big.Int
bigIntBravo *big.Int
bigIntCharlie *big.Int
bigIntDelta *big.Int
bigIntEcho *big.Int
ipSubZero [16]byte
}
func NewBuffer() *Buffer {
return &Buffer{
mtx... | buffered.go | 0.620047 | 0.415788 | buffered.go | starcoder |
package bits
import (
"encoding/binary"
"fmt"
"regexp"
"strings"
"sync"
tmmath "github.com/supragya/TendermintConnector/chains/cosmos/libs/math"
tmrand "github.com/supragya/TendermintConnector/chains/cosmos/libs/rand"
tmprotobits "github.com/supragya/TendermintConnector/chains/cosmos/proto/tendermint/libs/bit... | chains/cosmos/libs/bits/bit_array.go | 0.649245 | 0.407304 | bit_array.go | starcoder |
package storetest
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/store"
)
func TestPreferenceStore(t *testing.T, ss store.Store) {
t.Run("PreferenceSave", func(t *test... | store/storetest/preference_store.go | 0.524151 | 0.431884 | preference_store.go | starcoder |
package statistics
import (
"math"
"math/bits"
"sort"
"github.com/pingcap/errors"
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/expression"
planutil "github.com/pingcap/tidb/planner/util"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/types"
"git... | statistics/selectivity.go | 0.55254 | 0.428652 | selectivity.go | starcoder |
package d06
import (
"regexp"
"strings"
"github.com/jzimbel/adventofcode-go/solutions"
)
// intermediate data structure to make building the tree easier
type orbitMap map[string][]string
// standard tree structure with awareness of its parent and depth from the root
type tree struct {
label string
depth ... | solutions/y2019/d06/solution.go | 0.694613 | 0.44071 | solution.go | starcoder |
package swisstopo
import (
"math"
)
func CHtoWGSheight(y float64, x float64, h float64) float64 {
// Converts military to civil and to unit = 1000km
// Auxiliary values (% Bern)
y_aux := (y - 600000) / 1000000
x_aux := (x - 200000) / 1000000
// Process height
h = (h + 49.55) - (12.60 * y_aux) - (22.64 * x_aux... | scripts/go/WGS84_CH1903.go | 0.81283 | 0.519034 | WGS84_CH1903.go | starcoder |
package iso20022
// Cash movements from or to a fund as a result of investment funds transactions, eg, subscriptions or redemptions.
type EstimatedFundCashForecast3 struct {
// Unique technical identifier for an instance of a fund cash forecast within a fund cash forecast report as assigned by the issuer of the repo... | EstimatedFundCashForecast3.go | 0.860266 | 0.534612 | EstimatedFundCashForecast3.go | starcoder |
package rpc
import (
"encoding/binary"
"math"
"time"
"github.com/ebay/beam/logentry"
)
// TypePrefix returns a byte slice that contain a prefix of the encoding that contains
// the type. This will contain the type indicator, and for types that have units, will
// also contain the units ID.
func (o KGObject) Typ... | src/github.com/ebay/beam/rpc/kgobject_accessors.go | 0.64232 | 0.41834 | kgobject_accessors.go | starcoder |
package internal
var metricsFile = &File{
Name: "metrics",
imports: []string{
`otlpmetrics "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/metrics/v1"`,
},
testImports: []string{
`"testing"`,
``,
`"github.com/stretchr/testify/assert"`,
``,
`otlpmetrics "go.opentelemetry.io/collect... | cmd/pdatagen/internal/metrics_structs.go | 0.70028 | 0.470372 | metrics_structs.go | starcoder |
package binarytree
import (
"fmt"
"strings"
"github.com/ianadiwibowo/central-park/datastructures/queue"
)
type BinaryTree struct {
Root *BinaryTreeNode
}
type BinaryTreeNode struct {
Value int
Left *BinaryTreeNode
Right *BinaryTreeNode
}
// NewBinaryTree creates a new empty binary tree
func NewBinaryTree()... | datastructures/binarytree/binarytree.go | 0.784649 | 0.460653 | binarytree.go | starcoder |
package imaging
import (
"image"
"image/color"
)
// Clone returns a copy of the given image.
func Clone(img image.Image) *image.NRGBA {
dstBounds := img.Bounds().Sub(img.Bounds().Min)
dst := image.NewNRGBA(dstBounds)
switch src := img.(type) {
case *image.NRGBA:
copyNRGBA(dst, src)
case *image.NRGBA64:
co... | vendor/github.com/disintegration/imaging/clone.go | 0.625667 | 0.578389 | clone.go | starcoder |
package models
import (
"encoding/json"
"fmt"
"strconv"
)
// Features a Feature result set
type Features []Feature
func (a Features) Len() int { return len(a) }
func (a Features) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Features) Less(i, j int) bool { return a[i].Key < a[j].Key }
// Feat... | models/feature.go | 0.774071 | 0.405508 | feature.go | starcoder |
package etree
import (
"strconv"
"strings"
)
/*
A Path is an object that represents an optimized version of an
XPath-like search string. Although path strings are XPath-like,
only the following limited syntax is supported:
. Selects the current element
.. Selects the parent of ... | pkg/terraform/exec/vendor/github.com/beevik/etree/path.go | 0.777596 | 0.500549 | path.go | starcoder |
* (https://github.com/sipa/bips/blob/bip-schnorr/bip-schnorr.mediawiki).
*/
package secp256k1
/*
#include <stdlib.h>
#include "include/secp256k1_schnorrsig.h"
static unsigned char** makeBytesArray(int size) { return !size ? NULL : calloc(sizeof(unsigned char*), size); }
static void setBytesArray(unsigned char** a, u... | schnorrsig.go | 0.734024 | 0.444263 | schnorrsig.go | starcoder |
package constfold
import (
"github.com/VKCOM/noverify/src/meta"
)
// Plus performs arithmetic "+".
func Plus(x, y meta.ConstValue) meta.ConstValue {
switch x.Type {
case meta.Integer:
if y.Type == meta.Integer {
return meta.NewIntConst(x.GetInt() + y.GetInt())
}
case meta.Float:
if y.Type == meta.Float {... | src/constfold/binary_op.go | 0.647352 | 0.430686 | binary_op.go | starcoder |
package cornellbox
import (
"math/rand"
"github.com/peterstace/grayt/scene"
. "github.com/peterstace/grayt/scene/dsl"
"github.com/peterstace/grayt/xmath"
)
func SphereTree() scene.Scene {
cam := CornellCam(1.3)
cam.LookingAt = Vect(0.5, 0.25, -0.5)
cam.FieldOfViewInRadians *= 0.95
cam.AspectWide = 2
cam.Asp... | scene/cornellbox/spheretree.go | 0.677794 | 0.409752 | spheretree.go | starcoder |
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
package unix
import "time"
// TimespecToNsec converts a Timespec value into a number of
// nanoseconds since the Unix epoch.
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
// NsecToTimespec takes a number of n... | vendor/golang.org/x/sys/unix/timestruct.go | 0.834204 | 0.527012 | timestruct.go | starcoder |
package shcrypto
import (
"bytes"
"crypto/rand"
"io"
"math/big"
bn256 "github.com/ethereum/go-ethereum/crypto/bn256/cloudflare"
gocmp "github.com/google/go-cmp/cmp"
"github.com/pkg/errors"
)
var (
zeroG1 *bn256.G1
zeroG2 *bn256.G2
)
// Polynomial represents a polynomial over Z_q.
type Polynomial []*big.Int... | shlib/shcrypto/feldman.go | 0.802517 | 0.724256 | feldman.go | starcoder |
package iso20022
// Chain of parties involved in the settlement of a transaction, including receipts and deliveries, book transfers, treasury deals, or other activities, resulting in the movement of a security or amount of money from one account to another.
type ReceivingPartiesAndAccount8 struct {
// Party that buy... | ReceivingPartiesAndAccount8.go | 0.662687 | 0.457016 | ReceivingPartiesAndAccount8.go | starcoder |
package gosang
import (
"bytes"
"image"
"image/color"
"io"
"github.com/pkg/errors"
)
// offsetedReader implements io.Reader combining io.ReaderAt and offset.
type offsetedReader struct {
r io.ReaderAt
offset int64
}
func (or *offsetedReader) Read(p []byte) (int, error) {
n, err := or.r.ReadAt(p, or.off... | util.go | 0.576065 | 0.436922 | util.go | starcoder |
package giu
import (
"image"
"github.com/ianling/imgui-go"
)
type PlotWidget interface {
Plot()
}
type ImPlotYAxis int
const (
ImPlotYAxisLeft ImPlotYAxis = 0 // left (default)
ImPlotYAxisFirstOnRight ImPlotYAxis = 1 // first on right side
ImPlotYAxisSecondOnRight ImPlotYAxis = 2 // second on right... | Plot.go | 0.763307 | 0.477859 | Plot.go | starcoder |
package go2linq
// Reimplementing LINQ to Objects: Part 34 - SequenceEqual
// https://codeblog.jonskeet.uk/2011/01/14/reimplementing-linq-to-objects-part-34-sequenceequal/
// https://docs.microsoft.com/dotnet/api/system.linq.enumerable.sequenceequal
// SequenceEqual determines whether two sequences are equal by comp... | sequenceequal.go | 0.895788 | 0.627966 | sequenceequal.go | starcoder |
package squares
import (
"image"
"image/color"
"io"
svg "github.com/ajstarks/svgo"
"github.com/taironas/tinygraphs/draw"
)
// RandomGrid builds a grid image with with x colors selected at random for each quadrant.
func RandomGrid(m *image.RGBA, colors []color.RGBA, xSquares int, prob float64) {
size := m.Bound... | draw/squares/random.go | 0.676192 | 0.507263 | random.go | starcoder |
package kronasje
import (
"regexp"
"fmt"
)
// This spec tries to adhere to the 4th Berkely Distribution of the crontab
// manual (man 5 crontab) dated 19 April 2010.
// Regular expression strings
const (
startExp = `^`
endExp = `$`
everyExp = `\*`
singleOrDoubleDigit... | spec.go | 0.681727 | 0.432243 | spec.go | starcoder |
package geodesic
import (
"math"
)
// NaiveFind is the naive algorithm for determining the face containing a point.
// Searches every face on the sphere, so it's incredibly inefficient for large
// numbers of faces.
func NaiveFind(g *Geodesic, v Vector) int {
start := 0
minDistSq := math.MaxFloat64
for i, center ... | pkg/geodesic/find.go | 0.772616 | 0.436802 | find.go | starcoder |
package atomic
import (
"unsafe"
)
// A Value provides an atomic load and store of a consistently typed value.
// Values can be created as part of other data structures.
// The zero value for a Value returns nil from Load.
// Once Store has been called, a Value must not be copied.
type Value struct {
v interface{}... | go1.5/src/sync/atomic/value.go | 0.695958 | 0.426799 | value.go | starcoder |
package interval
import (
"sort"
"time"
"github.com/grokify/gocharts/data/timeseries"
"github.com/grokify/simplego/math/mathutil"
"github.com/grokify/simplego/time/month"
"github.com/grokify/simplego/time/timeutil"
"github.com/pkg/errors"
)
type XoXGrowth struct {
DateMap map[string]XoxPoint
YTD int64
... | data/timeseries/interval/xox_month.go | 0.537041 | 0.523786 | xox_month.go | starcoder |
package big
import (
"fmt"
"math"
"math/big"
"math/rand"
)
// A wrapper around math/big.Int which makes operations easier to express.
// The big difference is that this big.Int is immutable. Operations on
// these big.Ints are easier to write code with, but require more
// allocations under the hood. Totally wo... | big/int.go | 0.653348 | 0.46952 | int.go | starcoder |
package header
/**
* A Proxy-Authenticate header field value contains an authentication
* challenge. When a UAC sends a request to a proxy server, the proxy server
* MAY authenticate the originator before the request is processed. If no
* credentials (in the Proxy-Authorization header field) are provided in the
*... | sip/header/ProxyAuthenticateHeader.go | 0.851181 | 0.412175 | ProxyAuthenticateHeader.go | starcoder |
package engine
import (
"github.com/ivan1993spb/snake-bot/internal/types"
)
type Sight struct {
area Area
topLeft types.Dot
zeroedBottomRight types.Dot
width uint8
height uint8
}
// sightDivisor defines how many intervals of a given length
// we need to be able to fit within an area. In the 2D space
// t... | internal/bot/engine/sight.go | 0.576304 | 0.423935 | sight.go | starcoder |
package predicate
import (
"fmt"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"github.com/influxdata/influxdb/v2/models"
"github.com/influxdata/influxdb/v2/storage/reads/datatypes"
)
// TagRuleNode is a node type of a single tag rule.
type TagRuleNode influxdb.TagR... | predicate/tag_rule.go | 0.577853 | 0.431584 | tag_rule.go | starcoder |
package strftime
import "time"
/*
Strftime implements the POSIX strftime(3) function. The underlying
implementation uses the native C library function on Linux and Darwin, and a
pure Go replacement otherwise. There are some functional differences between
the implementations; see also the documentation of StrftimePure... | vendor/github.com/fastly/go-utils/strftime/strftime.go | 0.732209 | 0.677169 | strftime.go | starcoder |
package equality
import (
operatorv1alpha1 "github.com/projectcontour/contour-operator/api/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
)
// DaemonsetConfigChanged checks if curren... | internal/equality/equality.go | 0.740831 | 0.423339 | equality.go | starcoder |
package movers
import (
"github.com/wieku/danser-go/app/beatmap/difficulty"
"github.com/wieku/danser-go/app/beatmap/objects"
"github.com/wieku/danser-go/app/settings"
"github.com/wieku/danser-go/framework/math/curves"
"github.com/wieku/danser-go/framework/math/math32"
"github.com/wieku/danser-go/framework/math/m... | app/dance/movers/angleoffset.go | 0.679179 | 0.407717 | angleoffset.go | starcoder |
package metrics
// MonotonicCount tracks a raw counter, based on increasing counter values.
// Samples that have a lower value than the previous sample are ignored (since it usually
// means that the underlying raw counter has been reset).
// Example:
// submitting samples 2, 3, 6, 7 returns 5 (i.e. 7-2) on flush ;
... | pkg/metrics/monotonic_count.go | 0.888396 | 0.601857 | monotonic_count.go | starcoder |
package kml
import (
"github.com/twpayne/go-kml"
"github.com/twpayne/go-geom"
)
// Encode encodes an arbitrary geometry.
func Encode(g geom.T) (kml.Element, error) {
switch g := g.(type) {
case *geom.Point:
return EncodePoint(g), nil
case *geom.LineString:
return EncodeLineString(g), nil
case *geom.LinearR... | encoding/kml/kml.go | 0.778733 | 0.573917 | kml.go | starcoder |
package tfutils
func (s SimpleSchema) Required(status bool) SimpleSchema {
s.s.Required = status
return s
}
func (s SimpleSchema) Optional(status bool) SimpleSchema {
s.s.Optional = status
return s
}
func (s SimpleSchema) Computed(status bool) SimpleSchema {
s.s.Computed = status
return s
}
func (s SimpleSche... | schema.go | 0.850375 | 0.608769 | schema.go | starcoder |
package tedi
import (
"reflect"
"testing"
"unsafe"
"github.com/stretchr/testify/require"
"go.uber.org/dig"
)
// Test registers a function as a test.
func (t *Tedi) Test(name string, fn interface{}, labels ...string) {
testsLabel := newStringSet(labels...)
matchedLabels := testsLabel.Intersect(t.labels)
matc... | test.go | 0.586049 | 0.512632 | test.go | starcoder |
Package workflow implements a workflow manager to be used for
implementing composable kubeadm workflows.
Composable kubeadm workflows are built by an ordered sequence of phases;
each phase can have it's own, nested, ordered sequence of sub phases.
For instance
preflight Run master pre-flight checks
certs ... | cmd/kubeadm/app/cmd/phases/workflow/doc.go | 0.726911 | 0.654895 | doc.go | starcoder |
package redshift
import (
"fmt"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func dataSourceRedshiftSchema() *schema.Resource {
return &schema.Resource{
Description: `
A database contains one or more named schemas. Each schema in a database contains tables and other kinds of named o... | redshift/data_source_redshift_schema.go | 0.770206 | 0.449816 | data_source_redshift_schema.go | starcoder |
package stringunescape
import (
"fmt"
"strings"
"github.com/relex/slog-agent/util"
)
// Unescaper is used to search and unescape characters like '\n', '\t' etc
// Unescaper instances contain no buffer and may be copied or concurrently used.
type Unescaper struct {
escapeChar byte
escapableCharMap []byte
}... | util/stringunescape/unescape.go | 0.580709 | 0.473231 | unescape.go | starcoder |
package quantum
import (
"fmt"
"math"
"math/cmplx"
"math/rand"
"time"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
// Represents a quantum register
type QReg struct {
// The width (number of qubits) of this quantum register.
width int
// The complex amplitudes for each of t... | src/quantum/qreg.go | 0.78403 | 0.636127 | qreg.go | starcoder |
package hll
import (
"fmt"
"sort"
)
// Bitstrings are uint64. Rho values (bucket counts in M) are uint64. Indices and p values are uint.
// rho results (position of first 1 in a bitstring) are uint8 because only 6 bits are required to
// encode the position of a bit in a 64-bit sequence (log2(64)==6).
// Return th... | sparseutil.go | 0.698021 | 0.666999 | sparseutil.go | starcoder |
package str
import (
"kidy/utils"
"math"
"math/rand"
"strings"
"time"
)
// Return the remainder of a string after a given value.
func After(subject, search string) string {
if search == "" {
return subject
}
values := strings.Split(subject, search)[1:]
if len(values) > 0 {
return strings.Join(values, se... | str/str.go | 0.77223 | 0.438966 | str.go | starcoder |
package flake
import (
"encoding/binary"
"fmt"
)
// Nil is the zero flake id.
const Nil = ID(0)
// Size returns the size (in bytes) of a flake id.
const Size = 8
// These constants define the distribution of bits in a flake id.
const (
// BucketBits is the number of bits dedicated to the bucket of the id
Bucket... | pkg/flake/id.go | 0.840193 | 0.435241 | id.go | starcoder |
package colorpicker
import (
"gioui.org/f32"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/clip"
"gioui.org/op/paint"
"gioui.org/unit"
"image"
"image/color"
"math"
)
const c = 0.55228475 // 4*(sqrt(2)-1)/3
func drawControl(p f32.Point, radius, width float32, gtx layout.Context) {
width = float32(gtx.Px(u... | colorpicker/draw.go | 0.639736 | 0.465934 | draw.go | starcoder |
package paint
import (
"image/color"
"math"
"github.com/tomowarkar/biome"
)
// Canvas :
type Canvas interface {
Fill(x, y int, obj int)
Line(x1, y1, x2, y2 int, px float64, obj int)
Square(x, y int, px, deg float64, obj int)
Triangle(x, y int, px, deg float64, obj int)
Dot(x, y int, px float64, obj int)
Dat... | paint/paint.go | 0.542742 | 0.468365 | paint.go | starcoder |
package heisenberg
import (
"fmt"
"math"
"math/cmplx"
)
// Sparse64 is an algebriac matrix
type Sparse64 struct {
R, C int
Matrix []map[int]complex64
}
func (a Sparse64) String() string {
output := ""
for i := 0; i < a.R; i++ {
for j := 0; j < a.C; j++ {
out := a.Matrix[i]
var value complex64
if... | sparse.go | 0.693992 | 0.536374 | sparse.go | starcoder |
// Package tracelog : logcalls.go provides formatting functions.
package tracelog
import (
"fmt"
)
//** STARTED AND COMPLETED
// Started uses the Serialize destination and adds a Started tag to the log line
func Started(title string, functionName string) {
logger.Trace.Output(2, fmt.Sprintf("%s : %s : Started\n",... | vendor/github.com/goinggo/tracelog/logcalls.go | 0.529993 | 0.467332 | logcalls.go | starcoder |
package main
import (
"fmt"
"io"
"text/template"
)
const checkNativeSelectable = `func checkNativeSelectable(t *Dense, axis int, dt Dtype) error {
if !t.IsNativelyAccessible() {
return errors.New("Cannot select on non-natively accessible data")
}
if axis >= t.Shape().Dims() && !(t.IsScalar() && axis == 0) {
... | genlib2/native_select.go | 0.697403 | 0.523786 | native_select.go | starcoder |
package golarm
type period int
type metric int
type state int
type procType int
var (
states = map[string]float64{
"S": 1.0,
"R": 2.0,
"T": 3.0,
"Z": 4.0,
"D": 5.0,
}
)
const (
freeMetric metric = iota + 1
usedMetric
timeMetric
statusMetric
)
// Linux process states to be used with status alarms
con... | metrics.go | 0.779154 | 0.465145 | metrics.go | starcoder |
package meta
import (
"fmt"
"math"
"sort"
"strconv"
"strings"
)
const (
RadiansToDegrees = 57.2957795
DegreesToKm = math.Pi * 6371.0 / 180.0
RadiansToKm = RadiansToDegrees * DegreesToKm
)
const (
placenameName = iota
placenameLatitude
placenameLongitude
placenameLevel
placenameLast
)
// Place... | meta/placenames.go | 0.802672 | 0.596874 | placenames.go | starcoder |
package processor
import (
"fmt"
"sync/atomic"
"time"
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/message/tracing"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/processor/condition"
"github.com/Jeffail/benthos/lib/response"
"github.com/Jeffail/benthos/lib/... | lib/processor/while.go | 0.691393 | 0.410284 | while.go | starcoder |
package planet
import (
"github.com/willbeason/worldproc/pkg/geodesic"
"github.com/willbeason/worldproc/pkg/noise"
"github.com/willbeason/worldproc/pkg/render"
"github.com/willbeason/worldproc/pkg/sun"
"image"
"math"
)
func AddTerrain(p *Planet, sphere *geodesic.Geodesic, perlinNoise *noise.PerlinFractal) {
p.... | pkg/planet/terrain.go | 0.626696 | 0.45181 | terrain.go | starcoder |
package dtables
import (
"errors"
"io"
"github.com/dolthub/dolt/go/libraries/doltcore/diff"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/env/actions"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/index"
"github.com/dolthub/go-mysql-server/sql"
)
... | go/libraries/doltcore/sqle/dtables/unscoped_diff_table.go | 0.658747 | 0.448728 | unscoped_diff_table.go | starcoder |
package query
import "fmt"
type (
reducer string
)
var (
// REDUCERS
// ReducerArgMax outputs for each tick, the tick and the concatenation separated by ‘,’ of the values of the labels for which the value is the maximum of Geo Time SeriesTM which are in the same equivalence class
ReducerArgMax = func(i float64... | query/reducers.go | 0.817319 | 0.63768 | reducers.go | starcoder |
package entities
import (
"errors"
"math/big"
"github.com/daoleno/uniswap-sdk-core/entities"
"github.com/daoleno/uniswapv3-sdk/constants"
"github.com/daoleno/uniswapv3-sdk/utils"
)
var (
ErrTickOrder = errors.New("tick order error")
ErrTickLower = errors.New("tick lower error")
ErrTickUpper = errors.New("tic... | entities/position.go | 0.758421 | 0.439447 | position.go | starcoder |
package ionoscloud
import (
"encoding/json"
"strings"
"time"
)
// PtrBool - returns a pointer to given boolean value.
func PtrBool(v bool) *bool { return &v }
// PtrInt - returns a pointer to given integer value.
func PtrInt(v int) *int { return &v }
// PtrInt32 - returns a pointer to given integer value.
func ... | utils.go | 0.788909 | 0.434461 | utils.go | starcoder |
package blurhash
import (
"fmt"
"github.com/buckket/go-blurhash/base83"
"image"
"math"
"strings"
)
func init() {
initLinearTable(channelToLinear[:])
}
var channelToLinear [256]float64
func initLinearTable(table []float64) {
for i := range table {
channelToLinear[i] = sRGBToLinear(i)
}
}
// An InvalidPara... | vendor/github.com/buckket/go-blurhash/encode.go | 0.759493 | 0.452899 | encode.go | starcoder |
package byteslice
// RUnset apply AND operation on a byte slice with an "unset" byte slice using little endian order.
func RUnset(data, unsetData []byte) []byte {
var dataLength = len(data)
if dataLength < 1 {
return data
}
unsetDataLength := len(unsetData)
operationLength := dataLength
operationCut := 0
if ... | byteslice_littleendian.go | 0.788868 | 0.598165 | byteslice_littleendian.go | starcoder |
package graph
import (
i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55 "github.com/microsoft/kiota/abstractions/go/serialization"
)
// WorkbookTableRow
type WorkbookTableRow struct {
Entity
// Returns the index number of the row within the rows collection of the table. Zero-indexed. Rea... | models/microsoft/graph/workbook_table_row.go | 0.717309 | 0.454896 | workbook_table_row.go | starcoder |
package coordtransform
import (
"math"
)
const (
offset = 0.00669342162296594323
axis = 6378245.0
)
// IsOutOFChina 范围检测
func IsOutOFChina(p Point) bool {
lon, lat := p.Lon, p.Lat
return !(lon > 72.004 && lon < 135.05 && lat > 3.86 && lat < 53.55)
}
// delta
func delta(p Point) Point {
lon, lat := p.Lon, p.... | coordtransform.go | 0.543106 | 0.424412 | coordtransform.go | starcoder |
package p174
import "fmt"
/**
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and must fight his way through the dungeon to rescue the pr... | algorithms/p174/174.go | 0.505859 | 0.707481 | 174.go | starcoder |
package xyml
import (
"fmt"
"gopkg.in/yaml.v3"
)
const (
errNoPos = `expected a node of type %s, instead got type %s`
errWithPos = errNoPos + ` @ %d:%d`
errKind = `expected a node of kind %s, instead got %s`
errKindPos = errKind + ` @ %d:%d`
)
// RequireBinary returns an error if the given node is not of... | v1/pkg/xyml/require.go | 0.771672 | 0.561636 | require.go | starcoder |
package ecs
// TraversalMode represents a graph traversal mode.
type TraversalMode uint8
const (
// TraverseDFS is Depth First Search traversal, starting from all matching
// roots.
TraverseDFS TraversalMode = 1 << iota
traverseCo
// TraverseCoDFS is Reversed Depth First Search traversal, starting from
// all ... | internal/ecs/graph_traversal.go | 0.511961 | 0.446796 | graph_traversal.go | starcoder |
package stat
/**
* Statistics for identifier resource.
*/
type Streamidentifierstats struct {
/**
* Name of the stream identifier.
*/
Name string `json:"name,omitempty"`
/**
* Values on which grouping is performed are displayed in the output as row titles. If grouping is performed on two or more fields, their... | resource/stat/streamidentifier_stats.go | 0.760117 | 0.428771 | streamidentifier_stats.go | starcoder |
package main
import (
"errors"
"fmt"
)
// piece is a higolot daily calendar puzzle piece.
type piece [][]bool
// width returns the number of grid columns required to accommodate the piece.
func (p *piece) width() int {
return len((*p)[0])
}
// height returns the number of grid rows required to accommodate the pi... | solver.go | 0.618896 | 0.468791 | solver.go | starcoder |
package quantumchess
import "fmt"
//InvalidMove is an error returned when we try to perform an invalid move on the board.
// Returns the square we want to move to.
type InvalidMove int
//InvalidPiece is an error returned when we expect a piece to be on the board, but it isn't
// Returns the position where we expecte... | pkg/quantumchess/error.go | 0.839043 | 0.585842 | error.go | starcoder |
// Package queueimpl6 implements an unbounded, dynamically growing FIFO queue.
// Internally, queue store the values in fixed sized slices that are linked using a singly linked list.
// This implementation tests the queue performance when performing lazy creation of the first slice as
// well as starting with an slice... | queueimpl6/queueimpl6.go | 0.84412 | 0.58886 | queueimpl6.go | starcoder |
package timedata
import (
"math"
"sort"
"time"
)
// ResampleTimeSeriesData resamples the given [timestamp,value] data to numsteps between start-end (returns numSteps+1 points).
// If the data does not extend past start/end then there will likely be NaN in the output data.
func ResampleTimeSeriesData(data [][]float... | pkg/timedata/timedata.go | 0.728555 | 0.633481 | timedata.go | starcoder |
package kernelsupport
type kernelFeatureVersion struct {
version KernelVersion
features KernelFeatures
}
// a list of eBPF kernel features which are available from a given kernel version forward.
// largely based on https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md
var featureMinVersion = []kernel... | kernelsupport/versions.go | 0.759582 | 0.41182 | versions.go | starcoder |
package golisp2
import "fmt"
type (
// ArgMapper is a utility that makes it easier to map lists of values to
ArgMapper struct {
iter valueIterator
err error
}
// valueIterator is a generic way to traverse/process a set of value-like
// objects.
valueIterator interface {
// Next returns the next value in... | arg_mapper.go | 0.587825 | 0.476641 | arg_mapper.go | starcoder |
package vector
import (
"math"
)
func min(a, b int) int {
if a < b {
return a
}
return b
}
// Vector represents mathematical vector.
type Vector []float64
// New returns vector of specified szie.
func New(size int) Vector {
return make(Vector, size)
}
// NewWithValues returns vector with specified values.
/... | vector.go | 0.904879 | 0.665404 | vector.go | starcoder |
// +build appengine
package simd
// This file contains functions which operate on slices of 2- or 4-byte
// elements (typically small structs or integers) in ways that differ from the
// corresponding operations on single-byte elements.
// In this context, there is little point in making the interface based on
// []... | simd/multibyte_appengine.go | 0.521715 | 0.435001 | multibyte_appengine.go | starcoder |
package cli
import (
"context"
"encoding/json"
"fmt"
"log"
"net/url"
"os"
"path"
"strconv"
"strings"
"time"
"github.com/Vivino/rankdb/api/client"
"github.com/goadesign/goa"
goaclient "github.com/goadesign/goa/client"
uuid "github.com/goadesign/goa/uuid"
"github.com/spf13/cobra"
)
type (
// DeleteBac... | api/tool/cli/commands.go | 0.620392 | 0.452899 | commands.go | starcoder |
package xlsx
import (
"github.com/plandem/xlsx/format"
"github.com/plandem/xlsx/types"
)
//Range is a object that provides some functionality for cells inside of range. E.g.: A1:D12
type Range struct {
//we don't want to pollute Range with bound's public properties
bounds types.Bounds
sheet Sheet
}
//newRangeFr... | range.go | 0.666605 | 0.479626 | range.go | starcoder |
package dataframe
import (
"fmt"
"reflect"
"strings"
"github.com/ptiger10/pd/internal/index"
"github.com/ptiger10/pd/internal/values"
"github.com/ptiger10/pd/options"
)
// A DataFrame is a 2D collection of one or more Series with a shared index and associated columns.
type DataFrame struct {
name string
v... | dataframe/dataframe.go | 0.629319 | 0.400837 | dataframe.go | starcoder |
package comments
import (
"fmt"
"strings"
"sigs.k8s.io/kustomize/kyaml/yaml"
)
// lostComment specifies a mapping between a fieldName (in the old structure), which doesn't exist in the
// new tree, and its related comment. It optionally specifies the line number of the comment, a positive
// line number is used t... | pkg/serializer/comments/lost.go | 0.617282 | 0.48688 | lost.go | starcoder |
package html_builder
func Text(text string) Node {
return TextNode(text)
}
func Br() Node {
return RawNode("<br/>")
}
func Hr() Node {
return RawNode("<hr/>")
}
func A(attributes Attrs, children ...Node) Node {
return Element{"a", attributes, children}
}
func Abbr(attributes Attrs, children ...Node) Node {
retu... | elements.go | 0.850018 | 0.45532 | elements.go | starcoder |
package graphlib
import (
"math"
"strconv"
)
type Point struct {
X uint
Y uint
}
type MapNode struct {
point Point
name string
Links []MapEdge
}
type MapEdge struct {
Dist uint
from *MapNode
to *MapNode
}
type MapGraph struct {
nodes map[string]*MapNode
CoorExists map[string]bool
NodeExists ma... | graphmap.go | 0.587707 | 0.426799 | graphmap.go | starcoder |
package ast
import (
"fmt"
"strconv"
"time"
)
var _ BoolNode = (*BoolConstNode)(nil)
var _ DatetimeNode = (*DatetimeConstNode)(nil)
var _ Int64Node = (*Int64ConstNode)(nil)
var _ Float64Node = (*Float64ConstNode)(nil)
var _ StringNode = (*StringConstNode)(nil)
func NewBoolConstNode(value bool) BoolNode {
return ... | storage/ast/node_const.go | 0.763219 | 0.408808 | node_const.go | starcoder |
package window
import (
"syscall/js"
)
func (document document) Selection() Selection {
return Selection(document.Call("getSelection"))
}
type (
Selection js.Value
Range js.Value
)
func (selection Selection) Range(index int) Range {
return Range(js.Value(selection).Call("getRangeAt", index))
}
func (selec... | selection.go | 0.742702 | 0.407687 | selection.go | starcoder |
package mmdbwriter
import (
"net"
"github.com/maxmind/mmdbwriter/mmdbtype"
"github.com/pkg/errors"
)
type recordType byte
const (
recordTypeEmpty recordType = iota
recordTypeData
recordTypeNode
recordTypeAlias
recordTypeFixedNode
recordTypeReserved
)
type record struct {
node *node
valueKey data... | node.go | 0.565779 | 0.471102 | node.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.