text stringlengths 11 4.05M |
|---|
package uploadcard
import (
"archive/zip"
"bytes"
"encoding/base64"
"fmt"
"io/ioutil"
"net/http"
"path/filepath"
"text/template"
"github.com/HanYu1983/gomod/lib/db2"
tool "github.com/HanYu1983/gomod/lib/tool"
"google.golang.org/appengine"
)
func Serve_ParseResult(w http.ResponseWriter, r *http.Request) {... |
package freee
import (
"fmt"
"net/url"
)
func SetCompanyID(v *url.Values, companyID uint32) {
v.Set("company_id", fmt.Sprintf("%d", companyID))
}
|
/**
* Copyright (c) 2018-present, MultiVAC Foundation.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package consensus
import (
"github.com/stretchr/testify/assert"
"math/rand"
"testing"
"github.com/multivactech/MultiVAC/mode... |
package main
import (
"fmt"
)
func twoSum(nums []int, target int) []int {
var ans []int
if numsLen := len(nums); numsLen > 0 {
for i := 0; i < numsLen; i++ {
for j := i + 1; j < numsLen; j++ {
if sum := nums[i] + nums[j]; sum == target {
ans = append(ans, i)
ans = append(ans, j)
break
}... |
package main
func main() {
var x int
switch y++; x {
case 1:
}
}
|
package other
import (
"github.com/coredumptoday/practice/linear"
)
func CopyLinkListWithRandPtr(head *linear.NodeJmp) *linear.NodeJmp {
if head == nil || head.Next == nil {
return head
}
cur := head
for cur != nil {
nNode := &linear.NodeJmp{
Value: cur.Value,
Next: cur.Next,
}
cur.Next = nNode
... |
/**
* DEFER
*
* A defer statement pushes a function call onto a list. The list of
* saved calls is executed after the surrounding function returns.
*
* Rules
* 1. A deferred functions arguments are evaluated when the defer statement is evaluated
* 2. Deferred function calls are executed Last In First Out order ... |
package enums
const (
SZ int = 100
SH int = 130
HK int = 160
)
|
package authlete
import (
"fmt"
"testing"
)
func TestParse(t *testing.T) {
cases := []struct {
input string
success bool
want BasicCredentials
}{
{
input: "Basic YWxhZGRpbjpvcGVuc2VzYW1l",
success: true,
want: BasicCredentials{"aladdin", "opensesame"},
},
{
input: "BAsiC YWxhZ... |
package health
import (
"context"
"testing"
"github.com/jrapoport/gothic/test/tsrv"
"github.com/stretchr/testify/assert"
)
func TestHealthServer_HealthCheck(t *testing.T) {
t.Parallel()
s, _ := tsrv.RPCServer(t, false)
srv := newHealthServer(s)
ctx := context.Background()
res, err := srv.HealthCheck(ctx, ni... |
package utils
import (
"fmt"
"os"
"text/tabwriter"
"time"
)
type ProgressPrinter struct {
numWriters int
progressWriters []ProgressWriter
prevProgress []uint64
tw *tabwriter.Writer
linesWritten int
}
func (pp *ProgressPrinter) PrintProgress() {
if pp.linesWritten > 0 {
for i := 0;... |
package concerts
import (
"fmt"
)
func DoWork(){
fmt.Println("Hello Concerts")
} |
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
// See License for license information.
package types
import (
"encoding/json"
"sort"
)
type Value interface {
GetID() ID
}
type Setter interface {
Set(Value)
}
type Getter interface {
Get(Value)
}
type ValueArray interface {
Len() int
Get... |
package eth
import (
commitmenttypes "github.com/bianjieai/tibc-sdk-go/commitment"
tibctypes "github.com/bianjieai/tibc-sdk-go/types"
)
var _ tibctypes.ClientState = (*ClientState)(nil)
func (m ClientState) ClientType() string {
return "009-eth"
}
func (m ClientState) GetLatestHeight() tibctypes.Height {
return... |
/**
* Doubly LinkedList to solve problem. Keeps track of size in a variable and traverses from
* either the head or tail of the list depending position of the given index.
*
*/
package main
import (
"bufio"
"errors"
"fmt"
"os"
"strconv"
"strings"
)
/**
4
10 200 3 40000 5
200
*/
func main() {
reader := bu... |
package game
import "errors"
var (
// ErrNotYourTurn is returned when the wrong player
// attempts to make a move.
ErrNotYourTurn = errors.New("not your turn")
// ErrOutsideBoard is returned when the players
// move is outside the board they are playing on.
ErrOutsideBoard = errors.New("outside board")
// Er... |
package main
import (
"image"
"image/draw"
"sync"
"github.com/driusan/de/demodel"
"github.com/driusan/de/kbmap"
"github.com/driusan/de/renderer"
"github.com/driusan/de/viewer"
"golang.org/x/exp/shiny/screen"
"golang.org/x/mobile/event/size"
)
// dewindow encapsulates the shiny window of de.
type dewindow st... |
package cleanup
import (
"context"
"io/ioutil"
"os"
"path"
"time"
"github.com/ssok8s/ssok8s/pkg/log"
"github.com/ssok8s/ssok8s/pkg/registry"
"github.com/ssok8s/ssok8s/pkg/setting"
)
type CleanUpService struct {
log log.Logger
Cfg *setting.Cfg `inject:""`
}
func init() {
registry.RegisterService(&CleanUpS... |
package main
import (
"bytes"
"fmt"
"net/http"
"os"
"github.com/apex/log"
"github.com/jackmcguire1/UserService/api/healthcheck"
"github.com/jackmcguire1/UserService/api/searchapi"
"github.com/jackmcguire1/UserService/api/userapi"
"github.com/jackmcguire1/UserService/dom/user"
"github.com/jackmcguire1/UserSe... |
package main
import (
"../../internal/handlers"
"../../internal/utils"
)
func main() {
utils.ShowHello()
handlers.ShowMenu()
}
|
package cmd
import (
"fmt"
"os"
)
func CmdPrintln(a ...interface{}) (int, error) {
return fmt.Println(a...)
}
func CmdPrintErrorln(a ...interface{}) (int, error) {
return fmt.Fprintln(os.Stderr, a...)
}
func CmdPrettyPrintln(a ...interface{}) (int, error) {
return fmt.Fprintln(os.Stdout, a...)
}
|
package main
import (
"errors"
"flag"
"fmt"
"io"
"log"
"net"
"strings"
"time"
)
var (
masterAddr *net.TCPAddr
raddr *net.TCPAddr
saddr *net.TCPAddr
localAddr = flag.String("listen", ":9999", "local address")
sentinelAddr = flag.String("sentinel", ":26379", "remote address")
masterName = ... |
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"runtime"
"sync"
)
type HttpHost struct {
Host string
}
func main() {
hosts := []string{"www.baidu.com", "www.sina.com"}
url := "192.168.1.20"
buffer := bytes.NewBufferString("")
fmt.Fprintf(buffer, `func FindProxyForURL(url, host) {`)
for _, hos... |
package main
import (
"bufio"
"flag"
"os"
"strconv"
)
var loading_has_completed = false
var largest_previous_prime = 0
func Generate(out chan<- int) {
i := LoadDataFile(out)
i |= 1
loading_has_completed = true
largest_previous_prime = i
for {
i++
out <- i
}
}
func Filter(in <-chan int, out chan<- in... |
package main
import (
"bufio"
"fmt"
"log"
"os"
)
func abs(a int) int {
if a < 0 {
return -a
}
return a
}
func delta(h1, m1, s1, h2, m2, s2 int) string {
t := abs((h1-h2)*3600 + (m1-m2)*60 + s1 - s2)
return fmt.Sprintf("%02d:%02d:%02d", t/3600, (t/60)%60, t%60)
}
func main() {
var h1, m1, s1, h2, m2, s2 ... |
package sprigmath
import (
"github.com/Masterminds/sprig"
"math"
"strconv"
)
func GenericFuncMap() map[string]interface{} {
funcMap := sprig.GenericFuncMap()
for k, v := range functions {
funcMap[k] = v
}
return funcMap
}
var functions = map[string]interface{}{
// conversions
"atoi": strconv.Atoi,
... |
package dictionary
import (
"testing"
)
//测试Search方法,参数为map和key
func TestSearchDictionary(t *testing.T) {
dictionary := map[string]string{"test": "this is a test"}
got := Search(dictionary, "test")
want := "this is a test"
assertString(t, got, want)
}
//测试Search方法,Search添加Dictionary Type作为Reciever
func TestSear... |
package gobcnbicing
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
// BCNBicing type holds a list of bike stations on the city
type BCNBicing struct {
Stations []struct {
Altitude string `json:"altitude"`
Bikes string `json:"bikes"`
ID string `json:"id"`
Latitude ... |
package command
type Command struct {
Name string
Targets []string
BoolFlags map[string]bool
ValueFlags map[string]string
}
func NewCommand(name string) *Command {
return &Command{
Name: name,
Targets: []string{},
BoolFlags: map[string]bool{},
ValueFlags: map[string]string{},
}
}
fu... |
package github
import (
"context"
"errors"
"fmt"
"net/http"
"os"
"regexp"
"github.com/google/go-github/v31/github"
"golang.org/x/oauth2"
"github.com/weaveworks/go-git-provider/pkg/providers"
)
const (
EnvVarGitHubToken = "GITHUB_TOKEN"
)
var (
sshFull = regexp.MustCompile(`ssh://git@github.com/([^/]+)/(... |
package problem0237
// ListNode is a struct
type ListNode struct {
Val int
Next *ListNode
}
func deleteNode(node *ListNode) {
*node = *node.Next
}
|
package internal
import (
"log"
"os"
client "github.com/influxdata/influxdb1-client/v2"
)
func Connect() client.Client {
username := os.Getenv("DB_USER")
password := os.Getenv("DB_PW")
dbhost := os.Getenv("DB_HOST")
conf := client.HTTPConfig {
Addr: dbhost,
Username... |
package column_test
import (
"context"
"fmt"
"os"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vahid-sohrabloo/chconn/v2"
"github.com/vahid-sohrabloo/chconn/v2/column"
)
func TestString(t *testing.T) {
t.Parallel()
connString := os.Getenv("CHX... |
package Data
type Data struct {
CallId string `json:"callId"`
Location string `json:"location"`
Situation string `json:"situation"`
Name string `json:"name"`
}
func (d Data) UpdateTable() error {
return nil
}
|
package main
import (
"fmt"
"sort"
"strings"
"testing"
)
type team struct {
id int
cs string
}
type teams []team
func (slice teams) Len() int { return len(slice) }
func (slice teams) Less(i, j int) bool { return slice[i].id < slice[j].id }
func (slice teams) Swap(i, j int) { slice[i], slice[j] ... |
package swordoffer
//114. 外星文字典
//现有一种使用英语字母的外星文语言,这门语言的字母顺序与英语顺序不同。
//
//给定一个字符串列表 words ,作为这门语言的词典,words 中的字符串已经 按这门新语言的字母顺序进行了排序 。
//
//请你根据该词典还原出此语言中已知的字母顺序,并 按字母递增顺序 排列。若不存在合法字母顺序,返回 "" 。若存在多种可能的合法字母顺序,返回其中 任意一种 顺序即可。
//
//字符串 s 字典顺序小于 字符串 t 有两种情况:
//
//在第一个不同字母处,如果 s 中的字母在这门外星语言的字母顺序中位于 t 中字母之前,那么s 的字典顺序小于 t 。
/... |
package main
import "fmt"
func main() {
numbers := []int{31, 13, 12, 4, 18, 16, 7, 2, 3, 0, 10}
sortedNums := bubbleSort(numbers)
fmt.Println(sortedNums)
}
func bubbleSort(numbers []int) []int {
swapped := false
for i := 0; i < len(numbers)-1; i++ {
if numbers[i] > numbers[i+1] {
swapped = true
numbers... |
package gormzap
import (
"database/sql/driver"
"io/ioutil"
stdlog "log"
"testing"
"github.com/erikstmartin/go-testdb"
"github.com/jinzhu/gorm"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest"
)
func Benchmark_WithTestDB(b *testing.B) {
// https://github.com/uber-go/zap/blob/35aad584952... |
/*@Author : Manasvini Banavara Suryanarayana
*SJSU ID : 010102040
*CMPE 273 Lab#3
*/
package main
import (
"fmt"
"./httprouter"
"net/http"
"strconv"
"encoding/json"
)
type Response1 struct {
Key int `json:"key"`
Value string `json:"value"`
}
type Response2 struct {
Arr []Response1 `json:"... |
package objs
import (
"sort"
"strconv"
)
type UserState struct {
UserId int `json:"user_id"`
Username string `json:"username"`
Score float64 `json:"score"`
}
func (us *UserState) FromUserData(np UserNameplate, ns UserScore) {
us.Username = np.DisplayName
us.UserId, _ = strconv.Atoi(np.Username)
us.... |
package stack
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"sort"
"strings"
"time"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/compose/convert"
"github.com/docker/cli/cli/compose/loader"
composetypes "github.com/docker/cli/cli/compose/types"
"github.com/docker/docker/api/types"
"git... |
// Copyright 2019 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package e2e
const (
simpleSuccessfulPipeline = `
node() {
sh 'exit 0'
}
`
simpleFailedPipeline = `
node() {
sh 'exit 1'
}
`
pipelineWithEnvs = `
node() {
echo "FOO1 is ${env.FOO1}"
echo "FOO2 is ${env.FOO2}"
}
`
sampl... |
package model
type Dict struct {
ID int `json:"id"`
JpName string `json:"jp_name"`
EngName string `json:"eng_name"`
Body string `json:"body"`
Tags []string `json:"tags"`
}
|
package fmap
import (
"fmt"
)
// Iter struct maintains the current state for walking the *Map data structure.
type Iter struct {
kvIdx int
curLeaf leafI
tblNextNode tableIterFunc
stack *tableIterStack
}
func newIter(root tableI) *Iter {
var it = new(Iter)
//it.kvIdx = 0
//it.curLeaf = nil
it... |
package cmd
import (
"context"
"net/http"
"os"
"os/signal"
"time"
"github.com/allegro/bigcache"
"github.com/dotkom/image-server/api"
gorm_adapter "github.com/dotkom/image-server/storage/gorm"
s3_adapter "github.com/dotkom/image-server/storage/s3"
"github.com/gorilla/mux"
log "github.com/sirupsen/logrus"
"... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
"sort"
"flag"
//"text/tabwriter"
//"phd/polymorphism"
//"github.com/biogo/boom"
)
//Usage: go run formatEST.go focal.species.vcf ancestral1.species.vcf ancestral2.species.vcf all.species.vcf "synonymous" > out.formatted.est
//focal.species.vcf: Th... |
package hasm
import (
"fmt"
"github.com/leonhfr/nand2tetris/src/hasm/symboltable"
)
type CCommand struct {
Dest string `json:"dest"`
Comp string `json:"comp"`
Jump string `json:"jump"`
}
func NewC(dest, comp, jump string) CCommand {
return CCommand{dest, comp, jump}
}
func (c CCommand) Handle(st *symboltable... |
package config
import "github.com/gobuffalo/envy"
type Configuration struct {
DatabaseURL string
}
var config *Configuration
func GetConfig() *Configuration {
if config == nil {
config = &Configuration{
DatabaseURL: envy.Get("DATABASE_URL", "postgres://postgres:@postgres:5432/postgres?sslmode=disable"),
}
... |
package sstats
import "math"
// StdDev computes the streaming standard deviation, sqrt((Σx^2 + n*x̄^2 - 2*x̄*Σx)/n-1)
type StdDev struct {
xx *SumSq
xm *Mean
}
// NewStdDev creates a new standard deviation statistic with a given circular buffer size
func NewStdDev(size int) (*StdDev, error) {
xx, err := NewSumSq(... |
package chartserver
import (
"errors"
"net/url"
)
//Controller is used to handle flows of related requests based on the corresponding handlers
//A reverse proxy will be created and managed to proxy the related traffics between API and
//backend chart server
type Controller struct {
//The access endpoint of the bac... |
package database
import (
"github.com/lotteryjs/ten-minutes-app/model"
"github.com/stretchr/testify/assert"
)
func (s *DatabaseSuite) TestCreateAttackPattern() {
s.db.DB.Collection("mitre_attack").Drop(nil)
killChainPhase := model.KillChainPhase{
KillChainName: "mitre_attack",
PhaseName: "privilege-escal... |
package machineLearning
import (
"math/rand"
"fmt"
)
func Actions()[]func(int) int{
_actions := []func(int) int{
func(x int) int { return x + 1 },
func(x int) int { return 0 },
func(x int) int { return (x / 2) },
func(x int) int { return x * 100 },
func(x int) int { return x % 2 }}
return _actions
}
... |
package mint
//sudo service mongodb start
import (
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
type BudgetDBNoSQL struct {
c *mgo.Collection
}
func NewBudgetDBNoSQL() (*BudgetDBNoSQL, error) {
sess, err := mgo.Dial("localhost")
if err != nil {
return nil, err
}
db := sess.DB("testdb")
c := db.C("... |
package schain
import (
"fmt"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/openrtb_ext"
)
// BidderToPrebidSChains organizes the ORTB 2.5 multiple root schain nodes into a map of schain nodes by bidder
func BidderToPrebidSChains(sChains []*openrtb_ext.ExtRequestPrebidSChain) (map[str... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package login
import (
"context"
"fmt"
"time"
"chromiumos/tast/common/hwsec"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/uiauto/faillog"
"chromiumos... |
package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
g := gin.Default()
g.GET("v1/api/images", func(context *gin.Context) {
context.JSON(http.StatusOK, gin.H{
"images": "docker",
})
})
g.GET("v2/api/dir:path", func(context *gin.Context) {
context.JSON(http.StatusOK, gin.H{
"... |
//dsp video duration directional
package logic
type Duration struct {
Min int
Max int
}
func (d Duration) UnderDuration(duration int) bool {
return (d.Min == 0 || duration >= d.Min) && (d.Max == 0 || duration < d.Max)
}
|
package actions
const (
PerformAction = "action.octant.dev/performAction"
TriggerJob = "action.jenkins-x.io/job"
TriggerBootJob = "action.jenkins-x.io/triggerBootJob"
)
|
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file 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 writi... |
package rocserv
import (
"errors"
"fmt"
"github.com/opentracing-contrib/go-grpc"
"github.com/opentracing/opentracing-go"
"github.com/shawnfeng/sutil/slog"
"github.com/shawnfeng/sutil/stime"
"google.golang.org/grpc"
"sync"
"time"
)
type ServProtocol int
const (
GRPC ServProtocol = iota
THRIFT
HTTP
)
type... |
// Copyright 2021 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agre... |
package main
//invalid
//Case to check if float * int is type cast to int or float or does it give error (error is given)
func main() {
var x int = 6.5 * 7
}
|
package fiber
import (
"net/http"
"github.com/gojek/fiber/errors"
)
type Response interface {
IsSuccess() bool
Payload() []byte
StatusCode() int
BackendName() string
WithBackendName(string) Response
}
type ErrorResponse struct {
*CachedPayload
code int
backend string
}
func (resp *ErrorResponse) IsSuc... |
package main
import "fmt"
func main() {
s0 := []int{1,2,3,4,5,6,78,9}
fmt.Println("sssss",s0)
fmt.Println("sssssff",len(s0[:5]))
fmt.Println("sssssfffffss",s0[:5])
fmt.Println("sssssff",s0[5])
//s1 := make([]int)
s1 := make([]int,5)
copy(s1,s0[:5])
fmt.Println("so",s0)
fmt.Println("s1",s1)
s1 = append(s1... |
/*
* Copyright (c) 2019. ENNOO - All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file 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 o... |
package main
import "fmt"
// Pointers allow you to point to the memory address of a value
func main() {
// b is a pointer to a
a := 5
b := &a
fmt.Println(a, b)
fmt.Printf("%T %T\n", a, b)
// Use * to read val from address
fmt.Println(*b, *&a)
// Change val at a with pointer b
*b = 10
fmt.Println(a)
//... |
package client
import (
"encoding/json"
"fmt"
"net/url"
"os"
"strings"
"github.com/hyperhq/hyper/engine"
gflag "github.com/jessevdk/go-flags"
)
/*
-a, --author= Author (e.g., "Hello World <hello@a-team.com>")
-c, --change=[] Apply Dockerfile instruction to the created image
--help=false P... |
package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
)
func maxRangeSum(n int, q string) (r int) {
t := strings.Fields(q)
var c int
u := make([]int, len(t))
for ix, i := range t {
fmt.Sscan(i, &u[ix])
}
for i := 0; i < n; i++ {
c += u[i]
}
if c > r {
r = c
}
for len(u) > n {
c = c - u[0] + ... |
package common
import (
"bytes"
"io"
"testing"
"encoding/json"
"github.com/nautilus/events"
)
func TestLogging_writerPublishesToLogging(t *testing.T) {
// a mock event broker we can test with
broker := events.NewMockEventBroker()
// the byte string we are going to write
action := LogPayload{
Label: "lo... |
package admin
import (
"github.com/gin-gonic/gin"
"net/http"
)
func ListArticle(c *gin.Context) {
c.HTML(http.StatusOK, "admin/articlelist.html", gin.H{})
}
func AddArticle(c *gin.Context) {
c.HTML(http.StatusOK, "admin/articleadd.html", nil)
}
|
package sd
import (
"github.com/gin-gonic/gin"
"net/http"
)
const (
B = 1
KB = 1024 * B
MB = 1024 * KB
GB = 1024 * MB
)
// @Summary Shows OK as the ping-pong result
// @Description Shows OK as the ping-pong result
// @Tags sd
// @Accept json
// @Produce json
// @Success 200 {string} plain "OK"
// @Router /s... |
// Copyright 2018-present The Yumcoder Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Author: yumcoder (omid.jn@gmail.com)
//
package datatype
import (
"strconv"
"sync"
"testing"
)
// region different map implementations
... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package cellular
import (
"context"
"fmt"
"io/ioutil"
"net/http"
"time"
"chromiumos/tast/errors"
"chromiumos/tast/local/cellular"
"chromiumos/tast/local/modemmanage... |
package itree
import (
"sort"
)
type Tree struct {
root *intervalTreeNode
}
func NewTree(itvl []Interval) (Tree, error) {
var tree Tree
if len(itvl) == 0 {
return tree, nil
}
sort.Slice(itvl, func(i, j int) bool {
return itvl[i].End > itvl[j].End
})
rID := len(itvl) / 2
tree.root = newIntervalTreeNod... |
package httpio
import "net/http"
//TransFunc implements Transformer when casted to
type TransFunc func(a interface{}, r *http.Request, w http.ResponseWriter) error
//Transform allows a transfunc to be used as a Transformer
func (f TransFunc) Transform(a interface{}, r *http.Request, w http.ResponseWriter) error {
r... |
package main
import (
"github.com/magiconair/properties/assert"
"testing"
)
func Test_getMD5(t *testing.T) {
t.Run("not valid url", func(t *testing.T) {
resp := getMD5("google.com")
assert.Equal(t, resp, "")
})
t.Run("valid url", func(t *testing.T) {
resp := getMD5("http://google.com")
//check if the siz... |
package util
import "crypto/sha256"
// Merkle tree
// A Merkle tree is built for each block, and it starts with leaves where a leaf is a transaction hash
// MerkleTree represent a Merkle tree
type MerkleTree struct {
RootNode *MerkleNode
}
// MerkleNode represent a Merkle tree node
type MerkleNode struct {
Left ... |
package main
/*
--- Day 9: Marble Mania ---
You talk to the Elves while you wait for your navigation system to initialize. To pass the time, they introduce you to their favorite marble game.
The Elves play this game by taking turns arranging the marbles in a circle according to very particular rules. The marbles are ... |
package web
import (
"movie-app/handler"
)
type handlerModule struct {
user handler.UserHandler
genre handler.GenreHandler
movie handler.MovieHandler
movieGenre handler.MovieGenreHandler
review handler.ReviewHandler
}
func GetModule(service handlerService) handlerModule {
userHandler := ha... |
package mock
import "github.com/florianehmke/plexname/prompt"
type AskNumberFn func(question string) (int, error)
type AskStringFn func(question string) (string, error)
type ConfirmFn func(question string) (bool, error)
func NewMockPrompter(askNumberFn AskNumberFn, askStringFn AskStringFn, confirmFn ConfirmFn) promp... |
package cpu
import "testing"
func (p *CPU) oraImmediate(first byte, second byte) {
p.A = first
p.Memory.Write(second, 0)
p.Ora(0)
}
func TestOraSetsAccumulator(t *testing.T) {
var p *CPU = NewCPU()
p.oraImmediate(0x01, 0xff)
if p.A != 0xff {
t.Errorf("Binary ora seems not to have wo... |
// Copyright 2019 go-gtp authors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// Command sgw is a dead simple implementation of S-GW only with GTP-related features.
//
// S-GW follows the steps below if there's no unexpected events ... |
package set3
import (
"bytes"
"cryptopals/utils"
"testing"
)
func TestMT19937StreamCipher(t *testing.T) {
input := utils.GenerateRandomCharacters(8)
suffix := []byte("AAAAAAAAAAAAAA")
input = append(input, suffix...)
t.Log("Plaintext:", string(input))
key := uint16(getMT19937Seed())
t.Log("Key:", key)
c... |
package apis
import (
"encoding/hex"
"hash/fnv"
"regexp"
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/api/validation/path"
"k8s.io/apimachinery/pkg/util/validation"
)
const MaxNameLength = validation.DNS1123SubdomainMaxLength
var invalidL... |
package main
func adjacentElementsProduct(inputArray []int) int {
var result int = inputArray[0]*inputArray[1]
for i:=1; i < len(inputArray); i++ {
if len(inputArray) <= 2 {
return result
}
if inputArray[i]*inputArray[i-1] > result {
result = inputArray[i]*inputArray[i-1]
}
}
return result
} |
package gemini
import (
"context"
"fmt"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestClient_Balances(t *testing.T) {
type fields struct {
BaseURL string
apiKey string
apiSecret string
HTTPClient *http.Client
}
type args struct {
ctx context.Context
}
tests := []str... |
package Index
import (
"errors"
"github.com/PuerkitoBio/goquery"
"github.com/sirupsen/logrus"
"os"
"poetryAdmin/worker/app/config"
"poetryAdmin/worker/app/tools"
"poetryAdmin/worker/core/data"
"poetryAdmin/worker/core/define"
"poetryAdmin/worker/core/grasp/poetry/Category"
"poetryAdmin/worker/core/grasp/poet... |
package main
import (
"github.com/zairza-cetb/bench-routes/src/lib/handlers"
"github.com/zairza-cetb/bench-routes/src/lib/logger"
)
type qPingRoute struct {
URL string `json:"url"`
}
type qFloodPingRoute struct {
URL string `json:"url"`
}
type qJitterRoute struct {
URL string `json:"url"`
}
type qReqResDelayR... |
package glubcms
import (
"html/template"
"log"
"net/url"
"sync"
"time"
"github.com/lemmi/glubcms/backend"
)
type Entries []Entry
func (e Entries) Less(i, j int) bool {
switch {
case e[i].meta.IsIndex && !e[j].meta.IsIndex:
return false
case !e[i].meta.IsIndex && e[j].meta.IsIndex:
return true
case e[i... |
package categoryModel
import (
"hd-mall-ed/packages/common/database"
"hd-mall-ed/packages/common/database/tableModel"
)
type Category tableModel.Category
// 创建
func (category *Category) Create() error {
return database.DataBase.Create(category).Error
}
// 获取所有的列表数据
func (category *Category) Get() ([]*tableModel.... |
package TigoWeb
// MethodMapping http请求方式的一个映射
var MethodMapping = map[string]string{
"get": "Get",
"head": "Head",
"post": "Post",
"put": "Put",
"delete": "Delete",
"connect": "Connect",
"options": "Options",
"trace": "Trace",
"GET": "Get",
"HEAD": "Head",
"POST": "Post",
"PUT":... |
package db
import (
_ "github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
)
//DB as a driver gorm
var DB *gorm.DB
//OpenConnectionMysql open connection to mysql
func OpenConnectionMysql() (*gorm.DB, error) {
DB, err := gorm.Open("mysql", MysqlConnURL(BuildDbConfig()))
if err != nil {
return nil, err
}
... |
package ent
import (
"context"
log "github.com/sirupsen/logrus"
pb "way-jasy-cron/cron-logger/api"
"way-jasy-cron/cron-logger/internal/model/ent"
"way-jasy-cron/cron-logger/internal/model/ent/logger"
"way-jasy-cron/cron-logger/internal/model/ent_ex"
)
func (m *Manager) ListLog(ctx context.Context, req *ent_ex.L... |
// Copyright © 2018 John Slee <john@sleefamily.org>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify,... |
package ravendb
import (
"crypto/rand"
"encoding/hex"
)
// implements generating random uuid4 that mimics python's uuid.uuid4()
// it doesn't try to fully UUIDv4 compliant
// UUID represents a random 16-byte number
type UUID struct {
data [16]byte
}
// NewUUID creates a new UUID
func NewUUID() *UUID {
res := &U... |
package display
import "image"
// clip clips r against each image's bounds (after translating into the
// destination image's coordinate space) and shifts the points sp and mp by
// the same amount as the change in r.Min.
// Borrowed from "image".
func clip(dst image.Rectangle, r *image.Rectangle, src image.Rectangle... |
package model
import (
"github.com/guregu/null"
)
// StateCD
// 0 = pending
// 1 = fetching
// 2 = analyzing
// 3 = done
// 4 = error
// Project has uploaded repository information.
type Project struct {
UUID string `json:"uuid" gorm:"primary_key"`
UserID null.Int `json:"user_id"`
CartfileContent stri... |
package main
import "fmt"
type FibI interface {
Fib(n int) int
Wrap(fib FibI) FibI
}
type Fib struct {
Wrapper FibI
}
func (this *Fib) Fib(n int) int {
//wrapper := this.Wrapper
if this.Wrapper == nil {
this.Wrapper = this
}
fmt.Printf("Fib.Fib..%T...%v\n", this.Wrapper, n)
if n == 0 {
return 0
}
if n... |
package wkbcommon
import (
"bytes"
"encoding/binary"
"io"
"github.com/paulmach/orb"
)
// byteOrder represents little or big endian encoding.
// We don't use binary.ByteOrder because that is an interface
// that leaks to the heap all over the place.
type byteOrder int
const bigEndian byteOrder = 0
const littleEn... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.