text stringlengths 11 4.05M |
|---|
package views
import (
"fmt"
"strings"
"github.com/jenkins-x/jx-logging/v3/pkg/log"
v1 "github.com/jenkins-x/jx-api/v4/pkg/apis/jenkins.io/v1"
"github.com/jenkins-x/octant-jx/pkg/common/viewhelpers"
"github.com/jenkins-x/octant-jx/pkg/plugin"
"github.com/vmware-tanzu/octant/pkg/view/component"
corev1 "k8s.io... |
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package fileutil provides utilities for operating files in remote wifi tests.
package fileutil
import (
"context"
"os"
"path"
"strings"
"chromiumos/tast/errors"
"c... |
package uisession
import (
"context"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/cache"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
"github.com/tilt-dev/tilt/internal/controllers/apicmp"
"github.com/tilt-dev/tilt/internal/hud/we... |
package main
import (
"fmt"
"log"
"net/http"
"runtime"
"time"
)
// 这是一个recommend server
// Recommendation Service
func main() {
logGoroutines()
http.HandleFunc("/recommendations", recoHandler)
log.Fatal(http.ListenAndServe(":9090", nil))
}
func logGoroutines() {
ticker := time.NewTicker(500 * time.Milliseco... |
package v3
import (
"bytes"
"fmt"
"sort"
"go/constant"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sem/types"
"github.com/gogo/protobuf/sortkeys"
)
type bucket struct {
// The number of values in the bucket equal to upperBound.
numEq int64
// The number of... |
package parser_test
import (
"github.com/bytesparadise/libasciidoc/pkg/types"
. "github.com/bytesparadise/libasciidoc/testsupport"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("passthrough blocks", func() {
Context("in raw documents", func() {
Context("paragraph with attribute... |
package common
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("ResourceMatches", func() {
It("doesn't match", func() {
Expect(ResourceMatches("my-resource-name", "not-my-resource", false)).To(BeFalse())
})
It("does match", func() {
Expect(ResourceMatches("my-resource-name"... |
package Palindrome_Partitioning
func partition(s string) [][]string {
if len(s) == 0 {
return [][]string{}
}
results := make([][]string, 0)
backTracking(s, &results, []string{}, 0)
return results
}
func backTracking(s string, result *[][]string, subset []string, index int) {
if index == len(s) {
*result ... |
package server
import (
"encoding/json"
"errors"
"2C_vehicle_ms/pkg"
"log"
"net/http"
"strconv"
"github.com/gorilla/mux"
)
type favrouteRouter struct {
favrouteService root.FavrouteService
}
func NewFavrouteRouter(v root.FavrouteService, router *mux.Router) *mux.Router {
favrouteRouter := favrouteRouter{v}
... |
package update
import (
"encoding/json"
"fmt"
"net/http"
"os"
"github.com/ocoscope/face/db"
"github.com/ocoscope/face/utils"
"github.com/ocoscope/face/utils/answer"
)
func User(w http.ResponseWriter, r *http.Request) {
type tbody struct {
CompanyID, UserID ... |
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by appl... |
package main
import (
"encoding/json"
)
// layer 1 => CommandFrame
type CommandFrame struct {
/*
Kind 1 => Payload = SessionMessage, Body = empty
Kind 2 => Payload = empty, Body = CommandFrame
Kind 4 => Payload = empty, Body = RoomMsg
*/
Kind int `json:"kind"`
Payload string `json:"payload"`
Signature string `jso... |
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package wilco
import (
"context"
"chromiumos/tast/local/bundles/cros/wilco/pre"
"chromiumos/tast/local/wilco"
"chromiumos/tast/testing"
dtcpb "chromiumos/wilco_dtc"
)
... |
package routes
import (
"context"
"github.com/ONSdigital/dp-hello-world-controller/config"
"github.com/ONSdigital/dp-hello-world-controller/handlers"
health "github.com/ONSdigital/dp-healthcheck/healthcheck"
"github.com/ONSdigital/log.go/log"
"github.com/gorilla/mux"
)
// Setup registers routes for the servic... |
package main
import "fmt"
func main() { // 0 1 2 3 4 5 6 7 8 9
req := []int{5, 7, 9, 10, 11, 12, 13, 14, 28, 42}
seq := []int{}
// tag := 0
for i := 1; i < len(req); i++ {
seq = append(seq, req[i]-req[i-1])
}
fmt.Println(seq)
type Set struct {
begin int
end int
}
result := []Set{}
fo... |
package models
import "github.com/jinzhu/gorm"
// Tip for tip model
type Tip struct {
gorm.Model
Content string `json:"content"`
}
|
package jsonutils
import (
"encoding/json"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/joshprzybyszewski/cribbage/model"
)
func TestUnmarshalPlayerAction(t *testing.T) {
testCases := []struct {
msg string
pa model.PlayerAction
}{{
msg: `deal... |
package openstack
import (
"fmt"
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
"github.com/gophercloud/gophercloud/pagination"
)
//go:generate faux --interface ComputeInstanceAPI --output fakes/compute_instance_api.go
type ComputeInstanceAPI interface {
GetComputeInstancePager() pagination.Pa... |
package main
import (
"bufio"
"os"
"sync"
)
var channels = map[string]*Log{}
func GetLog(channel string) (*Log, error) {
log, ok := channels[channel]
if !ok {
var err error
log, err = NewLog(channel)
if err != nil {
return nil, err
}
channels[channel] = log
}
return log, nil
}
type Log struct {... |
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package firmware
import (
"reflect"
"testing"
pb "chromiumos/tast/services/cros/firmware"
)
// flags converts a list of ints to a slice of pb.GBBFlags.
func flags(f ...... |
package summary_test
import (
"bytes"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/go-task/task/v3/internal/logger"
"github.com/go-task/task/v3/internal/summary"
"github.com/go-task/task/v3/taskfile"
)
func TestPrintsDependenciesIfPresent(t *testing.T) {
buffer, l := createDummyLogge... |
package fun
import (
"fmt"
"reflect"
"github.com/marcuswestin/fun-go/errs"
)
type parallel2Result struct {
i int
val interface{}
err errs.Err
}
func Parallel2(funs ...interface{}) ([]interface{}, errs.Err) {
resChan := make(chan parallel2Result)
results := make([]interface{}, len(funs))
// Dispatch funct... |
package size
import (
"container/list"
"context"
"sync"
"github.com/upfluence/pkg/cache/policy"
)
type Policy struct {
sync.Mutex
size int
l *list.List
ks map[string]*list.Element
ctx context.Context
cancel context.CancelFunc
fn func(string)
closeOnce sync.Once
ch chan string
}
func New... |
package testenv
import "path"
var (
root = "../.."
)
// SetRoot set the root path for the other relative paths, e.g. AssetPath.
// Usually set to point to the repositories root.
func SetRoot(dir string) {
root = dir
}
// Root returns the relative path to the repositories root
func Root() string {
return root
}
... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
var n int64
var sticks []int64
scanner := bufio.NewScanner(os.Stdin)
if scanner.Scan() {
n, _ = strconv.ParseInt(scanner.Text(), 10, 64)
}
if scanner.Scan() {
s := scanner.Text()
nums := strings.Fields(s)
for _, numstr :... |
package main
import (
"github.com/Rubentxu/lbricks/engi"
"github.com/Rubentxu/lbricks"
)
var (
imprimir string
bot lbricks.Drawable
batch *engi.Batch
font *engi.Font
tick float64
)
func main() {
game:= &Game{}
game.InitContext()
engi.Open("Demo", 800, 600, false, game.EventSystem)
}
type Game struct... |
package main
import (
"bytes"
"fmt"
"io"
"log"
"net"
"net/url"
"strconv"
"strings"
)
func main(){
log.SetFlags(log.LstdFlags | log.Lshortfile)
fmt.Println("proxy main init...")
l,err :=net.Listen("tcp",":1088")
if err !=nil{
log.Panic(err)
}
for{
client,err := l.Accept()
if err != nil{
log.Pani... |
package main
import "fmt"
func main() {
switch {
case false:
fmt.Println("not printing")
case (2+2 == 4):
fmt.Println("print")
fallthrough
case (3 == 4):
fmt.Println("not printing 2")
fallthrough
case (3 == 3):
fmt.Println("print 2")
fallthrough
default:
fmt.Println("default case")
}
switch "... |
package main
import (
"fmt"
"net/http"
"io/ioutil"
"consistentHashing"
"log"
"strings"
"strconv"
"github.com/julienschmidt/httprouter"
)
// Variable Declarations
// A ring representing the nodes on a circle hashed using Consistent Hashing Algorithm
var Ring *consistentHashing.HashRing
// An array of my serve... |
package markdown
import "testing"
func TestDocument(t *testing.T) {
var tests = []string{
// Empty document.
"",
"",
" ",
"",
// This shouldn't panic.
// https://github.com/russross/blackfriday/issues/172
"[]:<",
"<p>[]:<</p>\n",
// This shouldn't panic.
// https://github.com/russross/bla... |
/*
Copyright 2019 The Kubernetes 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, ... |
package main
import (
"flag"
"fmt"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"sync"
"golang.org/x/net/html"
)
func getPageURLAndPageNumber() (string, int) {
var numberOfPageToCrawl int
var err error
if len(os.Args) < 2 {
fmt.Printf("Provide url to start crawling")
os.Exit(1)
}
numberOfPageToC... |
package xorm
import (
"database/sql"
"fmt"
"reflect"
"runtime/debug"
"testing"
"time"
"strings"
"io/ioutil"
"os"
"encoding/json"
"log"
)
const (
dbUrl = "root:1234@/xtest?charset=utf8"
)
func init() {
SetDebugModel(true)
//f, _ := os.OpenFile("sample.json",os.O_RDONLY, 0777)
f, _ := os.OpenFile("qc... |
package handler
import (
"context"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/eventstore/models"
es_models "github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/eventstore/spooler"
"github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
iam_model... |
package module
import (
"fmt"
"github.com/dnaeon/gru/graph"
"github.com/dnaeon/gru/resource"
)
// ResourceMap type is a map which keys are the
// resource ids and their values are the actual resources
type ResourceMap map[string]resource.Resource
// ResourceCollection creates a map of the unique resources
// con... |
package opslevel
// OpsLevel 开放代理套餐种类
type OpsLevel = string
const (
// NORMAL 普通套餐
NORMAL OpsLevel = "normal"
// VIP VIP套餐
VIP OpsLevel = "vip"
// SVIP SVIP套餐
SVIP OpsLevel = "svip"
// ENT 专业版套餐
ENT OpsLevel = "ent"
)
|
package scanner
import (
"testing"
"github.com/lukeomalley/glocks/token"
)
func TestScanner(t *testing.T) {
input := `
var a = 10;
var b = 20;
var c = a + b;
print c;
`
tests := []struct {
expectedType token.Type
expectedLexeme string
}{
{token.VAR, "var"},
{token.IDENTIFIER, "a"},
{token.... |
// Copyright (c) Red Hat, Inc.
// Copyright Contributors to the Open Cluster Management project
package managedcluster
import (
"fmt"
"os"
"strconv"
clusterv1 "github.com/open-cluster-management/api/cluster/v1"
workv1 "github.com/open-cluster-management/api/work/v1"
hivev1 "github.com/openshift/hive/apis/hive/... |
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/swag"
strfmt "... |
package create
import (
"os"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/dolittle/platform-api/pkg/aiven"
platformK8s "github.com/dolittle/platform-api/pkg/platform/k8s"
"github.com/dolittle/platform-api/pkg/platform/microservice/m3connector"
"github.com/dolittl... |
package identity
import (
"bytes"
"context"
"crypto/md5"
"encoding/json"
"fmt"
"os"
"text/template"
"github.com/dexidp/dex/server"
dexstorage "github.com/dexidp/dex/storage"
"github.com/ghodss/yaml"
"github.com/pkg/errors"
kotsv1beta1 "github.com/replicatedhq/kots/kotskinds/apis/kots/v1beta1"
dextypes "g... |
package main
import "fmt"
func main() {
arr := []int{8, 9, 5, 7, 1, 2, 5, 7, 6, 3, 5, 4, 8, 1, 8, 5, 3, 5, 8, 4}
result := mergeSort(arr, "s")
fmt.Println(result)
fmt.Println(arr[len(arr):])
}
/**
归并排序(Merge sort,台湾译作:合并排序)是建立在归并操作上的一种有效的排序算法。该算法是采用分治法(Divide and Conquer)的一个非常典型的应用
分治思想,时间复杂度为:O(n*l... |
package main
import "fmt"
func fact(x uint) uint {
if x <= 1 {
return 1
}
return x * fact(x-1)
}
func fibo_(x int, dp map[int]int) int {
if v, ok := dp[x]; ok {
return v
}
if x <= 1 {
return 1
}
dp[x] = fibo_(x-1, dp) + fibo_(x-2, dp)
return dp[x]
}
func fibo(x int) int {
return fibo_(x, make... |
package auth
import (
"fmt"
"net/http"
"os"
"regexp"
"strings"
"time"
"github.com/dgrijalva/jwt-go"
)
type userModel struct {
Email string `binding:"required"`
Password string `binding:"required"`
}
// Regex for containing one "@", one period and at least one character before and after them
var emailReg... |
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in complian... |
package scraper
// DefaultBootstrapAddrs are the set of bootstrap addresses the scraper will connect to by default.
var DefaultBootstrapAddrs = []string{
"/dnsaddr/sjc-2.bootstrap.libp2p.io/p2p/QmZa1sAxajnQjVM8WjWXoMbmPd7NsWhfKsPkErzpm9wGkp",
"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjT... |
package ab_method
import (
//"fmt"
//"strings"
"math"
"sync"
"shogi"
)
type Watcher interface {
OnCheck( Node )
}
type Param struct {
Limit float64
Level int
RestLevel float64
Sign float64
Watcher Watcher
Parallel int
}
type Node interface {
String() string
Choices() []shogi.Command
Choose( shogi.Com... |
package formula
// import (
// "encoding/json"
// "io"
// "io/ioutil"
// "os"
// "path/filepath"
// "strconv"
// )
// // Formula is
// type Formula struct {
// Number1 string
// Number2 string
// }
// // Output is
// type Output struct {
// Input *Formula `json:"input,omitempty"`
// Sum string `json:"o... |
package hndlrs_test
import (
"testing"
"graphelier/core/graphelier-service/api/hndlrs"
"graphelier/core/graphelier-service/models"
. "graphelier/core/graphelier-service/utils/test_utils"
"github.com/stretchr/testify/assert"
)
var instrumentGains []*models.InstrumentGain = []*models.InstrumentGain{
&models.Ins... |
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/openshift-metalkube/kni-installer/pkg/asset/installconfig"
assetstore "github.com/openshift-metalkube/kni-installer/pkg/asset/store"
"github.com/openshift-met... |
package service
import (
"encoding/json"
"net/http"
"strings"
"sync"
"github.com/labstack/echo"
"github.com/Aegon-n/sentinel-bot/socks5-proxy/nodes/master-node/models"
"github.com/Aegon-n/sentinel-bot/socks5-proxy/nodes/master-node/utils"
)
func AddNewUser(ctx echo.Context) error {
var body models.AddUser
i... |
package codes
import (
//"fmt"
)
func RomanNumeral(s string) int {
s="CMLII"
reflect:=make(map[string]int,0)
reflect["M"]=1000
reflect["D"]=500
reflect["C"]=100
reflect["L"]=50
reflect["X"]=10
reflect["V"]=5
reflect["I"]=1
res :=[]byte(s)
before :=res[0]
result :=0
for i:=range res{
result += reflect... |
/*
Copyright 2020 The Skaffold 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, sof... |
// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2020 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package fingerprint
import "encoding/hex"
// type for SHA3 fingerprints
type Fingerprint [32]byte
// MarshalText - convert fingerprint to little ... |
package Watcher
import (
"bytes"
"github.com/radovskyb/watcher"
"github.com/victorneuret/WatcherUpload/watcher/Config"
"io"
"log"
"mime/multipart"
"net/http"
"os"
"path/filepath"
)
func upload(event watcher.Event) {
file, err := os.Open(event.Path)
if err != nil {
log.Println(err)
return
}
defer func... |
/* hello-world-math-very-simple
This is not meant to be in any way a detailed list of the math
capability of GO only a demonstration of some of the simple math
operators that GO uses. this may be expanded later in another folder
to show more complex math operations
*/
package main //this is an executable file
import "... |
package math
import (
"jean/instructions/base"
"jean/instructions/factory"
"jean/rtda/jvmstack"
)
type DDIV struct {
base.NoOperandsInstruction
}
func (d *DDIV) Execute(frame *jvmstack.Frame) {
stack := frame.OperandStack()
v2 := stack.PopDouble()
v1 := stack.PopDouble()
res := v1 / v2
stack.PushDouble(r... |
package ravendb
// Size describes size of entity on disk
type Size struct {
SizeInBytes int64 `json:"SizeInBytes"`
HumaneSize string `json:"HumaneSize"`
}
|
package memory
import "github.com/adamluzsi/frameless/pkg/reflectkit"
// getNamespaceFor gives back the namespace string, or if empty, then set the namespace to the type value
func getNamespaceFor[T any](typ string, namespace *string) string {
if len(*namespace) == 0 {
*namespace = reflectkit.FullyQualifiedName(*n... |
package service
import (
"be_fs/models"
"be_fs/repository"
"fmt"
"log"
"net/http"
"strconv"
"github.com/labstack/echo"
)
type ResponseModel struct {
Code int `json: "code" validate: "required"`
Message string `json: "message" validate: "required"`
}
// Createfunction
func CreateUse... |
package naming
import "bytes"
func isLowerByte(r byte) bool {
return r >= 'a' && r <= 'z'
}
func isUpperByte(r byte) bool {
return r >= 'A' && r <= 'Z'
}
func toLowerByte(r byte) byte {
return r + ('a' - 'A')
}
func toUpperByte(r byte) byte {
return r - ('a' - 'A')
}
// underline naming to hump naming
// aa_b... |
package main
import (
"encoding/json"
"errors"
"fmt"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
"io/ioutil"
"log"
"os"
"os/user"
"strconv"
"strings"
"sync"
"time"
"github.com/subgraph/fw-daemon/sgfw"
)
type fpPreferences struct {
Winheight uint
Winwidth uint
Wintop uint
Winleft ... |
package controllers
import (
"github.com/astaxie/beego"
"restapp/models"
)
type ProxyController struct {
beego.Controller
}
func (p *ProxyController) GetUserInfo() {
proxy := &models.Proxy{}
err, users := proxy.GetAllUser()
if err != nil {
p.Data["error"] = err
} else {
p.Data["data"] = users
}
p.ServeJ... |
package Search_Insert_Position
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSearchInsert(t *testing.T) {
ast := assert.New(t)
ast.Equal(searchInsert([]int{1, 3, 5, 6}, 5), 2)
ast.Equal(searchInsert([]int{1, 3, 5, 6}, 2), 1)
ast.Equal(searchInsert([]int{1, 3, 5, 6}, 7), 4)
ast.Equal(sear... |
package config
import "log"
// GetConfig get current config
func GetConfig() Config {
return config
}
// GetAPIID get API ID
func GetAPIID() string {
return config.ApiId
}
// GetAPIHash get API Hash
func GetAPIHash() string {
return config.ApiHash
}
// GetBotToken get bot token
func GetBotToken() string {
retu... |
package serve
import "net/http"
// Context for serve
type Context struct {
Server *Server
Namespace *Namespace
Application *Application
Module *Module
User *User
URL string
Path string
}
// NewContext for create new context
func NewContext(server *Server, r *http.Request) *Context {
ctx := new... |
package main
import (
"flag"
"io/ioutil"
"log"
"net/http"
)
var args = []string{
"https://dns.twnic.tw/dns-query",
"https://doh-2.seby.io/dns-query",
"https://dns.containerpi.com/dns-query",
"https://cloudflare-dns.com/dns-query",
"https://doh-fi.blahdns.com/dns-query",
"https://doh-jp.blahdns.com/dns-query... |
package tools
import (
"bufio"
"errors"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"github.com/theckman/go-flock"
)
//CheckPath 检查文件夹是否存在,不存在则创建
func CheckPath(logPath string) error {
dir := filepath.Dir(logPath)
_, err := os.Stat(dir)
if err != nil {
if os.IsNotExist(err) {
err := os.Mk... |
package billing
import (
"github.com/stripe/stripe-go"
"github.com/stripe/stripe-go/charge"
)
const SECRET_KEY = "sk_live_IS0W5w62ttenjEpuQozj4VDE"
func Charge(amount uint, token string, name string) (chargeID string, err error) {
stripe.Key = SECRET_KEY
chargeParams := &stripe.ChargeParams{
Amount: uint64(a... |
// Copyright © 2020. All rights reserved.
// Author: Ilya Stroy.
// Contacts: qioalice@gmail.com, https://github.com/qioalice
// License: https://opensource.org/licenses/MIT
package ekaletter
import (
"fmt"
"reflect"
"time"
"unsafe"
"github.com/qioalice/ekago/v2/internal/ekaclike"
"github.com/qioalice/ekago/v2... |
package main
import (
"bufio"
"flag"
"fmt"
"os"
"strconv"
)
var port = flag.String("serial", "/dev/ttyACM0", "The serial port for the arduino")
var outfile = flag.String("outfile", "", "output file to write to")
func main() {
flag.Parse()
readings := make(chan uint16)
port, err := os.Open(*port)
if err !=... |
package LeetCode
import "fmt"
func Code70() {
fmt.Println(climbStairs(4))
}
/**
假设你正在爬楼梯。需要 n 阶你才能到达楼顶。
每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?
注意:给定 n 是一个正整数。
示例 1:
输入: 2
输出: 2
解释: 有两种方法可以爬到楼顶。
1. 1 阶 + 1 阶
2. 2 阶
示例 2:
输入: 3
输出: 3
解释: 有三种方法可以爬到楼顶。
1. 1 阶 + 1 阶 + 1 阶
2. 1 阶 + 2 阶
3. 2 阶 + 1 阶
*/
func climbS... |
package adapter
import (
"github.com/Placons/oneapp-logger/logger"
"io"
)
// closes http body stream while preserving error in defer
func closeBody(body io.ReadCloser, err *error, l *logger.StandardLogger) {
l.Debug("Closing body stream.")
e := body.Close()
if err == nil && e != nil {
l.Debug("Got an error whi... |
package gemini
import (
"context"
"encoding/json"
"net/http"
)
type TickerInput struct {
Ticker string
}
type TickerResponse struct {
Ask string `json:"ask"`
Bid string `json:"bid"`
Last string `json:"last"`
Volume Volume `json:"volume"`
}
type Volume struct {
Btc string `json:"BTC"`
Usd ... |
package grpc
import (
"context"
"database/sql"
"fmt"
"net"
"github.com/bns-engineering/platformbanking-card/common/logging"
pt "github.com/bns-engineering/platformbanking-card/handler/grpc/proto"
"github.com/bns-engineering/platformbanking-presenter/common/lookup"
"google.golang.org/grpc"
"google.golang.org/... |
package main
import (
"bufio"
"os"
"fmt"
"strconv"
"strings"
)
func main() {
//var s string
//var s2 string
//
//// Send in the reference of the string s
//fmt.Scanln(&s, &s2)
//// Print the value of it.
//fmt.Println(s, s2)
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter string: ")
str, _ := rea... |
package scraper
import (
"bytes"
"errors"
"net/http"
"net/http/cookiejar"
"strings"
)
var app App
//Debug to set debugging mode for more logging output
var Debug *bool
//Start Scraper which logs into lms portal and creates a client cookiejar which stores cookie which is useful to maintain
//login session throu... |
package main
import (
"context"
"fmt"
"time"
)
func main() {
forever := make(chan struct{})
ctx, cancel := context.WithCancel(context.Background())
go func(ctx context.Context) {
for {
select {
case <-ctx.Done():
forever <-struct{}{}
return
default:
fmt.Print... |
package service
import (
"galaxy-weather/model"
"github.com/sirupsen/logrus"
)
type IPeriodService interface {
GetAll() (*[]model.Period, error)
GetStats() (interface{}, error)
}
type periodService struct{}
func newPeriodService() IPeriodService {
return &periodService{}
}
var PeriodService = newPeriodServic... |
package mmseg
import (
"math"
)
type wordPoint struct {
Offset, Length, Freq int
}
type chunk struct {
Length int
WordPoints []wordPoint
}
func (this *chunk) Get(index int) wordPoint {
return this.WordPoints[index]
}
func (this *chunk) WordAverageLength() float64 {
return float64(this.Length) / float64(l... |
package main
import (
"fmt"
)
var (
commandsCount = 10
// вероятность для того что используется регистровая адрессация
memoryVer float32 = 0.6
commandType float32 = 0.7
// CLC counting by type 2
commandCounting = 6
// CLC counting for memory access
commandMemoryCount = 3
)
func main() {
// reading from ... |
package sequence
import (
"crypto/sha256"
"fmt"
"os"
"strconv"
"strings"
"sync"
"sync/atomic"
)
type Sequence struct {
name string
filePath string
i int64
saveMtx sync.Mutex
lastSaved int64
DiskSaved int64
}
func NewSequence(name string, dir string) *Sequence {
s := &Sequence{name: name... |
package bean_util
import (
"errors"
"github.com/goinggo/mapstructure"
"reflect"
"strings"
)
func ProToStandard(in interface{}, out interface{}) (err error) {
if in == nil || out == nil {
err = errors.New("[ProToStandard] in or out is nil")
}
m := make(map[string]interface{})
elem := reflect.ValueOf(&in).Ele... |
package hbox
import (
"fmt"
"path/filepath"
"io/fs"
"os/exec"
"strings"
"github.com/gregfolker/honey/pkg/log"
"github.com/pkg/errors"
)
const (
HboxExt = ".hbox"
HboxToMp4 = "HboxToMp4.exe"
)
func HboxToMp4Present(d string) error {
found := false
err := filepath.Walk(d, func(path s... |
// Helper functions to access/update db.
package model
import (
"errors"
"time"
"github.com/jinzhu/gorm"
_ "github.com/golang-migrate/migrate/database/postgres" // Driver
_ "github.com/golang-migrate/migrate/source/file" // Driver
_ "github.com/lib/pq" // Driver
)
//Get... |
package main
type point {
x, y int
}
|
package system
import (
potato "github.com/rise-worlds/potato-go"
)
func NewBidname(bidder, newname potato.AccountName, bid potato.Asset) *potato.Action {
a := &potato.Action{
Account: AN("potato"),
Name: ActN("bidname"),
Authorization: []potato.PermissionLevel{
{Actor: bidder, Permission: PN("active")}... |
package ravendb
import (
"net/http"
)
var (
_ IServerOperation = &GetDatabaseRecordOperation{}
)
type GetDatabaseRecordOperation struct {
database string
Command *GetDatabaseRecordCommand
}
func NewGetDatabaseRecordOperation(database string) *GetDatabaseRecordOperation {
return &GetDatabaseRecordOperation{
... |
package main
import (
"math"
"github.com/davecgh/go-spew/spew"
)
type Point struct {
x float64
y float64
}
func distance(p, q Point) float64 {
dx := p.x - q.x
dy := p.y - q.y
return math.Sqrt(dx*dx + dy*dy)
}
func main() {
var p Point
var q Point = Point{10, 10}
r := Point{x: 100, y: 100}
spew.Dump(p, ... |
package controllers
import (
"bookingSystem/models"
"github.com/astaxie/beego/orm"
)
type AuthAdminController struct {
Base
}
// @router /auth/login [get,post]
func (c *AuthAdminController) Login() {
if c.Ctx.Request.Method == "GET" {
c.TplName = "login.html"
} else {
c.SetSession("admin_auth", 1)
o := or... |
package apis
import (
. "background/models"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
)
// GetClassesStudentApi
// path: classes_student
// Input: ID,password
// Output(JSON array)
// img: String
// (标识课程的照片,如果没有照片就弄个默认的)
// name: String
// (课程名字)
// ID: String
// (课程ID)
func GetClassesStudentApi(c... |
package protocol
import (
"io"
"github.com/13k/go-steam-resources/steamlang"
"github.com/13k/go-steam/steamid"
)
// ClientStructMessage represents a struct backed client message.
type ClientStructMessage struct {
Header *ClientStructMessageHeader
Body StructMessageBody
Payload []byte
}
var _ ClientMessage... |
package ffxiv
import (
"bytes"
"errors"
"fmt"
"regexp"
"strconv"
"strings"
"unicode"
"github.com/PuerkitoBio/goquery"
"github.com/aerogo/http/client"
)
var digit = regexp.MustCompile("[0-9]+")
// Character represents a Final Fantasy XIV character.
type Character struct {
Nick string
Server stri... |
package cmd
import (
"fmt"
"github.com/bitmaelum/bitmaelum-server/core"
"github.com/bitmaelum/bitmaelum-server/core/account/client"
"github.com/bitmaelum/bitmaelum-server/core/password"
"github.com/opentracing/opentracing-go/log"
"github.com/spf13/cobra"
)
var unlockAccountCmd = &cobra.Command{
Use: "unlock... |
//package with commands
package commands
// Help возвращает приветственное сообщение
func Help() string {
return "Поиск по имени: /search или /s \n" +
"Поиск по автору: /author или /a \n" +
"Последние 20 книг: /last или /l \n" +
"Случайная книга: /r \n" +
"Статистика: /stat \n\n" +
"------------------------... |
package main
func each(handler func(string), text string) bool {
if finished {
return false
}
if len(text) >= maxlen {
handler(text)
} else {
handler(text)
for i, c := range dict {
if len(text) < len(startAt) && i < startAt[len(text)] {
continue
}
if !each(handler, text+string(c)) {
return... |
package migration
import "net/http"
func (op *Payload_OtpParameters) ServeHTTP(w http.ResponseWriter, r *http.Request) {
pic, err := op.QR()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Write(pic)
}
|
package pushTemplate
import (
"github.com/JeonYang/chanPool"
)
type Push interface {
Push(send ...Send) error
Start()
Stop()
}
func NewPush(chanPool chanPool.Pool, resultChanLen, resultsMaxLen int, resultFunc func(result []Result)) Push {
return &push{chanPool: chanPool, resultMaxLen: resultsMaxLen, resultChan... |
package leetcode
/*
665. 非递减数列
给你一个长度为 n 的整数数组,请你判断在 最多 改变 1 个元素的情况下,该数组能否变成一个非递减数列。
我们是这样定义一个非递减数列的: 对于数组中所有的 i (0 <= i <= n-2),总满足 nums[i] <= nums[i + 1]。
示例 1:
输入: nums = [4,2,3]
输出: true
解释: 你可以通过把第一个4变成1来使得它成为一个非递减数列。
示例 2:
输入: nums = [4,2,1]
输出: false
解释: 你不能在只改变一个元素的情况下将其变为非递减数列。
说明:
1 <= n <= 10 ^ 4
-... |
/**
* (C) Copyright IBM Corp. 2021.
*
* 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.