text stringlengths 11 4.05M |
|---|
package cmd
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/fatih/color"
"github.com/porter-dev/porter/cli/cmd/api"
"github.com/porter-dev/porter/cli/cmd/github"
"github.com/spf13/cobra"
"github.com/docker/cli/cli/co... |
/*
* median-stats : Calculate Hub median statistics
*/
package main
import (
"encoding/csv"
"fmt"
"io"
"log"
"os"
"sort"
"strconv"
"strings"
)
func main() {
distroheavy := map[string]int{
"debian": 1,
"ubuntu": 1,
"centos": 1,
"fedora": 1}
file, err := os.Open("docker-hub-stats.csv")
if err !=... |
package stream
import (
"context"
"errors"
"net/http"
"net/http/httptest"
"net/url"
"sync"
"testing"
"time"
"github.com/sirupsen/logrus"
"github.com/danfaizer/gowse"
agent "github.com/adevinta/vulcan-agent"
"github.com/adevinta/vulcan-agent/check"
)
const (
streamPath = "stream"
streamName = "ev... |
package getcontent
import (
"bufio"
"database/sql"
_ "github.com/go-sql-driver/mysql"
"fmt"
"github.com/yangyouwei/xiaoshuo_content/read_conf"
"io"
"strings"
"log"
"os"
"regexp"
"sync"
)
type booksinfo struct {
Id int `db:"id"`
Sourcesfilename string `db:"Sourcesfilename"`
Chapterdone ... |
package controllers
import (
"database/sql"
"net/http"
"../config"
"../helpers"
"../models"
)
type PageDataSingle struct {
Title string
Description string
Singledata models.GetifobyUID
}
// Show Получение информации с конкретным ID
func Show(w http.ResponseWriter, r *http.Request) {
if r.Method != "... |
// Copyright (c) KwanJunWen
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
package estemplate
import "fmt"
// DatatypeDenseVector Specialised Datatype that stores dense vectors of float
// values. The maximum number of dimensions that can... |
// Fetcher for http://api.coindesk.com
package coindesk
import (
"errors"
"fmt"
"net/http"
"strings"
"time"
"github.com/l-vitaly/btcticker"
"github.com/l-vitaly/btcticker/httputil"
)
var (
errParse = errors.New("parse error")
errCurrencyNotFound = errors.New("currency not found")
)
const fetcher... |
package main
// Worth checking out is also fastwalk.go and its simblings in
// https://github.com/golang/tools/
// Unfortunately, it's not possible to import it :(
import (
"fmt"
"github.com/MichaelTJones/walk"
"os"
"path/filepath"
"sort"
"strings"
)
type kv struct {
key string
value int
}
func counti... |
package log
import (
"github.com/gin-gonic/gin"
"github.com/lestrrat-go/file-rotatelogs"
"github.com/sirupsen/logrus"
"go.rock.com/rock-platform/rock/server/conf"
"io"
"log"
"os"
"path/filepath"
"strings"
"time"
)
type Logger struct {
*logrus.Logger
}
var SingleLogger *Logger
func GetLogger() *Logger {
... |
package attr
import "testing"
func TestIsEmpty(t *testing.T) {
test := func(v interface{}, e bool) {
res := IsEmpty(v)
if res != e {
t.Errorf("(%v) expected empty (%t) but (%t)", v, e, res)
}
}
test(0, true)
test(1, false)
test(-1, false)
test(int64(0), true)
test(int(1), false)
test("", true)
tes... |
/**
* @Author: jinjiaji
* @Description:
* @File: sliding_window
* @Version: 1.0.0
* @Date: 2021/8/16 下午5:48
*/
package module5
import (
"sync"
"testing"
"time"
)
//TestDefaultCounter 模拟1000并行下的4亿次计数以及4亿次统计
func TestDefaultCounter(t *testing.T) {
qc := NewDefaultQueriesCounter()
defer qc.Close()
wg := sy... |
package shard
import (
"bytes"
"fmt"
"hash/crc32"
"testing"
"time"
"h12.io/sej"
)
func BenchmarkAppend(b *testing.B) {
tt := sej.Test{b}
path := tt.NewDir()
w, err := NewWriter(Path{path, "blue", 8}, shardFNV)
if err != nil {
b.Fatal(err)
}
keys := make([][]byte, b.N)
for i := range keys {
keys[i] ... |
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
)
var (
protoPath string
protoOut string
)
func init() {
flag.StringVar(&protoPath, "f", "", "proto源文件路径")
flag.StringVar(&protoOut, "t", "", "proto文件编译输出路径")
}
func main() {
flag.Parse()
... |
package db
import "github.com/gobjserver/gobjserver/core/entity"
// ObjectGatewayImpl .
type ObjectGatewayImpl struct {
Datatbase CommonDatabase
}
// FindAll .
func (gateway ObjectGatewayImpl) FindAll() ([]string, error) {
return gateway.Datatbase.GetTableNames()
}
// Insert .
func (gateway ObjectGatewayImpl) Ins... |
package main
import "time"
type Routine struct {
RoutineId int `json:"routine_id"`
Title string `json:"title"`
TotalDuration int `json:"total_duration"`
Character string `json:"character"`
CreatorTag string `json:"creator_tag"`
CreatorId int `json:"creator_id"`
... |
package converter
import (
"fmt"
"image"
"image/color"
_ "image/gif"
_ "image/jpeg"
_ "image/png"
"math"
"os"
"github.com/MarioCdeS/imgtoascii/converter/config"
)
const (
ramp10 = "@%#*+=-:. "
ramp70 = "$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\\|()1{}[]?-_+~<>i!lI;:,\"^`'. "
)
type Error struct {
Msg ... |
package inter
import "snatch_ssc/sys"
type SscData struct {
No sys.NullString `json:"no"` // 期号
Results sys.NullString `json:"results"` // 结果
// DrawTime sys.NullTime `json:"drawTime"` // 时间
}
type Snatch interface {
// 抓取网页
Snatch() (string, error)
// 解析网页数据
Resolve(string) []*SscData
}
|
package graph
import (
"fmt"
"math"
)
func hslahex(h, s, l, a float64) string {
r, g, b, xa := hsla(h, s, l, a)
return fmt.Sprintf("\"#%02x%02x%02x%02x\"", sat8(r), sat8(g), sat8(b), sat8(xa))
}
func hue(v1, v2, h float64) float64 {
if h < 0 {
h += 1
}
if h > 1 {
h -= 1
}
if 6*h < 1 {
return v1 + (v2-... |
package admin
import (
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/phantacix/go-admin-panel/core"
"github.com/phantacix/go-admin-panel/core/db"
"github.com/phantacix/go-admin-panel/module/admin/model"
"testing"
)
func init() {
core.Init("../../config/env/local/admin.json")
}
func TestAdminDBMigrate(t... |
// Copyright 2020 The VectorSQL Authors.
//
// Code is licensed under Apache License, Version 2.0.
package databases
import (
"os"
"sync"
"io/ioutil"
"path/filepath"
"columns"
"datatypes"
"parsers"
"storages"
"base/errors"
"parsers/sqlparser"
)
type OnDiskDatabase struct {
mu sync.RWMutex
ctx... |
package main
import (
"fmt"
"github.com/hyperledger/fabric-chaincode-go/shim"
"github.com/hyperledger/fabric-protos-go/peer"
)
// SimpleAsset implements a simple chaincode to manage an asset
type SimpleAsset struct{}
// Init func
func (t *SimpleAsset) Init(stub shim.ChaincodeStubInterface) peer.Response {
retur... |
package redis
import (
."asyncMessageSystem/app/config"
"github.com/gomodule/redigo/redis"
"log"
"strconv"
)
var Cache = new(Instance)
//func init(){
func Init(){
var err error
password := redis.DialPassword(Conf.Redis.Password)
database := redis.DialDatabase(Conf.Redis.Database)
Cache.Conn,err = redis.Dial(... |
package ravendb
var (
spatialCriteriaFactoryInstance = NewSpatialCriteriaFactory()
)
type SpatialCriteriaFactory struct {
}
func NewSpatialCriteriaFactory() *SpatialCriteriaFactory {
return &SpatialCriteriaFactory{}
}
func (f *SpatialCriteriaFactory) RelatesToShape(shapeWkt string, relation SpatialRelation) *WktC... |
package main
import (
"errors"
"fmt"
"regexp"
"strconv"
"strings"
"unicode"
"golang.org/x/net/html"
)
const (
SectionClass = "sectionHeading"
HighlightClass = "noteHeading"
NoteTextClass = "noteText"
AuthorClass = "authors"
TitleClass = "bookTitle"
)
type Highlight struct {
Color string
P... |
package conver
import (
"encoding/json"
"log"
"testing"
)
type Anyom1 struct {
Single string `align:"single"`
}
type Anyom struct {
Sex string `align:"sex"`
Anyom1
}
type People struct {
Age string `align:"age"`
Name string `align:"name"`
Message Msg `align:"msg"`
Anyom
}
type Msg struct {
Tim... |
// Based on: https://github.com/btcsuite/btcwallet/blob/master/walletsetup.go
/*
* Copyright (c) 2014-2015 The btcsuite developers
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission not... |
package main
import (
"math"
"sort"
"strconv"
"strings"
)
//726. 原子的数量
//给定一个化学式formula(作为字符串),返回每种原子的数量。
//
//原子总是以一个大写字母开始,接着跟随0个或任意个小写字母,表示原子的名字。
//
//如果数量大于 1,原子后会跟着数字表示原子的数量。如果数量等于 1 则不会跟数字。例如,H2O 和 H2O2 是可行的,但 H1O2 这个表达是不可行的。
//
//两个化学式连在一起是新的化学式。例如H2O2He3Mg4 也是化学式。
//
//一个括号中的化学式和数字(可选择性添加)也是化学式。例如 (H2O2) ... |
package Subdomain_Visit_Count
import (
"fmt"
"strconv"
"strings"
)
func subdomainVisits(cpdomains []string) []string {
var rst []string
var visits = make(map[string]int)
for _, v := range cpdomains {
splitNum := strings.Split(v, " ")
count, _ := strconv.Atoi(splitNum[0])
subDomains := splitNum[1]
visi... |
/**
* @Author: lzw5399
* @Date: 2021/1/16 21:43
* @Desc: 流程实例
*/
package controller
import (
"net/http"
"strconv"
"workflow/global/response"
"workflow/model/request"
"workflow/service"
"github.com/labstack/echo/v4"
)
var (
instanceSvc service.InstanceService = service.NewInstanceService()
)
// 创建新的实例
fu... |
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"regexp"
"strings"
)
type HashServer struct {
Url string
ResponseRegexp string
}
func main() {
fmt.Println(`
#####################################
# MD5 Cracker #
#-----------------------------... |
package main
import (
"fmt"
"reflect"
)
func main() {
fmt.Println("Hello, world")
fmt.Println("0", reflect.TypeOf(0).Name())
fmt.Println("2 ** 8 ", reflect.TypeOf(256).Name())
fmt.Println("2 ** 32 ", reflect.TypeOf(4294967296).Name())
fmt.Println("2 ** 64 ", reflect.TypeOf(184467440737095... |
package main
import (
"errors"
"fmt"
"log"
"net"
"net/http"
"os"
"github.com/gin-gonic/gin"
"github.com/sony/sonyflake"
)
func machineID() (uint16, error) {
ipStr := os.Getenv("MY_IP")
if len(ipStr) == 0 {
return 0, errors.New("'MY_IP' environment variable not set")
}
ip := net.ParseIP(ipStr)
if len(i... |
package main
import (
"encoding/json"
"fmt"
"github.com/julienschmidt/httprouter"
"io/ioutil"
"log"
"net/http"
"regexp"
)
type Anniversary struct {
Batchcomplete string `json:"batchcomplete"`
Warnings struct {
Extracts struct {
message string `json:"*"`
} `json:"extracts"`
} `json:"warnings"`
Q... |
package store
import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
"github.com/golang-migrate/migrate/v4"
"github.com/golang-migrate/migrate/v4/database/postgres"
_ "github.com/golang-migrate/migrate/v4/source/file"
_ "github.com/golang-migrate/migrate/v4/source/github"
"github.com/pkg/errors"
"nidavel... |
// Copyright (c) 2016-2019 Uber Technologies, 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... |
package template
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path"
"text/template"
)
// Template include template's infomation.
type Template struct {
Manifest Manifest
Args []Args
}
// NewTemplate return a new template instance.
func NewTemplate(templateURL string, options []stri... |
package BuddySimulator
import (
"math"
"fmt"
)
type Memory struct {
size uint
height uint
freeLists [][]*Block
}
func NewMemory(size uint) (*Memory, error) {
floatDepth := math.Log2(float64(size))
if math.Floor(floatDepth) != floatDepth {
return nil, fmt.Errorf("size must be a power of 2; got %d", ... |
package router
import (
"editorApi/controller/editorapi"
"editorApi/middleware"
"github.com/gin-gonic/gin"
)
func InitClassWeixinRouter(Router *gin.RouterGroup) {
LangRouter := Router.Group("editor").Use(middleware.CORSMiddleware())
{
LangRouter.POST("class_weixin/list", editorapi.ClassWeixinList)
LangRoute... |
package modules
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"github.com/spf13/cobra"
"golang.org/x/oauth2"
)
var baseUrl = "https://api.github.com"
type UserPlan struct {
Name string `json:"name"`
Space int64 `json:"space"`
PrivateRepo int64 `... |
package goudpscan_test
import (
"context"
"errors"
"net"
"sync"
"testing"
"time"
"github.com/KernelPryanic/goudpscan/goudpscan"
"github.com/KernelPryanic/goudpscan/unsafe"
"github.com/rs/zerolog/log"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNewOptions(t *testin... |
package server
import (
"github.com/Alireza-Ta/goask/model"
"github.com/Alireza-Ta/goask/validation"
"github.com/gin-gonic/gin"
"net/http"
"net/url"
"strconv"
)
//ReplyStore manages encapsulated database access.
type ReplyStore interface {
ListReply(query url.Values) (model.Replies, error)
CreateReply(r *mode... |
package main
import (
"encoding/json"
"fmt"
"html/template"
"io/ioutil"
"net/http"
"sort"
"strings"
"time"
"github.com/caarlos0/env"
)
type config struct {
GithubToken string `env:"GHTOKEN"`
Authors string `env:"AUTHORS"`
RequiredPRCount int `env:"REQUIRED_PR_COUNT"`
RefreshInterval int ... |
package views // import "github.com/jenkins-x/octant-jx/pkg/plugin/views"
import (
"html"
"strings"
"github.com/jenkins-x/jx-logging/v3/pkg/log"
v1 "github.com/jenkins-x/jx-api/v4/pkg/apis/jenkins.io/v1"
"github.com/jenkins-x/octant-jx/pkg/common/pluginctx"
"github.com/jenkins-x/octant-jx/pkg/common/viewhelper... |
package godb
import (
"bytes"
"unsafe"
)
// database btree node interface
type dbBTreeNode interface {
hasKey(k []byte) int // returns index of matching key if it exists, otherwise -1
}
// node represents a btree's node of order M.
// if M is 128 a node will occupy 4096 bytes.
// to ensure that a node has only 40... |
package protocol
import (
)
const (
Req = "req"
Res = "res"
MethodNodeInfo = "node.info"
MethodAgentInfo = "agent.info"
MethodExecScript = "script.exec"
MethodCreateFile = "file.create"
StatusOK = "ok"
StatusError = "error"
)
type Node struct {
Hostname string `json:"hostn... |
package export
import (
"fmt"
"io/ioutil"
"main/src/config"
"github.com/rs/zerolog/log"
"gopkg.in/yaml.v3"
)
type NodeExporterWinTelemetry struct {
Addr string `yaml:"addr"`
Path string `yaml:"path"`
MaxRequests int `yaml:"max-requests"`
}
type NodeExporterWinScrape struct {
TimeoutMargin ... |
package main
import (
"billable/api"
"billable/config"
"flag"
"fmt"
"log"
"net/http"
// "os"
_ "github.com/denisenkom/go-mssqldb"
"github.com/gorilla/mux"
"github.com/rs/cors"
)
var (
app = &api.App{}
)
func main() {
var configDir string
flag.StringVar(&configDir, "config", ".", "directory location o... |
package ravendb
// CompareExchangeValue represents value for compare exchange
type CompareExchangeValue struct {
Key string
Index int64
Value interface{}
}
// NewCompareExchangeValue returns new CompareExchangeValue
func NewCompareExchangeValue(key string, index int64, value interface{}) *CompareExchangeValue {
... |
/*
1 slice_reversal.go
// reverse reverses the contents of s in place
func reverse(s []int)
Output some slices before and after reversal.
*/
package main
import (
"fmt"
"sort"
"rand"
)
// reverse reverses the contents of s in place
func reverse(s []int){
j := len(s) - 1
/* TODO: can't figure out how to pass... |
package redis
import "time"
// connection redis const
const (
Host = "127.0.0.1"
Port = 6379
)
// config redis
const (
// set time key expiration on second
SetTimeExp = 1 * time.Minute
)
// possible key caching data
const (
// key for detail data user profile
UserProfile = "user_profile:id:%d"
// key for de... |
package tq
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestManifestDefaultsToFixedRetries(t *testing.T) {
assert.Equal(t, 8, NewManifest().MaxRetries())
}
func TestRetryCounterDefaultsToFixedRetries(t *testing.T) {
rc := newRetryCounter()
assert.Equal(t, 8, rc.MaxRetries)
}
func TestRetryCo... |
package process
import (
"context"
"errors"
"net"
"strings"
"time"
"github.com/coredns/coredns/plugin"
"github.com/miekg/dns"
"github.com/ajruckman/ContraCore/internal/functions"
"github.com/ajruckman/ContraCore/internal/system"
)
func DNS(name string, next plugin.Handler, ctx context.Context, w dns.Respon... |
package args
// Initiative type.
type Initiative string
const (
INITIATIVE_NEVER Initiative = "never"
INITIATIVE_AUTO = "auto"
INITIATIVE_MANUAL = "manual"
)
// PatchType represents the type of a binary patch, if any. Only bsdiff is supported
type PatchType string
const (
PATCHTYPE_BSDI... |
package main // version 0.0.3
import (
"bufio"
"fmt"
"os"
"strings"
"time"
"github.com/gempir/go-twitch-irc"
"github.com/sirpinwheel/overseer/handlers"
"github.com/sirpinwheel/overseer/settings"
"github.com/sirpinwheel/overseer/utils"
)
// BotClient - exportin connection
var BotClient *twitc... |
package database
import (
"context"
"database/sql"
"errors"
"fmt"
"strings"
"github.com/tahmooress/motor-shop/internal/entities/models"
)
func (m *Mysql) CreateBuyFactor(ctx context.Context, factor models.Factor, shopID models.ID) (*models.Factor, error) {
tx, err := m.db.Begin()
if err != nil {
return nil... |
package selector
import (
"context"
"errors"
"math/rand"
)
type RandomSelect struct {}
func (r *RandomSelect) Name () string {
return "random"
}
func (r *RandomSelect) Select (ctx context.Context, nodes []*Node) (*Node, error) {
if len(nodes) == 0 {
return nil, errors.New("NO_NODES")
}
var indexMap map[i... |
package events
import (
"fmt"
"github.com/Phala-Network/go-substrate-rpc-client/v3/types"
"github.com/vedhavyas/go-subkey/scale"
)
type BlockRewardInfo struct {
Seed types.U256 `json:"seed"`
OnlineTarget types.U256 `json:"onlineTarget"`
ComputeTarget types.U256 `json:"computeTarget"`
}
type PayoutRe... |
// +build windows
package adasync
import (
"fmt"
"testing"
"time"
)
func TestScanDrives(t *testing.T) {
t.Skip() //annoying test requiring human interaction
drives = make([]string, 0)
detectDrives()
fmt.Println(drives)
fmt.Println("Plug in drive")
time.Sleep(15 * time.Second)
newDrives, _ := detectDrives()... |
package godash
import (
"fmt"
"reflect"
)
// Filter out elements that fail the predicate.
//
// Input of type slice is supported as of now.
// Output is a slice in which filtered-in elements are stored.
// PredicateFn function is applied on each element of input to determine to filter or not
//
// Validations:
//
/... |
package api
func CurrentLoginName(client *Client, hostname string) (string, error) {
var query struct {
Viewer struct {
Login string
}
}
err := client.Query(hostname, "UserCurrent", &query, nil)
return query.Viewer.Login, err
}
func CurrentUserID(client *Client, hostname string) (string, error) {
var quer... |
// Copyright 2020 Insolar Network Ltd.
// All rights reserved.
// This material is licensed under the Insolar License version 1.0,
// available at https://github.com/insolar/block-explorer/blob/master/LICENSE.md.
package main
import (
"context"
"fmt"
"github.com/insolar/insconfig"
"gopkg.in/gormigrate.v1"
"git... |
package ml
import (
"bytes"
"fmt"
tf "github.com/galeone/tensorflow/tensorflow/go"
"github.com/galeone/tensorflow/tensorflow/go/op"
tg "github.com/galeone/tfgo"
"image"
"io"
"io/ioutil"
"os"
"strings"
)
type Coco struct {
model *tg.Model
labels []string
}
const path = "files/models/my_model/"
// NewCoc... |
package main
import (
"fmt"
"github.com/OlaleyeJumoke/GoInterfaceAndStruct/organization"
)
func main() {
p := organization.NewPerson("Jumoke", "Olaleye", organization.NewEuropeanUnionIdentifier("123456789", "Germany"))
fmt.Println(p)
fmt.Println(p.FullName())
err := p.SetTwitterHandler("@jumoke")
if err != ni... |
package main
import (
"bufio"
"fmt"
"io"
"os"
"strconv"
"strings"
)
func main() {
solve(os.Stdin, os.Stdout)
}
func solve(stdin io.Reader, stdout io.Writer) {
sc := bufio.NewScanner(stdin)
sc.Scan()
n, _ := strconv.Atoi(sc.Text())
sc.Scan()
k, _ := strconv.Atoi(sc.Text())
r, x, y := []int{}, []int{}, []... |
package main
import (
"encoding/json"
"errors"
"fmt"
"github.com/shirou/gopsutil/net"
log "github.com/sirupsen/logrus"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
"time"
)
// Define the metrics we wish to expose
var netIndic... |
package crd
import (
"context"
"log"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
api_v1 "github.com/cyberark/secretless-broker/pkg/apis/secretless.io/v1"
secretlessClientse... |
package set1
import (
"errors"
"fmt"
"math"
)
func hammingDistance(s1 []byte, s2 []byte) (int, error) {
if len(s1) != len(s2) {
return -1, errors.New("Undefined for strings of unequal length")
}
s1Binary := bytesToBinary(s1)
s2Binary := bytesToBinary(s2)
distance := 0
for i := range s1Binary {
if s1Bi... |
package gw
import (
"fmt"
"github.com/oceanho/gw/libs/gwreflect"
"reflect"
"sync"
)
type ObjectTyper struct {
Name string
DependOn []TyperDependency
Typer reflect.Type
ActualValue reflect.Value
newAPI reflect.Value
IsPtr bool
}
const (
IStoreName = "github.com/ocea... |
// Copyright 2021 Red Hat, Inc. and/or its affiliates
//
// 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 applic... |
package miembro
import (
log "commodus/internal/logger"
model "commodus/model"
miembro "commodus/model/miembro"
http "net/http"
schema "github.com/gorilla/schema"
echo "github.com/labstack/echo/v4"
)
// Constants
var systemError model.Error = model.Error{
Slug: "internal",
Message: "Failed to save due to ... |
package agent
import (
"agent/net"
)
type SSHAgent struct {
Commands chan string
Client *net.SSHClient
quit_chan chan bool
}
func New(user string, privateKey string, host string) *SSHAgent {
agent := new(SSHAgent)
agent.quit_chan = make(chan bool)
agent.Client = net.NewSSHClient(user, privateKey, host)
a... |
package rcl
import (
"math"
"sort"
)
// Pos is offset in bytes in current file
type Pos int
type Position struct {
File string
Offset int // offset in bytes, pos from 0
Line int // line number, pos from 1
Column int // column number
}
type File struct {
name string
lines []int // offset of the first ch... |
// 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 printpreview provides support for controlling Chrome print preview
// directly through the UI.
package printpreview
import (
"context"
"time"
"chromiumos/tast... |
package main
import (
"fmt"
"os"
. "github.com/carlpett/winlsa"
)
func main() {
luids, err := GetLogonSessions()
if err != nil {
fmt.Println("GetLogonSessions:", err)
os.Exit(1)
}
for _, luid := range luids {
sd, err := GetLogonSessionData(&luid)
if err != nil {
fmt.Println("LsaGetLogonSessionData... |
package main
import (
"encoding/json"
_ "encoding/json"
"fmt"
gorilla "github.com/gorilla/schema"
//"github.com/json-iterator/go"
"log"
"net/http"
_ "net/http/pprof"
)
var decoder = gorilla.NewDecoder()
type User struct {
Years int
Balance float32
Rating float32
Age int
AccountTyp... |
package main
import (
"fmt"
"io"
"os"
"github.com/Cloud-Foundations/Dominator/lib/log"
)
func listGroupMethodsSubcommand(args []string, logger log.DebugLogger) error {
if err := listGroupSMs(os.Stdout, args[0], args[1], logger); err != nil {
return fmt.Errorf("Error listing group methods: %s", err)
}
return... |
// 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, ... |
// Copyright 2017 Authors of Cilium
//
// 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 ... |
package odoo
import (
"fmt"
)
// ProcurementRule represents procurement.rule model.
type ProcurementRule struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Action *Selection `xmlrpc:"action,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
Compan... |
package controller
import (
"fmt"
"github.com/saxon134/go-utils/saData"
"github.com/saxon134/go-utils/saData/saHit"
"github.com/saxon134/go-utils/saOrm"
"github.com/saxon134/workflow/api"
"github.com/saxon134/workflow/db"
"github.com/saxon134/workflow/db/chat"
"github.com/saxon134/workflow/db/job"
"github.com... |
/*
Copyright 2020 The Skaffold 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 writing, sof... |
package google
import (
"go.opencensus.io/trace"
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/tracing"
)
type Config struct {
ProjectID string
MetricPrefix string
Fraction float64
}
func (c *Config) NewTracer() error {
if !envIsSet() {
return errors.ThrowInvalidArgumen... |
package main
import (
//"encoding/binary"
//"fmt"
"math/rand"
)
func _Fbase_107__rand_init() {
rand.Seed(_FgenRand_int64__())
} // _Fbase_107__rand_init
|
// 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"
"time"
"chromiumos/tast/common/shillconst"
"chromiumos/tast/common/testexec"
"chromiumos/tast/ctxutil"
"chromiumos/tast/local/cell... |
package util
import (
"bytes"
"encoding/json"
"fmt"
"math"
"math/rand"
"os"
"strconv"
"time"
"reflect"
)
const (
defaultRandomInt64Limit = int64(10000)
defaultRandomInt32Limit = int32(10000)
defaultRandomStringLength = int(6)
)
func MinInt(a, b int) int {
return int(math.Min(float64(a), float64(b))... |
package main
import (
"struct-package/management"
"fmt"
)
func main() {
user := management.User{ 3, "Adam", "Nasrudin", "Adam@gmail.com", true}
user2 := management.User{ 3, "Alifah", "Nurdianti", "alifah@gmail.com", true}
users := []management.User{user, user2}
group := management.Group{"Group Belajar", user,... |
package memutil
import (
"fmt"
"github.com/wetware/ww/internal/mem"
capnp "zombiezen.com/go/capnproto2"
)
// Alloc allocates a new memory segment.
func Alloc(a capnp.Arena) (mem.Any, error) {
_, seg, err := capnp.NewMessage(a)
if err != nil {
return mem.Any{}, fmt.Errorf("alloc error: %w", err)
}
// TODO(p... |
package goc
import "sort"
type item struct {
key string
val interface{}
lastVis int64
}
type lruCache struct {
cap, maxCap int
logicClock int64
m map[string]item
}
func (c *lruCache) set(key string, val interface{}) {
c.cap++
c.logicClock++
c.m[key] = item{key, val, c.logicClock}
// Di... |
package unload
import (
"bufio"
"io"
"net/textproto"
"sync"
)
// see https://golang.org/src/net
var (
bufioReaderPool sync.Pool
textprotoReaderPool sync.Pool
)
func newTextprotoReader(br *bufio.Reader) *textproto.Reader {
if v := textprotoReaderPool.Get(); v != nil {
tr := v.(*textproto.Reader)
tr.R ... |
package hash
import "github.com/VIVelev/btcd/crypto/hash/xripemd160"
// Implementing SHA-256 from scratch was fun, however, for RIPEMD160
// I am taking an existing implementation.
func Ripemd160(data []byte) [20]byte {
h := xripemd160.New()
h.Write(data)
var ret [20]byte
copy(ret[:], h.Sum(nil))
return ret
}
|
/* ######################################################################
# Author: (zhengfei@fcadx.cn)
# Created Time: 2019-07-03 17:49:25
# File Name: handlers_test.go
# Description:
####################################################################### */
//go test -v -tags consul ./handlers -run TestGetByIds -pwd... |
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
"io/ioutil"
"log"
"net/http"
"runtime"
"time"
)
func getFuturesAccountBalance() []byte {
timeStamp := makeTimestamp()
secret := "BfqSCwpNCslkepaOO7dTejFRz5thaGiTUBX1p4fZp6sDPDuJrtmNt6Wse9hMpTOF"
data := fmt.Sprintf("timestamp=%d", t... |
package cache
import (
"bytes"
"math"
"strconv"
"testing"
)
func TestRender(t *testing.T) {
s := new(serializer)
s.add("I1", &storeEntry{Values: []int64{4, 8}, Counters: []uint32{4, 4}, Cnt: 4})
s.add("I2", &storeEntry{Values: []int64{0, 0}, Counters: []uint32{0, 0}, Cnt: 0})
want := `{"status":"ok","data":... |
package leetcode
import "sort"
func rearrangeBarcodes(barcodes []int) []int {
m := map[int]int{}
for _, v := range barcodes {
m[v]++
}
content := make([][]int, 0, len(m))
for k, v := range m {
content = append(content, []int{k, v})
}
sort.Slice(content, func(i, j int) bool {
return content[i][1] > con... |
// Copyright 2020 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 metrics
import "github.com/cerana/cerana/provider"
// Metrics is a provider of system info and metrics functionality.
type Metrics struct{}
// RegisterTasks registers all of Metric's task handlers with the server.
func (m *Metrics) RegisterTasks(server *provider.Server) {
server.RegisterTask("metrics-cpu", ... |
// Copyright 2017 The Kubernetes 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 a... |
package main
// https://golang.org/pkg/fmt/
// https://golang.org/pkg/time/
import (
"fmt"
"time"
)
func main() {
fmt.Println("Welcome to the playground!")
fmt.Println("The time is ", time.Now())
}
|
package exec
import (
"github.com/araddon/qlbridge/expr"
)
// exec.Visitor implements standard Sql Visit() patterns to create
// a job Builder.
// An implementation of Visitor() will be be able to execute/run a Statement
type Visitor interface {
VisitPreparedStmt(stmt *expr.PreparedStatement) (interface{}, error)
... |
package main
// Leetcode 1111. (medium)
func maxDepthAfterSplit(seq string) []int {
l, r := 0, 0
res := make([]int, len(seq))
for i := range seq {
if seq[i] == '(' {
res[i] = l
l = (l + 1) % 2
} else {
res[i] = r
r = (r + 1) % 2
}
}
return res
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.