text stringlengths 11 4.05M |
|---|
package seev
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document02800101 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:seev.028.001.01 Document"`
Message *AgentCADeactivationInstructionV01 `xml:"AgtCADeactvtnInstr"`
}
func (d... |
package ztimer
import (
"log"
"math"
"sync"
"time"
)
//时间轮调度器
//依赖模块 delayfunc.go timer.go timewheel.go
const (
//默认缓冲触发的队列大小
MAX_CHAN_BUF = 2048
//默认最大误差时间
MAX_TIME_DELAY = 100
)
type TimerScheduler struct {
//当前调度器的最高优先级
tw *TimeWheel
//定时器编号累加器
idGen uint32
//已经触发定时器channel
triggerChan chan *DelayFu... |
// Copyright (c) 2018 Benjamin Borbe All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// The kafka-version-collector collects available versions of software and publish it to a topic.
package main
import (
"context"
"fmt"
"net/http"
"os"
... |
package main
import (
"bufio"
"fmt"
"os"
"github.com/nu7hatch/gouuid"
. "../middleware"
)
func readNotifications(publisher *TopicPublisher, session *TopicSession,topic string, channel (chan int)){
i := 0
for{
messageFromInput := sendMessage()
uuid_, _ := uuid.NewV4()
publisher.Send(session... |
package main
import (
"fmt"
)
//請將以下程式以物件導向方式重新撰寫,並利用Interface建立相關物件
// type AnimalsType int
// const (
// Duck AnimalsType = iota
// Dog
// Tiger
// )
// func New(t AnimalsType) string {
// switch t {
// case Duck:
// return "Pack Pack"
// case Dog:
// return "Wow Wow"
// case Tiger:
// return "H... |
package service
import (
"encoding/json"
"errors"
"github.com/gin-gonic/gin"
"github.com/godcong/role-manager-server/model"
"github.com/godcong/role-manager-server/permission"
log "github.com/sirupsen/logrus"
"strings"
)
// MaxMultipartMemory ...
const MaxMultipartMemory = 8 << 20
// LoginCheck ...
func Login... |
package PDU
import (
"github.com/andrewz1/gosmpp/Data"
"github.com/andrewz1/gosmpp/Exception"
"github.com/andrewz1/gosmpp/Utils"
)
type AlertNotification struct {
Request
}
func NewAlertNotification() *AlertNotification {
a := &AlertNotification{}
a.Construct()
return a
}
func (c *AlertNotification) Constru... |
package render
import (
"github.com/eriklupander/rt/internal/pkg/config"
"github.com/eriklupander/rt/internal/pkg/mat"
"github.com/stretchr/testify/assert"
"math"
"testing"
)
func TestReflectedColorForNonreflectiveMaterial(t *testing.T) {
w := mat.NewDefaultWorld()
rc := Context{world: w}
r := mat.NewRay(mat... |
package db
import "os"
type DB interface {
InitDB(conn map[string]string)
AddToDB(key string, val string)
ReadFromDB(id string) (string, error)
}
func CreateDB() DB {
params := make(map[string]string)
tmp := os.Getenv("MYSQL_SERVICE_HOST")
if tmp == "" {
tmp = "mysql"
}
param... |
package utils
import (
"net/http"
"io/ioutil"
"log"
"strings"
"bytes"
"fmt"
)
func GetContent(url string) string{
resp, err := http.Get(url)
if err != nil || resp == nil{
log.Printf("%s url connection issue",url)
return ""
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != ... |
package cmd
import (
"bytes"
"copyto/logic"
"fmt"
"github.com/gookit/color"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"io"
"testing"
)
type mockprn struct {
w *bytes.Buffer
}
func (m *mockprn) String() string {
return m.w.String()
}
func newMockPrn() logic.Printer {
return &mockprn{w:... |
package main
import (
"github.com/fleegrid/core"
"github.com/fleegrid/nat"
"github.com/fleegrid/pkt"
"github.com/fleegrid/sh"
"github.com/fleegrid/tun"
"net"
"syscall"
)
// DefaultServerSubnet default subnet for server
const DefaultServerSubnet = "10.152.219.2/24"
// Server Server context
type Server struct {... |
package compute
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
const (
// ServiceDownActionNone indicates no action will be taken when a pool service is down.
ServiceDownActionNone = "NONE"
// ServiceDownActionDrop indicates that a pool service will be dropped when it is down.
ServiceDownActionDrop = ... |
package main
import (
"github.com/alecthomas/pathways"
"net/http"
)
type KeyValueService struct {
service *pathways.Service
kv map[string]string
}
func KeyValueServiceMap(root string) *pathways.Service {
s := pathways.NewService(root)
str := ""
s.Path("/").Name("List").Get().APIResponseType(map[string]st... |
package main
import "fmt"
var z int
var a = 3
var b = 4
var c = 5
func tinggiSegitiga() int {
z = a + b
return z
}
func main() {
// assignmen operator
var x, o int
x += 1
x -= 1
// unary operator
x++
x--
var p = 100
fmt.Println(tinggiSegitiga())
fmt.Println(x, o, p)
}
|
package ingress
import (
"context"
"kourier/pkg/envoy"
"kourier/pkg/generator"
"knative.dev/pkg/tracker"
"knative.dev/serving/pkg/apis/networking/v1alpha1"
"knative.dev/pkg/network"
apierrors "k8s.io/apimachinery/pkg/api/errors"
kubeclient "k8s.io/client-go/kubernetes"
corev1listers "k8s.io/client-go/list... |
package server
import (
"io"
"log"
"net/http"
"os"
"service-import-data/repository"
"service-import-data/service"
)
type httpServer struct {
http.Handler
}
func NewServer() Storage {
return new(httpServer)
}
//Init new routes
func (h *httpServer) NewRoutes() {
log.Println("Init Routes")
router := http.New... |
// From https://github.com/aaronhackney/gowhois
package main
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"sync"
log "github.com/sirupsen/logrus"
)
type ReturnJSON struct {
WhoisRecord *Whois `json:"whoIsRecord"`
ContactRecord *ContactRecord `json:"ContactRecord,omitempty"`
}
ty... |
package openapi
import "encoding/json"
// OpenAPI represents the root document object of
// an OpenAPI document.
type OpenAPI struct {
OpenAPI string `json:"openapi" yaml:"openapi"`
Info *Info `json:"info" yaml:"info"`
Servers []*Server `json:"servers,omite... |
package curd
import (
"testing"
"github.com/stretchr/testify/assert"
)
var (
db = NewDB(
"test",
"test",
"",
"3306",
"test",
)
)
type Order struct {
ID int64 `db:"id"`
Status int `db:"status"`
}
func TestSelect(t *testing.T) {
ins := make([]*Order, 0)
err := db.R(
"order",
[]string{"id"... |
package logger
type multiBackend struct {
bes []Backend
}
func NewMultiBackend(bes ...Backend) (*multiBackend, error) {
var b multiBackend
b.bes = bes
return &b, nil
}
func (self *multiBackend) Log(s Severity, msg []byte) {
for _, be := range self.bes {
be.Log(s, msg)
}
}
func (self *multiBackend) Close() {... |
package main
import (
"fmt"
"net/http"
"os"
"time"
"github.com/getsentry/sentry-go"
"github.com/go-chi/chi"
"github.com/joho/godotenv"
"github.com/kelseyhightower/envconfig"
"go.uber.org/zap"
"rayyildiz.dev/app/internal/infra" // FIXME if your change your module name in `go.mod` file, don't forget to change... |
package main
import "github.com/torbensky/go-logfilter/example"
func main() {
example.Run()
/*
Output:
debug:File1
info:File1
warning:File1
error:File1
warning:File2
error:File2
*/
}
|
package gex
import (
"io"
"io/ioutil"
"log"
"os"
"github.com/izumin5210/execx"
"github.com/pkg/errors"
"github.com/spf13/afero"
"github.com/izumin5210/gex/pkg/manager"
"github.com/izumin5210/gex/pkg/manager/dep"
"github.com/izumin5210/gex/pkg/manager/mod"
"github.com/izumin5210/gex/pkg/tool"
)
// Config ... |
package config
import (
"encoding/json"
"io/ioutil"
)
type Target struct {
Host string
JQuery string
}
type Config struct {
IP string
Port string
Routes map[string]Target
AllowedQueryParameters []string
TimePerRequest int64
BurstRequests int64
}
func LoadConfig(path string) (*Config, error) {
raw, err :=... |
package container
import (
"os"
"syscall"
"time"
"github.com/criyle/go-sandbox/pkg/mount"
"github.com/criyle/go-sandbox/pkg/rlimit"
"github.com/criyle/go-sandbox/pkg/seccomp"
"github.com/criyle/go-sandbox/runner"
)
// cmd is the control message send into container
type cmd struct {
DeleteCmd *deleteCmd // de... |
package model
import (
"time"
)
// AuthenticationAttempt represents an authentication attempt row in the database.
type AuthenticationAttempt struct {
ID int `db:"id"`
Time time.Time `db:"time"`
Successful bool `db:"successful"`
Banned bool `db:"banned"`
Username ... |
package pipeline
import (
"sync"
"github.com/sherifabdlnaby/prism/app/pipeline/node"
"github.com/sherifabdlnaby/prism/pkg/job"
)
//recoverAsyncJobs checks pipeline's persisted unfinished jobs and re-apply them
func (p *pipeline) recoverAsyncJobs() error {
JobsList, err := p.bucket.GetAllAsyncJobs()
if err != n... |
package recipient
type RecipientType string
const (
Server RecipientType = "server"
Namespace RecipientType = "namespace"
Workflow RecipientType = "workflow"
Instance RecipientType = "instance"
Mirror RecipientType = "mirror"
)
func (rt RecipientType) String() string {
return string(rt)
}
|
package vo
type PesertaID string
type PesertaIDRequest struct {
GenerateID func() string
}
func NewPesertaID(req PesertaIDRequest) (PesertaID, error) {
obj := PesertaID(req.GenerateID())
return obj, nil
}
func (r PesertaID) String() string {
return string(r)
}
|
package catm
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00300104 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:catm.003.001.04 Document"`
Message *AcceptorConfigurationUpdateV04 `xml:"AccptrCfgtnUpd"`
}
func (d *Document... |
package Responsibility_Chain
import "strconv"
type Handler interface {
Handler(handerID int) string
}
type handler struct {
name string
next Handler
handlerID int
}
func NewHandler(name string,next Handler,handlerID int) *handler {
return &handler{
name:name,
next:next,
handlerID:handlerID,
}
}
func (h... |
package compute
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
// VIPPoolMember represents a combination of node and port as a member of a VIP pool.
type VIPPoolMember struct {
ID string `json:"id"`
Pool EntityReference `json:"pool"`
Node VIPNodeReference `j... |
package restserver
import "github.com/prometheus/client_golang/prometheus"
var metricLabelList = []string{"user", "repo", "type"}
var metricBlobWriteTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "rest_server_blob_write_total",
Help: "Total number of blobs written",
},
metricLabelList,
)
var... |
package main
func main() {
}
var keys = map[byte]bool{
'a': true,
'e': true,
'i': true,
'o': true,
'u': true,
}
func maxVowels(s string, k int) int {
left, right := 0, 0
mx := 0
win := 0
for right < len(s) {
if keys[s[right]] {
win++
}
right++
for right-left > k {
if keys[s[left]] {
win... |
package ctx
type ReqId struct {
RequestId string
CurrentRpcId string
NextSubRpcNo int
}
type Context struct {
ReqId ReqId
Data map[string]string
TimeLimit TimeLimit
TTL TTL
}
func NewContext(reqId, currentRpcId string, timelimit TimeLimit, ttl TTL) *Context {
return &Context{
ReqId: ReqId... |
package triviabot
import (
"encoding/json"
"errors"
"fmt"
"html"
"math/rand"
"net/http"
"strings"
"time"
"github.com/malware-unicorn/go-keybase-chat-bot/kbchat"
"github.com/malware-unicorn/go-keybase-chat-bot/kbchat/types/chat1"
"github.com/malware-unicorn/go-keybase-chat-bot/kbchat/types/keybase1"
"githu... |
package service
import (
"fmt"
"time"
"github.com/TRON-US/soter-order-service/common/constants"
"github.com/TRON-US/soter-order-service/common/errorm"
"github.com/TRON-US/soter-order-service/logger"
"github.com/TRON-US/soter-order-service/model"
"github.com/TRON-US/soter-order-service/utils"
"github.com/TRON... |
/*
Nil channel blocks forever for sender and reciever function
*/
package main
import "fmt"
func main() {
var ch chan int
ch <- 2
fmt.Println("VBlocked")
}
|
package stravaclient
import (
"context"
"strconv"
"time"
"github.com/antihax/optional"
"github.com/gobuffalo/envy"
"github.com/tcarreira/roaw2020/strava_client/swagger"
)
// StravaAPI contains a Strava API Client with the necessary context
type StravaAPI struct {
client *swagger.APIClient
ctx context.Cont... |
package jwt
import (
"github.com/dgrijalva/jwt-go"
"google.golang.org/grpc/status"
"time"
)
const (
Jwtkey = "com.hive-and-cell.com" //TODO !!! Change that
TokenExpired = 34
InvalidToken = 35
)
func CheckJwt(tokenString string) error {
claims := jwt.MapClaims{}
_, err := jwt.ParseWithClaims(tokenString... |
package main
import (
"basic-app-server/config"
"basic-app-server/core"
apperr "basic-app-server/errors"
"basic-app-server/logger"
"fmt"
"os"
"path"
"time"
"github.com/coreos/go-systemd/daemon"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)
const SOFTWARE_NAME = "UNKNOWN_SOFTW... |
package main
import (
"fmt"
"log"
"os"
"strconv"
)
const usage = `
usage:
crawl <starting-url> [num-workers=1]
If not specified, the number of workers will
default to 1. To specify more workers, pass
an integer as the second command-line argument.
`
const defaultNumWorkers = 1
type crawlResults struct {
pageI... |
package actors
import "github.com/dpordomingo/learning-exercises/ant/geo"
//Rover modelates an actor that can walk over a map and look for a target
type Rover interface {
//Init initializes the Ant searching for certain destiny from certain origin
Init(geo.Point, geo.Point)
//Position returns the position of the R... |
package config
import (
"flag"
"os"
"strconv"
"github.com/joho/godotenv"
_ "github.com/joho/godotenv/autoload"
)
var (
goAddrPort = flag.String("goAddrPort", ":8080", "RESTful api port")
)
var appConfig *AppConfig
func init() {
godotenv.Load()
}
// AppConfig mean app config struct
type AppConfig struct {
... |
package schema
import (
"github.com/facebook/ent"
"github.com/facebook/ent/schema/field"
)
// QccEnterpriseData holds the schema definition for the QccEnterpriseData entity.
type QccEnterpriseData struct {
ent.Schema
}
// Fields of the QccEnterpriseData.
func (QccEnterpriseData) Fields() []ent.Field {
return []e... |
package main
import (
"flag"
"fmt"
"net/url"
"os"
"github.com/dah8ra/ch4/omdbapi"
)
const baseurl = "http://omdbapi.com/?"
const basefilename = "../ex4.13/"
var word = flag.String("w", "frozen", "Search word")
func main() {
flag.Parse()
values := url.Values{}
values.Add("t", *word)
values.Add("r", "json")... |
package test_sandbox_sc
import (
"fmt"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance"
"github.com/iotaledger/wasp/packages/coretypes"
"github.com/iotaledger/wasp/packages/coretypes/cbalances"
"github.com/iotaledger/wasp/packages/kv/dict"
"github.com/iotaledger/wasp/packages/kv/kvdecoder"... |
package main
import (
"fmt"
"github.com/cloudfoundry/packit"
"laraboot-buildpacks/poc/laraboot"
)
// To be replaced using go generate
var TaskName = "unset"
func main() {
fmt.Printf("Detecting %s", TaskName)
packit.Detect(laraboot.Detect(TaskName))
}
|
package packages
import (
"fmt"
)
// TestPackageManager is a noop manager.
type TestPackageManager struct{}
func (t *TestPackageManager) Install(pkg, version string) (error, bool) {
return nil, false
}
func (t *TestPackageManager) Unitfile(pkg string) (string, error) {
return "", fmt.Errorf("not found: %s", pkg)... |
package wordCount
import (
"fmt"
"strings"
)
func WordCount(text string) map[string]int {
words := strings.Fields(text)
wordsCount := map[string]int{}
for _, word := range words {
wordsCount[strings.ToLower(word)]++
}
fmt.Println(wordsCount)
return wordsCount
}
|
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestStart(t *testing.T) {
monitor := tempMonitor{}
assert.NotNil(t, monitor)
}
|
package v1beta2
import (
"errors"
"github.com/devspace-cloud/devspace/pkg/devspace/config/versions/config"
"github.com/devspace-cloud/devspace/pkg/devspace/config/versions/util"
next "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/v1beta3"
"github.com/devspace-cloud/devspace/pkg/util/log"
"gith... |
// Copyright (c) 2017, Daniel Martí <mvdan@mvdan.cc>
// See LICENSE for licensing information
package interp
import (
"bytes"
"context"
"fmt"
"io"
"math"
"os"
"os/user"
"path/filepath"
"sort"
"strings"
"sync"
"time"
"mvdan.cc/sh/syntax"
)
// A Runner interprets shell programs. It cannot be reused once ... |
package crawl
import (
"testing"
"time"
. "./base"
)
func _d(s string) time.Time {
loc, _ := time.LoadLocation("Asia/Shanghai")
d, _ := time.ParseInLocation("2006-01-02 15:04:05", s, loc)
return d
}
func TestM1s2M5s(t *testing.T) {
type Case struct {
m1 []Tdata
m5 []Tdata
}
tests := []Case{
// 09:35... |
// +build nobootstrap
// Contains routines to marshal between internal structures and
// proto-generated equivalents.
// The duplication is unfortunate but it's preferable to needing
// to run proto / gRPC compilers at bootstrap time.
package follow
import (
"errors"
"time"
"core"
pb "follow/proto/build_event"
... |
package models
// RepositoryList contains code repositories implemented by a certain paper.
type RepositoryList struct {
Count int64 `json:"count"`
Next *string `json:"next"`
Previous *string `json:"previous"`
Results []Repository `json:"results"`
}
type Repository struct {
URL s... |
package models
import (
"github.com/gophergala2016/source/core/foundation"
)
type UserTagRepository struct {
RootRepository
}
func NewUserTagRepository(ctx foundation.Context) *UserTagRepository {
return &UserTagRepository{
RootRepository: NewRootRepository(ctx),
}
}
func (r *UserTagRepository) FindLatestByUs... |
package main
import (
"fmt"
"net"
"time"
"github.com/rrawrriw/ite/dhcp"
"github.com/rrawrriw/ite/dictator"
)
func NewCluster() (dictator.Mission, dictator.ResponseChan) {
response := make(dictator.ResponseChan)
dhcpInAddr := net.UDPAddr{
IP: net.ParseIP("255.255.255.255"),
Port: 68,
}
dhcpOutAddr :=... |
package main
import (
_"github.com/go-sql-driver/mysql"
"testxorm/controllers"
"testxorm/db"
// "testxorm/model"
// "net/http"
)
func main(){
// book:=model.Book{
// Name:"book2",
// }
// http.HandleFunc("/insert",controllers.InsertBook1)
controllers.WriteIo("/book",db.GetJson)
controllers.WriteIo("/insert",db.I... |
package smpp34
var (
reqGNFields = []string{}
)
type GenericNack struct {
*Header
mandatoryFields map[string]Field
tlvFields map[uint16]*TLVField
}
func NewGenericNack(hdr *Header) (*GenericNack, error) {
s := &GenericNack{Header: hdr}
return s, nil
}
func (s *GenericNack) GetField(f string) Field {
r... |
package controllers
import (
"crud/models"
"strconv"
"strings"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"github.com/shopspring/decimal"
)
type ConsultaController struct {
beego.Controller
}
func (c *ConsultaController) Get() {
c.TplName = "consulta.tpl"
}
func (c *ConsultaController) Post(... |
package silverfish
import (
entity "silverfish/silverfish/entity"
interf "silverfish/silverfish/interface"
usecase "silverfish/silverfish/usecase"
)
// Silverfish export
type Silverfish struct {
Auth *Auth
Admin *Admin
User *User
Novel *Novel
Comic *Comic
}
// New export
func New(
hashSalt *string,
crawl... |
package removeDuplicates
func removeDuplicates(nums []int) int {
//[1,1,2]
if len(nums) <= 0 {
return 0
}
count := 1
i, j := 0, 0
for j = 1; j < len(nums); j++ {
if nums[j] == nums[j-1] {
continue
}
count++
i++
nums[i] = nums[j]
}
return count
}
|
package main
import (
"log"
"os"
"os/signal"
"syscall"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)
var (
clientset *kubernetes.Clientset
)
func main() {
// setup kubernetes client
clsConfig, err := rest.InClusterConfig()
if err != nil {
log.Fatal(err)
}
clientset, err = kubernetes.NewForC... |
package main
import "fmt"
func two_string() (string, string) {
return "zhong", "ting"
}
func main() {
z, t := two_string()
t, n := two_string()
fmt.Println(z, t, n)
var y string
g, y := two_string()
fmt.Println(g, y)
// 结论:
// 都可以实现变量重声明
}
|
package main
import (
"fmt"
"golang.org/x/tour/tree"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
Inorder(t, ch)
}
func Inorder(t *tree.Tree, ch chan int) {
if t.Left != nil {
Inorder(t.Left, ch)
}
ch <- t.Value
if t.Right != nil {... |
package sol
import "testing"
func TestBasic(t *testing.T) {
testcases := []struct {
input []int
want int
}{
{
input: []int{7, 1, 5, 3, 6, 4},
want: 5,
},
{
input: []int{7, 6, 4, 3, 1},
want: 0,
},
{
input: []int{},
want: 0,
},
{
input: []int{2, 1, 4},
want: 3,
},
{... |
package config
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/instructure-bridge/muss/testutil"
)
func assertExpandWithWarnings(t *testing.T, spec, exp, expStderr, msg string) {
var expanded string
stderr := testutil.CaptureStderr(t, func() {
expanded = expandWarnOnEmpty(spec)
})
... |
// A Tour of Go : Packages, variables, and functions
// https://go-tour-jp.appspot.com/basics/1
package main
import (
"fmt"
"math/cmplx"
"math/rand"
)
// varステートメントで変数を宣言する
var c, python, java bool
func main() {
{
// パッケージ名はインポートパスの最後の要素と同じ名前になる
fmt.Println("1. ", "My Favorite number is", rand.Intn(10))
}
... |
/*
Copyright IBM Corp. 2017 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 or ag... |
package dns
import (
"github.com/stretchr/testify/assert"
"net"
"testing"
)
func TestgetKnownDomain(t *testing.T) {
knownDomain, _ := getKnownDomain([]string{"ec2-52-38-207-226.us-west-2.compute.amazonaws.com"})
assert.Equal(t, "Amazon AWS", knownDomain)
knownDomain, _ = getKnownDomain([]string{"arn09s10-in-f4.... |
// Package kalman defines a data structure that aggregates measurements.
// Averages/counts measurements that are "close."
// Can quickly apply the current K & L and return the associated N^2.
package kalman
const EPS = 0.1 // Correction factor since KF is nonlinear
type Filter struct {
n int // Number of d... |
package library
import (
"encoding/json"
"errors"
"net/http"
"strings"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/tracing/opentracing"
httptransport "github.com/go-kit/kit/transport/http"
"github.com/go-zoo/bone"
stdopentracing "github.com/opentracing/opentracing-go"
"github.com/solher/kit-crud/cli... |
package Problem0591
func isValid(code string) bool {
res := true
return res
}
|
package kata
import "strings"
func bandNameGenerator(word string) string {
switch {
case word[0] == word[len(word)-1]: {
return (strings.ToUpper(string(word[0])) + string(word[1:len(word)]) + string(word[1:len(word)]))
}
case strings.Contains(word, "-"): {
h := strings.Index(word, "-")
i := h + 1
j := h +... |
package main
import (
"bytes"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
"log"
"os"
)
func main() {
privateKey, err := rsa.GenerateKey(rand.Reader, 128)
if err != nil {
log.Println(err)
return
}
privateKeyDer := x509.MarshalPKCS1PrivateKey(privateKey)
privateKeyBlock := pem.Block{... |
package main
import (
"fmt"
"sync"
)
func main() {
in := gen()
a := factorial(in)
b := factorial(in)
c := factorial(in)
d := factorial(in)
e := factorial(in)
f := factorial(in)
g := factorial(in)
h := factorial(in)
i := factorial(in)
j := factorial(in)
for n := range merge(a, b, c, d, e, f, g, h, i, j... |
package main
import "fmt"
func main() {
fmt.Println(arithmeticTriplets(
[]int{
0, 1, 4, 6, 7, 10,
}, 3))
}
func arithmeticTriplets(nums []int, diff int) int {
ans := 0
for i := 0; i < len(nums); i++ {
for j := i + 1; j < len(nums); j++ {
for k := j + 1; k < len(nums); k++ {
if nums[j]-nums[i] ==... |
func maxProfit(prices []int) int {
res:=0
min:=math.MaxInt16
for _,v:=range prices{
if v<min{
min=v
}
if v-min>res{
res=v-min
}
}
return res
}
|
package main
import (
"context"
"fmt"
"time"
"github.com/GlitchyGlitch/typinger/config"
"github.com/GlitchyGlitch/typinger/test"
"github.com/shurcooL/graphql"
"golang.org/x/oauth2"
)
const tdPath = "postgres/fixtures"
type user struct {
Typename graphql.String `graphql:"__typename"`
ID graphql.String... |
package main
import (
"flag"
"net/http"
"encoding/json"
"log"
"time"
"os"
"strconv"
"io"
"io/ioutil"
"github.com/cloudfoundry-community/go-cfclient"
)
var done chan bool
var target chan []TargetGroup
var (
ApiAddress = flag.String(
"api.address", "",
"Cloud Foundry ... |
package services_test
import (
"errors"
"github.com/cloudfoundry-incubator/notifications/fakes"
"github.com/cloudfoundry-incubator/notifications/models"
"github.com/cloudfoundry-incubator/notifications/web/services"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Upd... |
package types
import "math/big"
const (
AergoSystem = "aergo.system"
AergoName = "aergo.name"
AergoEnterprise = "aergo.enterprise"
MaxCandidates = 30
votePrefixLen = 2
VoteBP = "v1voteBP"
VoteGasPrice = "v1voteGasPrice"
VoteNumBP = "v1voteNumBP"
VoteNamePrice = "v1voteNamePrice"
... |
package skapt_test
import (
"bytes"
"errors"
"io"
"github.com/hoenirvili/skapt"
"github.com/hoenirvili/skapt/argument"
"github.com/hoenirvili/skapt/flag"
gc "gopkg.in/check.v1"
)
type appSuite struct{}
var _ = gc.Suite(&appSuite{})
func handler(ctx *skapt.Context) error {
return nil
}
func (a appSuite) def... |
package main
import (
"log"
"os"
"github.com/abdullah2993/goias3/ias3"
)
var (
accessKey = os.Getenv("IAS3_ACCESS_KEY")
secretKey = os.Getenv("IAS3_SECRET_KEY")
)
func init() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
func main() {
if accessKey == "" || secretKey == "" {
log.Fatalf("unable to find t... |
package grapheme
import (
"bufio"
"bytes"
"strconv"
"strings"
"testing"
"unicode"
"github.com/gioui/uax/internal/testdata"
"github.com/gioui/uax/internal/tracing"
"github.com/gioui/uax/segment"
)
func TestGraphemeClasses(t *testing.T) {
tracing.SetTestingLog(t)
c1 := LClass
if c1.String() != "LClass" {
... |
package main
import "fmt"
func combinationSum(candidates []int, target int) [][]int {
res := [][]int{}
cur := []int{}
combination2(candidates, target, cur, &res, 0)
return res
}
func combination2(candidates []int, target int, cur []int, res *[][]int, begin int) {
if target == 0 {
temp := make([]int, len(cur))... |
package leetcode
/*Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of candy that Bob has.
Since they are friends, they would like to exchange one candy bar each so that after the exchange, they both have the same total am... |
/**
*
* Create BY YooDing
*
* Des: 远程配置文件json数据
*
* Time: 2019/7/6 11:19 AM.
*
* <a href="https://github.com/YooDing/gone">Github</a>
*/
package model
import (
"github.com/bitly/go-simplejson"
"gone/utils"
"os"
"net/http"
"io/ioutil"
)
//
//type ZipUrl struct {
// ZipName string
// ZipPath string
//}
ty... |
/*
This challenge is a slightly different kind of Code Golf challenge. Rather than coding to match IO, you code to match an interface.
Background
Finite state machines are very useful design models for modeling event-based programming.
A state machine is defined by a set of states and tranitions between them.
The ma... |
/*
Copyright 2019 Dmitry Kolesnikov, 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... |
package main
import (
"bytes"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
)
const minimalSocketFilter = `__attribute__((section("socket"), used)) int main() { return 0; }`
func TestCompile(t *testing.T) {
dir := mustWriteTempFile(t, "test.c", minimalSocketFilter)
var dep bytes.Buffer
err := compile(... |
// +build !windows
package server
import (
"context"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
"testing"
"github.com/devspace-cloud/devspace/sync/remote"
"github.com/devspace-cloud/devspace/sync/util"
)
func TestDownstreamServer(t *testing.T) {
fromDir, err := ioutil.TempDir("", "")
if err != nil {
t... |
package cmd
import (
"log"
"github.com/spf13/cobra"
"github.com/yugabyte/yugabyte-db/managed/yba-installer/common"
)
func cleanCmd() *cobra.Command {
var removeData bool
clean := &cobra.Command{
Use: "clean [--all]",
Short: "The clean command uninstalls your YugabyteDB Anywhere instance.",
Long: `
... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/8/15 4:25 下午
# @File : lt_4_有序数组的中位数.go
# @Description :
# @Attention :
*/
package offer
func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {
l1, l2 := len(nums1), len(nums2)
left, right := 0, 0
start1, start2 := 0, 0
for i := 0; i <= (l1+l2)>>... |
/**
Copyright @ 2014 OPS, Qunar Inc. (qunar.com)
Author: tingfang.bao <tingfang.bao@qunar.com>
DateTime: 14-8-20 下午2:57
*/
package utils
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"reflect"
"regexp"
)
/**
正则表达式分组工具
例如
正则表达式(已经编译过):"(?P<name>[A-Za-z]+)-(?P<age>\\d+)"
name和page都是属性名称
字符串str:CGC-3... |
// Copyright 2016 by caixw, All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
// Package syntax 负责对标签语法的解析操作。
package syntax
import (
"log"
"github.com/issue9/is"
"github.com/tanxiaolong/apidoc/locale"
"github.com/tanxiaolong/apidoc/types"
"g... |
package action
import (
"errors"
"github.com/agiledragon/trans-dsl"
"github.com/agiledragon/trans-dsl/test/context"
)
type StubActivateSomething struct {
}
func (this *StubActivateSomething) Exec(transInfo *transdsl.TransInfo) error {
stubInfo := transInfo.AppInfo.(*context.StubInfo)
if stubInfo.X == "test" {
... |
package resource
import (
"time"
)
// DriveData holds the properties of a team drive.
type DriveData struct {
Name string `json:"name"`
Created time.Time `json:"created,omitempty"`
Permissions []Permission `json:"permissions,omitempty"`
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.