text stringlengths 11 4.05M |
|---|
package caaa
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01400102 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.014.001.02 Document"`
Message *AcceptorDiagnosticResponseV02 `xml:"AccptrDgnstcRspn"`
}
func (d *Document... |
// Copyright 2020 Google LLC
//
// 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 ... |
package main
import (
proto "github.com/ankurs/Feed/Feed/Feed_proto"
"github.com/ankurs/Feed/Feed/service"
"github.com/carousell/Orion/orion"
"github.com/carousell/Orion/orion/helpers"
)
func main() {
server := orion.GetDefaultServer("feed")
factory, err := helpers.NewSingleServiceFactory(service.GetServiceFac... |
package main_test
import (
. "code.cloudfoundry.org/smbbroker"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/pivotal-cf/brokerapi/v10"
)
var _ = Describe("Services", func() {
var (
services Services
)
BeforeEach(func() {
var err error
services, err = NewServicesFromConfig("./defau... |
package blockchain
import (
"bytes"
"crypto/sha256"
"encoding/binary"
"fmt"
"log"
"math"
"math/big"
)
// 1) Take the data from the block
// 2) Create a counter (nonce) which starts at 0
// 3) Create a hash of the data + the counter
// 4) Check the hash to see if it meets a set of requirements
// Requiremen... |
package controller
import (
"context"
"fmt"
"strings"
"testing"
"github.com/argoproj/argo/workflow/common"
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo/test"
)... |
/*
Copyright 2021 The KubeVela 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, so... |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
package keystone
import (
comv1 "github.com/openstack-k8s-operators/keystone-operator/pkg/apis/keystone/v1"
util "github.com/openstack-k8s-operators/lib-common/pkg/util"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type bootstrapOptions struct {
Admin... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
type responseJson struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn string `json:"expires_in"`
ExpiresOn string `json:"expires_on"`
NotBefore string `json:"not_before... |
package sys
import (
"os"
"time"
"github.com/cpusoft/goutil/belogs"
"github.com/cpusoft/goutil/conf"
"github.com/cpusoft/goutil/jsonutil"
)
//
func initReset(sysStyle SysStyle) (err error) {
start := time.Now()
belogs.Debug("initReset():will InitReset, sysStyle:", jsonutil.MarshalJson(sysStyle))
// reset db... |
package ag
// IsOwner returns true if the current user is the same as the given user ID.
func (u *User) IsOwner(userID uint64) bool {
return u.GetID() == userID
}
|
/*
Copyright 2021 CodeNotary, Inc. 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 agreed to i... |
package e2e
import (
"context"
"fmt"
"net"
"testing"
"time"
"github.com/devopstoday11/tarian/pkg/clusteragent"
"github.com/devopstoday11/tarian/pkg/podagent"
"github.com/devopstoday11/tarian/pkg/server"
"github.com/devopstoday11/tarian/pkg/server/dbstore"
"github.com/driftprogramming/pgxpoolmock"
"github.c... |
package api
import "encoding/json"
// ConvertInterfaceToJSONBytes converts any interface to json bytes.
func ConvertInterfaceToJSONBytes(input interface{}, inputError error) []byte {
if inputError != nil {
return nil
}
bytes, err := json.Marshal(input)
if err != nil {
return nil
}
return bytes
}
// Convert... |
package pgsql
import (
"database/sql"
"database/sql/driver"
"strconv"
)
// PathArrayFromFloat64Array2SliceSlice returns a driver.Valuer that produces a PostgreSQL path[] from the given Go [][][2]float64.
func PathArrayFromFloat64Array2SliceSlice(val [][][2]float64) driver.Valuer {
return pathArrayFromFloat64Array... |
package memsearch
import (
"errors"
"fmt"
"reflect"
"regexp"
"sort"
"strings"
"github.com/Sirupsen/logrus"
"github.com/manishrjain/gocrud/search"
"github.com/manishrjain/gocrud/x"
)
var log = x.Log("memsearch")
type MemSearch struct {
docs map[string]x.Doc
}
type MemQuery struct {
kind string
Doc... |
package quote
type responseStruct struct {
Contents contentStruct `json:"contents"`
}
type contentStruct struct {
Quotes []quoteStruct `json:"quotes"`
}
type quoteStruct struct {
Quote string `json:"quote"`
Author string `json:author`
}
|
package main
import "fmt"
type Trade struct {
Symbol string
Volume int
Price float64
Buy bool
}
func (t *Trade) Value() float64 { // use a pointer to pass object by reference, not value
value := float64(t.Volume) * t.Price
if t.Buy {
value = -value
}
return value
}
func main() {
t... |
package main
import (
"fmt"
"log"
"net/http"
"github.com/markus-azer/products-service/config"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/markus-azer/products-service/api/handler"
"github.com/markus-azer/products-service/api/me... |
package vulcand
import (
"math/rand"
"github.com/octoblu/vulcand-bundle/registry"
"github.com/vulcand/vulcand/api"
)
// Manager provides server management functions
// for vulcan
type Manager interface {
ShuffledServers() ([]*Server, error)
ServerRm(*Server) error
}
// HTTPManager implements manager over Vulca... |
package easygraph
import "sync"
//Variable respresents a query variable
type variable struct {
Name string
Value interface{}
}
// QueryBuilder is used to create Query Objects
type QueryBuilder struct {
mux sync.Mutex
}
//Query creates and returns a raw query
func (q *QueryBuilder) Query(query string) Query {
r... |
package main
func main() {
func(s string) {
println(s)
}("hello, world!")
}
|
package compute
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
// HealthMonitor represents a load-balancer persistence (stickiness) profile.
type HealthMonitor struct {
ID string `json:"id"`
Name string `json:"name"`
IsNodeCompatible bool `json:"nodeCompatible"`
IsPoolCompat... |
package protocol
import (
"bytes"
"encoding/binary"
"github.com/lucky2me/lucky2me-im/util"
"strconv"
"fmt"
)
func EncodePackage(message []byte) []byte {
return append(IntToBytes(len(message)), message...)
}
func DecodePackage(message []byte, reader chan []byte) []byte {
defer func() {
if err := recover(); ... |
package euclid
// gcd returns the greatest common divisor
func gcd(p, q uint) uint {
if q == 0 {
return p
}
r := p % q
return gcd(q, r)
}
|
package service
import (
"Fcoin/models"
"fmt"
_ "strings"
"time"
"github.com/astaxie/beego"
"github.com/tidwall/gjson"
)
type PriceData struct {
Ts uint64
Asks float64
Bids float64
}
var (
wss = "wss://api.fcoin.com/v2/ws"
price_array = []PriceData{}
price = float64(0)
depth = ""
... |
// Copyright (c) Facebook, Inc. and its affiliates.
// All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
package confighandler
// Rule represents a how a syslog matching rule should look like
type Rule struct {
Ru... |
package weave
import (
"testing"
)
func TestNewAccount(t *testing.T) {
data := []struct {
Email, Hash string
}{
{"john@doe.com", "7wohs32cngzuqt466q3ge7indszva4of"},
{"jane@doe.com", "vuuf3eqgloxpxmzph27f5a6ve7gzlrms"},
{"john@example.com", "kismw365lo7emoxr3ohojgpild6lph4b"},
}
for _, user := range dat... |
package main
import (
"github.com/getsentry/sentry-go"
"os"
"strconv"
"time"
)
func main() {
host := os.Getenv("RANCHER_HOST")
token := os.Getenv("RANCHER_TOKEN")
project := os.Getenv("RANCHER_PROJECT")
filepath := os.Getenv("FILE")
period := 60 * time.Second
if sec, err := strconv.Atoi(os.Getenv("PERIOD_SE... |
/*
This is a model of a forgiving HTML parser. Instead of parsing HTML and extracting attributes, in this code golf, the tag parser will be simple.
Write a function that parses a tag structure and returns its parenthized form. An opening tag consists of one lowercase letter, and a closing tag consists of one uppercas... |
package redis
import (
"strconv"
"time"
"github.com/garyburd/redigo/redis"
"github.com/any-lyu/go.library/errors"
)
// Client redis client
type Client struct {
Pool *redis.Pool
}
const redisNil = "redigo: nil returned" //redis正常返回
func redisOK(err error) (err2 error) {
if err == nil || err.Error() == redisN... |
package main
import (
"testing"
"github.com/rcrowley/go-metrics"
"time"
"math/rand"
"fmt"
)
func TestMeter(t *testing.T) {
p := metrics.NewTimer()
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i< 100; i++ {
x := r.Intn(200)
start := time.Now()
time.Sleep(time.Duration(x) * time.Milli... |
// +build linux
package system
import (
"strconv"
"strings"
pb_info "github.com/mickep76/grpc-exec-example/info"
)
func getCPU(s *pb_info.System) error {
o, err := readFile("/proc/cpuinfo")
if err != nil {
return err
}
cpuID := -1
cpuIDs := make(map[int]bool)
s.CpuCoresPerSocket = 0
s.CpuLogicalCores =... |
package main
import (
"fmt"
"net/http"
"io/ioutil"
"crypto/hmac"
"crypto/sha512"
"strings"
"time"
)
/* ---------------------------------------- */
type IApi interface {
GetDesc() (string)
Request() ([]byte, error)
Parser(body []byte) (error)
Save() (error)
}
func ApiDo(iapi IApi) (err error) {
start := ... |
package main
import (
"fmt"
)
func main() {
name := "josiah"
nameP := &name
fmt.Println(name)
fmt.Println(nameP)
*nameP = "josiahah"
fmt.Println(*nameP)
fmt.Println(name)
}
|
package vaku
import "fmt"
// PathDestroyVersions takes in a PathInput and calls the destroy on 'mount/destroy/path'
// This function only works on versioned (V2) key/value mounts.
func (c *Client) PathDestroyVersions(i *PathInput, versions []int) error {
var err error
// Initialize the input
i.opType = "destroyve... |
package entity
import "time"
// User export
type User struct {
IsAdmin bool `json:"isAdmin" bson:"isAdmin"`
Account string `json:"account" bson:"account"`
Password string `json:"password" bson:"password"`
RegisterDatetime time.Time `json:"registerDatetime" bson:"registerDa... |
// Package identity is a package to avoid a dependency cycle.
package identity
// State is the state for authentication.
type State interface {
SetRawIDToken(rawIDToken string)
}
|
/**
* tag_service
* @author liuzhen
* @Description
* @version 1.0.0 2021/1/28 17:50
*/
package service
import (
"backend/src/module"
"backend/src/repository"
"backend/src/utils"
"reflect"
"strings"
)
// 添加标签
func AddTag(param module.Tag) ResponseBody {
if utils.IsBlank(param.Name) {
return NewParamEmpty... |
package datasetapi
import (
"context"
stypes "github.com/lexis-project/lexis-backend-services-interface-datasets.git/client/staging"
// dtypes "github.com/lexis-project/lexis-backend-services-interface-datasets.git/client/data_set_management"
"github.com/lexis-project/lexis-backend-services-api.git/models"
// "git... |
package main
import "fmt"
/*
map 初始化 ,赋值 遍历 等操作
*/
func main() {
//1、声明时同时初始化
var countryMap = map[string]string{
"China": "Beijing",
"Japan": "Tokyo",
"India": "New Delhi",
"France": "Paris",
"Italy": "Rome",
}
printCountry(countryMap)
// 3、遍历map(无序)
// (1)、key 、value都遍历
for k, v := range... |
package cmd
import (
"encoding/json"
"log"
"os"
"github.com/loqwai/double-blind/study"
"github.com/spf13/cobra"
)
var initCommand = &cobra.Command{
Use: "init",
Short: "Initialize a config file for running a study",
Run: runInit,
Args: cobra.MaximumNArgs(1),
}
func init() {
initCommand.Flags().String... |
package server
import (
"FPproject/Frontend/models"
"encoding/json"
"net/http"
)
func index(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.Redirect(w, r, "/", http.StatusSeeOther)
return
}
tpl.ExecuteTemplate(w, "index.html", nil)
}
func home(w http.ResponseWriter, r *http.Request) {... |
package goSolution
import "testing"
func TestWordFilter_F(t *testing.T) {
wf := Constructor([]string{"apple", "banana", "bana"})
AssertEqual(t, 0, wf.F("a", "e"))
AssertEqual(t, 0, wf.F("", "e"))
AssertEqual(t, 2, wf.F("", ""))
AssertEqual(t, 2, wf.F("b", "na"))
AssertEqual(t, 1, wf.F("b", "banana"))
AssertEqu... |
/*
* Tencent is pleased to support the open source community by making Blueking Container Service available.
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obta... |
package cmd
import (
"log"
"github.com/spf13/cobra"
)
var (
dataPath string
)
var rootCmd = &cobra.Command{
Use: "db-traveller [command]",
Short: "db-traveller is a tool for analysis of okexchain db.",
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
}
func init() {
rootCm... |
package controller
import (
"context"
"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/... |
package main
import (
"errors"
"net/http"
"time"
"github.com/avaldevilap/greenlight/internal/data"
"github.com/go-playground/validator/v10"
)
func (app *application) createAuthenticationTokenHandler(w http.ResponseWriter, r *http.Request) {
var input struct {
Email string `json:"email" validate:"email"`
... |
package webhooks
import (
"github.com/novikk/splitbot/sage"
"github.com/novikk/splitbot/splitter"
)
var lastSpeaker string
var split splitter.Splitter
var sc sage.SageClient
func init() {
split = splitter.Splitter{}
sc = sage.SageClient{}
sc.RefreshToken = "4109e944807d9f7cda0c345fed136564a4a26501"
sc.AccessT... |
package zts
import (
"crypto/tls"
"testing"
"github.com/vespa-engine/vespa/client/go/mock"
)
func TestAccessToken(t *testing.T) {
httpClient := mock.HTTPClient{}
client, err := NewClient("http://example.com", &httpClient)
if err != nil {
t.Fatal(err)
}
httpClient.NextResponseString(400, `{"message": "bad r... |
package main;
func max(nums []int) int {
// Complete code
return -1;
}
func average(nums[]int) float64 {
// Complete code
return -1;
}
func mostFrequentWords(words []string) []string {
// Complete code
return []string{};
}
|
// Copyright 2021 PingCAP, 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 i... |
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ sdk.Msg = &MsgRecordReputation{}
// MsgRecordReputation - struct for recording reputation score
type MsgRecordReputation struct {
Account sdk.AccAddress `json:"creator" yaml:"creator"` // account address associated to reputati... |
package api
import (
"fmt"
"testing"
)
func TestToJSON(t *testing.T) {
fmt.Println("TestToJSON")
b := Book{Title: "Test Title", Author: "Test Author", ISBN: "100001"}
bJSON, err := ToJSON(b)
if err != nil {
fmt.Printf("ToJSON failed with err: %v\n", err)
t.FailNow()
}
expectedJSON := "{\"title\":\"Test Ti... |
/*
Copyright © 2022 SUSE LLC
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, software
dist... |
package main
import (
"bufio"
"context"
"crypto/ecdsa"
"encoding/json"
"flag"
"fmt"
"github.com/davecgh/go-spew/spew"
"github.com/kr/pretty"
"github.com/libp2p/go-libp2p-peer"
pstore "github.com/libp2p/go-libp2p-peerstore"
ma "github.com/multiformats/go-multiaddr"
"log"
"sync"
"time"
)
// This is the ma... |
package ast
// EqualsCondition represents an equality field-value relation.
type EqualsCondition struct {
Field *Field
Value string
}
func (c *EqualsCondition) BuildQuery() string {
return c.Field.BuildQuery() + "=" + c.Value
}
|
package doulivery
import (
"crypto/md5"
"encoding/hex"
"encoding/json"
"fmt"
)
type Mailer struct {
Client *Client
Service string
From string
To []string
Subject string
Body string
Html bool
Files []File
}
type File struct {
Name string
Content []byte
}
func CreateMailer(client *Cl... |
/*
Copyright 2017 The Kubernetes Authors.
Copyright 2021 The TiChi 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 applic... |
package cmd
import (
"crypto/sha1"
"fmt"
"io/ioutil"
"os"
"os/signal"
"syscall"
"github.com/dylanratcliffe/deviant_ingest/ingest"
"github.com/nats-io/nats.go"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// saveCmd represents the save command
var saveCmd = &cobra.Co... |
package 获取
func lowestCommonAncestor(root *TreeNode, p *TreeNode, q *TreeNode) *TreeNode {
return getLCA(root, p, q)
}
// 获取最近公共祖先,不存在则返回nil
func getLCA(root *TreeNode, p *TreeNode, q *TreeNode) *TreeNode {
if root == nil || root == p || root == q {
return root
}
leftSearchResult := getLCA(root.Left, p, q)
rig... |
/*
Package labels64 implements DVID support for 64-bit label images. It simply
wraps the voxels package, setting NumChannels (1) and BytesPerVoxel(8).
*/
package labels64
import (
"github.com/janelia-flyem/dvid/datastore"
"github.com/janelia-flyem/dvid/datatype/voxels"
"github.com/janelia-flyem/dvid/dvid"
)
con... |
package module
import (
"testing"
"gopkg.in/go-playground/assert.v1"
)
func TestRegister(t *testing.T) {
name := "UltraMegaSuperCrusher"
expected := &mockPatcher{}
Register(name, func(c Config) (Patcher, error) {
expected.value = c["key"].(string)
return expected, nil
})
init, err := Lookup(name)
asser... |
package main
import (
"fmt"
)
func main() {
sentence := "peter piper picked a peck of pickled peppers";
word := "pickle";
total := 0;
for i := 0; i < len(sentence)- len(word); i++ {
compStr := sentence[i:i + len(word)]
comp := 0
for j := 0; j < len(word); j++ {
comp++
if word[j] != ... |
// Licensed to SolID under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. SolID licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compli... |
package server
import (
"fmt"
"io"
"log"
"strings"
"sync"
"github.com/NHAS/reverse_ssh/internal"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/terminal"
)
func proxyChannel(sshConn ssh.Conn, newChannel ssh.NewChannel) {
if connections[sshConn] == nil {
newChannel.Reject(ssh.Prohibited, "no remote lo... |
package util
import (
"sync"
)
type SafeMap struct {
data map[interface{}]interface{}
sync.Mutex
}
func NewSafeMap() *SafeMap {
return &SafeMap{data: make(map[interface{}]interface{})}
}
func (m *SafeMap) Set(k, v interface{}) {
m.Lock()
defer m.Unlock()
m.data[k] = v
}
func (m *SafeMap) Get(k inter... |
package day5_2018
import (
loader "aoc/dataloader"
"aoc/test"
"testing"
)
func TestPart1(t *testing.T) {
cases := []test.Case[string, int]{
{loader.Load("sample.txt")[0], 10},
{loader.Load("input.txt")[0], 10888},
}
err := test.Execute(cases, Part1)
if err != nil {
t.Error(err)
}
}
func TestPart2(t *te... |
package utils
import (
"crypto/md5"
"fmt"
"github.com/allentom/youcomic-api/config"
"path/filepath"
"strconv"
"time"
)
func EncodeFileName(fileName string) string {
nowString := time.Now().String()
ext := filepath.Ext(fileName)
return fmt.Sprintf("%x%s", md5.Sum([]byte(fileName+nowString)), ext)
}
func GetB... |
package rtk
import (
"path/filepath"
"runtime"
"github.com/flywave/go-geoid"
"github.com/flywave/go-proj"
)
func getCurrentDir() string {
_, file, _, _ := runtime.Caller(1)
return filepath.Dir(file)
}
func init() {
dir := getCurrentDir()
proj.SetFinder([]string{filepath.Join(dir, "../proj_data")})
}
type D... |
package main
import (
"connection"
"flag"
"github.com/gorilla/websocket"
"gosconf"
"goslib/logger"
"net/http"
)
type WSAgent struct {
mt int
wsConn *websocket.Conn
connIns *connection.Connection
}
func StartWSAgent() {
http.HandleFunc("/", wsHandler)
tcpConf := gosconf.TCP_SERVER_CONNECT_APP
addr ... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-08-17 13:08
# @File : main.go
# @Description :
# @Attention :
*/
package _map
|
package problem0717
import "testing"
func TestSolve(t *testing.T) {
t.Log(isOneBitCharacter([]int{1, 0, 0}))
t.Log(isOneBitCharacter([]int{1, 1, 1, 0}))
}
|
package main
import (
"fmt"
"log"
"net/http"
"video-manager/db"
"video-manager/routers"
"video-manager/utils"
"github.com/gorilla/mux"
)
func buildRouter() *mux.Router {
router := mux.NewRouter().StrictSlash(true)
routers.HomeRouter(router)
return router
}
func main() {
dbConnection := db.DatabaseConnect... |
package main
import (
"log"
"os"
"os/signal"
"github.com/spf13/viper"
"github.com/zerostick/zerostick/daemon/cmd"
)
func init() {
viper.SetDefault("templatesRoot", "./zerostick_web/templates")
viper.SetDefault("assetsRoot", "./zerostick_web/assets")
viper.SetDefault("certsRoot", "./zerostick_web/certs")
go... |
package common
import (
// "encoding/json"
)
type Response struct {
Error string `db:"error" json:"error"`
Message string `db:"message" json:"message"`
}
func ErrorBadReq() string {
return "Invalid Parameters"
}
// func ResponseError() {
// data := Response{
// Error: 400,
// Message: "Invalid Paramat... |
package 股票问题
const inf = 1000000000
func maxProfit(k int, prices []int) int {
maxProfitResult := make(map[int]int)
hasStockStatus := []int{0, 1}
result := 0
for day, price := range prices {
for _, hasStock := range hasStockStatus {
for countOfSell := 0; countOfSell <= k; countOfSell++ {
if hasStock == 0 ... |
package pipelines
import (
"testing"
"time"
)
var defaults = Chappati{
Verbose: false,
Count: 20,
NumBakers: 1,
BakeTime: 10 * time.Millisecond,
MakeTime: 10 * time.Millisecond,
PackageTime: 10 * time.Millisecond,
}
func Benchmark(b *testing.B) {
chapattiAriana := defaults
chapattiAriana.... |
// This file was generated for SObject DatacloudOwnedEntity, API Version v43.0 at 2018-07-30 03:47:26.982223499 -0400 EDT m=+13.325329941
package sobjects
import (
"fmt"
"strings"
)
type DatacloudOwnedEntity struct {
BaseSObject
CreatedById string `force:",omitempty"`
CreatedDate string `force:"... |
package dataset
import (
"github.com/emicklei/go-restful"
api "github.com/emicklei/go-restful-openapi"
"data-manager/dbcentral/etcd"
"data-manager/dbcentral/pg"
. "data-manager/types"
. "grm-service/util"
)
type DataSetSvc struct {
SysDB *pg.SystemDB
DynamicDB *etcd.DynamicDB
}
// WebService creates a n... |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package engine
import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/Azure/aks-engine/pkg/api"
"github.com/Azure/go-autorest/autorest/to"
)
func TestCreateKeyVault(t *testing.T) {
cs := &api.ContainerServic... |
package treeNodes
import (
"fmt"
"strconv"
"github.com/SealNTibbers/GotalkInterpreter/scanner"
)
type Scope struct {
variables map[string]SmalltalkObjectInterface
OuterScope *Scope
}
func (s *Scope) Initialize() *Scope {
s.variables = make(map[string]SmalltalkObjectInterface)
return s
}
func (s *Scope) Set... |
package main
import (
"bufio"
"context"
"flag"
"fmt"
"log"
"math"
"time"
"net/http"
"github.com/segmentio/kafka-go"
)
func ProcessMessages(serviceAddr string, frequency int, runLength int, httpClient *http.Client, w *kafka.Writer) {
for i := 0; i < runLength; i += frequency {
startTime := time.Now().Uni... |
package bets
import (
"context"
betsRps "github.com/ivansukach/bets/internal/repositories/bets"
blockedBetsRps "github.com/ivansukach/bets/internal/repositories/blocked-bets"
usersRps "github.com/ivansukach/bets/internal/repositories/blocked-users"
"github.com/jmoiron/sqlx"
log "github.com/sirupsen/logrus"
"mat... |
package client
import (
"bytes"
"fmt"
apiMapping "github.com/kulycloud/api-server/mapping"
apiServer "github.com/kulycloud/api-server/server"
"net/http"
)
func (c *Client) GetRoute(namespace string, name string) (*apiMapping.IncomingRoute, error) {
var route = &apiMapping.IncomingRoute{}
return route, c.Execut... |
package gredis
import "github.com/gomodule/redigo/redis"
var RedisConn *redis.Pool
func Setup() error {
RedisConn = &redis.Pool{
// TODO https://book.eddycjy.com/golang/gin/application-redis.html
// 看至 四、Redis 工具包
Dial: func() (conn redis.Conn, e error) {
//c, err := redis.Dial("tcp", setting)
},
TestO... |
package main
import (
"log"
server "net/http"
)
func setEndpoints() {
// Game endpoints
server.HandleFunc("/game/new", newGame)
server.HandleFunc("/game/make_move", makeMove)
server.HandleFunc("/game/get", getGame)
// Score endpoint
server.HandleFunc("/highscores", highScores)
}
func startServer() {
setEnd... |
package main
import(
"net/http"
)
func main(){
http.HandleFunc("/search", handler)
http.ListenAndServe("", nil)
}
func handler(w http.ResponseWriter, r *http.Request) {
server:= newServer(&w,r)
IDTokenStr, err := server.getStr.header("IDToken")
if err!=nil{
logger.Printf(err.Error())
server.execStr.respond(... |
package main
import (
"fmt"
"sort"
"strconv"
)
func main() {
//fmt.Println(punishmentNumber(10))
//fmt.Println(punishmentNumber(37))
//fmt.Println(punishmentNumber(36))
fmt.Println(punishmentNumber(45))
// 2025
//fmt.Println(handle(45, "2025"))
}
func Init() {
for i := 38; i <= 1000; i++ {
if handle(... |
package coding
import (
"math"
"sort"
)
/*
Given two integer arrays and a target which is a number.
Find pairs of number that you can make from these two arrays whose sum is the closest to the target.
Example 1:
Input: [-1, 3, 8, 2, 9, 5], [4, 1, 2, 10, 5, 20] 24
Output: [{3, 20}, {5, 20}]
*/
func SumCl... |
package Problem0459
import (
"strings"
)
func repeatedSubstringPattern(s string) bool {
if len(s) == 0 {
return false
}
size := len(s)
ss := (s + s)[1 : size*2-1]
return strings.Contains(ss, s)
}
|
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
package engine
import (
"fmt"
"github.com/Azure/aks-engine/pkg/api"
"github.com/Azure/aks-engine/pkg/helpers"
)
func getParameters(cs *api.ContainerService, generatorCode string, aksEngineVersion string) paramsMap {
... |
package mgmt
import (
"encoding/json"
"fmt"
"github.com/bitmaelum/bitmaelum-suite/cmd/bm-server/handler"
"github.com/bitmaelum/bitmaelum-suite/internal/apikey"
"github.com/bitmaelum/bitmaelum-suite/internal/container"
"github.com/bitmaelum/bitmaelum-suite/internal/parse"
"net/http"
)
type inputAPIKeyType struc... |
package workers
type WorkerPool struct {
size int
workers chan *Worker
}
type Task struct {
Function func()
Identifier int
}
func (pool *WorkerPool) Run(task Task) bool {
worker, ok := <-pool.workers
go worker.run(task)
return ok
}
func New(size int) *WorkerPool {
workers := make(chan *Worker, size)
poo... |
package main
import "fmt"
type Person struct {
Name string
}
func (p Person) speck() {
fmt.Printf("%v是个好人\n", p.Name)
}
func (p Person) jisuan() {
sum := 0
for i := 1; i <= 1000; i++ {
sum += i
}
fmt.Printf("1+...+1000结果是%d\n", sum)
}
func (p Person) jisuan2(n int) {
sum := 0
for i := 1; i <= n; i++ {
su... |
package main
import (
"fmt"
"time"
)
func main() {
ch := make(chan struct{})
for i := 0; i < 10; i++ {
go func() {
<-ch
fmt.Println("Close channel")
}()
}
time.AfterFunc(5 * time.Second, func() {
fmt.Println("time.AfterFunc")
close(ch)
})
}
|
/*
Suppose you are given the following code:
class FooBar {
public void foo() {
for (int i = 0; i < n; i++) {
print("foo");
}
}
public void bar() {
for (int i = 0; i < n; i++) {
print("bar");
}
}
}
The same instance of FooBar will be passed to two different threads:
thread A will... |
package db
import (
"encoding/binary"
"time"
"github.com/boltdb/bolt"
)
var bucketName = []byte("tasks")
var db *bolt.DB
type TaskItem struct {
Id int
Value string
}
func OpenDB(path string) error {
var err error
db, err = bolt.Open(path, 0600, &bolt.Options{Timeout: 1 * time.Second})
if err != nil {
... |
/*
Tencent is pleased to support the open source community by making Basic Service Configuration Platform available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except
in compliance with the License. You may obtain... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.