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 check
import (
"fmt"
"reflect"
)
// CheckEquality will check if two given interfaces are equal. Note it will
// only check the presense of object that are in the expected (e) interface.
// If the returned (r) interface has more object or keys no error will be
// returned
func CheckEquality(expected, given i... | check.go | 0.72526 | 0.596374 | check.go | starcoder |
package dreck
import (
"strings"
"testing"
)
var actionOptions = []struct {
title string
body string
expectedAction string
}{
{
title: "Correct reopen command",
body: Trigger + "reopen",
expectedAction: reopenConst,
},
{
title: "Correct close command",
... | comments_tes.go | 0.568296 | 0.444203 | comments_tes.go | starcoder |
package is
import (
"fmt"
"math"
"strconv"
"strings"
"time"
"github.com/stanleynguyen/is-thirteen/internal/anagram"
)
type numberMatcher struct {
value float64
Roughly roughlyMatcher
Not invertedMatcher
DivisibleBy divisibilityMatcher
SquareOf squareMatcher
GreaterThan greaterMatcher... | is.go | 0.752559 | 0.532668 | is.go | starcoder |
package processing
import (
"bufio"
"fmt"
"image"
"image/color"
"github.com/jakubnoga/kdtree"
"os"
"strconv"
)
// Processor provides image processing methods
type Processor interface {
Convert(color color.Color) color.Color
ConvertImage(image image.Image) image.Image
}
// ConvertImage using provided process... | processing.go | 0.781747 | 0.483283 | processing.go | starcoder |
package analysis
import (
"fmt"
"github.com/orange-lang/orange/pkg/ast"
)
// Scope encompasses the scope for statements and expressions that involve
// code blocks. For example, functions and if statements would both have their
// own scope.
type Scope struct {
// Node is tied to the node that this scope is repre... | pkg/analysis/scope.go | 0.69285 | 0.464051 | scope.go | starcoder |
package main
import (
"fmt"
"math"
)
type Box struct {
Min Tuple
Max Tuple
}
func NewBox(pmin, pmax Tuple) Box {
return Box{pmin, pmax}
}
func (b Box) Union(a Box) Box {
return Box{
Point(math.Min(a.Min.X, b.Min.X), math.Min(a.Min.Y, b.Min.Y), math.Min(a.Min.Z, b.Min.Z)),
Point(math.Max(a.Max.X, b.Max.X)... | bounding_box.go | 0.811974 | 0.504272 | bounding_box.go | starcoder |
package rangeset
import "sort"
// SymmetricDifference returns the symmetric difference of two sets.
func SymmetricDifference(s1, s2 RangeSet) RangeSet {
if len(s1) < len(s2) {
s1, s2 = s2, s1
}
if len(s1) == 0 {
return nil
}
set := make(RangeSet, len(s1), len(s1)+len(s2))
copy(set, s1)
for _, r := range... | symmetricdiff.go | 0.632162 | 0.494141 | symmetricdiff.go | starcoder |
package types
/*
We assume that instructions are unsigned numbers.
All instructions have an opcode in the first 6 bits.
Instructions can have the following fields:
`A' : 8 bits
`B' : 9 bits
`C' : 9 bits
'Ax' : 26 bits ('A', 'B', and 'C' together)
`Bx' : 18 bits (`B' and `C' together)
`sBx' : signed B... | types/instr.go | 0.615088 | 0.58255 | instr.go | starcoder |
package libovsdb
import (
"fmt"
"reflect"
)
var (
intType = reflect.TypeOf(0)
realType = reflect.TypeOf(0.0)
boolType = reflect.TypeOf(true)
strType = reflect.TypeOf("")
)
// ErrWrongType describes typing error
type ErrWrongType struct {
from string
expected string
got interface{}
}
func (e *Err... | vendor/github.com/ovn-org/libovsdb/bindings.go | 0.677047 | 0.423458 | bindings.go | starcoder |
package main
import (
"github.com/go-lsst/ncs/drivers/m702"
)
func init() {
params = []m702.Parameter{
{Index: [3]int{0, 1, 5}, Title: "Jog reference", DefVal: "0.0", RW: true},
{Index: [3]int{0, 1, 6}, Title: "Maximum Reference Clamp", DefVal: "3000.0 rpm", RW: true},
{Index: [3]int{0, 1, 7}, Title: "Minimum... | params.go | 0.592902 | 0.517388 | params.go | starcoder |
package geom
import (
"fmt"
)
type GeometryType int
const (
UnknownType GeometryType = iota
PointType
MultiPointType
LineStringType
MultiLineStringType
PolygonType
MultiPolygonType
GeometryCollectionType
)
func NewGeometry(val interface{}) *Geometry {
geometry := &Geometry{}
... | go/pkg/mojo/geom/geometry.go | 0.852184 | 0.597901 | geometry.go | starcoder |
package collision2d
import (
"fmt"
)
//Polygon struct represents a polygon with position and edges in a counter-clockwise fashion.
type Polygon struct {
Pos, Offset Vector
Angle float64
Points, CalcPoints, Edges, Normals []Vector
}
func (polygon Polygon) String... | polygon.go | 0.828973 | 0.809201 | polygon.go | starcoder |
package surface
import (
"sort"
"github.com/hunterloftis/pbr/pkg/geom"
"github.com/hunterloftis/pbr/pkg/render"
)
const (
minContents = 8
maxDepth = 16
)
type Tree struct {
branch
lights []render.Object
}
type branch struct {
surfaces []render.Surface
bounds *geom.Bounds
left *branch
right *... | pkg/surface/tree.go | 0.754192 | 0.417271 | tree.go | starcoder |
package navmeshv2
import (
"fmt"
"github.com/g3n/engine/math32"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
const (
BlocksX = 6
BlocksY = 6
BlocksTotal = BlocksX * BlocksY
TilesX = 96
TilesY = 96
TilesTotal = TilesX * TilesY
VerticesX = TilesX + 1
VerticesY = TilesY + ... | navmeshv2/rt_navmesh_terrain.go | 0.626238 | 0.438605 | rt_navmesh_terrain.go | starcoder |
package vips
/*
#cgo pkg-config: vips
#include "colour.h"
*/
import "C"
import (
"unsafe"
)
// Interpretation suggests how the values in an image should be interpreted.
// For example, a three-band float image of type InterpretationLAB
// should have its pixels interpreted as coordinates in CIE Lab space.
type Inte... | vips/colour.go | 0.582135 | 0.485051 | colour.go | starcoder |
package main
/**
给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。
如果数组中不存在目标值 target,返回[-1, -1]。
进阶:
你可以设计并实现时间复杂度为O(log n)的算法解决此问题吗?
示例 1:
输入:nums = [5,7,7,8,8,10], target = 8
输出:[3,4]
示例2:
输入:nums = [5,7,7,8,8,10], target = 6
输出:[-1,-1]
示例 3:
输入:nums = [], target = 0
输出:[-1,-1]
提示:
0 <= nums.length <= ... | leetcode/searchRange/searchRange.go | 0.628179 | 0.546496 | searchRange.go | starcoder |
package fennec
import (
"github.com/llgcode/draw2d/draw2dimg"
"image"
"image/color"
"image/png"
"math"
"os"
)
func VisualizeSpectre(spectre [][]Float, peaks []Peak, hashes []Hash) image.Image {
numRows := len(spectre)
var numCols int
if numRows > 0 {
numCols = len(spectre[0])
}
minInSpectre, maxInSpectr... | visualize.go | 0.574395 | 0.434401 | visualize.go | starcoder |
package validate
import (
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
)
func MaintenanceTimeZone() pluginsdk.SchemaValidateFunc {
// Output from [System.TimeZoneInfo]::GetSystemTimeZones()
candidates := []string{
... | terraform/azurerm/vendor/github.com/hashicorp/terraform-provider-azurerm/internal/services/maintenance/validate/maintenance.go | 0.539226 | 0.560072 | maintenance.go | starcoder |
package tart
// The triangular moving average (TMA) is a technical indicator that is similar
// to other moving averages. The TMA shows the average (or mean) price of an
// asset over a specified number of data points—usually a number of price bars.
// However, the triangular moving average differs in that it is doubl... | trima.go | 0.908179 | 0.72054 | trima.go | starcoder |
package particle
import (
"C"
"math"
"reflect"
"unsafe"
"github.com/losinggeneration/hge"
"github.com/losinggeneration/hge/helpers/color"
"github.com/losinggeneration/hge/helpers/rect"
"github.com/losinggeneration/hge/helpers/sprite"
"github.com/losinggeneration/hge/helpers/vector"
"github.com/losinggenerat... | helpers/particle/particle.go | 0.551815 | 0.438184 | particle.go | starcoder |
// Package atomic provides low-level atomic memory primitives
// useful for implementing synchronization algorithms.
package atomic
import (
"sync/atomic"
"unsafe"
)
// SwapInt32 atomically stores new into *addr and returns the previous *addr value.
func SwapInt32(addr *int32, new int32) (old int32) {
return atom... | atomic.go | 0.810816 | 0.447943 | atomic.go | starcoder |
package main
import (
"container/heap"
)
/*
题目:滑动窗口中位数
中位数是有序序列最中间的那个数。如果序列的长度是偶数,则没有最中间的数;此时中位数是最中间的两个数的平均数。
例如:
[2,3,4],中位数是 3
[2,3],中位数是 (2 + 3) / 2 = 2.5
给你一个数组 nums,有一个长度为 k 的窗口从最左端滑动到最右端。窗口中有 k 个数,每次窗口向右移动 1 位。你的任务是找出每次窗口移动后得到的新窗口中元素的中位数,并输出由它们组成的数组。
提示:
你可以假设 k 始终有效,即:k 始终小于输入的非空数组的元素个数。
与真实值误差在 10 ^ -5 以... | internal/leetcode/480.sliding-window-median/main.go | 0.507568 | 0.539772 | main.go | starcoder |
package reflect
import (
"reflect"
"unsafe"
)
func value_Copy(dst Value, src Value) int {
return reflect.Copy(toRV(dst), toRV(src))
}
func value_Append(v Value, args ...Value) Value {
return toV(reflect.Append(toRV(v), toRVs(args)...))
}
func value_AppendSlice(s, t Value) Value {
return toV(reflect.AppendSlice... | value.go | 0.674587 | 0.620392 | value.go | starcoder |
package pathway
import (
"fmt"
"math"
"regexp"
"strings"
"github.com/pkg/errors"
"github.com/google/simhospital/pkg/sample"
)
const (
// maxSignificantDigits is the maximum number of decimal digits allowed in the
// 'percentage_of_patients' field in pathways.
maxSignificantDigits = 3
// defaultPercentage ... | pkg/pathway/distribution_manager.go | 0.689096 | 0.403067 | distribution_manager.go | starcoder |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"math"
"math/rand"
"os"
"sort"
"strconv"
"time"
)
type Point struct {
x, y int
}
type Edge struct {
from, to int
}
type LineSegment struct {
from, to Point
}
type PosePoint struct {
fixed bool
point Point
}
type PointAndIndex struct {
i... | markproto/markproto.go | 0.678007 | 0.405508 | markproto.go | starcoder |
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use these files except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed unde... | tablemap.go | 0.597725 | 0.418845 | tablemap.go | starcoder |
package src
import (
"strings"
"strconv"
)
/** Defines the matrix struct */
type Matrix struct{
M int; // defines number of rows (dimension in R^M)
N int; // defines number of cols (dimension in R^N)
rows [][]float64;
cols [][]float64;
}
func NewMatrix(values [][]float64) (*Matrix, string) {... | src/Matrix.go | 0.601008 | 0.570391 | Matrix.go | starcoder |
package dht22
import (
"math"
"math/rand"
)
// CalcHeatIndex calculates the heat index based on temp and humidity.
func CalcHeatIndex(tempC float64, humidity float64) *float64 {
// Based on a code from the https://github.com/chrissnell/gopherwx project.
// Thanks to https://github.com/chrissnell
temp := tempCto... | internal/dht22/utility.go | 0.655997 | 0.423339 | utility.go | starcoder |
package packed
// Efficient sequential read/write of packed integers.
type BulkOperationPacked3 struct {
*BulkOperationPacked
}
func newBulkOperationPacked3() BulkOperation {
return &BulkOperationPacked3{newBulkOperationPacked(3)}
}
func (op *BulkOperationPacked3) decodeLongToInt(blocks []int64, values []int3... | vendor/github.com/balzaczyy/golucene/core/util/packed/bulkOperation3.go | 0.538741 | 0.764716 | bulkOperation3.go | starcoder |
package bubblebabble
import "strconv"
// The table of Babble vowels.
var vow = []byte("aeiouy")
// The table of Babble consonants.
var con = []byte("bcdfghklmnprstvzx")
// updateChecksum calculates a new Babble checksum value based on the next two
// bytes of input data.
func updateChecksum(c, data1, data2 byte) by... | babble.go | 0.737347 | 0.413418 | babble.go | starcoder |
package jaeger
import (
"fmt"
"github.com/uber/jaeger/model"
"github.com/uber/jaeger/thrift-gen/jaeger"
)
// FromDomain takes an arrya of model.Span and returns
// an array of jaeger.Span. If errors are found during
// conversion of tags, then error tags are appended.
func FromDomain(spans []*model.Span) []*jae... | model/converter/thrift/jaeger/from_domain.go | 0.620622 | 0.53692 | from_domain.go | starcoder |
package tablebook
// Table represents a single table with columnNames and rows
type Table struct {
name string
columnNames []string
rows [][]interface{}
}
// EvaluatedColumn represents a function that can be evaluated dynamically
// when exporting to a predefined format.
type EvaluatedColumn func(tab... | table.go | 0.838283 | 0.512815 | table.go | starcoder |
package series
import (
"fmt"
"math"
"strconv"
"strings"
)
type stringElement struct {
e string
nan bool
}
// force stringElement struct to implement Element interface
var _ Element = (*stringElement)(nil)
func (e *stringElement) Set(value interface{}) {
e.nan = false
switch val := value.(type) {
case st... | series/type-string.go | 0.601477 | 0.463323 | type-string.go | starcoder |
package charlatan
import (
"errors"
"fmt"
)
// operand is an operand, can be evaluated and have to return a constant.
// Returns a error, if the evaluation is not possible
type operand interface {
Evaluate(Record) (*Const, error)
String() string
}
var _ operand = Const{}
var _ operand = &Field{}
// comparison i... | plugins/data/parser/ql/charlatan/operand.go | 0.811974 | 0.487978 | operand.go | starcoder |
package wapsnmp
import (
"encoding/hex"
"net"
"testing"
"time"
)
// Internal structure to take care of responses.
type expectAndRespond struct {
expect string
respond []string
}
/* A udpStub is a UDP stubbing tool.
You test UDP programs by using
NewUdpStub().Expect("aabbcc").andReturn([]string("dde... | udp_stub_connection.go | 0.752468 | 0.426023 | udp_stub_connection.go | starcoder |
package accounting
import (
"context"
"sync"
"github.com/rclone/rclone/fs/rc"
"github.com/rclone/rclone/fs"
)
const globalStats = "global_stats"
var groups *statsGroups
func init() {
// Init stats container
groups = newStatsGroups()
// Set the function pointer up in fs
fs.CountError = GlobalStats().Error... | fs/accounting/stats_groups.go | 0.763836 | 0.671901 | stats_groups.go | starcoder |
package stream
import (
"golang.org/x/exp/constraints"
"golang.org/x/exp/slices"
)
// SliceOrderedStream Generics constraints based on constraints.Ordered
type SliceOrderedStream[E constraints.Ordered] struct {
SliceComparableStream[E]
}
// NewSliceByOrdered new stream instance, generics constraints based on cons... | slice_ordered.go | 0.874961 | 0.405566 | slice_ordered.go | starcoder |
package proto
import (
"encoding/binary"
"io"
"unsafe"
)
// EncodeTag encodes a pair of field number and wire type into a protobuf tag.
func EncodeTag(f FieldNumber, t WireType) uint64 {
return uint64(f)<<3 | uint64(t)
}
// EncodeZigZag returns v as a zig-zag encoded value.
func EncodeZigZag(v int64) uint64 {
r... | proto/encode.go | 0.719088 | 0.501221 | encode.go | starcoder |
package common
// A driver is able to talk to HyperV and perform certain
// operations with it. Some of the operations on here may seem overly
// specific, but they were built specifically in mind to handle features
// of the HyperV builder for Packer, and to abstract differences in
// versions out of the builder step... | vendor/github.com/hashicorp/packer/builder/hyperv/common/driver.go | 0.717804 | 0.476884 | driver.go | starcoder |
package iso20022
// Parameters applied to the settlement of a security transfer.
type DeliverInformation8 struct {
// Total amount of money paid /to be paid or received in exchange for the financial instrument in the individual order.
SettlementAmount *ActiveCurrencyAndAmount `xml:"SttlmAmt,omitempty"`
// Indicat... | DeliverInformation8.go | 0.747339 | 0.422326 | DeliverInformation8.go | starcoder |
package main
import (
"math/rand"
"time"
"fmt"
)
func random_sequence(minimum, maximum int) []int { //returns a shuffled array
array := make([]int, 0)
for i := minimum; i < maximum; i++ { //create array and append numbers to it
array = append(array, i)
}
rand.Seed(time.Now().UnixNano())
rand.Shuffle(len(ar... | quick-sort/quick-sort.go | 0.657428 | 0.456591 | quick-sort.go | starcoder |
package examples
// ImmutableAppleSizer defines an interface for sizing methods on Apple collections.
type ImmutableAppleSizer interface {
// IsEmpty tests whether ImmutableAppleCollection is empty.
IsEmpty() bool
// NonEmpty tests whether ImmutableAppleCollection is empty.
NonEmpty() bool
// Size returns the ... | examples/immutable_apple_collection.go | 0.74872 | 0.532364 | immutable_apple_collection.go | starcoder |
package openapi
import (
"encoding/json"
"fmt"
"net/url"
"strings"
"time"
"github.com/twilio/twilio-go/client"
)
// Optional parameters for the method 'CreateComposition'
type CreateCompositionParams struct {
// An array of track names from the same group room to merge into the new composition. Can include ... | rest/video/v1/compositions.go | 0.810666 | 0.517205 | compositions.go | starcoder |
package main
import (
"bufio"
"bytes"
"errors"
"fmt"
"io"
"log"
"os"
"strconv"
)
const (
// Black is a dark Pixel.
Black = 0
// White is a bright Pixel.
White = 1
// Trans is a transparent Pixel.
Trans = 2
)
// Pixel are the basic elements of a Layer.
type Pixel uint8
// Layer of the Space Image Forma... | day08/main.go | 0.703651 | 0.426799 | main.go | starcoder |
package strmatcher
import (
"regexp"
)
// Matcher is the interface to determine a string matches a pattern.
type Matcher interface {
// Match returns true if the given string matches a predefined pattern.
Match(string) bool
}
// Type is the type of the matcher.
type Type byte
const (
// Full is the type of matc... | common/strmatcher/strmatcher.go | 0.824321 | 0.509581 | strmatcher.go | starcoder |
// Buffered reading and decoding of DWARF data streams.
package dwarf
import (
"encoding/binary"
"strconv"
)
// Data buffer being decoded.
type buf struct {
dwarf *Data
order binary.ByteOrder
format dataFormat
name string
off Offset
data []byte
err error
}
// Data format, other than byte order... | src/debug/dwarf/buf.go | 0.603231 | 0.476458 | buf.go | starcoder |
package eaopt
import (
"math/rand"
)
// Type specific mutations for slices
// MutNormalFloat64 modifies a float64 gene if a coin toss is under a defined
// mutation rate. The new gene value is a random value sampled from a normal
// distribution centered on the gene's current value and with a standard
// deviation ... | mutation.go | 0.758511 | 0.549943 | mutation.go | starcoder |
package datadog
import (
"encoding/json"
"fmt"
)
// SyntheticsAPIStep The steps used in a Synthetics multistep API test.
type SyntheticsAPIStep struct {
// Determines whether or not to continue with test if this step fails.
AllowFailure *bool `json:"allowFailure,omitempty"`
// Array of assertions used for the t... | api/v1/datadog/model_synthetics_api_step.go | 0.740268 | 0.406685 | model_synthetics_api_step.go | starcoder |
package dasel
import (
"fmt"
"reflect"
)
// Query uses the given selector to query the current node and return the result.
func (n *Node) Query(selector string) (*Node, error) {
n.Selector.Remaining = selector
rootNode := n
if err := buildFindChain(rootNode); err != nil {
return nil, err
}
return lastNode(... | node_query.go | 0.80525 | 0.464051 | node_query.go | starcoder |
package iso20022
// Parameters applied to the settlement of a security transfer.
type ReceiveInformation14 struct {
// Date and time at which the securities are to be exchanged at the International Central Securities Depository (ICSD) or Central Securities Depository (CSD).
RequestedSettlementDate *ISODate `xml:"Re... | ReceiveInformation14.go | 0.778649 | 0.486819 | ReceiveInformation14.go | starcoder |
package fffb
// Params parameterizes feedforward (FF) and feedback (FB) inhibition (FFFB)
// based on average (or maximum) netinput (FF) and activation (FB)
type Params struct {
On bool `desc:"enable this level of inhibition"`
Gi float32 `min:"0" def:"1.8" desc:"[1.5-2.3 typical, can go lower or highe... | fffb/fffb.go | 0.774583 | 0.656961 | fffb.go | starcoder |
package gonum
import "github.com/gopherd/gonum/blas"
// Dlagtm performs one of the matrix-matrix operations
// C = alpha * A * B + beta * C if trans == blas.NoTrans
// C = alpha * Aᵀ * B + beta * C if trans == blas.Trans or blas.ConjTrans
// where A is an m×m tridiagonal matrix represented by its diagonals dl, ... | lapack/gonum/dlagtm.go | 0.584271 | 0.413951 | dlagtm.go | starcoder |
package coord
import (
"math"
"strconv"
"strings"
)
func Direction(location_0 string, location string, angle float64) (direct string) {
//以正北为y正方向,以正东为x正方向
longitude_0_x, latitude_0_y := LocationStringToFloat(location_0)
longitude_x, latitude_y := LocationStringToFloat(location)
y_0_latitude, x_0_longitude :=... | tools/coord/direction.go | 0.503662 | 0.509032 | direction.go | starcoder |
package plaid
import (
"encoding/json"
)
// Holding A securities holding at an institution.
type Holding struct {
// The Plaid `account_id` associated with the holding.
AccountId string `json:"account_id"`
// The Plaid `security_id` associated with the holding.
SecurityId string `json:"security_id"`
// The las... | plaid/model_holding.go | 0.847306 | 0.509337 | model_holding.go | starcoder |
package zset
import (
"math/rand"
"sync"
)
const zSkiplistMaxlevel = 32
type (
skipListLevel struct {
forward *skipListNode
span uint64
}
skipListNode struct {
key string
score float64
backward *skipListNode
level []*skipListLevel
}
obj struct {
key string
attachment inte... | zset.go | 0.508056 | 0.408159 | zset.go | starcoder |
package crypto
import (
"github.com/smallstep/cli/command"
"github.com/smallstep/cli/command/crypto/hash"
"github.com/smallstep/cli/command/crypto/jose"
"github.com/smallstep/cli/command/crypto/jwe"
"github.com/smallstep/cli/command/crypto/jwk"
"github.com/smallstep/cli/command/crypto/jws"
"github.com/smallstep... | command/crypto/crypto.go | 0.772101 | 0.418281 | crypto.go | starcoder |
package stdlib
import (
"fmt"
"github.com/vida-lang/vida/vida"
)
// GFunctionFromFloatToFloat wraps a Go function type func(float64)float64
func GFunctionFromFloatToFloat(functionName string, fn func(float64) float64) vida.GFunction {
return vida.GFunction{Name: functionName, Value: func(args ...vida.Value) (vida... | stdlib/wrappers.go | 0.611382 | 0.572305 | wrappers.go | starcoder |
package p5
import (
"gioui.org/f32"
"gioui.org/op"
"gioui.org/op/clip"
"gioui.org/op/paint"
)
func (p *Proc) BeginPath() *Path {
pp := &Path{proc: p}
return pp
}
type Path struct {
proc *Proc
funcs []func(p *clip.Path)
vtx int
}
func (p *Path) pt(x, y float64) f32.Point {
return p.proc.pt(x, y)
}
fun... | path.go | 0.660939 | 0.511046 | path.go | starcoder |
package virustotal
import (
"context"
"crypto/sha256"
"fmt"
"io"
"os"
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 tableVirusTotalFile(ctx context... | virustotal/table_virustotal_file.go | 0.573678 | 0.431165 | table_virustotal_file.go | starcoder |
package di
// Context represents a dependency injection container.
// A Context has a scope and may have a parent with a wider scope
// and children with a narrower scope.
// Objects can be retrieved from the Context.
// If the desired object does not already exist in the Context,
// it is built thanks to the object D... | contextInterface.go | 0.697712 | 0.506042 | contextInterface.go | starcoder |
package filter
// LabelMatch is used to filter objects with labels
type LabelMatch interface {
Match(map[string]string) bool
EmptyOrMatch(map[string]string) bool
}
// LabelMatchEq checks if the value of a label is equal to a value
type LabelMatchEq struct {
Key string
Value string
}
// Match checks the label v... | pkg/client/filter/labels.go | 0.802091 | 0.654136 | labels.go | starcoder |
package solution
/*
leetcode: https://leetcode.com/problems/minimum-genetic-mutation/
*/
/*
We can convert this problem into graph whether each node is a gene string.
For two nodes, they will connect to each other if they are different from each other
by one single character.
We build connected array and then us... | lesson-08/bfs/433-minimum-genetic-mutation/solution.go | 0.791136 | 0.497437 | solution.go | starcoder |
package enry
import (
"math"
"sort"
"github.com/bzz/enry/v2/internal/tokenizer"
)
// classifier is the interface in charge to detect the possible languages of the given content based on a set of
// candidates. Candidates is a map which can be used to assign weights to languages dynamically.
type classifier interf... | classifier.go | 0.779532 | 0.457016 | classifier.go | starcoder |
package eZmaxApi
import (
"encoding/json"
)
// EzsignfolderResponse An Ezsignfolder Object
type EzsignfolderResponse struct {
// The unique ID of the Ezsignfoldertype.
FkiEzsignfoldertypeID int32 `json:"fkiEzsignfoldertypeID"`
// The unique ID of the Ezsigntsarequirement. Determine if a Time Stamping Authority ... | model_ezsignfolder_response.go | 0.690455 | 0.414662 | model_ezsignfolder_response.go | starcoder |
package twistededwards
import (
"math/big"
"github.com/consensys/gnark-crypto/ecc"
"github.com/consensys/gnark/frontend"
)
// Point point on a twisted Edwards curve in a Snark cs
type Point struct {
X, Y frontend.Variable
}
// MustBeOnCurve checks if a point is on the reduced twisted Edwards curve
// -x^2 + y^2... | std/algebra/twistededwards/point.go | 0.75766 | 0.417865 | point.go | starcoder |
package gcounterfeiter
import (
"fmt"
"github.com/onsi/gomega/types"
"github.com/tjarratt/gcounterfeiter/invocations"
)
type argumentVerifyingMatcher struct {
functionToMatch string
baseMatcher types.GomegaMatcher
argMatchers []types.GomegaMatcher
expected invocations.Recorder
wasNotInvoked ... | vendor/github.com/tjarratt/gcounterfeiter/argument_verifying.go | 0.691185 | 0.426859 | argument_verifying.go | starcoder |
// Package descrypt provides low-level access to DES crypt functions.
package descrypt
import (
"github.com/sergeymakinen/go-crypt/internal/hashutil"
)
// permute816 returns the permutation of the given 64-bit code with
// the specified 8x16 permutation table.
func permute816(c uint64, p [8][16]uint64) uint64 {
va... | des/descrypt/des.go | 0.763836 | 0.481637 | des.go | starcoder |
package conduct
import (
"github.com/cpmech/gosl/chk"
"github.com/cpmech/gosl/fun"
"github.com/cpmech/gosl/fun/dbf"
)
// M1 implements the liquid-gas conductivity model # 1
type M1 struct {
// parameters for liquid
λ0l float64
λ1l float64
αl float64
βl float64
// parameters for gas
λ0g float64
λ1g flo... | mdl/conduct/m1.go | 0.66061 | 0.446495 | m1.go | starcoder |
package logged
import (
"strconv"
"sync"
"time"
"unsafe"
)
// pool is a pool of Buffers.
type pool struct {
p *sync.Pool
}
// newPool creates a new instance of pool.
func newPool(size int) pool {
return pool{p: &sync.Pool{
New: func() interface{} {
return &buffer{b: make([]byte, 0, size)}
},
}}
}
// G... | buffer.go | 0.811041 | 0.427098 | buffer.go | starcoder |
package utils
import (
"bytes"
"fmt"
"math"
"reflect"
"strconv"
)
var floatType = reflect.TypeOf(float64(0))
var stringType = reflect.TypeOf("")
func GetFloat(unk interface{}) (float64, error) {
switch i := unk.(type) {
case float64:
return i, nil
case float32:
return float64(i), nil
case int64:
retur... | utils/utils.go | 0.558809 | 0.432303 | utils.go | starcoder |
package continuous
import (
"github.com/jtejido/ggsl/specfunc"
"github.com/jtejido/stats"
"github.com/jtejido/stats/err"
"math"
"math/rand"
)
// Generalized Beta of the first kind
// https://en.wikipedia.org/wiki/Generalized_beta_distribution#Generalized_beta_of_the_first_kind_(GB1)
type GB1 struct {
baseContin... | dist/continuous/generalized_beta_first_kind.go | 0.776411 | 0.438244 | generalized_beta_first_kind.go | starcoder |
package runner
import (
"context"
"fmt"
"io"
"os"
"time"
"djinn-ci.com/errors"
)
var (
errStageNotFound = errors.New("stage could not be found")
errTimedOut = errors.New("timed out")
errRunFailed = errors.New("run failed")
createTimeout = time.Duration(time.Minute * 5)
contextStatuses = map[er... | runner/runner.go | 0.525125 | 0.413655 | runner.go | starcoder |
package openapi
import (
"encoding/json"
"fmt"
"net/url"
"strings"
"github.com/NellybettIrahola/twilio-go/client"
)
// Optional parameters for the method 'CreateRatePlan'
type CreateRatePlanParams struct {
// Whether SIMs can use GPRS/3G/4G/LTE data connectivity.
DataEnabled *bool `json:"DataEnabled,omitemp... | rest/wireless/v1/rate_plans.go | 0.726523 | 0.573081 | rate_plans.go | starcoder |
package uinput
import (
"fmt"
"io"
"os"
"syscall"
)
// A Mouse is a device that will trigger an absolute change event.
// For details see: https://www.kernel.org/doc/Documentation/input/event-codes.txt
type Mouse interface {
// MoveLeft will move the mouse cursor left by the given number of pixel.
MoveLeft(pixe... | mouse.go | 0.70416 | 0.414425 | mouse.go | starcoder |
// Package providing PALS dynamic programming alignment routines.
package dp
import (
"github.com/biogo/biogo/align/pals/filter"
"github.com/biogo/biogo/seq/linear"
"errors"
"sort"
"sync"
)
// A Params holds dynamic programming alignment parameters.
type Params struct {
MinHitLength int
MinId float64
... | align/pals/dp/align.go | 0.672654 | 0.403949 | align.go | starcoder |
package data
import (
"time"
"github.com/cjburchell/reefstatus/server/history/model"
"github.com/pkg/errors"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
type mongoData struct {
session *mgo.Session
db *mgo.Database
}
func (m *mongoData) setup(address string) error {
session, err := mgo.Dial(address)
i... | server/history/data/mongo.go | 0.513425 | 0.40751 | mongo.go | starcoder |
package dfl
import (
"github.com/pkg/errors"
)
// And is a BinaryOperator which represents the logical boolean AND operation of left and right values.
type And struct {
*BinaryOperator
}
func (a And) Dfl(quotes []string, pretty bool, tabs int) string {
return a.BinaryOperator.Dfl("and", quotes, pretty, tabs)
}
... | pkg/dfl/And.go | 0.845688 | 0.493409 | And.go | starcoder |
package set
import (
"bytes"
"github.com/marcsantiago/collections"
)
type Set map[collections.Data]struct{}
// New creates an initialized set
func New() Set {
return make(Set)
}
// Add adds a unique item to the set
func (s Set) Add(data collections.Data) {
s[data] = struct{}{}
}
// Clear removes all elements ... | set/set.go | 0.772531 | 0.404566 | set.go | starcoder |
package zero_one_knapsack
import (
"math"
"sort"
)
/*
the defination of the solution tree are as follows.
use the Len Less Swap to satisfy the sort interface.
use the SearchTree to find the nodeid'x' in TreeNodeSlice.
*/
type TreeNode struct {
nodeid uint64
visited bool
}
type TreeNodeSlice []TreeNode
fun... | backtracking.go | 0.513668 | 0.44348 | backtracking.go | starcoder |
package crackingthecodinginterview
// Graph Graph data struct
type Graph struct {
nodeLookup map[int]*GraphNode
}
// GraphNode a Graph node
type GraphNode struct {
ID int
Value int
Childs []*GraphNode
}
// MakeGraph makes a new Graph
func MakeGraph() *Graph {
return &Graph{
nodeLookup: make(map[int]*Grap... | internal/crackingthecodinginterview/graph.go | 0.721351 | 0.499756 | graph.go | starcoder |
package commission
import (
"fmt"
"sort"
"go.polydawn.net/go-timeless-api"
)
/*
Compute a simple topological sort of the steps based on the wire imports.
We break ties based on lexigraphical sort on the step names.
We choose this simple tie-breaker rather than attempting any fancier
logic based on e.g. downs... | commission/order.go | 0.528533 | 0.549459 | order.go | starcoder |
package typed
import (
"reflect"
"sigs.k8s.io/structured-merge-diff/fieldpath"
"sigs.k8s.io/structured-merge-diff/value"
)
// deducedTypedValue holds a value and guesses what it is and what to
// do with it.
type deducedTypedValue struct {
value value.Value
}
// AsTypedDeduced is going to generate it's own type... | vendor/sigs.k8s.io/structured-merge-diff/typed/deduced.go | 0.645679 | 0.403802 | deduced.go | starcoder |
package canopen
type DicRecord struct {
Description string
Index uint16
Name string
SDOClient *SDOClient
SubIndexes map[uint8]DicObject
SubNames map[string]uint8
}
// GetIndex of DicRecord
func (record *DicRecord) GetIndex() uint16 {
return record.Index
}
// GetSubIndex not applicable
func (r... | dic_record.go | 0.635562 | 0.407333 | dic_record.go | starcoder |
package models
import (
"github.com/aspose-tasks-cloud/aspose-tasks-cloud-go/api/custom"
)
// Represents the details of a recurring task in a project.
type RecurringInfo struct {
// Represents a recurrence pattern of the recurring task. Can be one of the values of enum.
RecurrencePattern *RecurrencePattern `json:... | api/models/recurring_info.go | 0.826537 | 0.46642 | recurring_info.go | starcoder |
package gorm
import (
"fmt"
"strings"
"github.com/infobloxopen/atlas-app-toolkit/op"
)
// FilterStringToGorm is a shortcut to parse a filter string using default FilteringParser implementation
// and call FilteringToGorm on the returned filtering expression.
func FilterStringToGorm(filter string) (string, []inter... | op/gorm/filtering.go | 0.680029 | 0.531939 | filtering.go | starcoder |
package conv
// Int8ToBytes is the fastest way to convert int8 into byte slice
func Int8ToBytes(n int8, buf *[4]byte) []byte {
if 0 == n {
return digits1[0]
}
return i8Dig(n, buf)
}
// Int16ToBytes is the fastest way to convert int16 into byte slice
func Int16ToBytes(n int16, buf *[6]byte) []byte {
if 0 == n {
... | conv/int.go | 0.653016 | 0.548553 | int.go | starcoder |
package pattern
import (
"fmt"
"math"
)
// SquaresMosaic generator pattern.
func (p Pattern) SquaresMosaic() {
size := p.reMap(p.seedToInt(0, 1), 0, 15, 15, 50)
// fill the canvas with shapes
columns := math.Ceil(float64(p.Width) / size)
size = float64(p.Width) / columns
cols := int(columns)
rows := int(floa... | geopattern/pattern/squares_mosaic.go | 0.635562 | 0.568895 | squares_mosaic.go | starcoder |
package main
import (
"fmt"
"math"
"time"
)
func main() {
renderer := NewRenderer(60, 20)
camera := NewCamera(50, 1, 0.1, 100)
camera.Pos = Vector{0, 0, -10}
camera.Rot = LookAt(Vector{}, camera.Pos, Vector{0, 1, 0})
ca := NewCube(5)
ca.Pos = Vector{5, 0, 0}
cb := NewCube(3)
cb.Pos = Vector{-5, 0, 0}
s... | 3d/renderer.go | 0.739986 | 0.574634 | renderer.go | starcoder |
package processor
import (
"fmt"
"time"
"github.com/Jeffail/benthos/lib/log"
"github.com/Jeffail/benthos/lib/metrics"
"github.com/Jeffail/benthos/lib/types"
"github.com/Jeffail/benthos/lib/util/text"
)
//------------------------------------------------------------------------------
func init() {
Constructor... | lib/processor/log.go | 0.809427 | 0.753739 | log.go | starcoder |
package pawf
import "math"
func pacificAtlantic(matrix [][]int) [][]int {
return dfs(matrix)
}
// dfs time complexity O(MN), space complexity O(MN)
func dfs(matrix [][]int) [][]int {
var res [][]int
m := len(matrix)
if m < 1 {
return res
}
n := len(matrix[0])
if n < 1 {
re... | 417_pacific_atlantic_water_flow/pawf.go | 0.702224 | 0.411879 | pawf.go | starcoder |
package evolution
import (
"fmt"
"math"
)
const (
FitnessAbsolute = "FitnessAbsolute"
FitnessThresholdedAntagonistRatio = "FitnessThresholdedAntagonistRatio"
FitnessProtagonistThresholdTally = "FitnessProtagonistThresholdTally"
FitnessRatio = "FitnessRatio"
FitnessMonoTh... | evolution/fitness.go | 0.526099 | 0.587115 | fitness.go | starcoder |
package tester
import (
"errors"
"time"
)
// DataPoint represents a sample of data.
type DataPoint struct {
Time time.Time
Value float64
}
// Metric provides a function to get data points of this metric.
type Metric interface {
// Setup is used to setup the metric before the test
Setup(options interface{}) er... | tester/metric.go | 0.86388 | 0.436322 | metric.go | starcoder |
package main
import "fmt"
type Point struct {
X int
Y int
}
func onTheSameLine(p1, p2, p3 Point) bool {
v1 := Point{
X: p2.X - p1.X,
Y: p2.Y - p1.Y,
}
v2 := Point{
X: p3.X - p1.X,
Y: p3.Y - p1.Y,
}
return (int64(v1.X)*int64(v2.Y) - int64(v2.X)*int64(v1.Y)) == 0
}
func maxPoints(points []Point) int {... | leetcode/max-points-on-a-line/solution.go | 0.542863 | 0.460168 | solution.go | starcoder |
package bcgo
import "fmt"
// ErrBlockHashIncorrect is returned when the given hash does not match the hash of the given block.
type ErrBlockHashIncorrect struct {
}
func (e ErrBlockHashIncorrect) Error() string {
return "Hash doesn't match block hash"
}
// ErrChainInvalid is returned when a block fails validation ... | errors.go | 0.853745 | 0.436142 | errors.go | starcoder |
package secp256k1go
import (
"encoding/hex"
"fmt"
"math/big"
)
var (
// BigInt1 represents big int with value 1
BigInt1 = new(big.Int).SetInt64(1)
)
// Number wraps the big.Int
type Number struct {
big.Int
}
// Print prints the label with hex number string
func (num *Number) Print(label string) {
fmt.Println... | src/cipher/secp256k1-go/secp256k1-go2/num.go | 0.593845 | 0.437343 | num.go | starcoder |
package message
import (
"bytes"
"math/big"
"strings"
"github.com/dusk-network/dusk-blockchain/pkg/core/consensus/header"
"github.com/dusk-network/dusk-blockchain/pkg/core/data/block"
"github.com/dusk-network/dusk-blockchain/pkg/core/data/ipc/blindbid"
"github.com/dusk-network/dusk-blockchain/pkg/p2p/wire/enc... | pkg/p2p/wire/message/score.go | 0.708818 | 0.404449 | score.go | starcoder |
package common
import (
"fmt"
"github.com/mikeyhu/glipso/interfaces"
)
// P (PAIR)
type P struct {
head interfaces.Value
tail interfaces.Iterable
}
// IsType for P
func (p P) IsType() {}
// IsValue for P
func (p P) IsValue() {}
// String representation of P
func (p P) String() string {
return fmt.Sprintf("P(%... | common/iterable.go | 0.773901 | 0.406626 | iterable.go | starcoder |
package schema
import mapset "github.com/deckarep/golang-set"
import "encoding/json"
// SchemaGraph represent the graph of a source
type SchemaGraph struct {
Vertices mapset.Set
Edges mapset.Set
}
// SchemaGraphJSON is the json representation of a schema graph
type SchemaGraphJSON struct {
Vertices []AssetTyp... | internal/schema/graph.go | 0.74158 | 0.457803 | graph.go | starcoder |
package toxiproxy
import (
"bytes"
"encoding/json"
"fmt"
"io"
"strings"
"sync"
"github.com/Shopify/toxiproxy/v2/stream"
"github.com/Shopify/toxiproxy/v2/toxics"
)
// ToxicCollection contains a list of toxics that are chained together. Each proxy
// has its own collection. A hidden noop toxic is always mainta... | toxic_collection.go | 0.574992 | 0.421195 | toxic_collection.go | starcoder |
package stringcque
// SimpleStringCircularQueue is a simple circular buffer of strings
type SimpleStringCircularQueue struct {
stringSlice []string
capacity int
indexOfLastElementAfterWrapAround int
indexInSliceForNextInsert int
indexOfLastSliceElement ... | simple_string_circular_queue.go | 0.721253 | 0.444685 | simple_string_circular_queue.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.