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 search_query_injection
import (
"github.com/threagile/threagile/model"
)
func Category() model.RiskCategory {
return model.RiskCategory{
Id: "search-query-injection",
Title: "Search-Query Injection",
Description: "Quando um servidor de mecanismo de pesquisa é acessado, os riscos de injeção de consu... | risks/built-in/search-query-injection/search-query-injection-rule.go | 0.573559 | 0.469703 | search-query-injection-rule.go | starcoder |
package hyperneat
import (
"sort"
"github.com/klokare/evo"
"github.com/klokare/evo/neat"
)
// Constants for the output index
const (
Weight int = iota
Bias
LEO
)
// Seeder creates the seed population geared towards Cppns. Each encoded substrate will have 8
// inputs, one for each dimension of the source and t... | hyperneat/seeder.go | 0.651466 | 0.561636 | seeder.go | starcoder |
package main
type MinHeap struct {
items []int64
}
func (m *MinHeap) GetLeftChildIndex(parentIndex int64) int64 {
return 2*parentIndex + 1
}
func (m *MinHeap) GetRightChildIndex(parentIndex int64) int64 {
return 2*parentIndex + 2
}
func (m *MinHeap) HasLeftChild(index int64) bool {
return m.GetLeftChildInde... | ed/ad/tree/_minHeap.go | 0.548432 | 0.460956 | _minHeap.go | starcoder |
package trivyscanner
import (
"math"
"github.com/aquasecurity/trivy-db/pkg/types"
"github.com/klustair/cvssv3"
log "github.com/sirupsen/logrus"
cvssv2 "github.com/umisama/go-cvss"
)
type Cvss struct {
V2 struct {
Vector string `json:"vector"`
Vendor string `json:"vendor"`
Scores struct {
Base ... | pkg/trivyscanner/cvss.go | 0.590779 | 0.461927 | cvss.go | starcoder |
// Package descriptions provides the descriptions as used by the graphql endpoint for Weaviate
package descriptions
// Local
const (
LocalFetch = "Fetch Beacons that are similar to a specified concept from the Objects subsets on a Weaviate network"
LocalFetchObj = "An object used to perform a Fuzzy Fetch to sear... | adapters/handlers/graphql/descriptions/fetch.go | 0.716219 | 0.729881 | fetch.go | starcoder |
package copypasta
import (
. "fmt"
"math/bits"
)
/*
标准库 "math/bits" 包含了位运算常用的函数,如二进制中 1 的个数、二进制表示的长度等
注意:bits.Len(0) 返回的是 0 而不是 1
bits.Len(x) 相当于 int(Log2(x)+eps)+1
或者说 2^(Len(x)-1) <= x < 2^Len(x)
TIPS: & 和 | 在区间求和上具有单调性;^ 的区间求和见 strings.go 中的 trie.maxXor
** 代码和题目见下面的 bitOpTrick 和 bitOpTrickCnt
常用等式(若改... | copypasta/bits.go | 0.582135 | 0.582135 | bits.go | starcoder |
package container
import (
"log"
"reflect"
)
// CreateInvocable - Binding should be a struct or function
func CreateInvocable(bindingType reflect.Type) *Invocable {
isInvoc, invocableType := isInvocable(bindingType)
if !isInvoc {
log.Printf("type passed to CreateInvocable (%s) is not an invocable type(function ... | invocable.go | 0.614047 | 0.509032 | invocable.go | starcoder |
package datastructure
import (
"errors"
"fmt"
"reflect"
)
// CircularQueue implements circular queue with slice,
// last index of CircularQueue don't contain value, so acturl capacity is size - 1
type CircularQueue[T any] struct {
data []T
front int
rear int
size int
}
// NewCircularQueue return a empty Ci... | datastructure/queue/circularqueue.go | 0.704668 | 0.474388 | circularqueue.go | starcoder |
package emacs
import (
"fmt"
"math"
"time"
)
// #include "wrappers.h"
import "C"
// Time is a type with underlying type time.Time that knows how to convert
// itself from and to an Emacs time value.
type Time time.Time
// String formats the time as a string. It calls time.Time.String.
func (t Time) String() st... | time.go | 0.835249 | 0.541409 | time.go | starcoder |
package goalgorithms
func hoarePartition(a []int, left, right int) int {
p := a[left+(right-left)/2]
i := left
j := right - 1
for {
for a[i] < p {
i++
}
for a[j] > p {
j--
}
if i >= j {
return j
}
a[i], a[j] = a[j], a[i]
}
}
func quickSortHoare(a []int, left, right int) {
if right-left... | sort/quick.go | 0.790813 | 0.642334 | quick.go | starcoder |
package main
import (
"fmt"
"strconv"
"github.com/jung-kurt/gofpdf"
)
func main() {
// Change papersize to letter because 'Murica is special!
pdf := gofpdf.New(gofpdf.OrientationPortrait, gofpdf.UnitPoint, gofpdf.PageSizeLetter, "")
// Get page size. It depends on the unit defined in New.
w, h := pdf.GetPag... | gophercises/20-pdf/learn-gofpdf/main.go | 0.607081 | 0.407333 | main.go | starcoder |
package sequence_flow
import (
"fmt"
"bpxe.org/pkg/bpmn"
"bpxe.org/pkg/errors"
)
type SequenceFlow struct {
*bpmn.SequenceFlow
definitions *bpmn.Definitions
}
func Make(sequenceFlow *bpmn.SequenceFlow, definitions *bpmn.Definitions) SequenceFlow {
return SequenceFlow{
SequenceFlow: sequenceFlow,
definiti... | pkg/sequence_flow/sequence_flow.go | 0.548674 | 0.494385 | sequence_flow.go | starcoder |
package did
import (
"fmt"
"strings"
"github.com/di-wu/parser/ast"
)
// Argument describes the argument types of a Field.
type Argument struct {
// Name only serves documentation purposes and have no semantic significance.
Name *string
// Data is the data type of the argument.
Data Data
}
func convertArgumen... | did/func.go | 0.708717 | 0.414306 | func.go | starcoder |
package builds
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
buildapi "github.com/openshift/origin/pkg/build/api"
exutil "github.com/openshift/origin/test/extended/util"
eximages "github.com/openshift/origin/test/extended/images"
)
var _ = Describe("default: Check S2I and Docker build i... | test/extended/builds/labels.go | 0.53048 | 0.416559 | labels.go | starcoder |
package main
import (
"fmt"
"strings"
"github.com/zyedidia/micro/cmd/micro/optionprovider"
"github.com/zyedidia/tcell"
)
// OptionProvider is the signature of a function which returns all of the available options, potentially using the prefix
// data. For example, given input "abc\nab", start offset 4 and end of... | cmd/micro/completer.go | 0.681197 | 0.473475 | completer.go | starcoder |
package ds
// Heap vs Binary tree:
// - Heap is implemented as a array so no memory overhead. For each node in the binary tree two pointers are allocated.
// - **Average** insertion in heap is O(1) comparing to O(logn).
// - Heap only supports min operation and is simpler than binary tree.
// - Heap is easier to imple... | ds/heap.go | 0.793026 | 0.465873 | heap.go | starcoder |
package gen
import (
pschema "github.com/pulumi/pulumi/pkg/v3/codegen/schema"
v1 "k8s.io/api/core/v1"
)
var serviceSpec = pschema.ComplexTypeSpec{
ObjectTypeSpec: pschema.ObjectTypeSpec{
Properties: map[string]pschema.PropertySpec{
"type": {
TypeSpec: pschema.TypeSpec{
OneOf: []pschema.TypeSpec{
... | provider/pkg/gen/overlays.go | 0.50952 | 0.417331 | overlays.go | starcoder |
package grid
import (
"math/rand"
"time"
)
// dense is a corridor only skirmish grid. It is a Prim's maze where the
// dead-ends have been eliminated. Additionally each side of the grid is
// guaranteed to have one exit to the level exterior.
type dense struct {
grid // superclass grid.
}
// Generate a maze usi... | interfaces/vu/src/grid/dense.go | 0.613584 | 0.54359 | dense.go | starcoder |
package abcsort
import "sort"
// Sorter provides functionality to easily sort slices using a custom alphabet.
// A sorter is safe for concurrent use.
type Sorter struct {
// Alphabet is the custom alphabet
Alphabet string
// Weights is used for "normal" sorting.
Weights map[rune]int
// WeightsFold is used for f... | sorter.go | 0.776411 | 0.446857 | sorter.go | starcoder |
package interpolation ; import ( "math" ; "github.com/sjbog/math_tools" )
/* HIROSHI AKIMA "A method of smooth curve fitting" 1969
Summary
This method is based on a piecewise function composed of a set of polynomials, each of degree three, at most, and applicable to successive intervals of the given points.
Meth... | interpolation/akima.go | 0.565539 | 0.837487 | akima.go | starcoder |
package header
/**
* The Expires header field gives the relative time after which the message
* (or content) expires. The precise meaning of this is method dependent.
* The expiration time in an INVITE does not affect the duration of the
* actual session that may result from the invitation. Session descriptio... | sip/header/ExpiresHeader.go | 0.875215 | 0.534612 | ExpiresHeader.go | starcoder |
package tensor3
// methods with a matrix parameter can come with 'T' prefixed version, meaning the result is post transposed, or a "T" suffix meaning the parameter is transposed before the operation. adding transpose(s) is a no extra cost operation.
func (m *Matrix) TProduct(m2 Matrix) {
m[0].x, m[1].x, m[2].x, m[0]... | scaledint/matT.go | 0.500488 | 0.618924 | matT.go | starcoder |
package kafka
var metricsData = []byte(`{
"metrics": {
"lowercaseOutputName": true,
"rules": [
{
"labels": {
"clientId": "$3",
"partition": "$5",
"topic": "$4"
},
"name": "kafka_server_$1_$2",
"pattern": "kafka.server<t... | controllers/cloud.redhat.com/providers/kafka/metrics.go | 0.5 | 0.413122 | metrics.go | starcoder |
package timex
import (
"time"
)
const SimpleTime = "2006-01-02 15:04:05"
const SimpleTimeMills = "2006-01-02 15:04:05.000"
const SimpleDate = "2006-01-02"
// OfEpochMills convert unix epoch mills to time
func OfEpochMills(millis int64) time.Time {
return time.Unix(0, millis*int64(time.Millisecond))
}
// OfEpochSe... | timex/time_utils.go | 0.82308 | 0.540681 | time_utils.go | starcoder |
package c
const MOD = 1000000007
func modAdd(a, b int) int {
a += b
if a >= MOD {
a -= MOD
}
if a < 0 {
a += MOD
}
return a
}
func numsGame(nums []int) []int {
n := len(nums)
res := make([]int, n)
var root *Node
var sum int
for i := 0; i < n; i++ {
x := nums[i] - i
sum = sum + x
root = Insert(ro... | src/leetcode/contest/season2020/fall2/c/solution.go | 0.630799 | 0.419053 | solution.go | starcoder |
package graphhopper
import (
"io/ioutil"
"net/http"
"net/url"
"strings"
"golang.org/x/net/context"
"encoding/json"
)
// Linger please
var (
_ context.Context
)
type MatrixApiService service
/* MatrixApiService Matrix API
The Matrix API is part of the GraphHopper Directions API and with this API you can calcu... | go/api_matrix.go | 0.668772 | 0.512571 | api_matrix.go | starcoder |
package asciilines
import (
"os"
"fmt"
"io/ioutil"
"strings"
"errors"
"strconv"
)
// Since we are restricted to Ascii, 2-D array of bytes is sufficient
type AsciiLines [][]byte
func LoadTVG(filename string) (*AsciiLines, error) {
// Declare a single static object to work with
var stat... | asciilines/asciilines.go | 0.779196 | 0.400398 | asciilines.go | starcoder |
package wasmer
import (
"fmt"
"math"
)
// ValueType represents the `Value` type.
type ValueType int
const (
// TypeI32 represents the WebAssembly `i32` type.
TypeI32 ValueType = iota
// TypeI64 represents the WebAssembly `i64` type.
TypeI64
// TypeF32 represents the WebAssembly `f32` type.
TypeF32
// Typ... | vendor/github.com/wasmerio/go-ext-wasm/wasmer/value.go | 0.821116 | 0.479382 | value.go | starcoder |
package sqe
import (
"bytes"
"context"
"fmt"
"io"
"strings"
)
// MaxRecursionDeepness is the limit we impose on the number of direct ORs expression.
// It's possible to have more than that, just not in a single successive sequence or `1 or 2 or 3 ...`.
// This is to avoid first a speed problem where parsing star... | sqe/parser.go | 0.779616 | 0.536677 | parser.go | starcoder |
package main
import (
"fmt"
)
type Matrix struct {
matrix [][]Fraction
rows int
cols int
}
// Matrix constructor to initialize a matrix of slices (vectors)
func newMatrix(rows, cols int) Matrix {
var m Matrix
m.matrix = make([][]Fraction, rows)
m.rows = rows
m.cols = cols
// Initialize each row with `... | matrix.go | 0.763924 | 0.527742 | matrix.go | starcoder |
package common
import (
"fmt"
"strconv"
"strings"
)
type rang struct {
from int
to int
}
func (r *rang) IsIntersect(o *rang) bool {
l := r
u := o
if l.from > u.from {
l = o
u = r
}
return l.to >= u.from
}
type Quantum struct {
ranges []*rang
}
func NewQuantum() *Quantum {
return &Quantum{make([... | quantum.go | 0.548915 | 0.47725 | quantum.go | starcoder |
package elem
const DistanceThreshhold = 3
var (
closed []Coordinate
other []Coordinate
closedElementMap = make(map[Coordinate][5]int)
)
func findClosedLand(n Coordinate) {
var distancesGold = make([]float64, len(gold))
var distancesWood = make([]float64, len(wood))
var distancesLake = mak... | elem/closed.go | 0.542136 | 0.430327 | closed.go | starcoder |
package hole
import (
"math/rand"
"strconv"
"strings"
)
// a bounding box (bbox) is defined in
// terms of its top-left vertex coordinates
// (x, y) and its width and height (w, h).
type bbox struct{ x, y, w, h int }
// couldn't find a quick way to loop a struct
func strconvbox(box bbox) (out string) {
var outs ... | hole/intersection.go | 0.612541 | 0.482551 | intersection.go | starcoder |
package ch2
import (
"flag"
"fmt"
"strconv"
"log"
"io"
"os"
)
// CToF converts a Celsius temperature to Fahrenheit.
func CToF(c Celsius) Fahrenheit { return Fahrenheit(c*9/5 + 32) }
// FToC converts a Fahrenheit temperature to Celsius.
func FToC(f Fahrenheit) Celsius { return Celsius((f - 32) * 5 / 9) }
// CT... | ch2/conv.go | 0.567098 | 0.459622 | conv.go | starcoder |
package f64
import (
"math"
"github.com/colinrgodsey/cartesius/f64/filters"
)
// Grid2D creates a 2D grid-based interpolator using the provided filter.
// The Z axis of a sample is the value that will be interpolated.
func Grid2D(samples []Vec3, filter filters.GridFilter) (Function2D, error) {
stride, offs, max, ... | f64/grid.go | 0.780537 | 0.554772 | grid.go | starcoder |
package svg
import (
"github.com/goki/gi/gi"
"github.com/goki/ki/ki"
"github.com/goki/ki/kit"
"github.com/goki/mat32"
)
// Ellipse is a SVG ellipse
type Ellipse struct {
NodeBase
Pos mat32.Vec2 `xml:"{cx,cy}" desc:"position of the center of the ellipse"`
Radii mat32.Vec2 `xml:"{rx,ry}" desc:"radii of the el... | svg/ellipse.go | 0.81571 | 0.429968 | ellipse.go | starcoder |
package glm
import (
"fmt"
"math"
)
// VarianceType is used to specify a GLM variance function.
type VarianceType uint8
// BinomialVar, ... define variance functions for a GLM.
const (
BinomialVar VarianceType = iota
IdentityVar
ConstantVar
SquaredVar
CubedVar
)
// NewVariance returns a new variance function... | glm/varfuncs.go | 0.820218 | 0.542742 | varfuncs.go | starcoder |
package stats
import (
"sync"
"time"
"k8s.io/klog"
)
var (
// GlobalStats is a map that stores the duration of each stats.
GlobalStats map[Type]time.Duration
// CountStats is a map that stores the count of each stats.
CountStats map[Type]int
mutex *sync.RWMutex
)
// Type represents differnet statistics th... | pkg/stats/stats.go | 0.578448 | 0.436142 | stats.go | starcoder |
package linear
import (
"math"
)
type ArrayRealVector struct {
data []float64
}
/**
* Construct a vector of zeroes.
*
* @param size Size of the vector.
*/
func NewSizedArrayRealVector(size int) (*ArrayRealVector, error) {
return &ArrayRealVector{data: make([]float64, size)}, nil
}
/**
* Construct a... | array_real_vector.go | 0.903705 | 0.72431 | array_real_vector.go | starcoder |
package aws
import (
"testing"
"github.com/gruntwork-io/terratest/modules/ssh"
)
// FetchContentsOfFileFromInstance looks up the public IP address of the EC2 Instance with the given ID, connects to
// the Instance via SSH using the given username and Key Pair, fetches the contents of the file at the given path
// ... | modules/aws/ec2-files.go | 0.543106 | 0.413951 | ec2-files.go | starcoder |
package num
import (
"errors"
"fmt"
"math"
"strings"
)
const (
kiB float64 = 1024
miB float64 = kiB * 1024
giB float64 = miB * 1024
)
/*
Bytes takes n representing a number of bytes and produces
a human-friendly string that chooses the most compact form
possible. If there is a fractional unit it will be repre... | num/num.go | 0.544317 | 0.534552 | num.go | starcoder |
package assert
import (
"testing"
)
type Assertor struct {
t *testing.T
}
func New(t *testing.T) Assertor {
if t == nil {
panic("`t` could not be nil")
}
return Assertor{t}
}
func (assertor Assertor) AssertThatInt(got int) Integer {
return Integer{got: int64(got), t: assertor.t}
}
func (assertor Assertor) ... | common/assert/assert.go | 0.656768 | 0.750278 | assert.go | starcoder |
package testcomponent
import (
"context"
"encoding/json"
componenttest "github.com/ONSdigital/dp-component-test"
mongoDriver "github.com/ONSdigital/dp-mongodb/v3/mongodb"
"github.com/cucumber/godog"
"github.com/stretchr/testify/assert"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/prim... | testcomponent/steps.go | 0.541651 | 0.404155 | steps.go | starcoder |
package main
//returns true if white pawn can attack the specified square
func whitePawnAttack(sourceRow int, sourceCol int, targetRow int, targetCol int) bool {
if sourceRow-1 == targetRow && sourceCol-1 == targetCol { //capture top left
return true
} else if sourceRow-1 == targetRow && sourceCol+1 == targetCol {... | attack.go | 0.676513 | 0.478346 | attack.go | starcoder |
package ast
// Unify returns a set of variables that will be unified when the equality expression defined by
// terms a and b is evaluated. The unifier assumes that variables in the VarSet safe are already
// unified.
func Unify(safe VarSet, a *Term, b *Term) VarSet {
u := &unifier{
safe: safe,
unified: VarSe... | ast/unify.go | 0.648466 | 0.451871 | unify.go | starcoder |
package de
import "github.com/ContextLogic/cldr"
var calendar = cldr.Calendar{
Formats: cldr.CalendarFormats{
Date: cldr.CalendarDateFormat{Full: "EEEE, d. MMMM y", Long: "d. MMMM y", Medium: "dd.MM.y", Short: "dd.MM.yy"},
Time: cldr.CalendarDateFormat{Full: "HH:mm:ss zzzz", Long: "HH:mm:ss z", Medium: "... | resources/locales/de/calendar.go | 0.506347 | 0.440349 | calendar.go | starcoder |
package assimp
//#cgo windows LDFLAGS: -lassimp
//#cgo linux freebsd darwin openbsd pkg-config: assimp
//#include <assimp/types.h>
import "C"
type Plane C.struct_aiPlane
type Ray C.struct_aiRay
type Color3 C.struct_aiColor3D
type Return C.enum_aiReturn
const (
Return_Success Return = C.aiReturn_SUCCESS
Return... | Types.go | 0.687525 | 0.41941 | Types.go | starcoder |
package query
import (
"context"
"encoding/binary"
"io"
"github.com/gogo/protobuf/proto"
internal "github.com/influxdata/influxdb/query/internal"
)
// FloatPoint represents a point with a float64 value.
// DO NOT ADD ADDITIONAL FIELDS TO THIS STRUCT.
// See TestPoint_Fields in influxql/point_test.go for more d... | vendor/github.com/influxdata/influxdb/query/point.gen.go | 0.819352 | 0.48182 | point.gen.go | starcoder |
package picker
import (
"math"
"math/rand"
"github.com/chronos-tachyon/roxy/lib/syncrand"
)
// Picker is a utility class for picking values from a list using weighted
// random selection. The weight is based on a user-defined score function,
// where low scores are exponentially more favorable than high scores.
... | internal/picker/picker.go | 0.814459 | 0.611817 | picker.go | starcoder |
package wire
import (
"github.com/soteria-dag/soterd/chaincfg/chainhash"
"io"
)
const (
// maxParents is the maximum number of parents that a ParentSubHeader can contain
maxParents = 8
// ParentSize is the size in bytes of a parent
ParentSize = chainhash.HashSize + 32
ParentVersionSize = 4
ParentCountSize... | wire/parentsubheader.go | 0.684053 | 0.410756 | parentsubheader.go | starcoder |
package common
import (
"bytes"
"database/sql/driver"
"encoding/hex"
"fmt"
"math/big"
ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/harmony-one/harmony/internal/bech32"
"github.com/harmony-one/harmony/internal/utils"
"github.com/pkg/errors"
... | internal/common/address.go | 0.708414 | 0.423637 | address.go | starcoder |
package kol
import (
"golang.org/x/exp/maps"
)
// Set is an un-ordered collection of elements without duplicate elements.
type Set[E comparable] interface {
Collection[E]
}
type set[E comparable] struct {
m map[E]struct{}
}
func NewSet[E comparable](elements ...E) Set[E] {
m := make(map[E]struct{}, 0)
for _, e... | set.go | 0.656658 | 0.4165 | set.go | starcoder |
// player keeps track of all player-specific variables, as well as some basic logic functions to support more complex table logic
package player
import (
"hearts/logic/card"
)
// Returns a player instance with playerIndex equal to index
func NewPlayer(index int) *Player {
return &Player{
hand: nil,
tri... | go/src/hearts/logic/player/player.go | 0.715126 | 0.432183 | player.go | starcoder |
package ovsdb
import (
"encoding/json"
"fmt"
"reflect"
)
type ConditionFunction string
const (
// ConditionLessThan is the less than condition
ConditionLessThan ConditionFunction = "<"
// ConditionLessThanOrEqual is the less than or equal condition
ConditionLessThanOrEqual ConditionFunction = "<="
// Conditi... | go-controller/vendor/github.com/ovn-org/libovsdb/ovsdb/condition.go | 0.631481 | 0.45302 | condition.go | starcoder |
package iso20022
// Describes the type of product and the assets to be transferred.
type ISATransfer19 struct {
// Information identifying the primary individual investor, for example, name, address, social security number and date of birth.
PrimaryIndividualInvestor *IndividualPerson8 `xml:"PmryIndvInvstr,omitempt... | ISATransfer19.go | 0.718298 | 0.45302 | ISATransfer19.go | starcoder |
package zfs
type DatasetPathForest struct {
roots []*datasetPathTree
}
func NewDatasetPathForest() *DatasetPathForest {
return &DatasetPathForest{
make([]*datasetPathTree, 0),
}
}
func (f *DatasetPathForest) Add(p *DatasetPath) {
if len(p.comps) <= 0 {
panic("dataset path too short. must have length > 0")
}... | zfs/datasetpath_visitor.go | 0.630002 | 0.513485 | datasetpath_visitor.go | starcoder |
package strdist
import (
"fmt"
"sort"
)
// CaseMod represents the different behaviours with regards to case
// handling when measuring distances
type CaseMod int
const (
// NoCaseChange indicates that the case should not be changed
NoCaseChange CaseMod = iota
// ForceToLower indicates that the case should be fo... | strdist/finder.go | 0.738009 | 0.52275 | finder.go | starcoder |
package cli
const helpText = `
fns - a command line utility for managing serverless functions.
https://www.github.com/gbdubs/fns
Commands (* indicates not yet implemented)
* create_project creates a new collection of functions in a new folder
* create_fn creates a new function within a project
* deploy_project... | trash/help.go | 0.595375 | 0.634232 | help.go | starcoder |
package plaid
import (
"encoding/json"
)
// WalletTransactionAmount The amount and currency of a transaction
type WalletTransactionAmount struct {
// The ISO-4217 currency code of the transaction. Currently, only `\"GBP\"` is supported.
IsoCurrencyCode string `json:"iso_currency_code"`
// The amount of the trans... | plaid/model_wallet_transaction_amount.go | 0.784897 | 0.487246 | model_wallet_transaction_amount.go | starcoder |
package ovsdb
import (
"encoding/json"
"fmt"
"reflect"
)
// OvsMap is the JSON map structure used for OVSDB
// RFC 7047 uses the following notation for map as JSON doesnt support non-string keys for maps.
// A 2-element JSON array that represents a database map value. The
// first element of the array must be the... | go-controller/vendor/github.com/ovn-org/libovsdb/ovsdb/map.go | 0.595257 | 0.430447 | map.go | starcoder |
package collector
import (
"fmt"
"github.com/Tinkerforge/go-api-bindings/air_quality_bricklet"
"github.com/Tinkerforge/go-api-bindings/barometer_bricklet"
"github.com/Tinkerforge/go-api-bindings/barometer_v2_bricklet"
"github.com/Tinkerforge/go-api-bindings/humidity_bricklet"
"github.com/Tinkerforge/go-api-bind... | collector/bricklets.go | 0.599016 | 0.460895 | bricklets.go | starcoder |
package types
import (
"github.com/rancher/norman/pkg/types/convert"
)
var (
CondEQ = QueryConditionType{ModifierEQ, 1}
CondNE = QueryConditionType{ModifierNE, 1}
CondNull = QueryConditionType{ModifierNull, 0}
CondNotNull = QueryConditionType{ModifierNotNull, 0}
CondIn = QueryConditionType{Mod... | vendor/github.com/rancher/norman/pkg/types/condition.go | 0.622574 | 0.456713 | condition.go | starcoder |
package goma
import (
"math/rand"
"errors"
"time"
)
type Matrix struct {
Rows, Cols int
Data [][]float64
}
func (m *Matrix) Copy() (*Matrix) {
c := NewMatrix(m.Rows, m.Cols)
for i, _ := range m.Data {
copy(c.Data[i], m.Data[i])
}
return c
}
func NewMatrix(row... | goma.go | 0.793466 | 0.663049 | goma.go | starcoder |
package geojson
import (
"github.com/tidwall/tile38/pkg/geojson/geohash"
"github.com/tidwall/tile38/pkg/geojson/poly"
)
// MultiLineString is a geojson object with the type "MultiLineString"
type MultiLineString struct {
Coordinates [][]Position
BBox *BBox
bboxDefined bool
}
func fillMultiLineString(coor... | pkg/geojson/multilinestring.go | 0.727685 | 0.415432 | multilinestring.go | starcoder |
package openapi
import (
"encoding/json"
"fmt"
"net/url"
"strings"
)
// Optional parameters for the method 'CreateNotification'
type CreateNotificationParams struct {
// The actions to display for the notification. For APNS, translates to the `aps.category` value. For GCM, translates to the `data.twi_action` v... | rest/notify/v1/services_notifications.go | 0.797557 | 0.410697 | services_notifications.go | starcoder |
package geom
import "math"
// A Bounds represents a multi-dimensional bounding box.
type Bounds struct {
layout Layout
min Coord
max Coord
}
// NewBounds creates a new Bounds.
func NewBounds(layout Layout) *Bounds {
stride := layout.Stride()
min, max := make(Coord, stride), make(Coord, stride)
for i := 0... | vendor/github.com/twpayne/go-geom/bounds.go | 0.876145 | 0.437223 | bounds.go | starcoder |
package alphafoxtrot
type Airport struct {
ICAOCode string
Type string
Name string
LatitudeDeg float64
LongitudeDeg float64
ElevationFt int64
Continent string
Municipality string
ScheduledService bool
GPSCode string
IATACode string
L... | airport.go | 0.549399 | 0.466116 | airport.go | starcoder |
package main
import (
"fmt"
"math"
)
// Circle description
type Circle struct {
radius float64
}
// Rectangle description
type Rectangle struct {
width float64
height float64
}
// Triangle description
type Triangle struct {
a float64
b float64
c float64
}
// Cylinder description
type Cylinder struct {
ra... | software/development/languages/go-cheat-sheet/src/function-method-interface-package-example/method/method.go | 0.786582 | 0.451206 | method.go | starcoder |
package gstream
type Stream[T any] struct {
*sCtx[T]
}
func NewStream[T any](list []T) *Stream[T] {
return newStreamWithCtx(&sCtx[T]{values: list, loop: ST_SEQUENTIAL})
}
func newStreamWithCtx[T any](ctx *sCtx[T]) *Stream[T] {
return &Stream[T]{sCtx: ctx}
}
func Pass[T any](value T) T {
return value
}
func Map... | stream.go | 0.575111 | 0.419826 | stream.go | starcoder |
package xorfilter
import (
"math"
)
// Xor32 holds an xorfilter with approximately 32 bits per element and about one in a billion false positives.
type Xor32 struct {
XorFilterCommon
Fingerprints []uint32
}
// Populate32 creates an xor filter with approx 32 bits per element.
func Populate32(keys []uint64) (*Xor32... | xor32.go | 0.660939 | 0.503479 | xor32.go | starcoder |
package rstrie
import (
"bytes"
"github.com/PatrickCronin/routesum/pkg/routesum/bitslice"
)
// RSTrie is a radix-like trie of radix 2 whose stored "words" are the binary representations of networks and IPs. An
// optimization rstrie makes over a generic radix tree is that since routes covered by other routes don't... | pkg/routesum/rstrie/rstrie.go | 0.697506 | 0.496399 | rstrie.go | starcoder |
package wkt
import (
"fmt"
"reflect"
"strings"
"github.com/go-spatial/geom"
)
func isNil(a interface{}) bool {
defer func() { recover() }()
return a == nil || reflect.ValueOf(a).IsNil()
}
func isMultiLineStringerEmpty(ml geom.MultiLineStringer) bool {
if isNil(ml) || len(ml.LineStrings()) == 0 {
return tru... | encoding/wkt/wkt.go | 0.579638 | 0.40987 | wkt.go | starcoder |
package packetcache
import (
"math/bits"
"sync"
)
// The maximum size of packets stored in the cache. Chosen to be
// a multiple of 8.
const BufSize = 1504
// The maximum number of packets that constitute a keyframe.
const maxFrame = 1024
// entry represents a cached packet.
type entry struct {
seqno ... | packetcache/packetcache.go | 0.711531 | 0.425963 | packetcache.go | starcoder |
package operator
import (
"github.com/matrixorigin/matrixone/pkg/container/nulls"
"github.com/matrixorigin/matrixone/pkg/container/types"
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/encoding"
"github.com/matrixorigin/matrixone/pkg/vectorize/mul"
"github.com/ma... | pkg/sql/plan2/function/operator/mult.go | 0.563498 | 0.44342 | mult.go | starcoder |
package infinitescroll
// Checkbox represents the state of the select all checkbox
type Checkbox int
const (
// Checked is when the select all box is selected.
Checked Checkbox = iota
// Unchecked is when the select all box is deselected.
Unchecked
// Indeterminate is when the select all box is greyed out.
Inde... | infinitescroll/problem.go | 0.639173 | 0.470676 | problem.go | starcoder |
package stats
import (
"math"
"math/rand"
)
// NormalDist is a normal (Gaussian) distribution with mean Mu and
// standard deviation Sigma.
type NormalDist struct {
Mu, Sigma float64
}
// StdNormal is the standard normal distribution (Mu = 0, Sigma = 1)
var StdNormal = NormalDist{0, 1}
// 1/sqrt(2 * pi)
const i... | stats/normaldist.go | 0.761538 | 0.600803 | normaldist.go | starcoder |
package converter
import (
"encoding/json"
"fmt"
"strconv"
"strings"
)
type argInt []int
func (a argInt) Get(i int, args ...int) (r int) {
if i >= 0 && i < len(a) {
r = a[i]
} else if len(args) > 0 {
r = args[0]
}
return
}
// ToStr Convert any type to string.
func ToStr(value interface{}, ar... | generators/app/templates/pkg/converter/toString.go | 0.538012 | 0.440229 | toString.go | starcoder |
package common
import (
"time"
)
// LerpPosition handles vector lerp interpolations
type LerpPosition struct {
start time.Time
startPosition *Vector
duration time.Duration
endPosition *Vector
endFunc func()
isEndFuncSet bool
isDestroyed bool
isEnabled bool
}
// Lerp returns a pos... | common/lerp_position.go | 0.664649 | 0.427277 | lerp_position.go | starcoder |
package roast
import (
"fmt"
"reflect"
"strings"
"github.com/kamasamikon/miego/xmap"
"github.com/kamasamikon/miego/xtime"
"github.com/jinzhu/gorm"
)
type tabler interface {
TableName() string
}
type UpdateInfo struct {
Table string
SetArgs xmap.Map
WhereArgs xmap.Map
Err error
}
func SafeRe... | roast/saveoperation.go | 0.505127 | 0.409162 | saveoperation.go | starcoder |
package hijri
import (
"time"
dec "github.com/shopspring/decimal"
)
func dateToJD(date time.Time) float64 {
// Convert to UTC
date = date.UTC()
// Prepare variables for calculating
Y := int64(date.Year())
M := int64(date.Month())
D := int64(date.Day())
H := int64(date.Hour())
m := int64(date.Minute())
s ... | julian-days.go | 0.591487 | 0.403391 | julian-days.go | starcoder |
package main
import (
"bufio"
"fmt"
"math"
"os"
"sort"
)
type Asteroid struct {
x int
y int
angles map[float64]*Asteroid
}
const RADIAN_TO_DEGREE = 180 / math.Pi
func main() {
detectionTestN(1, 3, 4, 8)
detectionTestN(2, 5, 8, 33)
detectionTestN(3, 1, 2, 35)
detectionTestN(4, 6, 3, 41)
detect... | 2019/10/monitoringStation.go | 0.61878 | 0.448668 | monitoringStation.go | starcoder |
package table
import (
"fmt"
"io"
"sort"
"strings"
)
type (
// Table represents a table of data to be rendered.
Table struct {
Columns []Column
Data []Row
Sort []int
ColumnSpacing string
}
// Row is a single row of data in a table.
Row = []string
// Column represents metada... | cli/table/table.go | 0.71721 | 0.435001 | table.go | starcoder |
package base
import (
"fmt"
)
// Fitness is a measure of quality of a solution.
// Define Fitness A greater than B means A better than B, A less than B means A worse than B
type Fitness struct {
weights []float64
wvalues []float64
values []float64
valid bool
}
// NewFitness returns a fitness value using weig... | base/fitness.go | 0.825238 | 0.746578 | fitness.go | starcoder |
package commands
import (
"crypto/elliptic"
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"foil/cryptospecials"
"hash"
"math/big"
"github.com/spf13/cobra"
)
func init() {
oprfCmd.PersistentFlags().BoolVarP(&mask, "mask", "", false, "mask a string using the ECC-OPRF")
oprfCmd.PersistentFlags().BoolVarP(&s... | commands/oprf.go | 0.604049 | 0.407687 | oprf.go | starcoder |
package main
// These all were copy-pasted from xgraphics because newDrawable() didn't support user-specified geometry
import (
"fmt"
"image"
"github.com/BurntSushi/xgb/xproto"
"github.com/BurntSushi/xgbutil"
"github.com/BurntSushi/xgbutil/xgraphics"
"github.com/BurntSushi/xgbutil/xrect"
"github.com/BurntSush... | cmd/workrecorder/x11misery.go | 0.692226 | 0.472136 | x11misery.go | starcoder |
package tuple
import "math"
// Tuple is a structure to hold the X,Y,Z co-ordinates and a flag indicating if this is a vector or point.
type Tuple struct {
X float64
Y float64
Z float64
W float64
}
// Color is a structure to hold red green and blue values for a pixel.
type Color struct {
Red float64
Green ... | tuple/tuple.go | 0.943099 | 0.794425 | tuple.go | starcoder |
Coding Exercise #1
Create a function called cube() that takes a parameter of type float64 and returns the cube of that parameter (the parameter to the power of 3).
Are you stuck? Do you want to see the solution for this exercise? Click https://play.golang.org/p/4UMwXWkYDyy.
Coding Exercise #2
Create a Go program w... | more_code/coding_tasks/functions/main.go | 0.853134 | 0.843057 | main.go | starcoder |
package stardust
import (
"errors"
"math"
"strings"
"github.com/miku/stardust/set"
)
// Version of the application
const Version = "0.1.1"
// CompleteString returns all strings from pool that have a given prefix
func CompleteString(pool []string, prefix string) []string {
var candidates []string
for _, value ... | common.go | 0.776453 | 0.456894 | common.go | starcoder |
package iso20022
// Parameters applied to the settlement of a security.
type FundSettlementParameters4 struct {
// Date and time at which the securities are to be delivered or received.
SettlementDate *ISODate `xml:"SttlmDt,omitempty"`
// Place where the settlement of transaction will take place. In the context o... | FundSettlementParameters4.go | 0.786664 | 0.534916 | FundSettlementParameters4.go | starcoder |
package paillier
import (
"crypto/rand"
"errors"
"io"
"math/big"
)
var one = big.NewInt(1)
// ErrMessageTooLong is returned when attempting to encrypt a message which is
// too large for the size of the public key.
var ErrMessageTooLong = errors.New("paillier: message too long for Paillier public key size")
// ... | paillier.go | 0.690872 | 0.446133 | paillier.go | starcoder |
package vec3
import (
"fmt"
"github.com/scritch007/gm/math32"
)
type Vec3 [3]float32
func New(x, y, z float32) *Vec3 {
return &Vec3{x, y, z}
}
// Clone initializes a new Vec3 initialized with values from an existing one.
func (lhs *Vec3) Clone() *Vec3 {
return &Vec3{lhs[0], lhs[1], lhs[2]}
}
// Cross calculate... | vec3/vec3.go | 0.887558 | 0.447279 | vec3.go | starcoder |
package jwt
import (
"bytes"
"crypto"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/pem"
"errors"
"fmt"
"time"
)
/*
When validating a JWT, the following steps are performed. The order
of the steps is not significant in cases where there are no
dependencies between the inp... | validate.go | 0.642881 | 0.542984 | validate.go | starcoder |
package staticarray
import (
"github.com/influxdata/flux/array"
"github.com/influxdata/flux/memory"
"github.com/influxdata/flux/semantic"
)
type strings struct {
data []string
alloc *memory.Allocator
}
func String(data []string) array.String {
return &strings{data: data}
}
func (a *strings) Type() semantic.T... | internal/staticarray/string.go | 0.624752 | 0.460774 | string.go | starcoder |
package rbtree
// This file contains all RB tree search methods implementations
// Search searches value specified within search tree
func (tree *rbTree) Search(value Comparable) (Comparable, bool) {
n, ok := tree.SearchNode(value)
if !ok {
return nil, ok
}
return n.key, ok
}
func (tree *rbTree) Floor(value Co... | rbtree/search.go | 0.784526 | 0.410166 | search.go | starcoder |
package metric
import (
"fmt"
"github.com/codahale/hdrhistogram"
"strconv"
"sync/atomic"
"time"
)
type Histogram struct {
name string
pName string
histo *hdrhistogram.WindowedHistogram
overflowCount int64
}
type histogramExport struct {
Min float64
P50 float64
P95 fl... | instrumentation/metric/histogram.go | 0.770983 | 0.428114 | histogram.go | starcoder |
package ns
/**
* Configuration for variable resource.
*/
type Nsvariable struct {
/**
* Variable name. This follows the same syntax rules as other expression entity names:
It must begin with an alpha character (A-Z or a-z) or an underscore (_).
The rest of the characters must be alpha, numeric (0-9) or undersco... | resource/config/ns/nsvariable.go | 0.77081 | 0.557062 | nsvariable.go | starcoder |
package opt
// This file implements conversion of scalar expressions to tree.TypedExpr
import (
"fmt"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
)
var typedExprConvMap [numOperators]func(c *typedExprConvCtx, e *Expr) tree.TypedExpr
func init() {
// This code is not inline to avoid an initialization lo... | pkg/sql/opt/typed_expr.go | 0.78287 | 0.622086 | typed_expr.go | starcoder |
package pc
import (
"github.com/cadmean-ru/amphion/common/a"
"github.com/cadmean-ru/amphion/engine"
"github.com/cadmean-ru/amphion/rendering"
"github.com/go-gl/gl/v4.1-core/gl"
)
type TriangleRenderer struct {
*glPrimitiveRenderer
}
func (r *TriangleRenderer) OnStart() {
r.program = NewGlProgram(ShapeVertexSh... | frontend/pc/triangle.go | 0.564459 | 0.470372 | triangle.go | starcoder |
package geometry
import (
"math"
"github.com/gonum/matrix/mat64"
)
// TransMat is the Transformation Matrix representation.
type TransMat struct {
mat64.Dense
}
// NewTransMat creates a new Transformation Matrix which an 4x4 Idendity.
func NewTransMat() *TransMat {
data := []float64{
1, 0, 0, 0,
0, 1, 0, 0,... | matrix3.go | 0.814533 | 0.638765 | matrix3.go | starcoder |
package toscalib
// RequirementRelationshipType defines the Relationship type of a Requirement Definition
type RequirementRelationshipType struct {
Type string `yaml:"type" json:"type"`
Interfaces map[string]InterfaceDefinition `yaml:"interfaces,omitempty" json:"interfaces"`
}
// Unmar... | requirements.go | 0.837653 | 0.485417 | requirements.go | starcoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.