text stringlengths 11 4.05M |
|---|
/* Copyright © 2021
Author : mehtaarn000
Email : arnavm834@gmail.com
*/
package core
import (
"os/exec"
"runtime"
"io/ioutil"
"ssc/utils"
)
const bash_script = `
JSON=$(curl -sL https://api.github.com/repos/mehtaarn000/SuperSourceControl/releases)
SSCPATH=$(which ssc)
ZIPBALL=$(echo "$JSON" | tr '\r\n' ' ' | jq... |
package main
import (
"fmt"
)
func fn(arg int) int {
return arg + 42
}
func main() {
x := fn(54)
fmt.Printf("Hello world %d", x)
}
|
// 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 policy
import (
"context"
"time"
"chromiumos/tast/common/fixture"
"chromiumos/tast/common/pci"
"chromiumos/tast/common/policy"
"chromiumos/tast/common/policy/... |
package a
import (
"a/schema"
)
func foutside() {
_ = schema.Schema{
Type: schema.TypeList,
}
_ = schema.Schema{
Type: schema.TypeSet,
}
}
|
package itest
import (
"context"
"encoding/hex"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
"github.com/lightningnetwork/lnd/lntest"
"github.com/stretchr/testify/require"
)
// testTrackPayments tests whether a client that calls t... |
package v1
import (
"fmt"
"path"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/storageos/cluster-operator/internal/pkg/image"
"github.com/storageos/cluster-operator/internal/pkg/toleration"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are... |
package main
import (
"context"
"fmt"
"time"
"github.com/google/uuid"
vine "github.com/lack-io/vine/service"
log "github.com/lack-io/vine/service/logger"
proto "github.com/lack-io/vine-example/pubsub/proto"
)
// send events using the publisher
func sendEv(topic string, p vine.Event) {
t := time.NewTicker(ti... |
package v3
import (
"bytes"
"fmt"
"github.com/cockroachdb/cockroach/pkg/util/treeprinter"
)
func init() {
registerOperator(orderByOp, "order-by", orderByClass{})
}
func newOrderByExpr(input *expr) *expr {
return &expr{
op: orderByOp,
children: []*expr{input},
}
}
type orderByClass struct{}
var _ o... |
package ccmd
import (
"time"
"github.com/izumin5210/clicontrib/pkg/cbuild"
"github.com/spf13/cobra"
)
// NewVersionCommand returns a new command object for printing version information.
func NewVersionCommand() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Print version in... |
package webglglobe
import (
"github.com/go4orward/gowebgl/wcommon"
"github.com/go4orward/gowebgl/webgl2d"
)
type GlobeMarkLayer struct {
ScnObjs []*webgl2d.SceneObject // 2D SceneObjects to be rendered (in CAMERA space)
}
func NewGlobeMarkLayer() *GlobeMarkLayer {
mlayer := GlobeMarkLayer{}
mlayer.ScnObjs = mak... |
package commands
import (
"os/exec"
)
/*
Функция EXEC() – получает путь к файлу, который хочет открыть пользователь и при помощи
функции exec.Command и cmd.Run() выполняет запрос на запуск программы.
*/
func EXEC(pathToExeFile string) (err error) {
cmd := exec.Command(pathToExeFile)
cmd.Run()
return nil
}
|
// Copyright 2017 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
// Copyright 2020 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package router
import (
"down-date-server/src/api"
"github.com/gin-gonic/gin"
)
func InitBaseRoute(Router *gin.RouterGroup) {
UserRouter := Router.Group("")
{
UserRouter.POST("register", api.Register)
UserRouter.POST("login", api.Login)
}
}
func IintAuthRoute(Router *gin.RouterGroup) {
UserRouter := Route... |
package main
import "fmt"
func main() {
favSport := "coding"
switch favSport {
case "football":
fmt.Println("Football")
case "hockey":
fmt.Println("Hockey")
default:
fmt.Println("You don't have favorite sport")
}
}
|
// 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 youtube
import (
"context"
"regexp"
"time"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/ash"
"chromiumos/tast/local/... |
package main
import "fmt"
func summaryRanges(nums []int) []string {
if len(nums) == 0 {
return []string{}
}
var ret []string
start := nums[0]
end := nums[0]
for i := 1; i < len(nums); i++ {
if nums[i]-1 == nums[i-1] {
end = nums[i]
} else {
if start != end {
ret = append(ret, fmt.Sprintf("%d->%d... |
// Copyright 2014 Dirk Jablonowski. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package lcd20x4
import (
"github.com/dirkjabl/bricker"
"github.com/dirkjabl/bricker/device"
)
// ClearDisplay is a subscriber to clear the LCD display.
fu... |
package config
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestLoadConfig(t *testing.T) {
config := LoadConfig("../testdata/config/example.yml")
assert.Equal(t, "127.0.0.1:9999", config.Address)
}
func TestLoadDefaultConfig(t *testing.T) {
wd, _ := os.Getwd()
os.Chdir("../testdata/con... |
package database
import (
"database/sql"
"strings"
"fmt"
)
// execQuery is a simple wrapper for the "Exec" sql method.
func (gbs *goBanksSql) execQuery(query string, args ...interface{},
) (sql.Result, error) {
fmt.Printf("%s : %+v\n", query, args)
return gbs.db.Exec(query, args...)
}
// getRows is a simple wr... |
package controllers
import (
"net/http"
"rnl360-api/entity"
"rnl360-api/models"
u "rnl360-api/utils"
)
var GetAllResponseType = func(w http.ResponseWriter, r *http.Request) {
var rsponseTypeList []models.ResponseTypeModel
err_list := entity.GetAllResponseType(&rsponseTypeList)
if err_list != nil {
u.Respond... |
package cli
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestDisable(t *testing.T) {
for _, tc := range []struct {
name string
args []string
expectedEnabled []string
expectedError string
}{
{
"normal",
[]string{"enabled_a", "enabled_b"},
[]string{"ena... |
package main
import "fmt"
func main() {
//format printing example
fmt.Printf("true && true\t %v\n", true && true)
fmt.Printf("true && false\t %v\n",true && false)
fmt.Printf("true ||true\t %v\n",true || true)
fmt.Printf("true || false\t %v\n",true || false)
fmt.Printf("!true\t %v\n",!true)
fmt.Printf("!false\... |
// Copyright The Shipwright Contributors
//
// SPDX-License-Identifier: Apache-2.0
package resources
import (
buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
"github.com/shipwright-io/build/pkg/config"
"github.com/shipwright-io/build/pkg/reconciler/buildrun/resources/sources"
"github.com/te... |
package main
import "fmt"
var res [][]int
func main() {
res = [][]int{}
head := &TreeNode{}
levelTree(head, 0)
fmt.Println(res)
}
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
/*
3
/ \
9 20
/ \
15 7
*/
func levelTree(head *TreeNode, level int) {
if head != nil {
//当... |
package main
import "fmt"
import "os"
func swap(s []int, index1 int, index2 int) {
s[index1], s[index2] = s[index2], s[index1]
}
type heap struct {
data []int
size int
}
func (h *heap) left(index int) int { return (index+1)*2 - 1 }
func (h *heap) right(index int) int { return (index + 1) * 2 }
func (h *h... |
package session
// var (
// SessManager session.Manager = session.NewManager(&Builder{}, &session.ManagerConfig{
// Expire: 15 * time.Minute,
// Capacity: 100000,
// })
// )
// func GetSession(uid int64) (*Session, bool) {
// lock.RLock()
// defer lock.RUnlock()
//
// s, ok := active[uid]
// return s, ok... |
package servgo
import (
"fmt"
"net"
)
type Server struct {
addr string
numWorkers, maxQueued int
getHandler func(Request) Response
}
func NewServer(addr string, numWorkers, maxQueued int) Server {
server := Server{
addr: addr,
numWorkers: numWorkers,
maxQueued: maxQueue... |
// Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package server
import (
"github.com/ericelsken/golflog"
"net/http"
)
const (
STATIC_DIR = "/bower_components/"
TEMPL_DIR = "/app/templates/"
IMG_DIR = "/images/"
JS_DIR = "/app-ui/js/"
CSS_DIR = "/app-ui/css/"
TEMPLATE_DIR = "/app-ui/js/templates/"
)
type Server struct {
mux http.Handle... |
// Copyright 2017 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package main
import (
"encoding/json"
"errors"
"flag"
"fmt"
"github.com/matryer/filedb"
"log"
"strings"
)
const (
list = "list"
add = "add"
remove = "remove"
)
type path struct {
Path string
Hash string
}
func (p path) String() string {
return fmt.Sprintf("%s [%s]", p.Path, p.Hash)
}
func main() ... |
package main
import(
"fmt"
"strings"
)
func (c *Challenge) Challenge001() {
msg:=ReadFile(".\\Data\\001\\msg.txt")
url:="map"
fmt.Println(translate(msg))
fmt.Println(translate(url))
}
func getChar(r rune) rune {
// switch {
// case r >= 'a' && r <= 'z':
// return 'a' + (r-'a'+2)%26
// }
if (r >= 'a' &&... |
package aws
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
)
//Credential is a basic AWS credential
type Credential struct {
// AWS Region... |
package main
import "math"
type sphere struct {
Center vector `json:"center"`
Radius float64 `json:"radius"`
Reflectiveness float64 `json:"reflectiveness"`
Red float64 `json:"red"`
Green float64 `json:"green"`
Blue float64 `json:"blue"`
}
func (s *sphere) getRefle... |
package main
import "fmt"
func main() {
x := [5]float64{98, 93, 77, 82, 73}
var total float64 = 0
for _, value := range x {
total += value
}
fmt.Println("Total:", total)
fmt.Println("Avg:", total/float64(len(x)))
}
|
package main
import (
"image/color"
"engo.io/ecs"
"engo.io/engo"
"engo.io/engo/common"
)
const buttonOpenMenu = "OpenMenu"
type game struct{}
func (g *game) Type() string { return sceneGame }
func (g *game) Preload() {}
func (g *game) Setup(world *ecs.World) {
engo.Input.RegisterButton(buttonOpenMenu, en... |
// Copyright (C) 2019-2020 Zilliz. 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 l... |
//
// Copyright (c) SAS Institute 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 agre... |
package models
import (
"strconv"
"time"
"github.com/jinzhu/gorm"
)
/******************************************************************************************************
说明:系列赛模型
作者:w-zengtao
belongs_to Game
official id : steam_id & hltv_id
User Story
1. 每场系列赛由一到多场(Format)比赛组成
2. 每场系列赛只有左右两支队伍进行比赛
3. Live 表示... |
package command
import (
"encoding/json"
"fmt"
"os"
"strings"
"github.com/coreos/etcdctl/third_party/github.com/codegangsta/cli"
"github.com/coreos/etcdctl/third_party/github.com/coreos/go-etcd/etcd"
)
type handlerFunc func(*cli.Context, *etcd.Client) (*etcd.Response, error)
type printFunc func(*etcd.Response,... |
package filelock
import (
"os"
"k8s.io/client-go/tools/clientcmd"
)
func init() {
// We're using our own file locking mechanism
clientcmd.UseModifyConfigLock = false
}
func WithLock(configAccess clientcmd.ConfigAccess, action func() error) error {
return withLock(configAccess.GetDefaultFilename()+".lock", writ... |
// Copyright © 2020 Weald Technology Trading
// 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
import (
"bufio"
"context"
"fmt"
"net"
"os"
"sync"
flags "github.com/jessevdk/go-flags"
)
var opts struct {
ResolverIP string `short:"r" long:"resolver" description:"IP of the DNS resolver to use for lookups"`
Protocol string `short:"P" long:"protocol" choice:"tcp" choice:"udp" default:"udp" ... |
package file
import (
"os"
"io"
"fmt"
"regexp"
"encoding/json"
"io/ioutil"
"../ds"
"bytes"
)
func Write_Log(year, month, day string) {
var subEntries []ds.Entry
path := (ds.KConfig.LogPath + "/" + year)
// Make sure that the log dir exists
if ! exists(path) {
create_log_dir(path)
}
path = path+"/"+m... |
package parser
import (
"fmt"
"strings"
"github.com/bytesparadise/libasciidoc/pkg/types"
"github.com/davecgh/go-spew/spew"
log "github.com/sirupsen/logrus"
)
const (
// AttributeRefs the "attribute_refs" substitution
AttributeRefs string = "attributes" // TODO: no need to export
// Callouts the "callouts" su... |
package main
import (
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
const (
envVarPrefix = "AUTH_"
)
var (
version = "n/a"
commit = "n/a"
)
func main() {
err := newRootCmd().Execute()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func newRootCmd() *cobra.Co... |
package bytedance
import (
"fmt"
"strconv"
)
func Code1015() {
s1 := "1231312312313214314242424324234131231312312312312312312312312414324234234234234234324"
s2 := "456"
fmt.Println(multiply(s1, s2))
}
/**
给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。
示例 1:
输入: num1 = "2", num2 = "3"
输出: "6... |
package pickle
type Rick struct {
Portal string
}
|
package main
import (
"crypto/aes"
"crypto/cipher"
"sync"
)
// block is 128 bit , 16 byte
// key is 256 bit , 32 byte : fixed use 256 aes , not 128 , 196
//type _Taes struct {
// name string
// key []byte
//} // _Taes
// https://golang.org/pkg/crypto/cipher/#example_NewCBCEncrypter
var ___VencAesCbc__only__mux... |
package network
import (
"fmt"
"net"
"strings"
)
func GetMyIP() string {
allIPs, err := net.InterfaceAddrs()
if err != nil {
fmt.Println("network.GetMyIP()--> Error receiving IPs. IP set to localhost. Consider setting IP manually")
return "localhost"
}
IPString := make([]string, len(allIPs))
for i := ran... |
package httpclient
import (
"context"
"io"
)
type RequestPayload struct {
Context context.Context
Method string
Path string
Query map[string]string
Body io.Reader
}
|
package inject
import (
"bytes"
"html/template"
"github.com/richardcase/vault-initializer/pkg/model"
"k8s.io/api/apps/v1beta1"
)
func ResolveTemplate(deployment *v1beta1.Deployment, pathTemplate string) (string, error) {
pc := model.PathConfig{Namespace: deployment.Namespace, DeploymentName: deployment.Name, Co... |
package leetcode
func checkWays(pairs [][]int) int {
adj := map[int]map[int]bool{}
for _, pair := range pairs {
if adj[pair[0]] == nil {
adj[pair[0]] = map[int]bool{}
}
if adj[pair[1]] == nil {
adj[pair[1]] = map[int]bool{}
}
adj[pair[0]][pair[1]] = true
adj[pair[1]][pair[0]] = true
}
n := len(ad... |
package main
import (
"fmt"
"github.com/microcosm-cc/bluemonday"
"github.com/russross/blackfriday"
"io/ioutil"
"os"
)
func main() {
buf, err := ioutil.ReadAll(os.Stdin)
if err != nil {
fmt.Println("error:", err)
os.Exit(1)
}
unsafe := blackfriday.MarkdownCommon(buf)
html := bluemonday.UGCPolicy().Saniti... |
package ymdRedisServer
import (
"testing"
"github.com/orestonce/ymd/ymdAssert"
"net"
"github.com/orestonce/ymd/ymdError"
)
func TestNewRedisServer(t *testing.T) {
server := NewRedisServer()
err := server.RunLoal()
ymdAssert.True(err == nil, err)
}
func TestRedisServer_Addr(t *testing.T) {
server := NewRedisS... |
package spec_test
/*
// Tests from original Component, should be transferred to new Spec system.
func TestComposable(t *testing.T) {
t.Run("ID can be empty", func(t *testing.T) {
root := control.New()
assert.Equal(root.ID(), "")
})
t.Run("Scheduler() assigns Context", func(t *testing.T) {
box := Box(contex... |
package domain
import "time"
type User struct {
Name string
Mail string
Nick string
Pass string
Date *time.Time
}
func NewUser(name string, mail string, nick string, pass string) *User {
var date = time.Now()
var creado = User{Name: name, Mail: mail, Nick: nick, Pass: pass, Date: &date}
return &creado
}
|
package parser
// ColumnType is enum of column type
type ColumnType int
// Definitions of ColumnType
const (
Char ColumnType = iota
Varchar
Binary
VarBinary
Text
Bool
Int8
Int16
Int32
Int64
Uint8
Uint16
Uint32
Uint64
Float
Reference
)
var columnTypeNames = map[string]ColumnType{
"char": Char,
... |
// by Daniel Rodriguez @sadasant
// Original code written in C# by [Strilanc](https://github.com/Strilanc)
// Original repo: [NotAMonad](https://github.com/Strilanc/NotAMonad)
// This is the fixed code for an Issue I reported here: https://code.google.com/p/go/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status... |
package validator
type Validator struct {
Errors map[string]string
}
func New() *Validator {
return &Validator{
Errors: make(map[string]string),
}
}
func (v *Validator) AddError(key, message string) {
if _, exists := v.Errors[key]; !exists {
v.Errors[key] = message
}
}
func (v *Validator) Check(condition b... |
package mysql
import (
"context"
sq "github.com/Masterminds/squirrel"
"github.com/ddouglas/ledger"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
)
var merchantsTable = "merchants"
var merchantsColumns = []string{
"id",
"name",
"created_at",
"updated_at",
}
var merchantAliasesTable = "merchant_aliases"
... |
// A Pulumi package for creating and managing Kubernetes resources.
//
package kubernetes
|
package v0
import (
"bytes"
"math/rand"
"testing"
"github.com/golang/protobuf/proto"
"github.com/grafana/tempo/pkg/tempopb"
"github.com/grafana/tempo/pkg/util/test"
"github.com/stretchr/testify/assert"
)
func TestMarshalUnmarshal(t *testing.T) {
buffer := &bytes.Buffer{}
id := []byte{0x00, 0x01}
req := tes... |
package main
import (
"fmt"
"os"
)
const MAXW = 40
const MAXH = 20
// lraudm
func main() {
var canvas [MAXH][MAXW]int
pen := ArtistPen{0, 0, DirUp, PenUp}
prgm := os.Args[1]
for _, cmd := range prgm {
switch string(cmd) {
case "l":
pen.TurnLeft()
case "r":
pen.TurnRight()
case "a":
pen.TurnAro... |
package umeng_sdk_push
import (
"encoding/json"
"net/http"
"bytes"
"io/ioutil"
"log"
)
type UmengNotificationData struct {
AppKey string `json:"appkey"`
Timestamp string `json:"timestamp"`
Type string `json:"type"`
DeviceTokens string `json:"device_tokens"`
Alias... |
// Copyright 2019 - 2022 The Samply Community
//
// 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 lexer
import (
"github.com/leonhfr/nand2tetris/src/hasm/lexer/errors"
"github.com/leonhfr/nand2tetris/src/hasm/lexer/lexertoken"
)
func LexDestOrComp(lexer *Lexer) LexFn {
for {
if lexer.IsNext(lexertoken.EQUAL_SIGN) {
lexer.Emit(lexertoken.TOKEN_C_DEST)
return LexEqualSign
}
if lexer.IsNext(l... |
package categoryTest
import (
"result"
"net/url"
"strconv"
"userDate"
"commonFun"
"log"
"datePrepare"
"database/sql"
)
var conn *sql.DB
func AddCategoryTest()bool{
//增加测试结果,一个测试写一个
result.TesDetailResult("AddCategoryTest")
//case 1
values := url.Values{
"Tid":{""},
"Name":{"商品测试类型"+strconv.Itoa(userDate.... |
package util
import (
"github.com/gin-gonic/gin"
)
// StreamHandleResponse handles the Stream API response.
func StreamHandleResponse(context *gin.Context, body interface{}, err error, messageName string) bool {
if err != nil {
return false
}
context.SSEvent(messageName, body)
return true
}
|
package meta
type Team struct {
TeamID string `json:"teamID"`
TeamNameCH string `json:"teamNameCH"`
TeamNameEN string `json:"teamNameEN"`
}
|
package game
import (
"log"
"github.com/alienteam/omok-server/core"
)
// Game is a main server logic.
type Game struct {
//core.JsonMessageHandler
core.StringMessageHandler
users map[int]*User
rooms map[int]*Room
}
func (s *Game) OnEvent(e core.Event, c *core.Connection, m core.Message) {
switch e {
case c... |
/*
* @lc app=leetcode.cn id=89 lang=golang
*
* [89] 格雷编码
*/
package leetcode
import "math"
// @lc code=start
func grayCode(n int) []int {
/* if n == 1 {
return []int{0, 1}
}
gray := grayCode(n - 1)
res := make([]int, 1 << n)
for i := 0; i < len(gray); i++ {
res[i] = gray[i];
re... |
package main
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
)
func TestSoal1(t *testing.T) {
//with input 3A13 5X19 9Y20 2C18 1N20 3N20 1M21 1F14 9A21 3N21 0E13 5G14 8A23 9E22 3N14
//output 0E13 9E22 9A21 9Y20 8A23 1M21 1N20 1F14 2C18 5X19 5G14 3N21 3N20 3A13
req, err := http.NewRequest("POST", "... |
package re
import (
"regexp"
)
const PATTERN_MY string = `^(?i)(c\.?\s*)?(\d+)/(\-?\d{4}).*`
const PATTERN_MY_LONGFORM string = `^(January|February|March|April|May|June|July|August|September|October|November|December)\s+(\d{4}).*`
const PATTERN_MDY string = `^(?i)(c\.?\s*)?(\d+)/(\d+)/(\-?\d{4}).*`
const PATTERN_... |
package Next_Greater_Element_I
import "container/list"
func nextGreaterElement(nums1 []int, nums2 []int) []int {
stack := list.New()
greater := make(map[int]int, len(nums2))
for _, v := range nums2 {
for stack.Len() != 0 {
e := stack.Back()
if e.Value.(int) >= v {
break
}
stack.Remove(e)
... |
package main
import (
"net/http"
"time"
"github.com/garyburd/redigo/redis"
"log"
"strconv"
"flag"
)
var (
httpServerPort int
)
func init() {
const (
defaultHttpServerPort = 8080
usage = "http server port"
)
flag.IntVar(&httpServerPort, "port", defaultHttpServerPort, usage)
redisPool = &red... |
// 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 meta contains support code for Tast meta tests.
package meta
import (
"context"
"path/filepath"
"reflect"
"github.com/google/go-cmp/cmp"
"github.com/google/... |
package conf_test
import (
"testing"
"github.com/BedeWong/iStock/conf"
)
func TestfnInit(t *testing.T) {
//conf.init()
if conf.GetConfig() != conf.GetConfig() {
t.Logf("两次获取的对象不唯一:\n")
t.Logf("obj1:%v\n", conf.GetConfig())
t.Logf("obj2:%v\n", conf.GetConfig())
}
}
//func Test2(t *testing.T) {
// t.Error... |
package db
import (
"context"
"fmt"
"os"
"github.com/jackc/pgx/v4"
)
var DB *pgx.Conn
func Connect() {
db, err := pgx.Connect(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
panic(err)
}
//defer db.Close(context.Background())
DB = db
fmt.Println("DATABASE::CONNECTED")
}
|
package main
import (
"bufio"
"flag"
"fmt"
"os"
"runtime"
"time"
"github.com/otoolep/bleve-bench"
)
var batchSize = flag.Int("batchSize", 100, "batch size for indexing")
var nShards = flag.Int("shards", 1, "number of indexing shards")
var maxprocs = flag.Int("maxprocs", 1, "GOMAXPROCS")
var indexPath = flag.S... |
package v3
import (
"bytes"
"fmt"
"math"
"sort"
)
// groupID identifies a memo group. Groups have numbers greater than 0; a
// groupID of 0 indicates an empty expression or an unknown group.
type groupID int32
// exprID identifies an expression within its memo group.
type exprID int32
// memoLoc describes the l... |
package main
import (
"github.com/maestre3d/bob/bin"
)
func main() {
// Get bootstrapper
bootstrapper := new(bin.Bootstrap)
// Init CLI
bootstrapper.InitCLI()
}
|
// Copyright (C) 2019 rameshvk. All rights reserved.
// Use of this source code is governed by a MIT-style license
// that can be found in the LICENSE file.
// Package partition provides utilities to partition requests to a cluster.
//
// Every server in the cluster receives requests meant for any
// partition but the... |
package collector_mongod
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
storageEngine = prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "storage_engine"),
"The storage engine used by the MongoDB instance",
[]string{"engine"}, nil)
)
// StorageEngineStats
type StorageEngineStats s... |
package Group_Anagrams
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGroupAnagrams(t *testing.T) {
ast := assert.New(t)
ast.Equal([][]string{
[]string{"eat", "tea", "ate"},
[]string{"tan", "nat"},
[]string{"bat"},
},
groupAnagrams([]string{"eat", "tea", "tan", "ate", "nat", "bat"})... |
package controllers
import (
"net/http"
)
var base *Base
func init() {
base = initBase()
}
func Admin(writer http.ResponseWriter, request *http.Request) {
err := base.DisplayHtmlLayOut(writer, "index.html", nil, nil)
base.DisplayErrorHtml(writer, err)
}
func WelCome(writer http.ResponseWriter, req *http.Reques... |
package main
import (
"fmt"
"log"
"net/http"
"runtime/debug"
)
//Client side Error
func (app *application) clientError(w http.ResponseWriter, status int) {
http.Error(w, http.StatusText(status), status)
}
//Server side Error
func (app *application) serverError(w http.ResponseWriter, err error) {
log.Println("I... |
package git
import (
"context"
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestResolve(t *testing.T) {
tests := []struct {
name string
cloneFake func(context.Context, string, string, string, string) error
branch string
sha string
expectErr bool
}{
{
name: "resolv... |
package gpn
import (
"io/ioutil"
"os"
"testing"
)
func TestGetNumPages(t *testing.T) {
file, err := os.Open("pagination.xml")
defer file.Close()
if err != nil {
t.Errorf("can't no open testing file")
}
byts, _ := ioutil.ReadAll(file)
const expected = 519
actual := GetNumPages(byts)
if expected != actua... |
/*
Package benchmarks includes benchmarks for the components of the SSE
library.
*/
package benchmarks
|
// Copyright 2018 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 hnapi
const (
// TopStoriesURL is the URL used to retrieve the top hacker news stories item
// numbers.
TopStoriesURL = "https://hacker-news.firebaseio.com/v0/topstories.json"
)
// TopStoriesItemNumbers retrieves up to 500 top and new stories are at
// https://hacker-news.firebaseio.com/v0/topstories and
/... |
package db
type DbConfig struct {
Type string `yaml:"type,omitempty"`
}
var Config DbConfig = Defaults()
func SetConfig(config DbConfig) {
Config = config
}
|
package controllers
import (
"net/http"
"strconv"
"github.com/julienschmidt/httprouter"
"github.com/raggaer/castro/app/database"
"github.com/raggaer/castro/app/models"
"github.com/raggaer/castro/app/util"
)
// Home is the main aac homepage
func Home(w http.ResponseWriter, r *http.Request, ps httprouter.Params)... |
/**
硬币找零
状态节点为(amount+1)^2矩阵
一维:次数
二维:累加金额
从第1位开始用
*/
package dynamicProgramming
import "fmt"
type CoinChange struct {
arr []int // 面值(元)
cnt int // 硬币个数
amount int // 需要支付的金额
}
func newCoinChange(
arr []int, cnt, amount int) *CoinChange {
return &CoinChange{
arr: arr,
cnt: cnt,
amount: am... |
package models
type TaxLine struct {
ConektaBase
ID string `json:"id,omitempty"`
Description string `json:"description,omitempty"`
Amount float64 `json:"amount,omitempty"`
ParentID string `json:"parent_id,omitempty"`
}
|
package udwCryptoEncryptV3
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"errors"
"github.com/tachyon-protocol/udw/udwBase64"
"github.com/tachyon-protocol/udw/udwRand"
)
var magicCode4 = [4]byte{0xa7, 0x97, 0x6d, 0x15}
func EncryptV3(key *[32]byte, data []byte) (output []byte) {
Iv := udwRand.MustCryptoRandBy... |
package main
import (
"database/sql"
"flag"
"fmt"
"html/template"
"log"
"net/http"
"strconv"
"time"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/paalka/ewok/pkg/config"
"github.com/paalka/ewok/pkg/db"
"github.com/paalka/ewok/pkg/feed"
)
const (
ITEMS_PER_PAGE = 30
)
func re... |
package courses
import (
"encoding/json"
"github.com/gin-gonic/gin"
"net/http"
)
/* Public */
func SetupRoutes(router *gin.Engine) {
router.GET("/courses/:code", getCourseByCode)
router.GET("/courses/:code/posts", getCoursePosts)
router.POST("/courses/", createCourse)
}
/* GET */
func getCourseByCode(c *gin.Co... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.