text stringlengths 11 4.05M |
|---|
package common
import (
"github.com/alehano/gobootstrap/sys/tpl"
)
func init() {
tpl.RegisterMulti("views/common/tpl/", map[string]string{
"common.robots_txt": "robots_txt.tpl",
"common.not_found": "404.tpl",
})
}
|
/*
Given two positive integers n and k, generate all binaries between the integers 0 and (2^n) - 1, inclusive.
These binaries will be sorted in descending order according to the number of existing 1s on it, if there is a tie, we choose the lowest numerical value.
Return the k-th element from the sorted array created.
... |
package practices
func solution(places [][]string) []int {
// 1. places를 전체 순회하면서 `P`의 위치를 전부 담음.
// 2. `P`를 순회하면서 만족하지 않는 게 있는지 확인
// 3.
return []int{}
}
|
package main
import (
"fmt"
"image/png"
"io/ioutil"
"log"
"math/rand"
"os"
"time"
"github.com/unixpickle/autofunc"
"github.com/unixpickle/gans"
"github.com/unixpickle/mnist"
"github.com/unixpickle/sgd"
"github.com/unixpickle/weakai/neuralnet"
)
const (
StepSize = 0.001
BatchSize = 96
)
func main() {
... |
package rule
import (
"errors"
"net/http"
"time"
"github.com/sirupsen/logrus"
)
// TimeSetting Time Rule Setting
type TimeSetting struct {
StartHour int
StartMinutes int
EndHour int
EndMinutes int
Exclude bool
}
type timeRule struct {
ruleDue int64
startHour int
startMinutes int
... |
package main
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func insertIntoBST(root *TreeNode, val int) *TreeNode {
if root == nil {
return &TreeNode{Val: val}
}
curr := root
for curr != nil {
if curr.Val > val {
if curr.Left == nil {
curr.Left = &TreeNode{Val: val}
break
... |
// Pick the best hand(s) from a list of poker hands.
// Rules are found in https://en.wikipedia.org/wiki/List_of_poker_hands
// Need to select a font like Microsoft Yahei so sublime text can show correct characters
package poker
import (
"errors"
"regexp"
"sort"
"strings"
)
const testVersion = 4
type handRank in... |
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTrimMap(t *testing.T) {
t.Run("returns false if map is the same", func(t *testing.T) {
map1 := map[string]int{"b": 2, "a": 1}
map2 := map[string]int{"a": 1, "b": 2}
response := mapDiff(map1, map2)
assert.Equal(t, false, respon... |
package main
import "fmt"
func main() {
a := []Interval{Interval{1, 3}, Interval{6, 9}}
fmt.Println(insert(a, Interval{2, 5}))
a = []Interval{Interval{1, 2}, Interval{3, 5}, Interval{6, 7}, Interval{8, 10}, Interval{12, 16}}
fmt.Println(insert(a, Interval{4, 9}))
a = []Interval{Interval{1, 5}}
fmt.Println(inser... |
package client
import (
"os"
"os/exec"
"path/filepath"
"github.com/spf13/cobra"
)
var (
base = "src/github.com/rai-project"
all = []string{"mxnet", "tensorflow", "caffe", "caffe2"}
)
var startallCmd = &cobra.Command{
Use: "startallCmd",
Short: "startallCmd",
Aliases: []string{"startall", "start"},
... |
package clients
import (
"encoding/json"
"errors"
"fmt"
"net/url"
"path"
"strconv"
"strings"
"time"
"github.com/go-resty/resty"
deployer "github.com/hyperpilotio/deployer/apis"
"github.com/hyperpilotio/go-utils/funcs"
logging "github.com/op/go-logging"
"github.com/spf13/viper"
)
const (
ErrAWSError = "... |
package main
import "fmt"
type Skills []string
type Human struct {
name string
age int
weight int
}
type Student struct {
Human // 匿名字段,那么默认Student就包含了Human的所有字段
Skills //不仅仅是struct字段哦,所有的内置类型和自定义类型都是可以作为匿名字段的
int // 内置类型作为匿名字段
speciality string
}
func main() {
// 我们初始化一个学生
mark := St... |
package docker
import (
"fmt"
"net"
"net/url"
"os"
"strings"
"github.com/opentable/sous/tools/cli"
"github.com/opentable/sous/tools/cmd"
"github.com/opentable/sous/tools/dockermachine"
"github.com/opentable/sous/tools/file"
"github.com/opentable/sous/tools/path"
"github.com/opentable/sous/tools/version"
)
... |
package main
import (
"bufio"
"os"
"strconv"
"strings"
)
const maxLen = 201
var dp [maxLen][maxLen]int
var tdp [maxLen][maxLen]int
var one, two, three string
var one_len, two_len, three_len int
var (
r = bufio.NewReader(os.Stdin)
w = bufio.NewWriter(os.Stdout)
)
func init() {
for n := 0; n < maxLen; n++ {
... |
package main
import (
"context"
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"net"
"net/http"
"os"
"path"
"strconv"
"time"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/hashicorp/vault/api"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
"k8s.io/klog/v2"
)
var (
port ... |
package api
import (
"encoding/json"
"fmt"
"github.com/kurtosis-tech/kurtosis-client/golang/services"
"github.com/kurtosis-tech/kurtosis-libs/golang/testsuite/services_impl/datastore"
"github.com/palantir/stacktrace"
"github.com/sirupsen/logrus"
"os"
)
const (
port = 2434
configFileKey = "config-file"
tes... |
package main
import (
"fmt"
"time"
)
// Timer stores initial timer state and can print time since.
type Timer struct {
name string
start time.Time
}
// NewTimer creates a new timer and prints that it started.
func NewTimer(name string) Timer {
fmt.Printf("> %v\n", name)
return Timer{name, time.Now()}
}
// Do... |
package leetcode
/*Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.
Find the maximum area of an island in the given 2D array. (If there is no island, th... |
package chapter13
import (
"fmt"
"testing"
)
func TestIntersectSortedArrays(t *testing.T) {
a := []int{1, 3, 4, 6, 8, 10}
b := []int{3, 4, 5, 9, 10}
c := IntersectSortedArrays(a, b)
fmt.Printf("IntersectSortedArrays (%v , %v) = %v\n", a, b, c)
fmt.Println()
}
|
package filter
import (
"gocherry-api-gateway/components/common_enum"
"gocherry-api-gateway/components/redis_client"
"gocherry-api-gateway/proxy/enum"
)
type LimitingFilter struct {
Filter
}
func (f *LimitingFilter) Init(proxyContext *ProxyContext) {
}
func (f *LimitingFilter) Name(proxyContext *ProxyContext) s... |
package templatehelper
import "errors"
func NewEmptySlice(n int) []struct{} { return make([]struct{}, n) }
// for (i=from; i<to; i+=step)
func NewForSlice(from, to, step int) (r []int) {
r = make([]int, (to-from)/step)
for i := range r {
r[i] = from + step*i
}
return
}
func NewFromSlice(from, num int) []int {... |
package sw
import (
"hash"
"github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp"
)
type KeyGenerator interface {
KeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error)
}
type KeyDeriver interface {
KeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error)
}
type KeyImporter interface {
KeyImport(raw in... |
package handler
import (
"context"
"path/filepath"
"testing"
jinmuidpb "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/user/v1"
generalpb "github.com/jinmukeji/proto/v3/gen/micro/idl/ptypes/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
// LanguageTestSuite 语言测试
type ... |
package s3
import (
"fmt"
"net/url"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3iface"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/aws/aws-sdk-go/service/s3/s3manager/s3mana... |
package main
import (
"net/http"
"log"
"encoding/json"
"io/ioutil"
)
func NewServer(cache *Cache, port string) *Server {
server := Server{cache: cache}
server.listen(port)
return &server
}
type Server struct {
cache *Cache
server *http.Server
}
func (s *Server) Close() {
s.server.Shutdown(nil)
}
func ... |
package app
import (
"log"
"net/url"
"sync"
"time"
)
var StatisticsMap = &HostMap{hostmap: make(map[string]*URLMap)}
type Statistics struct {
Path string
RequestNum int64
MinTime time.Duration
MaxTime time.Duration
TotalTime time.Duration
}
type URLMap struct {
Host string
RequsetNum i... |
package loaders
import (
"context"
"time"
"github.com/syncromatics/kafmesh/internal/graph/loaders/generated"
"github.com/syncromatics/kafmesh/internal/graph/model"
"github.com/syncromatics/kafmesh/internal/graph/resolvers"
"github.com/pkg/errors"
)
//go:generate mockgen -source=./components.go -destination=./... |
func threeSumClosest(nums []int, target int) int {
sn := nums
sort.Ints(sn)
l := len(sn)
init := false
sum := 0; tempSum := 0
diff := 0; tempDiff := 0
for x := 0; x < l - 2; x++ {
y := x + 1
z := l - 1
for ;y < z; {
tempSum = sn[x] + sn[y] + sn[z]
... |
package main
import (
"time"
"github.com/TempleEight/spec-golang/match/dao"
"github.com/gorilla/mux"
)
func (e *env) setup(router *mux.Router) {
// Add user defined code here
e.hook.BeforeCreate(beforeCreateMatch)
}
func beforeCreateMatch(env *env, req createMatchRequest, input *dao.CreateMatchInput) *HookErro... |
package main
import (
"html/template"
"io"
"log"
"net/http"
"strconv"
"time"
"./data"
"./typefile"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
// レイアウト適用済のテンプレートを保存するmap
var templates map[string]*template.Template
type Template struct {
}
func (t *Template) Render(w io.Writer, name... |
/*
Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2.
For example:
For a mass of 12, divide by 3 and round down to get 4, then subtract 2 to get 2.
For a mass of 14, dividing by 3 and ro... |
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.
package restore
import (
"strings"
"github.com/pingcap/errors"
backuppb "github.com/pingcap/kvproto/pkg/brpb"
"github.com/pingcap/log"
berrors "github.com/pingcap/tidb/br/pkg/errors"
"github.com/pingcap/tidb/br/pkg/logutil"
"github.com/pingcap/tidb/br... |
package Model
type Account struct {
FirstName string
LastName string
}
func (acc *Account) ChangeName(firstName string, lastName string) {
acc.FirstName = firstName
acc.LastName = lastName
}
|
package server
import (
"strings"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/serbanmarti/fiber_rest_api/internal"
)
func configureFiber(app *fiber.App) {
// Configure panic recovery
app.Use(recover.New())
// Confi... |
package health
import (
"bytes"
"encoding/gob"
"errors"
"io"
"io/ioutil"
"os"
"sync"
)
type fileRepository struct {
filepath string
mu *sync.Mutex
checks checks
}
var _ Repository = (*fileRepository)(nil)
func NewFileRepository(filepath string) (Repository, error) {
existingChecks, err := checksFrom... |
/*main.go
*Tesla coding challenge
*Author: Daniel D'Souza
*/
package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
"strings"
)
type expression struct {
variables []string
constants int // simplify storage by keeping track of the sum of constants
}
type equation struct {
LHS string
RHS expression
}
... |
package main
import (
"fmt"
)
func main() {
var t int; fmt.Scan(&t)
for ;t>0;t-- {
var n int64; fmt.Scan(&n)
ans := 0
for n % 3 == 0 {
if n % 2 == 0 {
n /= 6
ans++
} else {
n *= 2
ans++
}
}
if n == 1 {
fmt.Println(ans)
} else {
... |
package pathfileops
import (
"fmt"
"io"
"strings"
"testing"
)
func TestFileMgr_GetAbsolutePath(t *testing.T) {
fh := FileHelper{}
relPath1 := "..\\logTest\\CmdrX\\CmdrX.log"
filePath1, err := fh.MakeAbsolutePath(relPath1)
if err != nil {
t.Errorf("Error returned by fh.MakeAbsolutePath(relPath1)... |
package main
import (
"strings"
"fmt"
"errors"
"strconv"
"bufio"
"os"
)
func main() {
calc := New()
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
calc.evaluate(scanner.Text())
if top, ok := calc.top(); ok {
fmt.Println(top)
}
}
if scanner.Err() != nil {
fmt.Errorf("%v", scanner.Er... |
package data
import (
"errors"
"gorm.io/gorm"
)
var (
ErrRecordNotFound = errors.New("record not found")
)
type Models struct {
Movies MovieModel
Users UserModel
Tokens TokenModel
Permissions PermissionModel
}
func NewModels(db *gorm.DB) Models {
return Models{
Movies: MovieModel{DB:... |
package xds
import (
"context"
"sync"
"github.com/prometheus/client_golang/prometheus"
)
type StatsCallbacks struct {
NoopCallbacks
ResponsesSentMetric *prometheus.CounterVec
RequestsReceivedMetric *prometheus.CounterVec
StreamsActive int
sync.RWMutex
}
var _ Callbacks = &StatsCallbacks{}
func ... |
package controller
import (
"github.com/gin-gonic/gin"
"github.com/yakuter/ugin/model"
"github.com/yakuter/ugin/service"
)
var err error
func (base *Controller) GetPost(c *gin.Context) {
id := c.Params.ByName("id")
post, err := service.GetPost(base.DB, id)
if err != nil {
c.AbortWithStatus(404)
}
c.JSON(... |
package mock
import (
"errors"
"fmt"
"github.com/aws/aws-sdk-go/service/sts"
)
// STSClient implements github.com/swipely/iam-docker/src/iam.STSClient.
type STSClient struct {
AssumableRoles map[string]*sts.Credentials
}
// NewSTSClient returns a mock STSClient.
func NewSTSClient() *STSClient {
return &STSClien... |
package handlers
import (
"encoding/json"
"io"
"net/http"
"github.com/root-gg/plik/server/common"
"github.com/root-gg/plik/server/context"
)
// CreateUser create a new user
func CreateUser(ctx *context.Context, resp http.ResponseWriter, req *http.Request) {
// Double check authorization
if !ctx.IsAdmin() {
... |
package scheduler
import (
"os"
"strconv"
"strings"
"time"
"types"
"github.com/golang/glog"
v1 "k8s.io/api/core/v1"
)
var (
podInfo map[string]v1.Pod // local pod
scheduleDataQ chan types.ScheduleData
executeDataQ chan types.ExecuteData
userDataQ chan types.UserData
sta... |
package handlers
import (
"fmt"
"github.com/bitmaelum/bitmaelum-suite/cmd/bm-client/pkg/vault"
"github.com/bitmaelum/bitmaelum-suite/internal"
"github.com/bitmaelum/bitmaelum-suite/internal/api"
"github.com/bitmaelum/bitmaelum-suite/internal/config"
"github.com/bitmaelum/bitmaelum-suite/internal/container"
"git... |
package katakana
// Katakana returns a map between katakana characters and their pronunciation
func Katakana() map[string]string {
Kata := make(map[string]string)
Kata["a"] = "ア"
Kata["i"] = "イ"
Kata["u"] = "ウ"
Kata["e"] = "エ"
Kata["o"] = "オ"
Kata["ka"] = "カ"
Kata["ki"] = "キ"
Kata["ku"] = "ク"
Kata["ke"] =... |
// Copyright (C) 2015 Scaleway. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE.md file.
package cli
import "fmt"
var cmdFlushCache = &Command{
Exec: runFlushCache,
UsageLine: "_flush-cache [OPTIONS]",
Description: "",
Hidden: t... |
package handler
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/go-playground/validator/v10"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
)
func TestHandler_TaskUpdate(t *testing.T) {
body := strings.NewReader(`{"priority": 5}`)
e := echo.New()
e.Validator = &... |
// Copyright 2023 Google LLC. 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 applica... |
package shuffle
import (
"fmt"
"math/big"
"testing"
)
func TestProduct(t *testing.T) {
com := Common{EC.G,EC.H}
// prover generate C
rx,ry,rz := big.NewInt(11), big.NewInt(22),big.NewInt(33)
x, y, z := big.NewInt(2), big.NewInt(4),big.NewInt(6)
X, Y, Z := Com(com,x,rx), Com(com,y,ry), Com(com,z,rz)
P_prod... |
package main
import "fmt"
func trap(height []int) int {
// S(water) = S(total=maxHeight*length) -
// S(reverse) - S(sum(height))
hl := len(height)
if hl == 0 {
return 0
}
left, right, sum := 0, 0, 0
for i := 0; i < hl; i++ {
if height[i] > height[left] {
left = i
}
if height[i] >= height... |
package admin
import (
"context"
"tpay_backend/model"
"tpay_backend/adminapi/internal/svc"
"tpay_backend/adminapi/internal/types"
"github.com/tal-tech/go-zero/core/logx"
)
type GetPlanformChannelSettingLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetPlanformChannel... |
package client
import (
"fmt"
"io"
"log"
"net"
"os/exec"
"sync"
"github.com/NHAS/reverse_ssh/internal"
"github.com/kr/pty"
"golang.org/x/crypto/ssh"
)
func proxyChannel(sshConn ssh.Conn, newChannel ssh.NewChannel) {
a := newChannel.ExtraData()
var drtMsg internal.ChannelOpenDirectMsg
err := ssh.Unmarsha... |
/*
Copyright (C) 2018 Synopsys, Inc.
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
"... |
package util
import (
"github.com/spf13/pflag"
"github.com/spf13/viper"
"go.uber.org/zap"
"sync"
)
var (
logger *zap.Logger
logOnce = sync.Once{}
)
func GetL() *zap.Logger {
logOnce.Do(func() {
debug := viper.GetBool("log.debug")
var (
l *zap.Logger
err error
)
if debug {
l, err = zap.NewD... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func getInput() (string, int) {
reader := bufio.NewReader(os.Stdin)
text, _ := reader.ReadString('\n')
str := strings.Replace(text, "\n", "", -1)
text, _ = reader.ReadString('\n')
text = strings.Replace(text, "\n", "", -1)
n, _ := strconv.A... |
/**
* Created with IntelliJ IDEA.
* User: Administrator
* Date: 14-2-25
* Time: 下午3:06
* To change this template use File | Settings | File Templates.
*/
package main
import (
"flag"
"fmt"
"os"
"time"
"runtime"
"log"
)
var (
//ipPort = flag.String("i", "127.0.0.1:8080", "IP port to listen on")
cpup... |
package main
import (
"bytes"
"encoding/json"
"fmt"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"io/fs"
"log"
"math/rand"
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
"time"
svg "github.com/ajstarks/svgo"
)
type (
EveMapper struct{
Galaxy NewEden
}
spyglassMap struct {
Nam... |
package notifications
import (
"github.com/spf13/viper"
)
// Dispatch is taking care of sending a message across all available channels
func Dispatch(service string, degraded bool) {
subject, body := builder(service, degraded)
if viper.GetBool("NOTIFICATIONS_ENABLE_EMAIL") == true {
email(subject, body)
}
}
|
package RegularExpressionMatching
import "testing"
func Test_isMatch(t *testing.T) {
type args struct {
s string
p string
}
tests := []struct {
name string
args args
want bool
}{
// TODO: Add test cases.
{
name: "first",
args: args{
s: "aa",
p: "a",
},
want: false,
},
{
na... |
package defs
const (
//Env = "env6"
//PodBaseDir = "/mnt/paas/kubernetes/kubelet/pods/"
//BackupDestBaseDir = "/tmp/pods/"
//RestApiUrl = "http://192.168.250.22:32598/online/podmetadata"
//Expired = 1
//LogDestDir = "/tmp/log-back"
EmptyDirName = "kubernetes.io~empty-dir"
UrlSuffix= "online/podmetadata"
)
typ... |
package main
import (
"fmt"
"net/http"
"github.com/ONSdigital/dp-api-audit-spike/auditing"
"github.com/ONSdigital/dp-api-audit-spike/handlers"
"github.com/gorilla/mux"
)
func main() {
if err := run(); err != nil {
fmt.Println(err.Error())
}
}
func run() error {
r := mux.NewRouter()
auditor := &auditing.... |
package main
import "fmt"
func sayHelloTo(firstName, lastName string) {
fmt.Println("Hello", firstName, lastName)
}
func main() {
sayHelloTo("Muhammad", "Zhuhry")
firstName := "Budi"
sayHelloTo(firstName, "Khanedy")
}
|
package tfcloud
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"strconv"
"strings"
)
const (
TF_CLOUD_URL = "https://app.terraform.io/api/v2/workspaces/%s/vars"
BEARER_TOKEN = "Bearer %s"
CONTENT_TYPE = "application/vnd.api+json"
)
type Attributes struct {
Category string `json:"c... |
/*
Copyright 2022 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, softw... |
package main
import (
"errors"
"fmt"
"io"
)
type mediaInfo struct {
r *mp4Reader
movie *MovieInfo
moof *movieFragment // current
dataPos int64
// for internal usage
currentState parsingState
leftAtomSize uint64
}
func newMediaInfo(r io.ReadSeeker) *mediaInfo {
return &mediaInfo{r: newMp4Reader(r),
... |
package upgrade_suite_test
import (
"fmt"
"os"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
cmdHelper "code.cloudfoundry.org/quarks-utils/testing"
"code.cloudfoundry.org/quarks-utils/testing/e2ehelper"
)
// This cannot run in parallel
var _ = Describe("Quarks Upgrade test", func() {
var (
... |
//go:build integration
// +build integration
// nolint:errcheck
package main
import (
"github.com/signaux-faibles/keycloakUpdater/v2/logger"
"github.com/signaux-faibles/keycloakUpdater/v2/structs"
"github.com/signaux-faibles/libwekan"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"... |
package main
import (
"im/config"
"im/internal/ws_conn"
"im/pkg/logger"
"im/pkg/rpc"
"im/pkg/util"
)
func main() {
logger.Init()
// 启动rpc服务
go func() {
defer util.RecoverPanic()
ws_conn.StartRPCServer()
}()
// 初始化Rpc Client
rpc.InitLogicIntClient(config.WSConn.LogicRPCAddrs)
// 启动长链接服务器
ws_conn.Sta... |
package notbearparser
var testStr = `<div class="test_class" id="test_id" data-pk="test-pk" disable test>`
var queryStr = `div[id=test_id, class=test_class, disable, hidden]`
// func TestRegexp(t *testing.T) {
// attrGroup := queryAttrRe.FindStringSubmatch(queryStr)
// _, tagAttrStr := attrGroup[1], attrGroup[2]
//... |
package tasks
import (
"net/http"
"io/ioutil"
"errors"
"strings"
"bytes"
)
type HttpTask struct {
Request *http.Request
*Task
}
func (this *HttpTask)Call()(bool) {
client := &http.Client{}
if resp, err := client.Do(this.Request); err == nil {
defer func() {
bo... |
package account
import (
"glsamaker/pkg/app/handler/authentication/totp"
"glsamaker/pkg/app/handler/authentication/utils"
"glsamaker/pkg/database/connection"
"glsamaker/pkg/logger"
"glsamaker/pkg/models"
"glsamaker/pkg/models/users"
"bytes"
"github.com/duo-labs/webauthn/webauthn"
"html/template"
"net/http"
)... |
package service
import (
"context"
"github.com/brunoluiz/grpc-example/simple"
"github.com/brunoluiz/grpc-example/simple/generated/api"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// NewServer Initiate a GRPC Server
func NewServer() *GRPCServer {
users := map[string]*simple.User{
"foo": &... |
package mockgen
// Controller is a struct demonstrating
// one way to initialize interfaces
type Controller struct {
GetSetter
}
// GetThenSet checks if a value is set. If not
// it sets it.
func (c *Controller) GetThenSet(key, value string) error {
val, err := c.Get(key)
if err != nil {
return err
}
if val !... |
package main
import (
"fmt"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
"io/ioutil"
"os"
"os/exec"
"strings"
"time"
)
type MyMainWindow struct {
*walk.MainWindow
}
var inTE, outTE *walk.TextEdit
var filePath *walk.LineEdit
var mw *MyMainWindow;
func main() {
mw = new(MyMainWindow)
MainWin... |
// Package dedup provides facilities for deduplicating
// template tables and copying into a destination partitions.
// It is currently somewhat NDT specific:
// 1. It expects tables to have task_filename field.
// 2. It expects destination table to be partitioned.
// 3. It does not explicitly check for schema compa... |
package main
import (
"fmt"
"go.jlucktay.dev/golang-workbench/flatten/pkg/flatten"
)
func main() {
start := []interface{}{
[]interface{}{
1,
2,
[]int{3},
},
4,
}
finish := flatten.Flatten(start)
fmt.Printf("Started with: %#v\n", start)
fmt.Printf("Finished with: %#v\n", finish)
}
|
package main
import (
"bufio"
"bytes"
"fmt"
"html/template"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"os/exec"
"path/filepath"
"regexp"
"sort"
"strings"
"time"
)
import "github.com/hashicorp/go-version"
type pkgpath = string
type semver = *version.Version
func docDir(pkg pkgpath, v semver) string {
ret... |
package main
import (
"log"
"math/rand"
"os"
"runtime/pprof"
"time"
)
const (
row = 10000
col = 10000
)
func fillMatrix(m *[row][col]int) {
s := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < row; i++ {
for j := 0; j < col; j++ {
m[i][j] = s.Intn(10000)
}
}
}
func calculate(m *[ro... |
package cfrida
import (
"fmt"
"testing"
)
func TestFrida_init(t *testing.T) {
fmt.Println("aa")
}
|
package Shuffle
import (
"math/rand"
)
type Solution struct {
origin []int
}
func Constructor(nums []int) Solution {
return Solution{
origin: nums,
}
}
/** Resets the array to its original configuration and return it. */
func (this *Solution) Reset() []int {
return this.origin
}
/** Returns a random shuffli... |
package download
import (
"github.com/gobuffalo/buffalo"
"github.com/gomods/athens/pkg/errors"
"github.com/gomods/athens/pkg/paths"
)
func getModuleParams(c buffalo.Context, op errors.Op) (mod string, vers string, err error) {
params, err := paths.GetAllParams(c)
if err != nil {
return "", "", errors.E(op, err... |
package main
import (
"fmt"
"os"
"os/exec"
"time"
)
// Get path of cmd in $PATH or Relative Path
func testLookUp() {
fmt.Println("Get path of `ls`")
path1, _ := exec.LookPath("ls")
fmt.Println("-> result: ", path1)
fmt.Println("Get path of non-exsit cmd `nocmd`")
_, err := exec.LookPath("nocmd")
if err != ... |
package admin
import (
"docktor/server/storage"
"docktor/server/types"
"net/http"
"github.com/labstack/echo/v4"
log "github.com/sirupsen/logrus"
)
// getConfig get the config
func getConfig(c echo.Context) error {
db := c.Get("DB").(*storage.Docktor)
m, err := db.Config().Find()
if err != nil {
log.WithFie... |
package controllers
import "net/http"
func GetUsers(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("List Users"))
}
func CreateUsers(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Create User"))
}
func GetUser(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("An User"))
}
func Updat... |
package model
import (
_ "encoding/json"
_ "gopkg.in/mgo.v2/bson"
)
type Permission struct{
OwnerRead bool `json:"owner_read" bson:"owner_read"`
OwnerWrite bool `json:"owner_write" bson:"owner_write"`
AuthedRead bool `json:"authed_read" bson:"authed_read"`
AuthedWrite bool `json:"authed_write" bson:"a... |
package objects
// Node is for node data
type Node struct {
ID int `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Status string `json:"status"`
ErrMsg string `json:"errMsg"`
}
|
package scaleadpt
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("CLIDriver", func() {
Describe("parseSnapdirOutput", func() {
// These output have been compiled from actual output observed as well
// as the reference:
// https://www.ibm.com/support/knowledgecenter/en/ST... |
package utils
type OkexConfig struct {
Enabled bool `json:"enabled"` //used for register okex upstream websocket and connection manager
ApiKey string `json:"api_key"`
ApiSecret string `json:"api_secret"`
}
var (
okexConfig OkexConfig
)
func InitOkexConfig(OkexConf OkexConfig) {
okexConfig = OkexConf
if ... |
package zsync
/**
zsync is a file transfer program. It allows you to download a file from a remote server, where you have a copy of an
older version of the file on your computer already. zsync downloads only the new parts of the file. It uses the same
algorithm as rsync. However, where rsync is designed for synchronis... |
package main
import (
"bytes"
"crypto/sha256"
"encoding/gob"
"encoding/json"
"fmt"
"log"
"time"
)
// Block struct
type Block struct {
Nonce int64
Timestamp int64
Extras string
PrevHash []byte
CurrHash []byte
Transactions []Transaction // add for TX
}
// NewBlock return a new bloc... |
// Copyright (c) 2016-2017 Daniel Oaks <daniel@danieloaks.net>
// released under the MIT license
package main
import (
"fmt"
"log"
"github.com/docopt/docopt-go"
"github.com/goshuirc/bnc/lib"
"github.com/goshuirc/bnc/lib/setup"
// Different parts of the project acting independantly
"github.com/goshuirc/bnc/li... |
// Copyright (c) 2013 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 or at
// https://developers.google.com/open-source/licenses/bsd.
// golint lints the Go source files named on its command line.
package main
import (
"f... |
package serializers
import (
"archive/zip"
"fmt"
"io/ioutil"
"strings"
"github.com/linkedin/goavro/v2"
"github.com/pkg/errors"
"github.com/batchcorp/plumber/printer"
)
func AvroEncode(schema, data []byte) ([]byte, error) {
codec, err := goavro.NewCodec(string(schema))
if err != nil {
return nil, errors.W... |
package industrydb
import (
_ "github.com/go-sql-driver/mysql"
"stockdb"
"entity/xlsentity"
"fmt"
//"excel"
//"util"
)
const(
IndustryInsert = "insert %s set code=?, parent=?, name=?, name_en=?"
IndustryDelete = "delete from %s where code=?"
IndustryUpdate = "update %s set parent=?... |
package main
import (
"flag"
"fmt"
"os"
)
func main() {
args := os.Args
fmt.Println(len(args), "\n", args)
fmt.Println("without binary program name", args[1:])
// this line will give error
// fmt.Println("without binary program name", args[2:])
namePtr := flag.String("name", "john", "a string")
flag.Parse... |
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"strconv"
"time"
auth "github.com/eecs4314prismbreak/WheyPal/auth"
rec "github.com/eecs4314prismbreak/WheyPal/recommendation"
user "github.com/eecs4314prismbreak/WheyPal/user"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"... |
// This file was generated for SObject FlexQueueItem, API Version v43.0 at 2018-07-30 03:48:03.014735922 -0400 EDT m=+49.359194446
package sobjects
import (
"fmt"
"strings"
)
type FlexQueueItem struct {
BaseSObject
AsyncApexJobId string `force:",omitempty"`
FlexQueueItemId string `force:",omitempty"`
Id ... |
package main
import (
"fmt"
"exer8"
)
func main(){
fmt.Println(exer8.Message)
fmt.Println(exer8.Hailstone(17))
fmt.Println(exer8.Hailstone(18))
fmt.Println(exer8.HailstoneSequenceAppend(5))
fmt.Println(exer8.HailstoneLength(5))
fmt.Println(exer8.HailstoneSequenceAllocate(5))
pt := exer8.NewPoint(3, 4.5)
fmt... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.