text stringlengths 11 4.05M |
|---|
package wordcounter
import (
"bufio"
)
type WordLineCounter struct {
words, lines int
terminated bool
}
func (c *WordLineCounter) Write(p []byte) (n int, err error) {
for _, b := range p {
if b == '\n' {
c.lines++
}
}
for b := p; len(b) > 0; {
advance, _, _ := bufio.ScanWords(b, true)
b = b[advanc... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/6/12 7:23 上午
# @File : lt_二叉树的最近公共祖先.go
# @Description :
# @Attention :
*/
package v2
func lowestCommonAncestor(root, p, q *TreeNode) *TreeNode {
if root == nil {
return nil
}
if root == p || root == q {
return root
}
leftRoot := lowestCommonAncestor... |
package aliyun
import (
"github.com/gogap/config"
"github.com/gogap/context"
"github.com/gogap/flow"
)
func init() {
flow.RegisterHandler("devops.aliyun.vpc.vpc.create", CreateVPC)
flow.RegisterHandler("devops.aliyun.vpc.vpc.delete", DeleteVPC)
flow.RegisterHandler("devops.aliyun.vpc.vpc.running.wait", WaitForA... |
// Copyright 2023 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 routes
import (
//"github.com/adamveld12/goadventure/game"
"fmt"
"github.com/adamveld12/goadventure/persistence"
"github.com/adamveld12/sessionauth"
"github.com/go-martini/martini"
"github.com/martini-contrib/render"
"github.com/martini-contrib/sessions"
"log"
"net/http"
)
func registerPageRoutes(r m... |
package main
import "testing"
func areEqual(a, b []string) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if a[i] != b[i] {
return false
}
}
return true
}
func checkFail(t *testing.T, resultWords, expectedWords []string) {
if !areEqual(resultWords, expectedWords) {
... |
package dbservice
import (
"testing"
"github.com/nerdyfactory/nf-backend-go-template/internal/testutil"
)
func TestConnect(t *testing.T) {
testutil.InitDb()
db, err := Connect()
if err != nil {
t.Errorf("Error opening db connection: %v", err)
return
}
err = db.Ping()
if err != nil {
t.Errorf("Error c... |
package minify
import (
"net/http"
)
var urlCss = "http://cssminifier.com/raw"
func MinifyCss(filepath string) {
MinifyFromFile(filepath, urlCss, "styles")
}
func AppCssHandler(writer http.ResponseWriter, request *http.Request) {
write(writer, "styles")
}
|
package main
import (
"bufio"
"bytes"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
"runtime/pprof"
"sort"
"github.com/p-id/regrep/internal/index"
"github.com/p-id/regrep/internal/regexp"
)
var usageMessage = `usage: regrep regexp [target-file-search] [-o target-result-output|stdout]
Regrep ... |
package core
import (
"sync"
"github.com/castillobg/ping/brokers"
)
var waitingForPong = make([]chan []byte, 0)
var pongListenersLock = new(sync.Mutex)
func Listen(broker brokers.BrokerAdapter, pongs chan []byte, pongListeners chan chan []byte) {
go func() {
// Listens for pong events
for pong := range pongs... |
// Package v1beta1 contains API Schema definitions for the test v1beta1 API group
// +k8s:deepcopy-gen=package,register
// +groupName=test.opsI
package v1beta1
|
package camt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document05900105 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:camt.059.001.05 Document"`
Message *NotificationToReceiveStatusReportV05 `xml:"NtfctnToRcvStsRpt"`
}
fu... |
package main
import (
"fmt"
)
func handleSlice(s []int , index int) {
fmt.Println("Received slice = ",s)
s[index] *= 2
fmt.Println("After change the content at index = ",s)
}
func doubles(s int) {
s *= 2
}
func doublePtr(s *int) {
*s *= 2
}
func main() {
fmt.Println("Let's learn how to pass slice to funct... |
// Copyright (c) 2017 Daniel Oaks <daniel@danieloaks.net>
// released under the MIT license
package caps
// Capability represents an optional feature that a client may request from the server.
type Capability string
const (
// LabelTagName is the tag name used for the labeled-response spec.
LabelTagName = "draft/l... |
package secret
import (
"github.com/spf13/cobra"
"opendev.org/airship/airshipctl/cmd/document/secret/generate"
"opendev.org/airship/airshipctl/pkg/environment"
)
// NewSecretCommand creates a new command for managing airshipctl secrets
func NewSecretCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Com... |
// Copyright 2016-2019 Authors of Cilium
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... |
/*
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... |
package eval
import (
"fmt"
)
func handleEQL(n *node, e *environment) interface{} {
if n.childen == nil || len(n.childen) < 2 {
panic(fmt.Sprintf("op: %s need 2 or more args", n.tok.String()))
}
for i := 1; i < len(n.childen); i++ {
if n.childen[0].value(e) != n.childen[i].value(e) {
return false
}
}
... |
package services
import (
"fmt"
"time"
"github.com/go-kit/kit/metrics"
kitprometheus "github.com/go-kit/kit/metrics/prometheus"
stdprometheus "github.com/prometheus/client_golang/prometheus"
)
type instrumentingMiddleware struct {
requestCount metrics.Counter
requestLatency metrics.Histogram
next ... |
package main
import (
"flag"
"fmt"
"sort"
filehandler "github.com/Brofo/is105-ica03/files/lineshift/lineshiftpack/filehandler"
)
var lines int
func main() {
argument := flag.Arg(0)
filename := flag.String("f", argument, "File to read")
flag.Parse()
LineCount(*filename)
fmt.Println("Linjer i tekstfilen: ",... |
package auth
import (
"crypto"
"crypto/rsa"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"log"
"time"
"encoding/base64"
"github.com/kataras/iris"
)
type AuthHeaderContent struct {
D []byte `json:"d"`
S []byte `json:"s"`
}
type AuthPayload struct {
exp *time.Time `json:"exp,omitempty"`
// TODO: Define... |
package main
import "fmt"
/*
全局变量 和局部变量
*/
var num int = 10
var num2 int = 20
func main() {
/* main 函数中 声明局部变量 */
num, num2, height := 1, 2, 3
fmt.Printf("man() num=%d , num2=%d,height=%d \n", num, num2, height)
ret := sum(num, num2)
fmt.Printf("main() ret=%d", ret)
}
func sum(num, num2 int) (ret int) {... |
package algorithm
/*
时间轮,内部的元素到期之后自动执行其回调方法
V1 不提供运行时数组扩容
V2 分层时间轮
时间轮算法实现延迟任务的处理
1. 数据结构:是一个环状数组,并且为了解决hash冲突,采用的是链地址法,名为Slot,并且存放的是其执行的任务(V3分发到线程池)
*/
// 因为时间轮是其内部到期之后自动执行回调
// 因此抽为接口
type SlotNodeInterfacer interface {
CallBack() (interface{}, error)
}
type slotNode struct {
data interface{}
next *slotNode... |
package sheet_logic
import "testing"
import "hub/sheet_logic/sheet_logic_types"
func TestShouldBeAbleToCreateIntConstant(t *testing.T) {
uut := NewIntConstant(variableName, exampleIntValue)
grammarElementScenario(t, uut.GrammarElement, sheet_logic_types.IntConstant)
assertCalculatesToInt(
t,
uut,
exampleInt... |
package cache
import (
"testing"
"time"
ut "github.com/ben-han-cn/cement/unittest"
"github.com/ben-han-cn/g53"
"github.com/ben-han-cn/vanguard/logger"
)
func buildMessage(name_ string, ips []string, ttl int) *g53.Message {
header := g53.Header{
Id: 1000,
Opcode: g53.OP_QUERY,
Rcode: g53.R_NOERROR... |
package main
import (
"fmt"
"github.com/garyburd/redigo/redis"
)
const HOST = "localhost:6379"
var pool *redis.Pool // 创建redis的连接池
func init() {
// 初始化一个连接池
pool = &redis.Pool{
MaxIdle: 16, //最初的一个连接数
//MaxActive: 10000, // 最大连接数
MaxActive: 0, // 最大连接数不受控制, 设置为0 按需分配
IdleTimeout: 3000, // 如果一个链接在300秒内没链... |
package ufs
import (
"defs"
"fd"
"fs"
"log"
"os"
"stat"
"ustr"
"vm"
)
//
// FS
//
type Ufs_t struct {
ahci *ahci_disk_t
fs *fs.Fs_t
cwd *fd.Cwd_t
}
func mkData(v uint8, n int) *vm.Fakeubuf_t {
hdata := make([]uint8, n)
for i := range hdata {
hdata[i] = v
}
ub := &vm.Fakeubuf_t{}
ub.Fake_init(hd... |
/*
Created by Todd Chaney
This is start of a library and API that is used in competitive programming, it contains
general functions that are necessary frequently. And useful information or that will be somewhere else.
TBD
*/
// The min function acting on integers
func min(x, y int) int {
if x < y {
return x
}
... |
package main
import (
// "encoding/json"
"bytes"
"compress/gzip"
_ "encoding/base64"
"fmt"
"log"
"os"
_ "reflect"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kinesis"
)
func main() {
sess := session.Must(session.NewSessionWithOption... |
// Copyright (c) 2020 Blockwatch Data Inc.
// Author: alex@blockwatch.cc
package micheline
import (
"bytes"
"encoding/binary"
"encoding/json"
"fmt"
"io"
)
type Script struct {
Code *Code `json:"code"` // code section, i.e. parameter & storage types, code
Storage *Prim `json:"storage"` // data section, i... |
package devicesearch
import (
"fmt"
"time"
"github.com/rakyll/portmidi"
"github.com/telyn/midi/korg/korgdevices"
"github.com/telyn/midi/korg/korgdispatch"
"github.com/telyn/midi/korg/korgsysex/search"
"github.com/telyn/midi/sysex"
)
type searcher struct {
in deviceStreams
out deviceStreams
seeking korgde... |
package redis_client
import (
"github.com/go-redis/redis"
services "gocherry-api-gateway/proxy/service"
"time"
)
type Client struct {
baseClient *redis.Client
}
//内部调用
func RedisClient(class string) *Client {
Addr := ""
Password := ""
DB := 0
appConfig := services.GetAppConfig()
switch class {
case "prox... |
package main
import (
_ "github.com/wangfmD/rvs/log"
loger "log"
"errors"
)
func main() {
loger.Println("ddd")
}
// package main
// import (
// "fmt"
// "github.com/satori/go.uuid"
// "github.com/wangfmD/rvs/setting"
// )
// func f1() {
// uuid1 := uuid.NewV4()
// fmt.Printf(",%T", uuid1.String())
// fm... |
// 45. DSA parameter tampering
package main
import (
"bufio"
"crypto/dsa"
"crypto/rand"
"crypto/sha256"
"errors"
"fmt"
"io"
"math/big"
weak "math/rand"
"os"
"strings"
"time"
)
const (
dsaPrime = `800000000000000089e1855218a0e7dac38136ffafa72eda7
859f2171e25e65eac698c1702578b07dc2a1076da241c76c6
2d374d83... |
package clock
import (
"context"
"runtime"
"sync"
"time"
)
// Mock 实现了 Clock 接口,并提供了 .Add*,.Set* 和 .Move 方法驱动时钟运行
//
// 为了尽可能真实地模拟时间的流逝,Mock.now 只会不断变大,不会出现逆转情况。
//
// RWMutex 锁住 Mock 时,其他 goroutine 的 Mock 方法会被阻塞。
// Mock 的运行也不适均匀的,有可能下一个时刻就是很久以后。
// 这是与 time 标准库的主要差异,使用 Mock 时,请特别注意。
//
// TODO: 删除此处内容
type Mock... |
// +build !no_gzip
package compress
import (
"bytes"
"compress/gzip"
"github.com/xitongsys/parquet-go/parquet"
"io/ioutil"
)
func init() {
compressors[parquet.CompressionCodec_GZIP] = &Compressor{
Compress: func(buf []byte) []byte {
var res bytes.Buffer
gzipWriter := gzip.NewWriter(&res)
gzipWriter.W... |
// winmetric project winmetric.go
// +build windows
package win
type (
HANDLE uintptr // handle
)
|
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use ... |
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func Test_findNumbers(t *testing.T) {
tcs := []struct {
input []int
output int
}{
{[]int{12, 345, 2, 6, 7896}, 2},
{[]int{555, 901, 482, 1771}, 1},
}
for _, tc := range tcs {
t.Run("성공", func(t *testing.T) {
result := findNumb... |
package utils
import (
"net/http"
tr "github.com/ebikode/eLearning-core/translation"
)
// Translate Tranlates string based on customer request lang param
func Translate(tParam tr.TParam, r *http.Request) string {
params, ok := r.URL.Query()["lang"]
lang := "en"
// Change the language if lang param is provided
... |
package bbir
import (
"strings"
)
func NewLine(header []string, record []string) *Line {
line := &Line{CustomFields: make(map[string]string)}
for i, v := range record {
if i < len(injectors) {
injectors[i](v, line)
} else {
line.CustomFields[header[i]] = v
}
}
return line
}
var injectors = []func(st... |
package main
import "fmt"
func main() {
matrix := [][]int{{1, 1, 1, 2}, {0, 5, 0, 4}, {2, 1, 3, 6}}
column := 2
var arr []int
for i := 0; i < len(matrix); i++ {
for j := 0; j < len(matrix[i]); j++ {
if j == column {
arr = append(arr, matrix[i][j])
}
}
}
fmt.Println(arr)
}
|
// Copyright 2023 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 clusterext
import (
"github.com/wish/ctl/pkg/client/filter"
"github.com/wish/ctl/pkg/client/types"
"log"
)
// Extension is an object that inserts cluster entries into the labels of objects
// it also supports filtering clusters by labels
type Extension struct {
ClusterExt map[string]map[string]string
K8E... |
package processor
import (
"github.com/bitmaelum/bitmaelum-suite/internal/container"
"github.com/bitmaelum/bitmaelum-suite/internal/message"
"github.com/sirupsen/logrus"
"io/ioutil"
)
// ProcessStuckIncomingMessages will process stuck message found in the incoming queue.
func ProcessStuckIncomingMessages() {
p, ... |
package rest
import (
"github.com/gin-gonic/gin"
"github.com/morteza-r/flexdb-server/app/api/rest/req"
"github.com/morteza-r/flexdb-server/app/application"
"net/http"
)
type DbController struct {
DbService application.DbService
}
func (pc *DbController) Query(c *gin.Context) {
var queryReq req.QueryRequest
er... |
package main
import (
"models"
"seeds"
//"fmt"
"databaseConn"
"fetcher"
)
func main() {
var db = databaseConn.DB{}.GetDB()
defer db.Close()
err := db.AutoMigrate(&models.Comment{}, &models.Post{}, &models.Image{}, &models.Subreddit{})
if err.Error != nil{
panic("Migrating failed")
}
seeds.Execute()
fetc... |
// Copyright 2016 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 cloud
import "strings"
type tpLinkChildIDs struct {
ChildIDs []string `json:"child_ids"`
}
type tpLinkContext struct {
TPLinkChildren tpLinkChildIDs `json:"context"`
SystemPayload string `json:"system"`
}
func buildContextPayload(systemCall string, ids []string) tpLinkContext {
var c = tpLinkCo... |
// Package jsonpbserializer implements a fsm.StateSerializer that uses jsonpb as
// the underlying JSON serializer, rather than stdlibs. This is used for
// providing consistent serialization of types generated by the protobuf
// compiler. If a type that is not a proto.Message is used, it will fall through
// to an alt... |
package routes
import (
"log"
"mux-rest-api/web/handler"
"github.com/gorilla/mux"
"go.mongodb.org/mongo-driver/mongo"
)
//MyRoutes - This interface provides the object with the responsibility to configure the routes of the application.
type MyRoutes interface {
Install(h handler.HandlerRoute)
}
//myRoutes - Th... |
// SPDX-License-Identifier: Apache-2.0
// Copyright © 2020 Intel Corporation
package af
import (
"context"
"encoding/json"
"net/http"
"net/url"
)
func createPfdTransaction(cliCtx context.Context, pfdTrans PfdManagement,
afCtx *Context) (PfdManagement, *http.Response, []byte, error) {
cliCfg := NewConfiguratio... |
package web
import (
"context"
"crypto/rand"
"crypto/sha1"
"fmt"
"net/http"
"strings"
"time"
"github.com/autograde/aguis/ci"
"github.com/autograde/aguis/database"
"github.com/autograde/aguis/scm"
"github.com/jinzhu/gorm"
"go.uber.org/zap"
webhooks "gopkg.in/go-playground/webhooks.v3"
"gopkg.in/go-playg... |
package domain
import "time"
// DiscountParam provide the period of discount
type DiscountParam struct {
Percentage float64
StartTime *time.Time
EndTime *time.Time
}
|
/*
Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.
The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough fo... |
package main
import "fmt"
func main() {
fmt.Println("input")
var name string
fmt.Scanln(&name)
fmt.Println("hello", name)
}
|
package containerimagebuilderpusher
import "github.com/nuclio/nuclio/pkg/processor/build/runtime"
// BuildOptions are options for building a container image
type BuildOptions struct {
Image string
ContextDir string
TempDir string
DockerfileInfo *runtime.ProcessorDockerfileI... |
package handler
import (
"encoding/json"
"log"
. "meli/pkg/request"
"net/http"
. "meli/cmd/data"
"github.com/gorilla/mux"
. "github.com/patrickmn/go-cache"
)
type Empty struct{}
func TopSecretSplitPushSingleHandler(w http.ResponseWriter, r *http.Request, c *Cache) {
var request SateliteRequest
err := json... |
package main
import (
"encoding/json"
"io/ioutil"
"net/http"
)
const spotPriceAPI = "https://api.coinbase.com/v2/prices/spot?currency=USD"
type Amount struct {
Amount string
Currency string
}
type PriceResponse struct {
Data Amount
}
func CurrentPrice() (string, error) {
resp, err := http.Get(spotPriceAPI)... |
package functions
// Diff returns the elements that needs to be added or removed from the first
// slice to have the same elements in the second slice.
//
// The order of elements is not taken into consideration, so the slices are
// treated sets that allow duplicate items.
//
// The added and removed returned may be ... |
package allyourbase
import (
"fmt"
)
func ConvertToBase(inputBase int, inputDigits []int, outputBase int) ([]int, error) {
err := isValidInput(inputBase, outputBase, inputDigits)
if err != nil {
return nil, err
}
value := convertToInt(inputDigits, inputBase)
return convertToDigits(value, outputBase), nil
}
f... |
package main
import (
"net/http"
"os"
"time"
. "github.com/izacus/PrometPush/src"
"github.com/getsentry/sentry-go"
"github.com/julienschmidt/httprouter"
"github.com/robfig/cron"
"github.com/scalingdata/gcfg"
log "github.com/sirupsen/logrus"
)
type Config struct {
Push struct {
Dsn string
Fi... |
package toolkit
import "regexp"
// GetWordsFormString 获取 str 中的单词
func GetWordsFormString(str string) (words []string) {
compile := regexp.MustCompile(`\w+`)
for _, word := range compile.FindAll([]byte(str), -1) {
words = append(words, string(word))
}
return words
}
|
package handlers
import (
"net/http"
"github.com/KyleWS/blog-api/api-server/logging"
"gopkg.in/mgo.v2/bson"
)
// CORS struct contains handler that will attach proper Access-Control headers
type CORS struct {
Handler http.Handler
}
// NewCORS returns cors object with given handler assigned
func NewCORS(handler h... |
package hello
import (
"fmt"
"log"
"go.mongodb.org/mongo-driver/bson"
"context"
"go.mongodb.org/mongo-driver/mongo"
"encoding/json"
"net/http"
)
type Person struct {
Name string `json:"name"`
Age int64 `json:"age"`
Ls []int `json:"ls"`
}
func GetProfile(w http.ResponseWriter, r *http.Request) {
per... |
package main
import (
"os"
"time"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/contrib/ginrus"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"urlshortener.api/urlshorten/delivery/http"
)
// SetupRouter returns a framework's instance
func SetupRouter(h *http.UrlHandler) *gin.Engine {
router ... |
/*
Copyright 2011 Google 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 in writing, software
di... |
package main
func reversePairs(nums []int) int {
res := 0
tmp := make([]int, len(nums))
mergeSort(nums, 0, len(nums)-1, tmp, &res)
return res
}
func mergeSort(nums []int, left, right int, tmp []int, res *int) {
if left >= right {
return
}
mid := left + (right-left)/2
mergeSort(nums, left, mid, tmp, res)
me... |
/*
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
*/
package main
import (
"fmt"
"math"
)
func main() {
n := int64(600851475143)
max := math.Ceil(math.Sqrt(float64(n)))
out := generate(&max)
for p := range out {
if n%p == 0 {
fmt.Println(p)... |
package pgsql_test
import (
"context"
"regexp"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/syahidfrd/go-boilerplate/domain"
"github.com/syahidfrd/go-boilerplate/repository/pgsql"
"gopkg.in/DATA-DOG/go-sqlmock.v1"
)
func TestCreate(t *testing.T) {
author := &domain.Author{
Name: ... |
package collections
import (
"text/template"
)
var FuncMap = template.FuncMap {
"find": Find,
"join": Join,
"pluck": Pluck,
"slice": Slice,
"sort": Sort,
"where": Where,
}
|
package redis
import (
"bytes"
"context"
"encoding/gob"
"errors"
"time"
"github.com/sirupsen/logrus"
"github.com/Secured-Finance/dione/cache"
"github.com/go-redis/redis/v8"
)
type Cache struct {
redisClient *redis.Client
ctx context.Context
name string
}
func NewCache(redisClient *redis.... |
package xmpp
import (
"encoding/xml"
)
const (
NSRemoteRosterManager = "urn:xmpp:tmp:roster-management:0"
RemoteRosterManagerTypeRequest = "request"
RemoteRosterManagerTypeAllowed = "allowed"
RemoteRosterManagerTypeRejected = "rejected"
)
// XEP-0321: Remote Roster Manager
type RemoteRosterManagerQuery stru... |
// Copyright 2022 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... |
// Copyright 2018 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
package sso
import (
"crypto/rsa"
"fmt"
"net/http"
"time"
jwt "github.com/dgrijalva/jwt-go"
"github.com/labstack/echo"
"golang.org/x/oauth2"
)
// JWTAuthConfig represents the config for the JWT authentication middleware.
type JWTAuthConfig struct {
TokenCookieName string
PrivateKey *rsa.PrivateKey
}
/... |
// Package xs contains eXtended actions (xactions) except storage services
// (mirror, ec) and extensions (downloader, lru).
/*
* Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved.
*/
package xs
import (
"github.com/NVIDIA/aistore/cluster"
"github.com/NVIDIA/aistore/cmn"
"github.com/NVIDIA/aistore/... |
package persistence
import (
"github.com/dollarshaveclub/acyl/pkg/config"
"github.com/dollarshaveclub/acyl/pkg/metrics"
"github.com/dollarshaveclub/acyl/pkg/models"
)
type QAType = models.QAType
type QAEnvironment = models.QAEnvironment
type QAEnvironments = models.QAEnvironments
type EnvironmentStatus = models.En... |
package main
import (
"time"
)
type VoteJob struct {
Name string
Proxy string
IsLast bool
HasSuccessVoted bool
HasFailVoted bool
HasError string
SuccessVoteText string
FailVoteText string
}
func (s *VoteJob) Run() {
image, cookieReceived, e... |
// Package gui contains templates and static files used in bridge admin GUI.
package gui
//go:generate go-bindata -ignore .+\.go$ -pkg gui -o bindata.go -prefix ../../../../../../gui/dist ../../../../../../gui/dist
|
package main
import (
"encoding/json"
"net/http"
"github.com/stripe/stripe-go"
"github.com/stripe/stripe-go/client"
"google.golang.org/appengine"
"google.golang.org/appengine/urlfetch"
)
type SoldResponse struct {
Sold int `json:"sold"`
}
type PaymentArgs struct {
BillingName string `json:"billin... |
package jaeger
import (
"context"
"fmt"
"github.com/opentracing/opentracing-go"
"github.com/uber/jaeger-client-go"
"github.com/uber/jaeger-client-go/config"
"io"
)
// InitJaeger returns an instance of Jaeger Tracer that samples 100% of traces and logs all spans to stdout.
func InitJaeger(service string, host st... |
/*
Copyright 2019 Adobe. All rights reserved.
This file is licensed to you 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... |
/*
* @lc app=leetcode.cn id=872 lang=golang
*
* [872] 叶子相似的树
*/
// @lc code=start
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
package main
func getLeaves(root *TreeNode) []int {
if root == nil {
return []int{}
}
if r... |
package router
import "net/http"
type (
Route struct {
Path string
Method string
Handler http.HandlerFunc
}
)
|
package Problem0224
func calculate(s string) int {
res := 0
stack := make([]int, 0, len(s))
sign := 1
num := 0
for i := 0; i < len(s); i++ {
switch s[i] {
case '1', '2', '3', '4', '5', '6', '7', '8', '9', '0':
// 提取 s 中的数字
num = 0
for ; i < len(s) && s[i] >= '0' && s[i] <= '9'; i++ {
num = 10*nu... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//447. Number of Boomerangs
//Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the di... |
package client
import (
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"time"
"github.com/ninjasphere/go-ninja/config"
)
type Node struct {
ID string `json:"node_id"`
SiteID string `json:"site_id"`
}
type Site struct {
ID string `json:"site_id"`
MasterNodeID string `jso... |
package format
import (
"github.com/plandem/xlsx/internal/ml/primitives"
)
//List of all possible values for UnderlineType
const (
UnderlineTypeSingle primitives.UnderlineType = "single"
UnderlineTypeDouble primitives.UnderlineType = "double"
UnderlineTypeSingleAccounting primitives.UnderlineT... |
package prometheuscustomexporter
import (
"bytes"
"context"
"errors"
metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1"
// TODO: once this repository has been transferred to the
// official census-ecosystem location, update this import path.
"go.opentelemetry.io/collector/compone... |
/*
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, softw... |
package kubeclient
import (
"encoding/json"
"fmt"
"golang.org/x/build/kubernetes/api"
"golang.org/x/net/context"
)
const (
endpointsPath = apiPrefix + "/namespaces/%s/endpoints"
)
func (c *Client) EndpointsList(ctx context.Context, namespace, label string) ([]api.Endpoints, error) {
var endpoints []api.Endpoi... |
package main
import "fmt"
func main() {
sum := 0
curr := 1
prev := 0
temp := 0
for curr < 4000000 {
temp = curr
curr = curr + prev
prev = temp
if curr%2 == 0 {
sum += curr
}
}
fmt.Println(sum)
}
|
package main
import (
"encoding/json"
"fmt"
"os"
)
type Address struct {
Type string
City string
Country string
}
type VCard struct {
FirstName string
LastName string
Addresses []*Address
Remark string
}
func main() {
pa := &Address{"private", "Aartselaar", "Belgium"}
wa := &Address{"work", "B... |
package preprocessing
import (
"bufio"
"github.com/semi-technologies/contextionary/compoundsplitting"
"github.com/stretchr/testify/assert"
"os"
"strings"
"testing"
)
func TestPreprocessorSplitterDictFile(t *testing.T) {
// Create the file
outputFile := "test_dict.splitdict"
GenerateSplittingDictFile("../test... |
package stack
import (
"strconv"
)
func calPoints(ops []string) int {
points := []int{}
for _, v := range ops {
l := len(points)
switch v {
case "+":
cur := points[l-2] + points[l-1]
points = append(points, cur)
case "D":
cur := 2 * points[l-1]
points = append(points, cur)
case "C":
points... |
// Copyright 2018 Kuei-chun Chen. All rights reserved.
package sim
import (
"context"
"os"
"testing"
"go.mongodb.org/mongo-driver/x/mongo/driver/connstring"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
var UnitTestURL = "mongodb://local... |
package main
import (
"MP1/initialization"
"MP1/tcp"
)
func main() {
// Read information from command line and configuration file to obtain the node the process should act as
// and a list of valid nodes to send messages to.
node, nodes := initialization.InitializeNode()
// Set up TCP listening for process, co... |
package Interprete
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"regexp"
"strconv"
"strings"
"../Metodos"
"../Structs"
)
func Interpreter(linea string, disco *[27]Structs.Disco) {
linea = ruta(linea)
linea = comentario(linea)
comando := strings.Split(linea, " ")
switch ejecutar := comando[0]; strings.ToLower... |
// este exemplo é um pequeno programa que ao ser executado verifica se uma lista de websites estão offline ou online
// este programa tem o mesmo próposito do anterior, porém, ao invés de utilizarmos os canais, a concorrência é implementada através dos wait groups
package main
import (
"fmt"
"net/http"
"sy... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.