_id stringlengths 40 40 | text stringlengths 81 2.19k | title stringclasses 1
value |
|---|---|---|
f7176693b242d5f3cd2c3638286145699db243f8 | ---
+++
@@ -4,7 +4,7 @@
// NullNewRelic returns a disabled New Relic appliaction.
func NullNewRelic() newrelic.Application {
- config := newrelic.NewConfig("smsprocessor", "")
+ config := newrelic.NewConfig("application", "")
config.Enabled = false
app, _ := newrelic.NewApplication(config)
| |
fae6ed236a31c146f8e5eb8dc09ef7b703a1389f | ---
+++
@@ -9,12 +9,19 @@
)
func handler(ctx *web.Context, path string) {
- input, err := ioutil.ReadFile("testdata/foo.md")
- if err != nil {
- ctx.NotFound("File Not Found\n" + err.Error())
+ if path == "" {
+ ctx.WriteString("foo")
+ return
+ } else {
+ input, err := iou... | |
41fb97bd457998a26e5e64a379c4b5d0d1c90f32 | ---
+++
@@ -9,7 +9,7 @@
Prefix string `json:"prefix,omitempty"`
Endpoint string `json:"endpoint"`
- DoNotUseTLS bool `json:"doNotUseTLS,omitempyy"`
+ DoNotUseTLS bool `json:"doNotUseTLS,omitempty"`
AccessKeyID string `json:"accessKeyID"`
SecretAccessKey string `json:"secretAccessKey" kopia:"sen... | |
bbcee77b028aa3fbd9c54fe129efcbd61bbb6365 | ---
+++
@@ -21,8 +21,10 @@
"time"
)
+var initTime = time.Now()
+
func now() int64 {
- // time.Now() is monotonic:
+ // time.Since() returns monotonic timer difference (#875):
// https://golang.org/pkg/time/#hdr-Monotonic_Clocks
- return time.Now().UnixNano()
+ return int64(time.Since(initTime))
} | |
32daf238e1f3ceb63b590198648a81a6cd56048b | ---
+++
@@ -1,13 +1,28 @@
package test_helpers
-import "github.com/pivotal-cf-experimental/cf-mysql-quota-enforcer/database"
+import (
+ "os"
+
+ "github.com/pivotal-cf-experimental/cf-mysql-quota-enforcer/config"
+ "github.com/pivotal-cf-experimental/cf-mysql-quota-enforcer/database"
+)
func NewRootDatabaseCon... | |
30f677249eef79da5e75cbfd35ed4df78c014e22 | ---
+++
@@ -6,16 +6,47 @@
type AnimeAiringDate struct {
Start string `json:"start"`
End string `json:"end"`
+
+ startHumanReadable string
+ endHumanReadable string
}
// StartDateHuman ...
func (airing *AnimeAiringDate) StartDateHuman() string {
- t, _ := time.Parse(time.RFC3339, airing.Start)
- return t... | |
bc7b920406a3f0a142fb57335463628fb9949929 | ---
+++
@@ -24,10 +24,6 @@
Message{"prefix", "command", []string{"one", "two", "three four"}},
":prefix command one two :three four"
},
- tcase {
- Message{Prefix: "prefix", Command: "command"},
- "asdf"
- },
};
for i, tc := range cases { | |
d2165be69c2be3b528f816c52db19f045940f249 | ---
+++
@@ -33,7 +33,7 @@
fmt.Fprintf(os.Stderr, "%s %s\r\n", bin, url)
var attr os.ProcAttr
- proc, err := os.StartProcess(command, []string{url}, &attr)
+ proc, err := os.StartProcess(bin, []string{bin, url}, &attr)
if err != nil {
return err
} | |
6ffdaa50bb51c6fe78e0634a316c468a29f31941 | ---
+++
@@ -1,7 +1,7 @@
package slug
import (
- "code.google.com/p/go.text/unicode/norm"
+ "golang.org/x/text/unicode/norm"
"regexp"
"strings"
"unicode" | |
424bc782bc1d5b5125a0e17aa319bd75132b6309 | ---
+++
@@ -14,8 +14,8 @@
// target OS and architecture, and writes the generated
// executable to the 'outDir' directory.
func goBuild(name string, version string, goos string, goarch string) {
- os.Setenv("goos", goos)
- os.Setenv("goarch", goarch)
+ os.Setenv("GOOS", goos)
+ os.Setenv("GOARCH", goarch)
out ... | |
d758ff96e486afc2359f5b958cc213d76c56f89c | ---
+++
@@ -6,10 +6,10 @@
// API key descriptions to use when requesting API keys from Ambassador Cloud.
const (
- KeyDescWorkstation = "laptop"
- KeyDescTrafficManager = "manager"
+ KeyDescWorkstation = "telepresence:workstation"
+ KeyDescTrafficManager = "telepresence:traffic-manager"
)
func KeyDescAg... | |
ea12a4c8c3d5fb880ab81c6cd169aba63732b536 | ---
+++
@@ -10,10 +10,10 @@
g.Describe("Get", func() {
g.It("Errors when connection refused", func() {
- _, err := Get("http://localhost", map[string]string{
+ _, err := Get("http://localhost:8000", map[string]string{
"foo": "bar",
})
- g.Assert(err.Error()).Equal("Get http://localhost: dial tcp... | |
0ae2689d0ae8593d6cba0d6dc7ee4c59ac3080cf | ---
+++
@@ -1,7 +1,6 @@
package events
import (
- "fmt"
"strconv"
"strings"
"time"
@@ -48,12 +47,9 @@
}
func (e *Event) DisplayTags() string {
+ // required as used in template
if e == nil {
return ""
}
- // if e.Tags == nil {
- // return ""
- // }
- fmt.Println(e)
return strings.Join(e.Tags, ... | |
b1f78a296047401f7794bef4ac229c5f6174517f | ---
+++
@@ -3,6 +3,7 @@
import (
"github.com/elves/elvish/cli"
"github.com/elves/elvish/cli/addons/histwalk"
+ "github.com/elves/elvish/cli/el"
"github.com/elves/elvish/cli/histutil"
"github.com/elves/elvish/eval"
)
@@ -14,13 +15,15 @@
eval.Ns{
"binding": bindingVar,
}.AddGoFns("<edit:history>", m... | |
d3dd3e6baf8432622a69f31650f8119edf157fca | ---
+++
@@ -17,7 +17,8 @@
txContext db.SafeTxContext,
) Store {
return &safeStoreImpl{
- impl: newStore(builder, executor, logger),
+ impl: newStore(builder, executor, logger),
+ txContext: txContext,
}
}
| |
a099b5569c226e498ab33e17a116be207557497d | ---
+++
@@ -1,9 +1,48 @@
//go:build !linux && !freebsd
package tuntap
+
+import (
+ "net"
+)
const flagTruncated = 0
func createInterface(ifPattern string, kind DevKind) (*Interface, error) {
panic("tuntap: Not implemented on this platform")
}
+
+// IPv6SLAAC enables/disables stateless address auto-confi... | |
e8f2bfa311a7353358a9d4ee326880526d4942fc | ---
+++
@@ -6,8 +6,25 @@
)
// Gnupg keyrings files
-var gPubringFile string = filepath.Join(os.Getenv("HOME"), ".gnupg", "pubring.gpg")
-var gSecringFile string = filepath.Join(os.Getenv("HOME"), ".gnupg", "secring.gpg")
+var gPubringFile string = func() string {
+ envPubring := os.Getenv("GNUPG_PUBRING_PATH")
+
... | |
27288b1b7adb8e07ab942b8c6e1f9c0df43fa4ab | ---
+++
@@ -3,18 +3,12 @@
package isatty
-import (
- "syscall"
- "unsafe"
-)
-
-const ioctlReadTermios = syscall.TIOCGETA
+import "golang.org/x/sys/unix"
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
- var termios syscall.Termios
- _, _, err := syscall.Sysca... | |
95431df442eed97dcc6fd45b71bd14ab378346d2 | ---
+++
@@ -1,41 +1,29 @@
package main
import (
+ "crypto/rand"
"encoding/hex"
"flag"
"log"
- "github.com/aarbt/bitcoin-base58"
"github.com/aarbt/hdkeys"
)
-var extendedKey = flag.String("extended_key", "", "")
+var seedHex = flag.String("seed", "", "hex encoded random seed between 16 and 64 bytes.")... | |
67c05a5d7585e9bed136e9b09a3bffe6a69f48fb | ---
+++
@@ -3,31 +3,39 @@
import (
"fmt"
- "log"
"testing"
)
-func Test(*testing.T) {
- d := &OuiDb{}
- err := d.Load("oui.txt")
+var db OuiDb
+func init() {
+ db = OuiDb{}
+ err := db.Load("oui.txt")
if err != nil {
- log.Fatal("Error %v", err)
+ panic(err.Error())
}
+}
- address, _ := ParseMAC("... | |
8a21b128d4deb874c05eb81ebbc1265175ad69ba | ---
+++
@@ -14,6 +14,11 @@
if backingFs == "xfs" {
msg += " Reformat the filesystem with ftype=1 to enable d_type support."
}
+
+ if backingFs == "extfs" {
+ msg += " Reformat the filesystem (or use tune2fs) with -O filetype flag to enable d_type support."
+ }
+
msg += " Backing filesystems without d_type s... | |
6d58e94977400501c09fc1c7ceaa29bc524583ef | ---
+++
@@ -11,3 +11,12 @@
func (m Move) IsCapture() bool {
return m.CapturedChecker != nil
}
+
+// CapturedPos returns position of captured checker for the move
+// if it caused capture or point outside of the board otherwise.
+func (m Move) CapturedPos() Point {
+ if !m.IsCapture() {
+ return Point{-1, -1}
+ }... | |
8b3863b00d216214994608ebb88d0cf6bbdaa290 | ---
+++
@@ -19,7 +19,9 @@
return err
}
- w.WriteHeader(statusCode)
+ if statusCode != http.StatusOK {
+ w.WriteHeader(statusCode)
+ }
encoder := json.NewEncoder(w)
encoder.SetEscapeHTML(true) | |
c3023b6ea764579035f6953ae18c39f0abdd9e6d | ---
+++
@@ -2,15 +2,12 @@
import (
"fmt"
- "syscall"
-
"github.com/buildkite/agent/v3/logger"
+ "golang.org/x/sys/windows"
)
func VersionDump(_ logger.Logger) (string, error) {
- dll := syscall.MustLoadDLL("kernel32.dll")
- p := dll.MustFindProc("GetVersion")
- v, _, _ := p.Call()
+ info := windows.RtlGetV... | |
a0cb02c4ea2aee903bad6b7762887e1830337e77 | ---
+++
@@ -4,8 +4,10 @@
// The uuid package generates and inspects UUIDs.
//
-// UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security Services.
+// UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security
+// Services.
//
-// This package is a partial wrapper around the github.com/go... | |
8d077c0d0a97cbd3e9c2d00c638898a2c2819236 | ---
+++
@@ -12,12 +12,10 @@
func main() {
var port int
- var host string
flag.IntVar(&port, "port", 2489, "TCP port number")
- flag.StringVar(&host, "host", "localhost", "Remote hostname")
flag.Parse()
- l, err := net.Listen("tcp", fmt.Sprintf("%s:%d", host, port))
+ l, err := net.Listen("tcp", fmt.Sprintf... | |
8f37aed8328cd444c3ae770f7b57773180bfc7d8 | ---
+++
@@ -1,7 +1,5 @@
package form
type Options struct {
- Fields []string
- Values map[string]interface{}
- Choices map[string]interface{}
+ Fields []string
} | |
81cbba68d09edf8c1ab70f439f1254f238e1ab16 | ---
+++
@@ -16,7 +16,7 @@
func BenchmarkEncryption(b *testing.B) {
s, _ := NewAESSessionEncoder([]byte(SessionKey), base64.StdEncoding)
- config.SessionKey = []byte(SessionKey)
+ config.SessionKey = SessionKey
for i := 0; i < b.N; i++ {
s.encryptStickyCookie(Host, Port)
@@ -25,7 +25,7 @@
func Benchmark... | |
46ce29dc34b300f1b704cfcb921d109bdff7ffc4 | ---
+++
@@ -19,6 +19,10 @@
req, err := http.NewRequest("POST", url, bytes.NewBuffer(b))
req.Header.Add("X-Viber-Auth-Token", v.AppKey)
req.Close = true
+
+ if v.client == nil {
+ v.client = &http.Client{}
+ }
resp, err := v.client.Do(req)
if err != nil { | |
79d4ef67b694ce875b11649cc504e32b22dab098 | ---
+++
@@ -1,6 +1,12 @@
package grid
-import "fmt"
+import (
+ "fmt"
+ "io"
+ "log"
+ "mime"
+ "os"
+)
// ExportService handles communication with the Export related
// methods of the GRiD API.
@@ -29,3 +35,22 @@
resp, err := s.client.Do(req, exportDetail)
return exportDetail.ExportFiles, resp, err
}
+
+... | |
ecdcc574d48390061b2c5a82bb714ad238d70653 | ---
+++
@@ -31,6 +31,8 @@
return multistep.ActionHalt
}
+ state.Put("machine", "")
+
return multistep.ActionContinue
}
| |
58759737673c35a11a89730e80a711ee87bf19e6 | ---
+++
@@ -17,5 +17,8 @@
Debugf(level uint8, format string, v ...interface{})
Debugln(level uint8, v ...interface{})
Logger
+}
+
+type DebugLogLevelSetter interface {
SetLevel(maxLevel int16)
} | |
d04023572e47e5c18fa549fe7f7de301e8470c63 | ---
+++
@@ -1,11 +1,19 @@
package core
import (
+ "fmt"
+
"github.com/akutz/gofig"
+
+ "github.com/emccode/rexray/util"
)
func init() {
initDrivers()
+
+ gofig.SetGlobalConfigPath(util.EtcDirPath())
+ gofig.SetUserConfigPath(fmt.Sprintf("%s/.rexray", util.HomeDir()))
+
gofig.Register(globalRegistration(... | |
e05259e391d6d62afe5f166c9d05c5933b9b86d8 | ---
+++
@@ -43,5 +43,9 @@
d.last[k] = v
}
}
+
+ if len(changes) == 0 {
+ return nil
+ }
return d.Notifier.Notify(changes)
} | |
b9c9f6ee854f9dde42b8f8f170a114497582bac7 | ---
+++
@@ -2,7 +2,7 @@
// Used in getmarkethistory
type Trade struct {
- OrderUuid string `json:"OrderUuid"`
+ OrderUuid int64 `json:"Id"`
Timestamp jTime `json:"TimeStamp"`
Quantity float64 `json:"Quantity"`
Price float64 `json:"Price"` | |
9cf66af6fdf5ccd6312014071e7eb6f631812a99 | ---
+++
@@ -13,17 +13,10 @@
}
func (api *API) UserAuthenticate(username, email, password string) (errs []error, body string) {
-
- type UserAuthenticateData struct {
- Username string `json:"username,omitempty"`
- Email string `json:"email,omitempty"`
- Password string `json:"password"`
- }
-
- data := User... | |
4f658348d5d5c920968b77c24b7d402f52b7f87c | ---
+++
@@ -18,7 +18,7 @@
// SendTextMessage uses Twilio to send a text message.
// See http://www.twilio.com/docs/api/rest/sending-sms for more information.
-func (twilio *Twilio) SendTextMessage(from, to, body, statusCallback, applicationSid string) (string, error) {
+func (twilio *Twilio) SendSMS(from, to, bod... | |
7a63dce37a0afd42bd9efc9687c55feeaef04130 | ---
+++
@@ -22,14 +22,14 @@
NumGameEventTypes = int(sentinel)
)
-type MoveDirection int
+type MoveDirection byte
const (
- North MoveDirection = iota
+ None MoveDirection = iota
+ North MoveDirection = 1 << (iota - 1)
East
South
West
- None
)
type PlayerMoveEvent struct { | |
74788afc2b0f03051b0fd92db0c0d1664dffd28c | ---
+++
@@ -3,17 +3,17 @@
import "github.com/BurntSushi/toml"
type Config struct {
- App App `toml:"application"`
- Deps Deps `toml:"dependencies"`
+ App ConfigApp `toml:"application"`
+ Deps ConfigDeps `toml:"dependencies"`
}
-type App struct {
+type ConfigApp struct {
Name string
Version string
... | |
246e8bcca34cb2f0b0504cc1eee466cdcac2135c | ---
+++
@@ -9,6 +9,9 @@
localtests "github.com/practicum/sandbox/testing"
)
+var sampleTxtFilepath string = localtests.
+ DataAssetFullPath("january.txt", reflectionToy{})
+
// reflectionToy is a dummy type created in the preprocess package as a trick to
// retrieve the package name. http://stackoverflow.com/a... | |
eccc2f678e62451c5515ebc136d6bc0da78cd969 | ---
+++
@@ -10,7 +10,7 @@
// runs a loop to keep the client alive until it is no longer active.
func main() {
// Request a server with the specified details.
- server, err := ircutil.CreateServer("irc.rizon.net", 6667, true, "");
+ server, err := ircutil.CreateServer("irc.rizon.net", 6697, true, "");
if err... | |
2c5dddc7f190e9edddd2296182b88e0212fa8069 | ---
+++
@@ -4,11 +4,14 @@
func Chunk(data []byte, size int) [][]byte {
+ count := len(data) - size
var chunks [][]byte
- for i:=0; i<len(data); i=i+size {
+ for i:=0; i<count; i=i+size {
chunks = append(chunks, data[i:i+size])
}
+
+ chunks = append(chunks, data[count*size:])
... | |
3546ca06a8e2311bf5f0b017da79aabf04894901 | ---
+++
@@ -2,17 +2,30 @@
import (
_ "fmt"
+ "io/ioutil"
"log"
"github.com/libgit2/git2go"
)
+var clone string = "./test"
+var repo string = "https://github.com/rollbrettler/go-playground.git"
+
func main() {
- var cloneOptions git.CloneOptions
- cloneOptions.Bare = true
+ var cloneOptions git.Clon... | |
1ff58bfae05ef4b367a73a952e8edb218373f195 | ---
+++
@@ -10,7 +10,7 @@
func main() {
if len(os.Args) < 3 {
- fmt.Fprintln(os.Stderr, "Usage: aroc DIRECTORY COMMAND [ARGS…]")
+ fmt.Fprintln(os.Stderr, "Usage: aroc DIRECTORY|FILE COMMAND [ARGS…]")
os.Exit(1)
}
@@ -20,7 +20,7 @@
go func() {
for _ = range ch {
- log.Println("Changes in direct... | |
95cfaeb5aa27c690ecf06c595fdfb056c1d86ad6 | ---
+++
@@ -6,11 +6,11 @@
)
func TestNewURL(t *testing.T) {
- url, err := NewURL("https://github.com/motemen/pusheen-explorer")
- Expect(url.String()).To(Equal("https://github.com/motemen/pusheen-explorer"))
+ httpsUrl, err := NewURL("https://github.com/motemen/pusheen-explorer")
+ Expect(httpsUrl.String()).To(Eq... | |
c14e4298246c74f064e60d0911b16792acf1caba | ---
+++
@@ -1,75 +1,23 @@
package main
import (
+ "bytes"
"fmt"
- "io"
"os"
"os/exec"
+ "github.com/johnny-morrice/pipeline"
)
func main() {
config := exec.Command("configbrot", os.Args[1:]...)
render := exec.Command("renderbrot")
- confoutp, conferrp, conferr := pipes(c... | |
b4039d9645e7c9479ab84427030da6e01acb7ed1 | ---
+++
@@ -1,15 +1,23 @@
package main
import (
- "fmt"
+ "html/template"
"net/http"
"os"
)
func hello(resp http.ResponseWriter, req *http.Request) {
- fmt.Fprintln(resp, "<html><head><title>How about them apples?!</title></head><body><h1>")
- fmt.Fprintln(resp, "Hello world!")
- fmt.Fprintln(resp, "</h1>... | |
b1c64b7458fff743e194812e8bec6ba90cf30512 | ---
+++
@@ -17,7 +17,7 @@
)
func init() {
- flag.BoolVar(&Production, "production", false, "run the server in production environment")
+ flag.BoolVar(&Production, "production", Production, "run the server in production environment")
flag.StringVar(&Address, "address", Address, "the address to listen and serving... | |
14496a7fed1e9ef222ec25a39574eb03e05e6c55 | ---
+++
@@ -2,6 +2,7 @@
package launcher
import (
+ "fmt"
"github.com/kardianos/osext"
"github.com/luisiturrios/gowin"
@@ -17,23 +18,24 @@
)
func CreateLaunchFile(autoLaunch bool) {
- var err error
+ var startupCommand string
+
+ lanternPath, err := osext.Executable()
+ if err != nil {
+ log.Errorf("Co... | |
7baa466a8cad03c01018d4bfb8366205604ce14f | ---
+++
@@ -8,7 +8,7 @@
)
func main() {
- key := os.Args[3]
+ key := os.Args[2]
client, err := controller.NewClient("", os.Getenv("CONTROLLER_AUTH_KEY"))
if err != nil { | |
e2bd4261796d40a3bb47ce84cb30c72e328c483d | ---
+++
@@ -7,13 +7,12 @@
)
func main() {
- word := os.Args[1]
if len(os.Args) != 2 {
fmt.Println("Exactly one argument is required")
os.Exit(1)
}
- s := strings.Split(word, "")
- generatePermutations(len(word)-1, s)
+ word := os.Args[1]
+ generatePermutations(len(word)-1, strings.Split(word, ""))
}
... | |
0ef7b331fbab892b121fa51f7ddd82dbcd040e3f | ---
+++
@@ -1,15 +1,18 @@
package interpreter
import (
- "fmt"
+ // "fmt"
+ "CodeCity/server/interpreter/object"
"testing"
)
const onePlusOne = `{"type":"Program","start":0,"end":5,"body":[{"type":"ExpressionStatement","start":0,"end":5,"expression":{"type":"BinaryExpression","start":0,"end":5,"left":{"type... | |
3a6634b2456fc0cd151e25cc90b3b6865bbb5332 | ---
+++
@@ -7,15 +7,14 @@
)
func ExampleRegister() {
- pdf := gofpdf.New("", "", "", "")
+ pdf := gofpdf.New("L", "mm", "A4", "")
pdf.SetFont("Helvetica", "", 12)
pdf.SetFillColor(200, 200, 220)
pdf.AddPage()
url := "https://github.com/jung-kurt/gofpdf/raw/master/image/logo_gofpdf.jpg?raw=true"
httpim... | |
d61adc880ea85c1adc4585afb2aac40ab1602f28 | ---
+++
@@ -6,14 +6,13 @@
"path/filepath"
)
-// Get name of lock file, which is derived from the monitoring event name
-func getLockfileName() string {
- return filepath.Join(os.TempDir(), monitoringEvent, monitoringEvent+".lock")
-}
-
// Create a new lock file
func createLock() (lockfile.Lockfile, error) {
- ... | |
569042e6dfe2dcf338cb5d584e4d9b7c170af669 | ---
+++
@@ -23,7 +23,7 @@
Package = "github.com/containerd/containerd"
// Version holds the complete version number. Filled in at linking time.
- Version = "1.6.0-beta.3+unknown"
+ Version = "1.6.0-beta.4+unknown"
// Revision is filled with the VCS (e.g. git) revision being used to build
// the program at... | |
94a623fa08b669a41452fa441ad8da2d93baa58b | ---
+++
@@ -2,24 +2,29 @@
import "fmt"
-type HTTP struct {
+type HTTP interface {
+ error
+ Code() int
+}
+
+type http struct {
*primitive
code int
}
-func (h HTTP) Code() int {
+func (h http) Code() int {
return h.code
}
func NewHTTP(cause error, code int, message string) error {
- return &HTTP{
+ ... | |
fdddd4a2bf3ee13eebd6699a54a0a86814fae116 | ---
+++
@@ -4,6 +4,7 @@
import (
"io"
+ "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
)
@@ -11,6 +12,7 @@
// DownloaderAPI is the interface type for s3manager.Downloader.
type DownloaderAPI interface {
Download(io.WriterAt, *s3.Ge... | |
e4be389a3f47b64e3877a42e0124db41c98856ea | ---
+++
@@ -1,6 +1,7 @@
package money
import (
+ "fmt"
"math"
"strings"
)
@@ -29,3 +30,12 @@
return strings.Join(r, separator)
}
+
+func splitValue(val float64) (integer, fractional string) {
+ i, f := math.Modf(val)
+
+ integer = fmt.Sprintf("%.0f", i)
+ fractional = fmt.Sprintf("%.2f", f)[2:]
+
+ retu... | |
aae7d0beac11cc3f583d9ec194708c7957d53896 | ---
+++
@@ -11,9 +11,9 @@
antibody() {
case "$1" in
bundle|update)
+ tmp_dir=$(mktemp -d)
while read -u 3 bundle; do
- touch /tmp/antibody-log && chmod 777 /tmp/antibody-log
- source "$bundle" 2&> /tmp/antibody-log
+ source "$bundle" 2&> ${temp_dir}/antibody-log
done 3< <( $ANTIBODY_BINARY $@ )
;... | |
9152646855d907c37c3dade6efba0bd7cea18dd2 | ---
+++
@@ -1,6 +1,11 @@
package option
-import "net/http"
+import (
+ "net/http"
+ "time"
+
+ "github.com/itchio/wharf/timeout"
+)
type EOSSettings struct {
HTTPClient *http.Client
@@ -8,8 +13,13 @@
func DefaultSettings() *EOSSettings {
return &EOSSettings{
- HTTPClient: http.DefaultClient,
+ HTTPClie... | |
500a68483fdd9a330ac58d8c8726d187e9e9b578 | ---
+++
@@ -7,13 +7,13 @@
)
var (
- sequenses = regexp.MustCompile(`(?:[^~\\]|\\.)*`)
+ sequenses = regexp.MustCompile(`(?:[^/\\]|\\.)*`)
branches = regexp.MustCompile(`(?:[^,\\]|\\.)*`)
)
func newMatcher(expr string) (m *regexp.Regexp, err error) {
expr = strings.Replace(expr, `\,`, `\\,`, -1)
- expr = ... | |
41bed60213c81ccb550342a1efc24fc48d3587dc | ---
+++
@@ -1,6 +1,8 @@
package main
import (
+ "bufio"
+ "io"
"log"
"os"
"path"
@@ -10,14 +12,33 @@
if len(os.Args) != 3 {
log.Fatalf("Usage: %s input-file output-file", path.Base(os.Args[0]))
}
+
i, err := os.Open(os.Args[1])
if err != nil {
- log.Fatalf("Cannot open %q for readin... | |
e2a18a2283a462746b649c25bdcc349b8ac51aab | ---
+++
@@ -25,3 +25,18 @@
h.setFocus(true)
}
}
+
+type serviceTaskScreenEventHandler struct {
+ baseEventHandler
+}
+
+func (h *serviceTaskScreenEventHandler) handle(event termbox.Event) {
+
+ switch event.Key {
+ case termbox.KeyEsc:
+ h.dry.ShowServices()
+ }
+
+ h.baseEventHandler.handle(event)
+
+} | |
cb5e4254572805c3e70a342ce3ad84124ea438fe | ---
+++
@@ -9,6 +9,7 @@
var (
callIPTablesFile = "/proc/sys/net/bridge/bridge-nf-call-iptables"
+ forward = "/proc/sys/net/ipv4/ip_forward"
)
func Configure() error {
@@ -16,5 +17,8 @@
if err := ioutil.WriteFile(callIPTablesFile, []byte("1"), 0640); err != nil {
logrus.Warnf("failed to write va... | |
1e0b0e6dbfa427afa1772b724f4418dd76313ac1 | ---
+++
@@ -20,8 +20,7 @@
// Validate ensures that at least one sub-validator validates.
func (v AnyOf) Validate(value interface{}) (interface{}, error) {
for _, validator := range v {
- var err error
- if value, err = validator.Validate(value); err == nil {
+ if value, err := validator.Validate(value); err ==... | |
ac78c8d8ca36008e9a8afbd4775eb450dcdb8b2b | ---
+++
@@ -50,5 +50,12 @@
os.Exit(1)
}
- printList()
+ switch args[1] {
+ default:
+ printUsage()
+ os.Exit(1)
+ case "list":
+ printList()
+ return
+ }
} | |
92506424bd2a53d3140129ee7eba1cda2b74220d | ---
+++
@@ -16,7 +16,7 @@
go func() {
defer out.Close()
- out.Write([]byte(input))
+ out.Write([]byte(input + "\n"))
}()
return CaptureSTDOUT(reader, func() { block() }) | |
a265d3c2f5eccd509c52e8c25048c8762161e82b | ---
+++
@@ -26,9 +26,9 @@
// Apply default options first
for _, opt := range defaultOptions {
- if err := opt(sm); err != nil {
+ if optErr := opt(sm); optErr != nil {
// Panic if default option could not be applied
- panic(err)
+ panic(optErr)
}
}
| |
cb7937baed0a0057305e347315b6ba9cdf55d8d4 | ---
+++
@@ -6,6 +6,8 @@
"github.com/gorilla/mux"
"log"
"net/http"
+ // neccessary to catch sql.ErrNoRows
+ "database/sql"
"github.com/alex1sz/shotcharter-go/models"
)
@@ -14,8 +16,17 @@
func GetGameByID(w http.ResponseWriter, req *http.Request) {
log.Println("GET request /games/:id")
params := mux.Var... | |
5eb90cd6f2d564fae0ba13901e3c0fe1d0ffccf2 | ---
+++
@@ -1,33 +1,56 @@
package dom
+// ElementNodeType - constant for element node
+const ElementNodeType = "DOM/ELEMENT_NODE"
+
+// TextNodeType - constant for element node
+const TextNodeType = "DOM/TEXT_NODE"
+
// Node - Node interface
-type Node interface{}
+type Node interface {
+ getChildren() []*Node
+ ... | |
eb35552fb363ccc70c0473a29e40161ead848e37 | ---
+++
@@ -9,3 +9,10 @@
func NewDaemonProxy() DaemonProxy {
return DaemonProxy{}
}
+
+// Command returns a cli command handler if one exists
+func (p DaemonProxy) Command(name string) func(...string) error {
+ return map[string]func(...string) error{
+ "daemon": p.CmdDaemon,
+ }[name]
+} | |
348b34b8072000c614740c1981c6900033321c65 | ---
+++
@@ -12,9 +12,9 @@
func (c *Chain) Handle(ctx context.Context, conn Conn, msg Message) context.Context {
chainCtx := ctx
for i := range *c {
- chainCtx = (*c)[i].Handle(chainCtx, conn, msg)
- if chainCtx == nil {
- chainCtx = ctx
+ rCtx := (*c)[i].Handle(chainCtx, conn, msg)
+ if rCtx != nil {
+ c... | |
759cbd58e1770a7e3c176e9e1727805640d9247e | ---
+++
@@ -35,9 +35,8 @@
// TaskFixture creates a fixture of tagreplication.Task.
func TaskFixture() *Task {
- id := randutil.Text(4)
- tag := fmt.Sprintf("prime/labrat-%s", id)
+ tag := core.TagFixture()
d := core.DigestFixture()
- dest := fmt.Sprintf("build-index-%s", id)
+ dest := fmt.Sprintf("build-index-%... | |
e2a811a0566a0bbaf4a1fdc5e1d59fae2a1b746e | ---
+++
@@ -1,6 +1,7 @@
package fetch
import (
+ "os"
"testing"
log "github.com/Sirupsen/logrus"
@@ -11,7 +12,11 @@
func TestFetchPublicKeys(t *testing.T) {
log.SetLevel(log.DebugLevel)
- keys, err := GitHubKeys("devopsfinland", GithubFetchParams{PublicMembersOnly: true})
+ keys, err := GitHubKeys("dev... | |
68f22a40f30279005d260ba38590e32a0eff01be | ---
+++
@@ -31,17 +31,5 @@
}
// Get the SELinux context of the rootDir.
- rootContext, err := selinux.Getfilecon(kl.getRootDir())
- if err != nil {
- return "", err
- }
-
- // There is a libcontainer bug where the null byte is not stripped from
- // the result of reading some selinux xattrs; strip it.
- //
- /... | |
6bcf463b019461454fb2164b725ad343b42bc386 | ---
+++
@@ -23,7 +23,7 @@
const (
defaultAddress = `\\.\pipe\containerd-containerd-test`
- testImage = "docker.io/microsoft/nanoserver:latest"
+ testImage = "docker.io/microsoft/nanoserver@sha256:8f78a4a7da4464973a5cd239732626141aec97e69ba3e4023357628630bc1ee2"
)
var ( | |
d3f84d8b2f9b3aa392b83d029787a2a452a0ca65 | ---
+++
@@ -1,6 +1,8 @@
package main
import (
+ "bytes"
+ "fmt"
"testing"
"github.com/stretchr/testify/assert"
@@ -26,3 +28,16 @@
c2.setup()
assert.Equal(t, logrus.WarnLevel, logger.Level)
}
+
+func TestLogrusWriter(t *testing.T) {
+ var buf bytes.Buffer
+ logger := logrus.New()
+ logger.Out = &buf
+ s... | |
cf440052ef862fdc929cac8f757963aea47c3ee4 | ---
+++
@@ -23,10 +23,12 @@
"go.chromium.org/luci/common/errors"
)
-func setSysProcAttr(_ *exec.Cmd) {}
+func setSysProcAttr(cmd *exec.Cmd) {
+ cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
+}
func (s *Subprocess) terminate() error {
- if err := s.cmd.Process.Signal(syscall.SIGTERM); err != nil {
+ if... | |
23e9f8fae329f0527ed22317abb85a5859546417 | ---
+++
@@ -1,14 +1,31 @@
package axis
+
+// Positionable is the interface for positionable
+// items on a axis
+type Positionable interface {
+ Current() Position
+ Since(Position) Distance
+}
+
+// Sleepable is the interface for sleepable provider
+type Sleepable interface {
+ Sleep(Distance)
+}
+
+// Trigger is t... | |
0a60f16853d284840a996c695ca621519ad32724 | ---
+++
@@ -8,7 +8,19 @@
type Context struct {
*fetchbot.Context
- Cache Cache
+ C Cache
+}
+
+func (c *Context) Cache() Cache {
+ return c.C
+}
+
+func (c *Context) Queue() *fetchbot.Queue {
+ return c.Q
+}
+
+func (c *Context) URL() *url.URL {
+ return c.Cmd.URL()
}
func (c *Context) SourceURL() *url.URL { | |
f798c3e07c1e0764cc2e61b18ba1350a64a3138b | ---
+++
@@ -2,10 +2,10 @@
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
-// +build go1
+// +build go1.1
// +build !go1.6
-package gb
+package internal
const (
showGOTRACEBACKBanner = false | |
289317f7082e35f2103d70449a3dd4db6861a5a1 | ---
+++
@@ -11,6 +11,9 @@
)
func main() {
+
+ // # Get stack name from --name
+ // # Get stack name from directory if not passed
pwd, err := os.Getwd()
if err != nil {
fmt.Println(err)
@@ -27,9 +30,37 @@
log.Fatal(err)
}
- for name, _ := range project.NetworkConfigs {
- ... | |
a48e7020f845bc5681c9c8588d120f0d99b310e9 | ---
+++
@@ -9,7 +9,10 @@
// RandomReward generates a random reward with rates given
func RandomReward(rates []models.RewardRate) int64 {
- sum := sumOfWeights(rates)
+ var sum int64
+ for i := range rates {
+ sum += rates[i].Weight
+ }
if sum < 1 {
panic("sum of reward rates weight should be greater than 0"... | |
a3c6388aa272447266d978ab905fa665746fd527 | ---
+++
@@ -5,21 +5,18 @@
"time"
)
-type Response interface {
- MakeATimestamp()
-}
+type Timestamp int64
type baseResponse struct {
Command string
- Timestamp int64
+ Timestamp Timestamp
}
-func (r *baseResponse) MakeATimestamp() {
- r.Timestamp = time.Now().UnixNano() / 1e6
+func (t *Timestamp) Marsh... | |
844fa0fb81ef01a35d54c2229e359f9afa0bf35c | ---
+++
@@ -29,8 +29,11 @@
jot.Printf("message dispatch: message %s with cmd %s and args %v", m.Text, cmd, args)
fn, ok := commands[cmd]
if !ok {
- q = oq
- return
+ fn, ok = commands["help"]
+ if !ok {
+ q = oq
+ return
+ }
}
q, response = fn(oq, m.Channel, m.User, args) | |
3b047c3778265bc35448c42bc01e729d20bd69b7 | ---
+++
@@ -27,7 +27,7 @@
e.Use(middleware.CORS())
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
- AllowOrigins: []string{"http://localhost:8100/"},
+ AllowOrigins: []string{"*", "http://192.168.43.108:8100/"},
}))
e.POST("/qoutes/", CreateQoute) | |
5d66fa46e201e4989964815561a47ca484df33a2 | ---
+++
@@ -6,11 +6,13 @@
log "github.com/sirupsen/logrus"
)
-func Watch(directory string, deployments chan<- string) {
+func Watch(directory string, batchInterval int, deployments chan<- string) {
done := make(chan bool)
defer close(done)
- watcher, err := NewBatcher(5 * time.Second)
+ log.Infof("Starting... | |
a719d3f1e2734708f6b57d645d9fdc53187e88d9 | ---
+++
@@ -12,9 +12,14 @@
var buf bytes.Buffer
for _, c := range []byte(s) {
if isEncodable(c) {
- buf.WriteByte('%')
- buf.WriteByte(hex[c>>4])
- buf.WriteByte(hex[c&15])
+ if c == '+' {
+ // replace plus-encoding with percent-encoding
+ buf.WriteString("%2520")
+ } else {
+ buf.WriteByte(... | |
34a8a447d17052cbcfafae7bdb4d9594011495e6 | ---
+++
@@ -12,7 +12,7 @@
keys *Keys
}
-func NewBot(config string) (*TBot, error) {
+func New(config string) (*TBot, error) {
keys, err := ReadConfig(config)
if err != nil {
return nil, err
@@ -29,7 +29,7 @@
NextTweet() string
}
-func (t *TBot) RunBot(creator TweetCreator) {
+func (t *TBot) Run(creat... | |
f9784b202625b37312b0f10a869b73bf049e71f6 | ---
+++
@@ -8,7 +8,7 @@
func (api *API) TokenAuth() gin.HandlerFunc {
return func(c *gin.Context) {
- if api.token != c.Request.Header.Get("token") {
+ if api.token != c.Request.Header.Get("Authorization") {
c.AbortWithStatus(http.StatusUnauthorized)
return
} | |
c2851c6b6ec2be65e9c09b31d64915049b62311a | ---
+++
@@ -6,7 +6,10 @@
"io/ioutil"
"os"
"github.com/robertkrimen/otto"
+ "github.com/robertkrimen/otto/underscore"
)
+
+var underscoreFlag *bool = flag.Bool("underscore", true, "Load underscore into the runtime environment")
func main() {
flag.Parse()
@@ -26,6 +29,9 @@
os.Exit(64)
}
}
+ if !*un... | |
2abbb29dd1512f32a7f85347c3c9554afaced493 | ---
+++
@@ -17,7 +17,7 @@
func (self *UnitsResource) Index(u *url.URL, h http.Header, req interface{}) (int, http.Header, *UnitsResponse, error) {
statusCode := http.StatusOK
- response := &UnitResponse{}
+ response := &UnitsResponse{}
units, err := self.Fleet.Units()
if err != nil { | |
ab410f4943fca756da19a3eb86ad94d999ae2167 | ---
+++
@@ -11,13 +11,7 @@
var _ = Describe("io helpers", func() {
It("will never overflow the pipe", func() {
- characters := make([]string, 0, 75000)
- for i := 0; i < 75000; i++ {
- characters = append(characters, "z")
- }
-
- str := strings.Join(characters, "")
-
+ str := strings.Repeat("z", 75000)
... | |
227dac8b50c8817e3a85497e76ad405d5e453d5a | ---
+++
@@ -18,37 +18,37 @@
flag.Parse()
processes, err := ps.Processes()
- if err != nil {
- panic(err)
- }
-
- err = checks.ProcessCheck(processes, requiredProcesses)
- if err != nil {
- log.Fatal(err)
+ if err == nil {
+ err = checks.ProcessCheck(processes, requiredProcesses)
+ if err != nil {
+ log.Pr... | |
95a3a717ed8f5ed245147a1b214218a8ad904098 | ---
+++
@@ -1,8 +1,8 @@
package id
import (
+ "crypto/rand"
"fmt"
- "crypto/rand"
)
// GenerateRandomString creates a random string of characters of the given
@@ -24,3 +24,15 @@
func GenSafeUniqueSlug(slug string) string {
return fmt.Sprintf("%s-%s", slug, GenerateRandomString("0123456789bcdfghjklmnpqrst... | |
283874315567f7a541ad7d7898fb0b93f205663f | ---
+++
@@ -1,17 +1,14 @@
package netlink
-/*
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <linux/if.h>
-#include <linux/if_tun.h>
-
-#define IFREQ_SIZE sizeof(struct ifreq)
-*/
-import "C"
+// ideally golang.org/x/sys/unix would define IfReq but it only has
+// IFNAMSIZ, hence this minimalistic impl... | |
c1411e0ad5199695c808c647e066bfc1c7650a7f | ---
+++
@@ -1,4 +1,8 @@
package test
+
+type E struct {
+ E1 string
+}
type T struct {
F1 string `json:"F1"`
@@ -7,4 +11,5 @@
F4 string `json:"-,"`
F5 string `json:","`
F6 string `json:""`
+ E `json:"e"`
} | |
4ba47bc9e4e1b7b0a0c8d656a18c73f623f74010 | ---
+++
@@ -1,14 +1,12 @@
package main
import (
- "fmt"
"html/template"
- "log"
"net/http"
- "os"
"sort"
"github.com/eknkc/amber"
+ "google.golang.org/appengine"
)
//template map
@@ -27,20 +25,7 @@
http.HandleFunc("/", animeHandler)
http.HandleFunc("/static/", staticHandler)
- //Sets url and p... | |
69aaaa10381d9487ff3cf9990fca3780e895e450 | ---
+++
@@ -9,8 +9,8 @@
var _ = Describe("Consul DNS checks", func() {
It("returns an error when host is not known", func() {
- err := ConsulDnsCheck("host-non-existing.")
- Expect(err).To(MatchError("Failed to resolve consul host host-non-existing.\nlookup host-non-existing.: getaddrinfow: No such host is kno... | |
8d834e22da1d8159ec61c9ee6a9a6542ca30fbd3 | ---
+++
@@ -28,7 +28,7 @@
return
}
- if iType == PNG {
+ if iType == PNG && !ctx.Options.Webp {
decoded, _, err := image.Decode(bytes.NewReader(*img_buff))
if err != nil {
warning("Can't decode PNG image, reason - %s", err) |
Subsets and Splits
Match Query to Corpus Titles
Matches queries with corpus entries based on their row numbers, providing a simple pairing of text data without revealing deeper insights or patterns.