text stringlengths 11 4.05M |
|---|
package css
const (
Absolute = "absolute"
AlignBaseline = "align-baseline"
AlignBottom = "align-bottom"
AlignMiddle = "align-middle"
AlignTextBottom = "align-text-bottom"
AlignTextTop = "align-text-top"
AlignTop ... |
package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq"
)
// DDL
const (
dropTable = `DROP TABLE IF EXISTS person`
createTable = `
CREATE TABLE person (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(20) DEFAULT NULL,
national_id long NOT NULL DEFAULT 0,
meta... |
package cloud
import (
"net/http"
"testing"
client "github.com/devspace-cloud/devspace/pkg/devspace/cloud/client/testing"
fakeBrowser "github.com/devspace-cloud/devspace/pkg/util/browser/testing"
log "github.com/devspace-cloud/devspace/pkg/util/log/testing"
"github.com/pkg/errors"
"gotest.tools/assert"
)
type... |
package instruction
type GitCommit struct{}
|
package adapter
import (
"os/exec"
"strings"
"testing"
"time"
"mqtt-adapter/src/config"
"mqtt-adapter/src/logger"
"github.com/sirupsen/logrus"
)
func TestNew(t *testing.T) {
svr := getMockServer()
defer svr.Close()
go svr.ListenAndServe(mockURL)
<-time.After(time.Millisecond * 100)
logger.Log = &logrus... |
package sese
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document00600103 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.006.001.03 Document"`
Message *TransferInCancellationRequestV03 `xml:"TrfInCxlReq"`
}
func (d *Documen... |
func findDuplicates(nums []int) []int {
var x int
var dupes []int
count := make(map[int]int)
for ; len(nums) > 0; {
x, nums = nums[len(nums)-1], nums[:len(nums)-1]
if _, ok := count[x]; ok {
count[x] += 1
} else {
count[x] = 1
}
}
for k, v := range count {
if v > 1 {
dupes = append(dupes, k)
... |
package route
import (
"net/http"
"pencil/lib"
"pencil/api/bind"
"pencil/api/confirm"
"pencil/api/cookie"
"pencil/api/filter"
"pencil/api/form"
"pencil/api/index"
"pencil/api/login"
"pencil/api/query"
"pencil/api/show"
"strings"
"time"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/9/7 9:22 下午
# @File : lt_76_最小覆盖子串.go
# @Description :
# @Attention :
*/
package offer
import "math"
func minWindow(s string, t string) string {
left, right := 0, 0
match := 0
start := 0
end := 0
min := math.MaxInt32
need := make(map[byte]int)
have :... |
package main
import "sync"
var lock sync.RWMutex
//var detailslock sync.RWMutex
func ingestafruizioni(hashfruizione, clientip, idvideoteca, idaps, edgeip, giorno, orario string, speed float64) {
lock.Lock()
defer lock.Unlock()
if F.Hashfruizione[hashfruizione] == false {
F.Hashfruizione[hashfruizione] = true
... |
// Gtk Go Clock demo
// License MIT
package main
import (
"fmt"
"math"
"time"
"github.com/gotk3/gotk3/cairo"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/gtk"
"image/color"
"golang.org/x/image/colornames"
)
// global var
var wfx float64
var wfy float64
var radius float64
var lastTime time.Time
var... |
// +build origin
package main
import (
"fmt"
)
func ccSay() {
fmt.Println("i'm CC")
}
const deadCode = false
|
package generator
import (
"io"
"log"
"strconv"
"strings"
"github.com/frk/gosql/internal/analysis"
"github.com/frk/gosql/internal/config"
"github.com/frk/gosql/internal/postgres"
"github.com/frk/gosql/internal/postgres/oid"
GO "github.com/frk/ast/golang"
SQL "github.com/frk/ast/sqlang"
)
var _ = log.Print... |
package leetcode
import "testing"
func TestIsPalindrome(t *testing.T) {
tests := []struct {
grid [][]byte
number int
}{
{
grid: [][]byte{
{'1', '1', '1', '1', '0'},
{'1', '1', '0', '1', '0'},
{'1', '1', '0', '0', '0'},
{'0', '0', '0', '0', '0'},
},
number: 1,
},
{
grid: [][]b... |
package main
import (
"fmt"
"log"
"net"
"strings"
"net/rpc/jsonrpc"
//"net/url"
//"net/http"
//"encoding/json"
"os"
)
type Stock struct {
name string
cost int
}
var ssp string
//var budget float32
func main() {
client, err := net.Dial("tcp", "127.0.0.1:1234")
if err != nil {
log.Fatal("dialing:", err... |
package configure
import (
"github.com/devspace-cloud/devspace/pkg/devspace/cloud"
"github.com/devspace-cloud/devspace/pkg/devspace/cloud/config"
"github.com/devspace-cloud/devspace/pkg/devspace/config/generated"
"github.com/devspace-cloud/devspace/pkg/devspace/config/versions/latest"
"github.com/devspace-cloud/d... |
package ctcp
import (
"errors"
"strings"
)
const ctcpChar = 0x01
const ctcpCharString = string(byte(ctcpChar))
// IsCTCP returns whether or not the given string is a valid CTCP command
func IsCTCP(s string) bool {
return len(s) > 1 && s[0] == ctcpChar
}
// CTCP represents a CTCP command and argument
type CTCP st... |
package events
import (
"context"
"encoding/json"
"fmt"
"math/big"
"strings"
"log"
"../db"
"../plasmacontract"
"../utils"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethere... |
package google
import (
"github.com/dgryski/dgoogauth"
"math"
"strconv"
"time"
)
func Index(secretKey string) string {
t := int64(math.Floor(float64(time.Now().Unix() / 30)))
return strconv.Itoa(dgoogauth.ComputeCode(secretKey, t))
}
|
package str
type Employee struct {
FirstName string
LastName string
//ERROR map[string]int
Age int
salary int
}
|
package main
import (
"fmt"
"log"
"os"
"os/exec"
"github.com/MovingtoMars/ssvm/ir"
"github.com/MovingtoMars/ssvm/target/platform"
"github.com/MovingtoMars/ssvm/target/x86"
)
// Testing SSVM
func main() {
mod := makeMod()
fmt.Print("\n\n\n")
output(mod)
}
func output(mod *ir.Module) {
target := x86.NewTar... |
package temple
// Initialise New Temple Context
func New(path string) (*Temple, error) {
tpl := Temple{ Path: path, Debug: true }
tpl.Context = Context{}
err := tpl.Compile()
if err != nil { return nil, err }
return &tpl, nil
}
|
// Copyright 2018 Diego Bernardes. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package flare
import (
"context"
"github.com/pkg/errors"
)
// WorkerWrap is used with Worker to implement a generic worker. The messages should be
// enca... |
// +build windows
package main
import (
"fmt"
)
// Hi from windows
func Hi() {
fmt.Println("Hi from: hello_windows.go")
}
// HiDup
func HiDup() {
fmt.Println("HiDup from: hello_windows.go")
}
|
package exchange
import (
"github.com/streamingfast/sparkle/entity"
)
func (s *Subgraph) HandlePairBurnEvent(ev *PairBurnEvent) error {
if s.StepBelow(3) {
return nil
}
trx := NewTransaction(ev.Transaction.Hash.Pretty())
if err := s.Load(trx); err != nil {
return err
}
// safety check
if !trx.Exists() {... |
package main
import (
"fmt"
"net/smtp"
"os"
"time"
)
// RepeatType defines how often the job is repeated. Defaults to None
type RepeatType uint
// RepeatType options
const (
RepeatNone RepeatType = iota
RepeatDaily
RepeatWeekly
RepeatMonthly
)
func (r RepeatType) String() string {
... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/8/19 8:46 下午
# @File : lt_15_3sum.go
# @Description :
# @Attention :
*/
package offer
// a+b+c =0
// 固定住首位 ,b,c 头尾双指针
// 然后 a+b+c >0 则移到尾巴指针, 若 a+b+c<0 则移动首指针 ,==0 的话,还需要去除重复元素
func threeSum(nums []int) [][]int {
// sort.Ints(nums)
threeSumQSort(nums,0, le... |
/**
- 4.5:编写一个就地处理函数,用于去除 []string slice 中相邻的重复字符串元素
*/
package main
import "fmt"
func main() {
a := []string{"s", "a", "a", "s", "d", "z", "a", "z", "v", "w", "w", "a", "a"}
removeMultiple(&a)
fmt.Println(a)
}
func removeMultiple(a *[]string) {
A := *a
l := len(A)
for i := 0; i < l-1; i++ {
prev := A[i]
... |
package variables
import "fmt"
// notice:
// naming variable for in-package scope first letter small
// naming variable for out-package scope first letter capital
// all variables must be used
// can't redeclare variables but can shadow them
func Variables() {
// ways to declare variable
var i int
i = 3
j ... |
// Source : https://oj.leetcode.com/problems/implement-strstr/
// Author : Austin Vern Songer
// Date : 2016-04-25
/**********************************************************************************
*
* Implement strStr().
*
* Returns a pointer to the first occurrence of needle in haystack, or null if needle is ... |
package coapmsg
import (
"errors"
"math/rand"
"net"
"sync"
"time"
)
// CurrentMessageID stores the current message id used/generated for messages
var CurrentMessageID = 0
var MESSAGEID_MUTEX *sync.Mutex
func init() {
rand.Seed(time.Now().UTC().UnixNano())
CurrentMessageID = rand.Intn(65535)
MESSAGEID_MUTEX... |
package main
import (
"crypto/rand"
"encoding/binary"
"sync"
"sync/atomic"
"github.com/justinfx/gofileseq"
)
var (
sFrameSets frameSetMap
sFileSeqs fileSeqMap
)
func init() {
sFrameSets = frameSetMap{
lock: new(sync.RWMutex),
m: make(map[FrameSetId]*frameSetRef),
}
sFileSeqs = fileSeqMap{
lock:... |
package server
import (
"context"
"fmt"
"io"
"net/http"
"path"
"strconv"
"strings"
"time"
"cloud.google.com/go/storage"
"github.com/rs/zerolog/log"
"google.golang.org/api/iterator"
)
const (
propertyIDLabel = "property_id"
addressLabel = "address"
fileCategoryLabel = "file_category"
yearLabel ... |
package client
import (
"bufio"
"bytes"
"encoding/json"
"net"
"net/http"
"strings"
"logs"
)
var (
request http.Request
ConnectonKeepAlive = true
)
func parseHTTP(conn net.Conn) {
request, err := http.ReadRequest(bufio.NewReader(conn))
if err != nil {
logs.Errl.Printf("parse net conn error: %... |
package main
import (
"fmt"
)
func main() {
ceiling := 1000
bases := []int{3, 5}
sum := sumMultiplesUpTo(ceiling, bases)
fmt.Println("Total sum is", sum)
}
func sumMultiplesUpTo(ceiling int, bases []int) int {
sum := 0
for i := 0; i < ceiling; i++ {
sum += valueIfMultipleOfAny(i, bases)
}
return sum
}... |
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"github.com/cloud9-tools/go-sstable"
)
var output = flag.String("output", "", "SSTable file to generate")
func main() {
flag.Parse()
if *output == "" {
flag.Usage()
fmt.Fprintln(os.Stderr, "error: missing required flag -output=")
os.E... |
package main
import "fmt"
func main() {
array := map[string] string{"1": "January", "2":"February", "3":"March"}
fmt.Println(array["1"])
fmt.Println(array["2"])
fmt.Println(array["3"])
}
|
package main
import (
"bufio"
"fmt"
"os"
"reflect"
"unsafe"
)
var r = bufio.NewReader(os.Stdin)
func main() {
stack_buf := [16]byte{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'}
fmt.Println("[+] Hello, hacker! [+]")
fmt.Println("[?] C4N y0u hAcK mE?? [?]")
fmt.Print("[... |
package database
import "time"
type Vocab struct {
ID string `db:"id"`
Lang string `db:"lang"`
Priority int `db:"priority"`
Style string `db:"style"`
Audio string `db:"audio_url"`
Toughness int `db:"toughness"`
HeisigDefinit... |
package cloudflare
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"regexp"
"strings"
"time"
"golang.org/x/net/idna"
)
// ErrMissingBINDContents is for when the BIND file contents is required but not set.
var ErrMissingBINDContents = errors.New("required BIND config contents missing")
... |
// This file was generated for SObject WaveCompatibilityCheckItem, API Version v43.0 at 2018-07-30 03:47:49.418832935 -0400 EDT m=+35.762781287
package sobjects
import (
"fmt"
"strings"
)
type WaveCompatibilityCheckItem struct {
BaseSObject
CreatedById string `force:",omitempty"`
CreatedDate ... |
package main
import (
"archive/zip"
"bytes"
"fmt"
)
func main() {
data := []byte("This is not a zip file")
nonZipFile := bytes.NewReader(data)
_, err := zip.NewReader(nonZipFile, int64(len(data)))
if err == zip.ErrFormat {
fmt.Println("no zip file")
}
}
|
package q2
import (
"sort"
"testing"
)
func TestGetMinimumMoves(t *testing.T) {
var tests = []struct {
in []int32
want int32
}{
{[]int32{5, 1, 3, 2}, 2}, // 3 -> 5
{[]int32{1, 3, 2, 5}, 2}, // 3 -> 5
{[]int32{5, 2, 1, 3}, 3}, // 2 -> 3 -> 5
{[]int32{1, 3, 5, 2}, 2... |
package env
import (
"fmt"
"os"
)
// Get returns an environment variable
func Get(key string) string {
return os.Getenv(key)
}
// GetDefault returns an environment variable, of a default value if it is not set
func GetDefault(key, def string) string {
value := Get(key)
if value == "" {
return def
}
return v... |
package database
import "github.com/Cristofori/kmud/utils"
type Zone struct {
DbObject `bson:",inline"`
Name string
}
func NewZone(name string) *Zone {
zone := &Zone{
Name: utils.FormatName(name),
}
zone.init(zone)
return zone
}
func (self *Zone) GetName() string {
self.ReadLock()
defer self.ReadUnlock(... |
package clock
import (
"fmt"
"time"
)
//Clock - it's a clock yo
type Clock struct {
hours int
minutes int
}
//New - creates a new clock
func New(hours int, minutes int) Clock {
t := time.Date(0, 0, 0, 0, 0, 0, 0, time.UTC)
t = t.Add(time.Hour * time.Duration(hours))
t = t.Add(time.Minute * time.Duration(min... |
package tcp
import (
"net"
"google.golang.org/grpc"
)
type Server struct {
*grpc.Server
net.Listener
}
func (s *Server) Serve() error {
return s.Server.Serve(s.Listener)
}
func NewServer(address string) (*Server, error) {
lis, err := net.Listen("tcp", address)
if err != nil {
return nil, err
}
server :=... |
package services
import "github.com/cloudfoundry-incubator/notifications/models"
type TemplateDeleterInterface interface {
Delete(string) error
}
type TemplateDeleter struct {
TemplatesRepo models.TemplatesRepoInterface
Database models.DatabaseInterface
}
func NewTemplateDeleter(repo models.Templat... |
package backend
import (
"context"
"github.com/sirupsen/logrus"
"github.com/uw-labs/broximo/store"
"github.com/uw-labs/substrate"
"github.com/uw-labs/sync/rungroup"
)
type badgerSink struct {
topic string
store store.TopicStore
logger *logrus.Logger
}
func (sink *badgerSink) PublishMessages(ctx context.Co... |
// Copyright 2018 Lars Hoogestraat
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package handler
import (
"database/sql"
"fmt"
"net/http"
"time"
"git.hoogi.eu/snafu/go-blog/httperror"
"git.hoogi.eu/snafu/go-blog/middleware"
"git.hoogi.eu/snafu/go-blog/... |
// ClueGetter - Does things with mail
//
// Copyright 2016 Dolf Schimmel, Freeaqingme.
//
// This Source Code Form is subject to the terms of the two-clause BSD license.
// For its contents, please refer to the LICENSE file.
//
package core
import (
"database/sql"
"database/sql/driver"
"fmt"
"time"
_ "github.com... |
/*
TESTO ESERCIZIO
--------------------
Vi è dato un programma (che trovate su Moodle: tunnelBug.go)
che simuli la seguente situazione: Ci sono due gruppi di palline G1 e G2
in due luoghi diversi L1 e L2 uniti da un tunnel.
In L1 e in L2 ci sono due persone P1 e P2.
La persona P1 vuole lanciare tutte le palline in G... |
package sessions
type Session struct {
Id int64
AccountId int64
Key string
Created int64
Expires int64
}
//Clientside Session
type SessionResponse struct {
Key string `json:"key"`
Expires int64 `json:"expires"`
}
|
package models
import (
"github.com/astaxie/beego/logs"
)
//ProblemsRes rest
type ProblemsRes struct {
Code int `json:"code"`
Message string `json:"message"`
Data struct {
Items []Problems `json:"items"`
Total int64 `json:"total"`
} `json:"data"`
}
//Problems struct
type Problems struct {
Ack... |
package debug
import (
"testing"
"errors"
)
func TestPrint(t *testing.T) {
Print("Hello")
Print("Hello %d %s", 123, "Alice")
Print(errors.New("some error"))
Logger = nil
Print("No output")
}
|
package controller
import (
"github.com/appscode/go/log"
apps_util "github.com/appscode/kutil/apps/v1"
api "github.com/kubedb/apimachinery/apis/kubedb/v1alpha1"
kerr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
)
func (c *Controller) Exists(... |
package encode
import (
"bytes"
"encoding/base64"
"github.com/sirupsen/logrus"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
"io/ioutil"
)
func GbkToUtf8(s []byte) []byte{
reader := transform.NewReader(bytes.NewReader(s), simplifiedchinese.GBK.NewDecoder())
bRead, err := ioutil.... |
package main
import (
"bufio"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
)
var Stacks = map[string]string{
"math": "math.stackexchange",
"physics": "physics.stackexchange",
"overflow": "stackoverflow",
"scifi": "scifi.stackexchange",
"software": "software.stackexchange",
"... |
package main
import (
"fmt"
"os"
"regexp"
"strings"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/badvassal/wllib/defs"
"github.com/badvassal/wllib/gen/wlerr"
"github.com/badvassal/wllib/wlutil"
"github.com/badvassal/wlmanip"
)
var WltsetVersion = "0.0.1"
func onErr(err error) {
f... |
package worker
import (
"fmt"
"net/http"
"time"
)
type HttpResp struct {
// Error error
Error string
Code int
Status string
TimeDur float64
}
func HttpRequest(url *string, method *string, verbose bool) (result HttpResp) {
client := &http.Client{
// CheckRedirect: redirectPolicyFunc,
Timeout: tim... |
package main
import (
"go.core/lesson3/engine/pkg/stub"
"testing"
)
func Test_find(t *testing.T) {
var s stub.Spider
data, err := scan(s, "stub", 2)
if err != nil {
t.Errorf("Ошибка при использовании заглушки")
}
tests := []struct {
name string
arg string
want int
}{
{"1", "1", 1},
{"2", "2", 1}... |
package main
import (
"fmt"
"sort"
)
// https://leetcode-cn.com/problems/video-stitching/
func videoStitching(clips [][]int, T int) int {
n := len(clips)
if n == 0 {
return -1
}
sort.Sort(videos(clips))
ends := make([]int, n+1)
end, cnt := 0, 0
for i := 0; i < n; i++ {
if i == 0 && clips[i][0] != 0 ||... |
package utils
// 返回的结构体
type SuccessReturn struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
var (
ReturnCode10001 = NewFailureReturn(10001, "服务器错误请稍后重试")
ReturnCode10002 = NewFailureReturn(10002, "登入超时请重新登入")
ReturnCode10003 = NewFailureReturn(1... |
package plaintext
import (
"bufio"
"io"
"github.com/scnewma/pwaudit/pkg/pw"
)
// Loader loads passwords from a
// line-delimited reader source.
type Loader struct {
scanner *bufio.Scanner
passwords chan pw.Password
err error
}
// NewLoader returns a new Loader from r.
func NewLoader(r io.Reader) *Loade... |
package schoolmeal
import (
"testing"
"time"
)
func TestTimestamp(t *testing.T) {
tz, err := time.LoadLocation("Asia/Seoul")
if err != nil {
t.Error("Unexpected Error", err)
t.Failed()
}
date := time.Date(2019, time.February, 3, 15, 32, 21, 0, tz)
if stamp := Timestamp(date); stamp != "2019.02.03" {
t.... |
package port
import (
"net"
"strconv"
)
// CheckHostPort if a port is available
func CheckHostPort(host string, port int) (status bool, err error) {
// Concatenate a colon and the port
host = host + ":" + strconv.Itoa(port)
// Try to create a server with the port
server, err := net.Listen("tcp", host)
// if ... |
// Copyright 2021 BoCloud
//
// 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 wri... |
package validation
import (
"testing"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/util/validation/field"
"github.com/openshift/installer/pkg/types"
"github.com/openshift/installer/pkg/types/vsphere"
)
func TestValidateMachinePool(t *testing.T) {
cases := []struct {
name string
... |
package main
import (
"fmt"
)
const (
input = "428 players; last marble is worth 72061 points"
realNumPlayers = 428
realLastMarble = 72061
testNumPlayers = 10
testLastMarble = 1618
special = 23
stepsBack = 7
)
var (
numPlayers = realNumPlayers
lastMarble = realLastMarble
)
func main() {
part... |
package main
import (
"log"
"github.com/spf13/cobra"
"github.com/antonosmond/cloudkat/commands"
)
func main() {
cloudkat := &cobra.Command{
Use: "cloudkat",
}
cloudkat.AddCommand(commands.Commands...)
err := cloudkat.Execute()
if (err != nil) {
log.Fatal(err)
}
}
|
/*
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 not use this fi... |
package main
/*
for the webserver version, there are only a few things that the browser
can do:
"Please roll the dice and tell me the result"
"Here is the move for 'black'; show me the board"
or "Tell me the move for 'black', and show me the board"
The response should be in some form that the browser can easil... |
package statistics
import (
"./../transfer/task"
"./models"
"cydex"
"cydex/transfer"
// clog "github.com/cihub/seelog"
"sync"
)
type BitrateArray []uint64
// 任务统计
type StatTask struct {
Type int
segs_total_bytes map[string]uint64
bitrates []uint64
}
func NewStatTask() *StatTask {
o := ... |
/* The Computer Language Benchmarks Game
* http://shootout.alioth.debian.org/
*
* contributed by Krzysztof Kowalczyk
*/
package main
import (
"bytes"
"io/ioutil"
"log"
"os"
"time"
)
var comptbl = [256]uint8{}
func build_comptbl() {
l1 := []byte("UACBDKRWSN")
l2 := []byte("ATGVHMYWSN")
l1_lower := bytes.... |
package api
import "time"
// DBModel is the base model for all db items
type DBModel struct {
ID uint `json:"id" gorm:"primary_key"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
}
// User is the struct that holds user specific information
type User ... |
package main
import (
"fmt"
)
type myType int
var x myType
func main() {
fmt.Printf("Valor: %v\n", x)
fmt.Printf("Tipo: %T\n", x)
x = 42
fmt.Printf("Novo valor: %v\n", x)
// types https://golang.org/ref/spec#Types
}
|
// Package cflag is an extension to the standard flag package
// that brings support of complex types.
package cflag
|
package writer
import "testing"
func TestWriteToPath(t *testing.T) {
testwriter := Writer{}
testwriter.SetOutput("test.txt")
content := []string{"compton", "puppy", "mennya", "doota"}
testwriter.WriteToPath(content)
}
|
package main
//1280 x 720
func main() {
}
|
package test
import (
"fmt"
)
func Puts() {
fmt.Printf("hello world\n")
}
func Add(a, b int) int {
return a + b
}
|
package providers
import (
"github.com/bbcloudGroup/gothic/di"
"gothic-app/datasource"
)
func RegisterDatabase(container di.Container) {
container.Register(datasource.NewMovies)
container.Register(datasource.NewAdmin)
container.Register(datasource.NewCache)
}
|
package server
import (
"fmt"
"net/http"
"github.com/majgis/htmls/template"
)
// rootHandlerFactory returns function to serve page with list of routes
func rootHandlerFactory(htmlTemplates []template.HTMLTemplate) func(http.ResponseWriter, *http.Request) {
rootTemplate := []byte("<h3>Routes:</h3><ul>")
for _, h... |
package config
import (
"KServer/library/kiface/ikafka"
"gopkg.in/yaml.v3"
"io/ioutil"
"log"
"os"
)
type KafkaConfig struct {
Env bool `yaml:"env"`
Host string `yaml:"host"`
Port string `yaml:"port"`
}
func NewKafkaConfig(filename string) ikafka.IKafkaConf {
conf := &KafkaConfig{}
path, _ := os.Getwd()
... |
package main
import (
"encoding/json"
"fmt"
"github.com/sirupsen/logrus"
"io/ioutil"
"net/http"
)
type httpMethods struct {
queue Queue
log *logrus.Logger
}
func (h * httpMethods) Add(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
if r.Method != http.MethodPost {
w.WriteHeader(http.Status... |
/*
Package grapheme implements Unicode Annex #29 grapheme breaking.
UAX#29 is the Unicode Annex for breaking text into graphemes, words
and sentences.
It defines code-point classes and sets of rules
for how to place break points and break inhibitors.
This file is about grapheme breaking.
Typical Usage with a Segmente... |
package main
import (
// "strings"
"log"
"fmt"
// "os/exec"
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
type Customer struct {
id int
domain string
version sql.NullInt64
server sql.NullInt64
server_slot sql.NullInt64
_switch int
container sql.NullString
switch_container sql.NullString
options ... |
package main
import (
"errors"
"fmt"
)
func main() {
var username = "nobody"
fmt.Print("plese type your name")
fmt.Scanln(&username)
err := validate(username)
if err != nil {
fmt.Printf("You are not as cool as leslie! %s\n", username)
return
}
fmt.Println("hello, ", username)
}
func validate(username s... |
package sdl
type SDL_JoystickID uint32
type SDL_JoystickPowerLevel int32
const (
SDL_JOYSTICK_POWER_UNKNOWN SDL_JoystickPowerLevel = -1
SDL_JOYSTICK_POWER_EMPTY SDL_JoystickPowerLevel = 0
SDL_JOYSTICK_POWER_LOW SDL_JoystickPowerLevel = 1
SDL_JOYSTICK_POWER_MEDIUM SDL_JoystickPowerLevel = 2
SDL_JOYSTICK_PO... |
package service
import (
"github.com/TodoApp2021/gorestreact/pkg/kafka"
"github.com/TodoApp2021/gorestreact/pkg/models"
"github.com/TodoApp2021/gorestreact/pkg/repository"
)
type TodoListService struct {
repo repository.TodoList
producer kafka.TodoList // TODO
}
func NewTodoListService(repo repository.TodoL... |
package user
type User struct {
ID string `json:"id,omitempty"`
Email string `json:"email,omitempty"`
Password string `json:"password,omitempty"`
Name string `json:"name,omitempty"`
Role string `json:"role,omitempty"`
}
|
package _55_Jump_Game
import "math"
func canJump(nums []int) bool {
// return canJumpDP(nums)
return canJumpGreedy(nums)
}
func canJumpDP(nums []int) bool {
length := len(nums)
// 0为不可达,1为可达
dp := make([]int, length)
dp[len(dp)-1] = 1
for i := length - 2; i >= 0; i-- {
furthestJump := int(math.Min(float64(i... |
package main
import "fmt"
func main() {
x := 4000000
fmt.Println("Sum of all even numbers in fibonaci sequence up to", x, "=", fibonacisum(x))
}
func fibonacisum(x int) int {
a, b, c, s := 1, 1, 2, 0
for ; c <= x; c = a + b {
//println(c)
a = b
b = c
if c%2 == 0 {
if c == 2 {
fmt.Print(c)
} els... |
package medtronic
const (
Reservoir Command = 0x73
)
// Reservoir returns the amount of insulin remaining.
func (pump *Pump) Reservoir() Insulin {
// Format of response depends on the pump family.
newer := pump.Family() >= 23
data := pump.Execute(Reservoir)
if pump.Error() != nil {
return 0
}
if newer {
if... |
package logger
import (
"bytes"
"fmt"
"sort"
"strings"
"github.com/sirupsen/logrus"
)
type SimpleFormatter struct{}
func (s *SimpleFormatter) Format(entry *logrus.Entry) ([]byte, error) {
b := &bytes.Buffer{}
concat(b, printTime(entry))
concat(b, " ")
concat(b, printLevel(entry))
//concat(b, " ")
//conca... |
package pkg
type LinkConfig struct {
Timeout *int `yaml:"timeout"`
RequestRepeats *int `yaml:"request-repeats"`
AllowRedirect *bool `yaml:"allow-redirect"`
}
func NewLinkConfig(link Link, file *File) *LinkConfig {
if file.Config != nil {
for _, linkFile := range file.Links {
if (link.RelPath == lin... |
package internal
import (
"net/rpc"
"github.com/hashicorp/go-plugin"
"github.com/jonmorehouse/gatekeeper/gatekeeper"
)
type StartArgs struct{}
type StartResp struct {
Err *gatekeeper.Error
}
type StopArgs struct{}
type StopResp struct {
Err *gatekeeper.Error
}
type HeartbeatArgs struct{}
type HeartbeatResp st... |
package virtual_security
import (
"sync"
"time"
)
var (
priceStoreSingleton iPriceStore
priceStoreSingletonMutex sync.Mutex
)
// getPriceStore - 価格ストアの取得
func getPriceStore(clock iClock) iPriceStore {
priceStoreSingletonMutex.Lock()
defer priceStoreSingletonMutex.Unlock()
if priceStoreSingleton == nil {... |
package main
import (
"flag"
"fmt"
"os"
"strings"
"time"
"github.com/DynamoGraph/rdfm/reader"
slog "github.com/DynamoGraph/syslog"
)
var inputFile = flag.String("f", "rdf_test.rdf", "RDF Filename ")
var numFilms = flag.Int("n", 0, "Number of Films to migrate")
func syslog(s string) {
slog.Log("rdfLoader: ",... |
// Copyright 2017 Jeff Foley. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"os"
"path"
"github.com/OWASP/Amass/amass/core"
"github.com/OWASP/Amass/amass/handlers"
"github.com/OWASP/Amass/amass/utils/vi... |
package main
import (
"bufio"
"fmt"
"os"
"sync"
"errors"
)
const noWall byte = (0) // The first flag
const southWall byte = (1 << 0) // The first flag
const eastWall byte = (1 << 1) // The second flag
var initialize sync.Once
var boundsr int
var boundsc int
type Maze struct {
walls [][]byte
cells [][]in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.