text stringlengths 11 4.05M |
|---|
package user
import (
"github.com/saxon134/workflow/enum"
"time"
)
const TBNUser = "user"
type TblUser struct {
Id int64 `orm:"" json:"id"`
CreateAt *time.Time `orm:"" json:"createAt"`
Name string `orm:"varchar(30)" json:"name"`
Account string `orm:"varchar(30)" json:"account"`
Pas... |
package service
import (
"bytes"
"encoding/json"
"fmt"
login "github.com/carprks/login/service"
permissions "github.com/carprks/permissions/service"
"io/ioutil"
"net/http"
"os"
"strings"
"time"
)
// RegisterObject ...
type RegisterObject struct {
Identifier string `json:"identifier"`
Em... |
package scheduler
type EventName string
const (
TimerUpdate EventName = "TimerUpdate"
TimerIRQ EventName = "TimerIRQ"
OAMDMA EventName = "Oamdma"
HDMA EventName = "Hdma"
EndMode0 EventName = "EndMode0"
EndMode1 EventName = "EndMode1"
EndMode2 EventName = "EndMode2"
EndMode3 EventNam... |
package main
import (
"crypto/rand"
"database/sql"
"encoding/hex"
"encoding/json"
"github.com/dgrijalva/jwt-go"
"github.com/go-redis/redis"
"github.com/gofrs/uuid"
"github.com/julienschmidt/httprouter"
"github.com/rso-bicycle/users/models"
"github.com/volatiletech/sqlboiler/boil"
"github.com/volatiletech/sq... |
package main
import (
"io/ioutil"
)
type Store interface {
GetIP() (string, error)
PutIP(ip string) error
}
type Storage struct{}
var StorePath = "/tmp/cf-ddns-v2.bat"
func (s *Storage) GetIP() (string, error) {
dat, err := ioutil.ReadFile(StorePath)
if err != nil {
return "", err
}
return string(dat), ni... |
package ulog
import (
"errors"
"fmt"
"github.com/sirupsen/logrus"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
)
const (
Mb int = 1024000
DefaultMaxSize = 100
_depth = 9
)
type Formatter struct {
TimestampFormat string
}
var strScanID = "NONE"
func (f *Formatter) F... |
package log
import (
"fmt"
"github.com/rs/zerolog"
"os"
"strings"
"time"
)
var Logger zerolog.Logger
func Log(level string, msg string) {
output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC3339}
output.FormatLevel = func(i interface{}) string {
return strings.ToUpper(fmt.Sprintf("| %-6s|", ... |
package Kth_Largest_Element_in_an_Array
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFind(t *testing.T) {
ast := assert.New(t)
ast.Equal(5, findKthLargest3([]int{3,2,1,5,6,4}, 2))
ast.Equal(8, findKthLargest3([]int{1, 2, 4, 6, 7, 8, 534, 4, 7, 63, 1}, 3))
}
|
package main
import "crypto/sha256"
type Digest []byte
type Hasher func(...[]byte) []byte
func xorhasher(data ...[]byte) []byte {
var result byte
for _, elem := range data {
var sum byte
for _, b := range elem {
sum = sum ^ b
}
result = result ^ sum
}
return []byte{result}
}
func pearsonhasher(data ... |
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... |
//Package fndds implements an Ingest for Food Survey data
package fndds
import (
"encoding/csv"
"fmt"
"io"
"log"
"os"
"strconv"
"time"
"github.com/littlebunch/gnutdata-bfpd-api/admin/ingest"
"github.com/littlebunch/gnutdata-bfpd-api/admin/ingest/dictionaries"
"github.com/littlebunch/gnutdata-bfpd-api/ds"
f... |
package utils
type EmptyStruct struct{}
var Empty = EmptyStruct{}
|
package scan_test
import (
"time"
"github.com/phogolabs/orm/dialect/sql/scan"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Iter", func() {
type Student struct {
ID string `db:"id,primary_key"`
Name string `db:"name"`
CreatedAt time.Time `db:"created_at,read_... |
package admin_models
import (
"github.com/astaxie/beego/orm"
)
func (ap *AdminPassword) TableName() string {
return "admin_password"
}
func (ap *AdminPassword) Insert() error {
if _, err := orm.NewOrm().Insert(ap); err != nil {
return err
}
return nil
}
func (ap *AdminPassword) Read(fields ...string) erro... |
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
"strings"
"time"
)
func serveWebsite() {
http.Handle("/", http.FileServer(http.Dir("./public")))
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
http.HandleFunc("/upload", uploadHandler)
http.HandleFunc("/p/... |
package main
import (
"github.com/gin-gonic/gin"
"log"
"strconv"
"strings"
)
func LogAndQuit(err error) bool {
if err != nil {
log.Fatalln(err)
return false
} else {
return true
}
}
func LogAndPanic(err error) bool {
if err != nil {
log.Panicln(err)
return false
} else {
return true
}
}
// A m... |
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
// See License for license information.
package command
import (
"fmt"
"github.com/mattermost/mattermost-plugin-mscalendar/server/config"
)
func (c *Command) help(parameters ...string) (string, bool, error) {
resp := fmt.Sprintf("Mattermost Micr... |
package resolver
import (
"fmt"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/opsee/basic/schema"
opsee_aws_autoscaling "github.com/opsee/basic/schema/aws/autoscaling"
opsee_aws_ec2 "github.com/opsee/basic/schema/aws/ec2"
opsee_aws_ecs "github.com/opsee/basic/schema/aws/ecs"
opsee_aws_elb "github.com/... |
package newmodel
import (
"container/list"
"dlog"
"encoding/binary"
"fastrpc"
"fmt"
"genericsmr"
"genericsmrproto"
"io"
"log"
"net/rpc"
"newmodelproto"
"state"
"strings"
"time"
)
const CHAN_BUFFER_SIZE = 200000
const TRUE = uint8(1)
const FALSE = uint8(0)
const ADAPT_TIME_SEC = 10
const HEART_BEAT = 500... |
package user
import "errors"
type KratosUser struct {
ID string `json:"id"`
SchemaID string `json:"schema_id"`
SchemaURL string `json:"schema_url"`
Traits KratosUserTraits `json:"traits"`
}
type KratosUserTraits struct {
Email string `json:"email"`
Tenants []string ... |
package txmgr
import (
"ledger/DbService"
)
func UserRegisterHandler(username, password, IDNumber, PhoneNumber string) error {
//TODO call ledger interface.
ok, err := DbService.InsertRegister(username, password, IDNumber, PhoneNumber)
if !ok {
logger.Error(err)
return err
}
return nil
}
|
package geolocate
import (
"context"
"net/http"
)
func invalidIPLookup(
ctx context.Context,
httpClient *http.Client,
logger Logger,
userAgent string,
) (string, error) {
return "invalid IP", nil
}
|
package netmgr
import (
"encoding/json"
"net"
"github.com/ajruckman/ContraCore/internal/schema"
"github.com/ajruckman/ContraCore/internal/system"
)
var transmitQueue = make(chan schema.Log)
func ProcessQuery(log schema.Log) {
transmitQueue <- log
logCache = append(logCache, log)
if len(logCache) > cacheSize... |
package models
type UserActivityType string
const (
UserQuestionActivity UserActivityType = "UserQuestionActivity"
UserAnswerActivity UserActivityType = "UserAnswerActivity"
UserReportActivity UserActivityType = "UserReportActivity"
UserStandupActivity UserActivityType = "UserStandupActivity"
UserGr... |
package telnet
import (
"context"
"errors"
"fmt"
"regexp"
"strings"
"time"
)
type Shell struct {
c *Conn
opt *Options
isRun bool
regxp *regexp.Regexp
down context.CancelFunc
in chan<- Command
out <-chan CommandBack
copyWrite bool
}
func NewShell(c *Conn, opt *Opt... |
package management
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs"
"github.com/zouyx/jodzadmin/service/zk"
)
const SOURCE_PATH ="/jodz/jobScheduler"
type SynchronizerController struct {
beego.Controller
}
func (this *SynchronizerController) Get() {
path := this.GetString("path")
if path==... |
package ristretto
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
var hitCount = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "cache_trap_collection",
Name: "hit_count",
}, []string{"type", "status"})
|
/*
Copyright 2021 The Machine Controller 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
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... |
package core
import (
"errors"
"fmt"
"time"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/core/loadpoint"
"github.com/evcc-io/evcc/core/wrapper"
)
var _ loadpoint.API = (*Loadpoint)(nil)
// Title returns the human-readable loadpoint title
func (lp *Loadpoint) Title() string {
return lp.Title_
}
// ... |
package command
//Todo is used to store a text and status of single task
type Todo struct {
Index int
Text string
Status bool
}
//Todos is used to store a list of Todo task
type Todos struct {
Todos []Todo
}
|
package raftkv
import "labrpc"
import "crypto/rand"
import "math/big"
import "sync"
import "fmt"
type Clerk struct {
servers []*labrpc.ClientEnd
seqNum int
mu sync.Mutex
lastIdx int
// You will have to modify this struct.
}
func nrand() int64 {
max := big.NewInt(int64(1) << 62)
bigx, _ := rand.Int(rand.R... |
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... |
// Copyright 2017 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 storage
type Img struct {
ID string `db:"id"`
ShortDesc string `db:"description"`
Region string `db:"region"`
Location string `db:"location"`
Content []byte `db:"content"`
Size int `db:"size"`
Name string `db:"name"`
CreatedAt string `db:"added"`
}
|
package main
import (
"fmt"
"sync"
)
// sync包提供了基本的同步基元,如互斥锁
// 除了Once和WaitGroup类型,大部分都是适用于低水平程序线程,高水平的同步使用channel通信更好一些
// 本包的类型的值不应被拷贝
func main() {
// 协程同步
exampleWaitGroup()
// 协程中只调用单次方法
exampleOnce()
// 利用互斥锁进行线程操作
exampleCond()
// 资源池
examplePool()
// 并发读写互斥锁
exampleRWMutex()
// 并发map
exampleMap... |
//https://leetcode.com/problems/add-two-numbers-ii/?tab=Description
func reverseList(l*ListNode)*ListNode{
if l==nil || l.Next==nil {
return l
}
var r *ListNode=nil
for l!=nil{
p:=l.Next
l.Next=r
r=l
l=p
}
return r
}
func addTwoNumbers(l1 *Lis... |
package main
func main() {
var x int = a
}
|
// Package server implements a simple UDP server that ACKs every valid packet it receives.
// Example usage from golang/bin/
// # Runs a basic server *locally* that returns each valid UDP packet received.
// ./server
//
// # Specify ports to receive and send on and to.
// ./server --client_ip=192.168.2.3 --client_rcv_... |
package qr
import (
"image/png"
"os"
"github.com/boombuler/barcode/qr"
file2 "tools/internal/file"
"models"
)
//GenerateQRCodeFile 根据内容生成二维码图片
func GenerateQRCodeFile(content string) models.File {
qrCode, _ := qr.Encode(content, qr.M, qr.Auto)
newQrCodeFile := file2.CreateEmptyFile("png")
file, _ := os.Creat... |
package vehicle
import (
"fmt"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/provider"
"github.com/evcc-io/evcc/util"
)
//go:generate go run ../cmd/tools/decorate.go -f decorateVehicle -b api.Vehicle -t "api.ChargeState,Status,func() (api.ChargeStatus, error)" -t "api.VehicleRange,Range,func() (int64, e... |
package main
import (
"flag"
"fmt"
"log"
"net"
"strconv"
"github.com/gin-gonic/gin"
"github.com/hanherb/omdb-api/answers"
content "github.com/hanherb/omdb-api/lib/controllerGrpc"
controllerRest "github.com/hanherb/omdb-api/lib/controllerRest"
"github.com/hanherb/omdb-api/lib/services"
"github.com/hanherb/o... |
package main
import (
"fmt"
"github.com/lxyuma/score-training/questions/scales"
"github.com/lxyuma/score-training/structures"
// "os"
)
func main() {
num := structures.IntervalNum(structures.C, structures.E)
name := structures.IntervalName(num)
fmt.Println(name)
fmt.Println(structures.Cflat.IsSharp())
pro... |
// Copyright 2020 SEQSENSE, Inc.
//
// 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 ... |
package smartling
// FileStatus describes file translation status obtained by GetFileStatus
// method.
type FileStatus struct {
File
TotalStringCount int
TotalWordCount int
TotalCount int
Items []FileStatusTranslation
}
|
package main
import (
"fmt"
"github.com/balalay12/intern-test/golang/rest-service/handlers"
"github.com/gorilla/mux"
"net/http"
"log"
)
func main() {
r := mux.NewRouter()
r.HandleFunc("/", handlers.GetUsers).Methods("GET")
r.HandleFunc("/user/{id:[0-9]+}", handlers.GetUser).Methods("GET")
r.HandleFunc("/new"... |
package main
import (
"fmt"
"regexp"
)
func matchPattern(pattern string) func(name string) bool {
reg := regexp.MustCompile(pattern)
return func(name string) bool {
return reg.MatchString(name)
}
}
func filterStrings(list []string, pattern string) []string {
cleaned := []string{}
match := matchPattern(patte... |
package main
import (
"encoding/json"
"fmt"
)
func main() {
//Quando a estrutura tem letra maiúscula, ele pode ser usado externamente
type Pessoa struct {
Nome string `json:"Nome"`
Idade int `json:"Idade"`
//Dentro do Json, Crianças equivale a Filhos no Go.
Filhos []string `json:"Crianças"`
}
sb :... |
// Copyright (c) 2013 Mathieu Turcotte
// Licensed under the MIT license.
package browserchannel
import (
"encoding/json"
"errors"
"fmt"
"log"
"sync"
"time"
)
var (
ErrClosed = errors.New("channel closed")
)
const (
maxOutgoingArrays = 100
channelReopenTimeoutDelay = 20 * time.Second
backChannel... |
package main
import "projects/DesignPatternsByGo/behavioralPatterns/observer"
func main(){
eventCenter := observer.NewEventCenter()
r_1 := observer.EventReciver{}
r_2 := observer.EventReciver{}
eventCenter.Register(&r_1)
eventCenter.Register(&r_2)
eventCenter.Notify(observer.Event{1})
eventCenter.Degister(&r_... |
package main
import "math/rand"
import "os"
import "strconv"
func TestBubbleSort2(outfile string) (err error) {
file, err := os.Create(outfile)
if err != nil {
return
}
for i:=0; i<10000; i++ {
str := strconv.Itoa(rand.Intn(65536))
file.WriteString(str + "\n")
... |
package main
import "testing"
func TestCapitalizeWord(t *testing.T) {
var tests = []struct {
input, result string
}{
{"foo", "Foo"},
{"fooBar", "FooBar"},
{"österreich", "Österreich"},
{"Österreich", "Österreich"},
{"über", "Über"},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
r... |
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"os"
"os/signal"
"sync"
)
var interrupted = make(chan struct{})
var subProcExited = make(chan struct{})
func processSignals() {
sig... |
package suites
import (
"github.com/adamluzsi/testcase"
"testing"
)
// Suite represent a resource specification also known as "contract".
//
// The main goal of a resource Spec is to introduce dependency injection pattern
// at logical level between consumers and suppliers.
// In other words any expectations from a... |
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
const maxWorkers = 5
type jobx struct {
name string
duration time.Duration
}
func doWorkx(id int, j jobx) {
fmt.Printf("worker%d: started %s, working for %fs\n", id, j.name, j.duration.Seconds())
time.Sleep(j.duration)
fmt.Printf("... |
package main
import (
"context"
"fmt"
"time"
sumallpb "github.com/Sadham-Hussian/go-gRPC/stream/client-streaming/sumAll/proto"
"google.golang.org/grpc"
)
func main() {
conn, err := grpc.Dial("localhost:4000", grpc.WithInsecure())
if err != nil {
panic(err)
}
defer conn.Close()
client := sumallpb.NewSumA... |
package stormpath
import (
"gopkg.in/dgrijalva/jwt-go.v3"
)
//SSOTokenClaims are the JWT for initiating an IDSite workflow
//
//see: http://docs.stormpath.com/guides/using-id-site/
type SSOTokenClaims struct {
jwt.StandardClaims
CallbackURI string `json:"cb_uri,omitempty"`
Path string `... |
package cloudformation
// AWSEC2SpotFleet_LaunchTemplateConfig AWS CloudFormation Resource (AWS::EC2::SpotFleet.LaunchTemplateConfig)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-launchtemplateconfig.html
type AWSEC2SpotFleet_LaunchTemplateConfig struct {
// Laun... |
package versions
import (
"fmt"
"testing"
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
"gotest.tools/assert"
)
func TestValidateImageName(t *testing.T) {
config := &latest.Config{
Images: map[string]*latest.Image{
"default": {
Image: "localhost:5000/node",
},
},
}
err := val... |
package security
import (
"crypto"
"crypto/md5"
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"crypto/x509"
"encoding/pem"
"errors"
"hash"
"io/ioutil"
)
var (
// ErrHashTypeNotAllowed represents that input has type is not allowed
ErrHashTypeNotAllowed = errors.New("Hash algori... |
/*
*Copyright (c) 2019-2021, Alibaba Group Holding Limited;
*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 ... |
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
package cmd
import (
"fmt"
"os"
"regexp"
"path/filepath"
"github.com/spf13/cobra"
)
func runFind(starts []string, pattern *regexp.Regexp) error {
for _, start := range starts ... |
package client
import (
"github.com/pmacik/k8s-rds/pkg/crd"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
)
// This file implement all the (CRUD) client methods we need to access our CR ob... |
package day27
//给定一个整数,编写一个函数来判断它是否是 2 的幂次方。
//
// 示例 1:
//
// 输入: 1
//输出: true
//解释: 20 = 1
//
// 示例 2:
//
// 输入: 16
//输出: true
//解释: 24 = 16
//
// 示例 3:
//
// 输入: 218
//输出: false
// Related Topics 位运算 数学
//leetcode submit region begin(Prohibit modification and deletion)
/*
思路1:首先要搞清楚什么是2的冥次方、在数学中很好理解、但在二进制中应该怎么表... |
package im
import (
"log"
"net/http"
)
/*
聊天室服务
*/
/*
在线服务
*/
/*
用户服务
*/
//注册
type UserRegisterHandler interface {
Register(writer http.ResponseWriter, request *http.Request)
UnRegister(writer http.ResponseWriter, request *http.Request)
UserModify(writer http.ResponseWriter, request *http.Request)
}
typ... |
package dsl
import (
"fmt"
"log"
"net"
"net/rpc"
"os"
"os/exec"
"reflect"
"strings"
"testing"
"time"
"github.com/pact-foundation/pact-go/daemon"
"github.com/pact-foundation/pact-go/types"
"github.com/pact-foundation/pact-go/utils"
)
// Use this to wait for a daemon to be running prior
// to running test... |
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agree... |
package main
import (
"fmt"
"github.com/spf13/cobra"
"github.com/vishvananda/netlink"
)
var mode string
var rdmaNetnsCfgCmds = &cobra.Command{
Use: "rdmanetns",
Short: "RDMA Net namespace configuration commands",
RunE: func(cmd *cobra.Command, args []string) error {
cmd.HelpFunc()(cmd, args)
return nil
... |
package main
import (
_ "fmt"
"testing"
)
func TestWallet(t *testing.T) {
t.Run("Deposit", func (t * testing.T) {
w := Wallet{}
w.Deposit(Bitcoin(10))
assertBalance(t, w, Bitcoin(10))
})
t.Run("Withdraw", func (t *testing.T) {
w := Wallet{Bitcoin(30)}
err := w.Withdraw(Bitcoin(10))
... |
package main
import (
"reflect"
"testing"
)
func TestGap(t *testing.T) {
type args struct {
g int
m int
n int
}
tests := []struct {
name string
args args
want []int
}{
{name: "1", args: args{g: 2, m: 100, n: 110}, want: []int{101, 103}},
{name: "2", args: args{g: 4, m: 100, n: 110}, want: []int{... |
// Copyright 2015 go-smpp authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package smpp
import (
"testing"
"time"
"golang.org/x/time/rate"
"github.com/veoo/go-smpp/smpp/pdu"
"github.com/veoo/go-smpp/smpp/pdu/pdufield"
"github... |
package ircdiscord
import (
"fmt"
"regexp"
"strings"
"github.com/diamondburned/arikawa/discord"
"gopkg.in/irc.v3"
)
func (c *Client) joinChannel(name string) error {
if c.guild == nil {
return fmt.Errorf("JOIN for non-guilds is currently unimplemented")
}
channels, err := c.session.Channels(c.guild.ID)
i... |
package invibes
import (
"encoding/json"
"testing"
"github.com/prebid/prebid-server/openrtb_ext"
)
func TestValidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fatalf("Failed to fetch the json-schemas. %v", err)
}
for _, validPa... |
package kayzen
import (
"encoding/json"
"fmt"
"net/http"
"text/template"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/errortypes"
"github.com/prebid/prebid-server/macros"
"github.com/prebid/prebi... |
package etcd
type MemberInfo struct {
IP string
ClientPort string
}
var ClusterMembers []MemberInfo
|
package main
import (
"fmt"
"time"
"math/rand"
)
func f(from string) {
for i := 0; i < 3; i++ {
fmt.Println(from, ":", i)
time.Sleep(time.Duration(rand.Int31n(1000)) * time.Millisecond)
}
}
func main() {
go f("goroutine1")
go f("goroutine2")
go func(msg string) {
fmt.Println(msg)
}("gor... |
package main
import (
"fmt"
"math"
)
type Elf struct {
number, presents int
}
func solve(elvesCount int) {
var elves []Elf
for i := 0; i < elvesCount; i++ {
elves = append(elves, Elf{i+1, 1})
}
for i := 0; i < len(elves) && !onlyOne(elves); {
if elves[i].presents != 0 {
//fmt.Println(elv... |
// Copyright © 2017 Casey Marshall
//
// 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 t... |
package config
import (
"github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
"github.com/robfig/cron"
"github.com/spf13/afero"
"github.com/spf13/viper"
kitlog "github.com/go-kit/kit/log"
"log"
"os"
"os/user"
"runtime"
)
func init() {
logger := kitlog.NewJSONLogger(kitlog.NewSyncWriter(os.Stdout))
log... |
package normal_starting
type player struct {
userName string
userId uint64
}
|
package common
// GetBlocksRoundedUp returns the number of blocks given sie, rounded up
func GetBlocksRoundedUp(size uint64, blockSize uint64) uint16 {
return uint16(size/blockSize) + Iffuint16((size%blockSize) == 0, 0, 1)
}
////////////////////////////////////////////////////////////////////////////////////////////... |
package main
// Leetcode 116. (medium)
func connect(root *TreeNode3) *TreeNode3 {
res := recursiveConnect(root, 0, [][]*TreeNode3{})
for i := range res {
for j := range res[i] {
if j+1 != len(res[i]) {
res[i][j].Next = res[i][j+1]
}
}
}
return root
}
func recursiveConnect(root *TreeNode3, depth int,... |
package response
// 请求返回值
const (
CodeSuccess = 0 // 成功返回
CodeFail = 1
CodeFailRetry = 2 //需要改参数重试
)
// Response 用户响应数据
type RespData struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
//请求成功,返回
func Success(data interface{}) RespData {
r... |
package kata
import "strings"
func DuplicateEncode(word string) (result string) {
charMap := make(map[string]int)
for _, c := range word {
charMap[strings.ToLower(string(c))] += 1
}
for _, c := range word {
if charMap[strings.ToLower(string(c))] > 1 {
result += ")"
} else {
result += "("
}
}
retur... |
package cloudformation
// AWSCloudFrontCloudFrontOriginAccessIdentity_CloudFrontOriginAccessIdentityConfig AWS CloudFormation Resource (AWS::CloudFront::CloudFrontOriginAccessIdentity.CloudFrontOriginAccessIdentityConfig)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-c... |
package gl
import (
"github.com/galaco/gosigl"
"github.com/galaco/lambda-client/renderer/camera"
"github.com/galaco/lambda-client/renderer/gl/bsp"
material2 "github.com/galaco/lambda-client/renderer/gl/material"
"github.com/galaco/lambda-client/renderer/gl/prop"
"github.com/galaco/lambda-client/renderer/gl/shade... |
package hello
import (
"crypto/rand"
"crypto/rsa"
"encoding/json"
"fmt"
"net/http"
"github.com/dgrijalva/jwt-go"
"golang.org/x/crypto/bcrypt"
"appengine"
"appengine/datastore"
)
var secretKey, _ = rsa.GenerateKey(rand.Reader, 1024)
/* TODO: API endpoints for authentication system:
Handler middleware to pr... |
package main
import (
"fmt"
"os"
"strings"
"github.com/blankon/irgsh-go/pkg/systemutil"
"github.com/google/uuid"
"github.com/manifoldco/promptui"
)
func InitBase() (err error) {
logPath := irgshConfig.Builder.Workdir
logPath += "/irgsh-builder-init-base-" + uuid.New().String() + ".log"
go systemutil.StreamL... |
package main
import (
"fmt"
"github.com/apitable/apitable-sdks/apitable.go/lib/common"
"github.com/apitable/apitable-sdks/apitable.go/lib/common/profile"
apitable "github.com/apitable/apitable-sdks/apitable.go/lib/datasheet"
"github.com/tencentyun/scf-go-lib/cloudfunction"
"math"
"os"
)
func getRecords(credent... |
package ui
import (
"testing"
"github.com/stretchr/testify/assert"
)
func BenchmarkUI(b *testing.B) {
w, h := 20, 10
ui := New(w, h)
btn := NewButton(w-10, h-4)
btn.Position = Point{X: 5, Y: 3}
ui.AddComponent(btn)
fnt, _ := NewFont(defaultFontName, 6, 72, White)
txt := NewText(fnt)
txt.SetText("HELLO")... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"strings"
"time"
"github.com/gofiber/fiber"
"golang.org/x/net/html"
)
type Hackathon struct {
Link string `json:"link"`
Name string `json:"name"`
}
type SubmissionPeriod struct {
Begins string `json:"begins"`
Ends string `json:"... |
// Copyrigth (c) 2016, Samvel Khalatyan. All rights reserved.
package issues
import (
"time"
)
// Issues is a list of issues found
type Issues struct {
TotalCount int `json:"total_count"`
Items []*Item
}
// Item is a single GitHub issue
type Item struct {
ID int
Title string
Body string
Num... |
package kata
import "strings"
func PartList(arr []string) string {
results := ""
for i:=1; i<len(arr); i++ {
first := strings.Join(arr[:i], " ")
second := strings.Join(arr[i:], " ")
results += "(" + first + ", " + second + ")"
}
return results
} |
package merkletree
import (
"encoding/hex"
"testing"
)
func TestNewMerkleTree(t *testing.T) {
mt1 := NewMerkleTree([][]byte{[]byte("hello"), []byte("world")})
if hex.EncodeToString(mt1.WithFirst([]byte("first"))) != "11f206ce3848f46083c5f30d01b95a8dd75194ef5781b24202d34720b2b4c12f" {
t.Fail()
}
if GetMerkle... |
/*
*Copyright (c) 2019-2021, Alibaba Group Holding Limited;
*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 ... |
package forum
import (
//"fmt"
//"github.com/astaxie/beego"
"net/http"
"strings"
"tripod/convert"
"webserver/common"
"webserver/controllers"
"webserver/models"
"webserver/models/maccount"
)
type AddTopicController struct {
controllers.BaseController
}
func (c *AddTopicController) Post() {
defer c.Recover(... |
package main
import "fmt"
func baka() (int) {
return 9
}
func biggest32() (int, int) {
return 2147483647, -2147483647
}
func main() {
cirno := baka()
fmt.Println(cirno)
max, min := biggest32()
fmt.Println(max, min)
_, justMin := biggest32()
fmt.Println(justMin)
}
|
package day9
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func IntToIntSlice(num int) (res []int) {
numStr := strconv.Itoa(num)
digits := strings.Split(numStr, "")
for _, d := range digits {
n, _ := strconv.Atoi(d)
res = append(res, n)
}
return res
}
func ParseOperation(operation int) (opcode, mod... |
package main
import "fmt"
func main() {
grid := [][]int{
{1, 2},
{3, 4},
}
minPath := minPathSum(grid)
fmt.Println(minPath)
a := "hello"
b := "hello"
fmt.Println(a == b)
}
func minPathSum(grid [][]int) int {
row := len(grid)
if row == 0 {
return 0
}
col := len(grid[0])
minPathGrid := newMinPathGri... |
package files
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/rs/zerolog/log"
"github.com/BlackCodes/logbud/flag"
)
type CloneFile struct {
project string
ModFile string
dir string
buildDir string
paths map[string]string // original==>new
}
func NewCloneFile() *CloneFile... |
// Database API
package db
import (
"encoding/json"
"fmt"
"github.com/gophergala/echodb/dbwebsocket"
"io/ioutil"
"math/rand"
"os"
"path"
"strconv"
"strings"
"sync"
"time"
)
const (
PARTS_LENGTH_FILE = "_count" // Holds total count of parittions
)
type Database struct {
path string
numParts in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.