_id stringlengths 40 40 | text stringlengths 81 2.19k | title stringclasses 1
value |
|---|---|---|
4660d7d17f163b506ad8d8a410efe7fdc7ed06b6 | ---
+++
@@ -48,7 +48,7 @@
func toPort(p string) int {
ps, err := strconv.Atoi(p)
if err != nil {
- log.Printf("[ERROR] Invalid port number: %d", p)
+ log.Printf("[ERROR] Invalid port number: %s", p)
}
return ps | |
809e04f2d16c4bac5b7d38f13537d3debfe0d914 | ---
+++
@@ -5,7 +5,7 @@
"github.com/mcroydon/goplayground/similarity"
)
-func ExampleUse() {
+func Example() {
// Create a similarity engine
sim := similarity.New()
| |
1e106de4ea1789a593dfc207470e844f7b911e0a | ---
+++
@@ -16,13 +16,13 @@
Body []byte
}
-func (uk UnknownFrame) Size() int {
- return len(uk.Body)
+func (uf UnknownFrame) Size() int {
+ return len(uf.Body)
}
-func (uk UnknownFrame) WriteTo(w io.Writer) (n int64, err error) {
+func (uf UnknownFrame) WriteTo(w io.Writer) (n int64, err error) {
var i int
... | |
ee0bb560054d6a1f103a1600838cf8e18c28bd88 | ---
+++
@@ -4,6 +4,7 @@
"fmt"
"github.com/anaminus/rbxmk"
+ "github.com/robloxapi/types"
)
// registry contains registered Formats.
@@ -21,5 +22,8 @@
// cannotEncode returns an error indicating that v cannot be encoded.
func cannotEncode(v interface{}) error {
+ if v, ok := v.(types.Value); ok {
+ retu... | |
d904cf0beee88aeb9a4094ec119de958621b1856 | ---
+++
@@ -24,7 +24,7 @@
var Resource = &core.Resource{
Name: "bridge",
ServiceType: reflect.TypeOf(&bridge.Service{}),
- Category: core.ResourceCategoryStorage,
+ Category: core.ResourceCategoryNetworking,
CommandCategories: []core.Category{
{
Key: "basic", | |
b7f2285ba304b0473025902fd6508a175cf51420 | ---
+++
@@ -22,7 +22,7 @@
return manager
}
-func (manager emailManager) send(to string, subject string, content string) {
+func (manager emailManager) Send(to string, subject string, content string) {
auth := smtp.PlainAuth("", manager.Login, manager.Password, manager.Host)
recipients := []string{to}
| |
0e93f1795a8a479ce4ac381d103727b55f68b1e4 | ---
+++
@@ -3,6 +3,7 @@
import (
"flag"
"github.com/zenazn/goji"
+ "github.com/zenazn/goji/web"
"github.com/zenazn/goji/web/middleware"
"net/http"
)
@@ -18,6 +19,8 @@
if conf.Proxy {
goji.Insert(middleware.RealIP, middleware.Logger)
}
+
+ goji.Use(serveLapitar)
register("/skin/:player", serveSkin... | |
04b72b4a7ddd37d4615f4fcc125211ee93518780 | ---
+++
@@ -15,15 +15,11 @@
func (t TemplateGenerator) Generate(state storage.State) string {
return fmt.Sprintf(`
variable "vsphere_subnet" {}
-variable "jumpbox_ip" {
- default = ""
-}
+variable "jumpbox_ip" {}
variable "internal_gw" {}
variable "network_name" {}
variable "vcenter_cluster" {}
-variable "bos... | |
3125d02cf6b842700239ca67ef5b7f96951d28b7 | ---
+++
@@ -3,6 +3,7 @@
import (
"fmt"
"net"
+ "strings"
)
const (
@@ -27,18 +28,8 @@
// Build list of "host:port" strings.
for _, a := range addrs {
- target := parseTargetDomainName(a.Target)
+ target := strings.TrimRight(a.Target, ".")
addr = append(addr, fmt.Sprintf("%s:%d", target, a.Port))
... | |
84494e3ce36f35807ca004f44b0c8936f78ed835 | ---
+++
@@ -1,6 +1,8 @@
package wats
import (
+ "time"
+
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
@@ -25,7 +27,8 @@
It("doesn't die when printing 32MB", func() {
beforeId := helpers.CurlApp(appName, "/id")
- Expect(helpers.CurlAppWithTimeout(appName, "/l... | |
0f81fc87f193ce12bf44bdbef149514ced6ad36e | ---
+++
@@ -5,6 +5,7 @@
"os"
)
+// ParseUsername returns an array of user strings or an error if no arguments provided
func ParseUsername() ([]string, error) {
args := os.Args
@@ -12,7 +13,5 @@
log.Fatal("Please supply at least one GitHub username")
}
- // username := args[0]
- // return username, ni... | |
927939dfc6d6612f488da7a189b4f2299e99eea7 | ---
+++
@@ -4,7 +4,7 @@
"net/url"
)
-var GitTreesURL = Hyperlink("repos/{owner}/{repo}/git/trees/{/sha}{?recursive}")
+var GitTreesURL = Hyperlink("repos/{owner}/{repo}/git/trees/{sha}{?recursive}")
func (c *Client) GitTrees(url *url.URL) (trees *GitTreesService) {
trees = &GitTreesService{client: c, URL: u... | |
4a0e50ddd5da0ad298b0807f3ea0cb5adc4693b5 | ---
+++
@@ -29,5 +29,19 @@
Eventually(session).Should(Say("OK"))
Eventually(session).Should(Exit(0))
})
+
+ When("the user already has the desired role", func() {
+ BeforeEach(func() {
+ session := helpers.CF("set-org-role", username, orgName, "OrgManager")
+ Eventually(session).Should(Say("Assign... | |
84776c4e432013fb267fb5084740be416116e699 | ---
+++
@@ -1,7 +1,6 @@
package restic
import (
- "log"
"net"
"os"
)
@@ -34,7 +33,6 @@
// Close closes both streams.
func (s *StdioConn) Close() error {
- log.Printf("Server.Close()\n")
err1 := s.stdin.Close()
err2 := s.stdout.Close()
if err1 != nil { | |
a13ef780694f22260e1b0bb5ef80b7aff4eb0b24 | ---
+++
@@ -14,7 +14,7 @@
var v1 int = i;
if foo1(v1) != 1 { panicln(1) }
var v2 int32 = i.(int).(int32);
- if foo1(v2) != 1 { panicln(2) }
+ if foo2(v2) != 1 { panicln(2) }
var v3 int32 = i; // This implicit type conversion should fail at runtime.
- if foo1(v3) != 1 { panicln(3) }
+ if foo2(v3) != 1 ... | |
51870c87146b68ef2184494b0617118468871481 | ---
+++
@@ -3,7 +3,46 @@
import (
"os"
"fmt"
+ "io/ioutil"
+ "log"
+ "encoding/json"
+ "flag"
)
+
+type RepositorySettings struct {
+ LandingPage string // TODO unmarshal into enum like type
+ Private bool
+ MainBranch string
+ Forks string // TODO: Unmarshal 'forks' into an enum like type
+ DeployKe... | |
dd8265b042b9a9194eb792bdb1611f0096c05b62 | ---
+++
@@ -13,7 +13,11 @@
)
func NewClient(cfg *config.Config) (*dockerClient.Client, error) {
- client, err := dockerClient.NewClient(cfg.DockerEndpoint)
+ endpoint := "unix:///var/run/docker.sock"
+ if cfg != nil {
+ endpoint = cfg.DockerEndpoint
+ }
+ client, err := dockerClient.NewClient(endpoint)
if err ... | |
ff05bb523b574b14c16dc8ac5744ab2d7a08a9b7 | ---
+++
@@ -11,11 +11,11 @@
//
// If the scores file is empty, the returned entries are empty.
func (c *Config) ReadEntries() (*scoring.Entries, error) {
- var entries *scoring.Entries
+ var entries scoring.Entries
scoresFile, err := c.scoresFile()
if err != nil {
- return entries, nil
+ return &entries, n... | |
68fe9c1000e3e6cf3fba586ee4f319f62feeecb3 | ---
+++
@@ -1,8 +1,6 @@
package cmd
import (
- "syscall"
-
"github.com/spf13/cobra"
)
@@ -11,13 +9,11 @@
Short: "Stop a daemon",
Long: "",
RunE: func(cmd *cobra.Command, args []string) error {
-
- syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
-
- return nil
+ _, err := restClient.R().Post("/api/v... | |
20b747c3fbd9d547dbb232c8560630e102f11e45 | ---
+++
@@ -1,7 +1,7 @@
package controllers
import (
- "github.com/anonx/sunplate/skeleton/assets/views"
+ v "github.com/anonx/sunplate/skeleton/assets/views"
"github.com/anonx/sunplate/action"
)
@@ -18,14 +18,14 @@
// Index is an action that is used for generation of a greeting form.
func (c *App) Index... | |
8ba5485db6ebfa824458df98db6df29cbe128332 | ---
+++
@@ -19,7 +19,7 @@
fields := make([]zapcore.Field, len(data))
i := 0
for k, v := range data {
- fields[i] = zap.Reflect(k, v)
+ fields[i] = zap.Any(k, v)
i++
}
| |
2c0a355ba4328baae3e266d06f2b29c9efff996e | ---
+++
@@ -6,13 +6,18 @@
"github.com/Cepave/open-falcon-backend/cmd"
"github.com/spf13/cobra"
- flag "github.com/spf13/pflag"
)
var versionFlag bool
var RootCmd = &cobra.Command{
Use: "open-falcon",
+ Run: func(cmd *cobra.Command, args []string) {
+ if versionFlag {
+ fmt.Printf("Open-Falcon versio... | |
f53e12216c70c4fc0a423cd873eb76d50e2a1e2f | ---
+++
@@ -7,10 +7,18 @@
// HelpForHelp shows overall usage information for the BigV client, including a list of available commands.
func (cmds *CommandSet) HelpForHelp() {
- // TODO(telyn): write real usage information
fmt.Println("bigv command-line client (the new, cool one)")
fmt.Println()
- fmt.Println("... | |
c3a633c440d6658490191a819be4f33b909f808a | ---
+++
@@ -1,18 +1,17 @@
package main
import (
-// "bufio"
-// "fmt"
-// "os"
-// "regexp"
+ "bufio"
+ "fmt"
+ "os"
+ "regexp"
)
func findDeviceFromMount (mount string) (string, error) {
// stub for Mac devel
- return "/dev/xvda", nil
- /*
+ //return "/dev/xvda", nil
var device string = "... | |
eb4c0f0437eb7d8ffd678f9ce0bde2f8e2651e1f | ---
+++
@@ -7,11 +7,6 @@
"testing"
gitjujutesting "github.com/juju/testing"
- jc "github.com/juju/testing/checkers"
- gc "gopkg.in/check.v1"
- "gopkg.in/mgo.v2"
-
- "github.com/juju/juju/mongo"
)
// MgoTestPackage should be called to register the tests for any package
@@ -19,28 +14,3 @@
func MgoTestPackage... | |
fec55e7fe9f34ab5ea4eb54df8c945dc5ab46e70 | ---
+++
@@ -15,12 +15,8 @@
// Mapping holding all of the UIs that can be learned. The mapping
// holds a generator to generate the UI.
-var allUI map[string]func() (UI, error)
-
-func init() {
- allUI = make(map[string]func() (UI, error))
-
- Register("simple", newSimpleUI)
+var allUI = map[string]func() (UI, er... | |
9608a88347f547e8ba767ad34f24b5fd61688eae | ---
+++
@@ -5,12 +5,13 @@
"github.com/eris-ltd/erisdb/server"
"os"
"github.com/gin-gonic/gin"
+ "path"
)
func main() {
gin.SetMode(gin.ReleaseMode)
- baseDir := os.Getenv("HOME") + "/.edbservers"
+ baseDir := path.Join(os.TempDir(), "/.edbservers")
ss := ess.NewServerServer(baseDir)
proc := server.N... | |
ed0a57ba99d9cdab0167e4df1851f8755fd5217d | ---
+++
@@ -2,6 +2,7 @@
import (
"flag"
+ "fmt"
"github.com/anchor/picolog"
"github.com/fractalcat/emogo"
zmq "github.com/pebbe/zmq4"
@@ -9,6 +10,17 @@
)
var Logger *picolog.Logger
+
+func readFrames(e *emogo.EmokitContext, out chan *emogo.EmokitFrame) {
+ for {
+ f, err := e.WaitGetFrame()
+ if err ... | |
4653497dc470d2d9e10d16bf8450d83a47abd522 | ---
+++
@@ -5,10 +5,10 @@
)
func TestUpdate(t *testing.T) {
- s1 := Update(users, Values{"name": "client"})
+ stmt := Update(users, Values{"name": "client"})
expectedSQL(
t,
- s1,
+ stmt,
`UPDATE "users" SET "name" = $1`,
1,
)
@@ -18,19 +18,25 @@
"password": "blank",
}
- s2 := Update(users, ... | |
794b4dcd83c62ded650d58a198f3764f5fcc74b7 | ---
+++
@@ -32,7 +32,7 @@
if p.CorrectAnswer == "NA" {
fmt.Println("Problem", p.ID, "has not been solved yet.")
} else {
- fmt.Println("Answer to problem", p.ID, "is", p.Solver())
+ fmt.Println("Answer to problem", p.ID, "is", p.Solver(), "(took", p.Attempts, "attempts)")
}
}
| |
a6ac84b7c8d5c2de2d5f2dc735503f07325ce9c1 | ---
+++
@@ -32,7 +32,7 @@
func handleSigTerm() {
// shutdown
- c := make(chan os.Signal)
+ c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c | |
12c14bfd34be16ffe6796b24ef7693cfe63ee109 | ---
+++
@@ -20,7 +20,7 @@
*/
server.Get("/v1/users", common.CheckAuth, Login)
server.Post("/v1/users", CreateUser)
- server.Put("/v1/users", common.CheckAuth, UpdateUser)
+ server.Put("/v1/users/:username", common.CheckAuth, UpdateUser)
/*
User repository routes | |
622f62c62b102a7e2a71688d9163b90fcd55326c | ---
+++
@@ -11,12 +11,12 @@
func Control(network, address string, c syscall.RawConn) error {
var err error
c.Control(func(fd uintptr) {
- err = syscall.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
+ err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
if err != nil {
... | |
bd82db83810aa98ca78bbe742b1f95f3413a4073 | ---
+++
@@ -4,6 +4,9 @@
"goa.design/goa/v3/eval"
"goa.design/goa/v3/expr"
)
+
+// Val is an alias for expr.Val.
+type Val expr.Val
// Value sets the example value.
// | |
82573bb49c3a80fa55616f0d3b0fee563b0cef17 | ---
+++
@@ -2,6 +2,10 @@
import (
"encoding/json"
+ "time"
+
+ "code.google.com/p/go-uuid/uuid"
+
"iotrules/mylog"
)
@@ -27,6 +31,8 @@
defer func() { mylog.Debugf("exit NewNotifFromCB (%+v,%v)\n", n, err) }()
n = &Notif{Data: map[string]interface{}{}}
+ n.ID = uuid.New()
+ n.Received = time.Now()
... | |
16bf85fc85d292271efdd3b9fcbc91abe1e2c4de | ---
+++
@@ -26,6 +26,11 @@
for hostname, sub := range herd.subsByName {
if sub.hostname == "" {
subsToDelete = append(subsToDelete, hostname)
+ if sub.connection != nil {
+ // Destroying a Client doesn't free up all the memory, so call
+ // the Close() method to free up the memory.
+ sub.connectio... | |
a97b09ce55a0be3ad5a34c2b4a92cd324924809b | ---
+++
@@ -13,9 +13,11 @@
import "unsafe"
+func init() {
+ C.pg_query_init()
+}
+
func Parse(input string) string {
- C.pg_query_init()
-
input_c := C.CString(input)
defer C.free(unsafe.Pointer(input_c))
| |
46688a6f88fdf54ed64b0669386cda3024c080c7 | ---
+++
@@ -15,12 +15,14 @@
}
func (c *catalogServices) CommandFlags() *flag.FlagSet {
- return newFlagSet()
+ f := newFlagSet()
+
+ c.addDatacenterFlag(f)
+ c.addOutputFlags(f, false)
+ c.addConsistencyFlags(f)
+
+ return f
}
-
-// addDatacenterOption(cmd)
-// addTemplateOption(cmd)
-// addConsistencyOptions(cm... | |
e377444404f140bb5eff13b9cc38d8cc4b362b50 | ---
+++
@@ -21,6 +21,12 @@
return err
}
+ // Darken background area
+ err = exec.Command(
+ "gsettings", "set", "org.gnome.desktop.background",
+ "primary-color", "#000000",
+ ).Run()
+
// Set the background (gnome3 only atm)
err = exec.Command(
"gsettings", "set", "org.gnome.desktop.background", | |
de2a451f9c30ada011f0b5e471fd04a3770f9be1 | ---
+++
@@ -22,6 +22,19 @@
}
}
+func (vb *VirtualBox) CreateHardDisk(format, location string) (*Medium, error) {
+ vb.Logon()
+
+ request := vboxwebsrv.IVirtualBoxcreateHardDisk{This: vb.managedObjectId, Format: format, Location: location}
+
+ response, err := vb.IVirtualBoxcreateHardDisk(&request)
+ if err != n... | |
430a6a56aaa63b8236a9b71fb4e4c07d31b68cf9 | ---
+++
@@ -28,6 +28,12 @@
const OpenStackJumpboxKeystoneV3Ops = `---
- type: remove
+ path: /instance_groups/name=jumpbox/networks/name=public
+
+- type: remove
+ path: /networks/name=public
+
+- type: remove
path: /cloud_provider/properties/openstack/tenant
- type: replace | |
605ca2cc43ff3ac0971da11ca974738000896fd1 | ---
+++
@@ -22,7 +22,7 @@
func main() {
d := net.Dialer{Timeout: 10 * time.Second}
- p := make(chan bool, 500) // make 500 parallel connection
+ p := make(chan struct{}, 500) // make 500 parallel connection
wg := sync.WaitGroup{}
c := func(port int) {
@@ -37,7 +37,7 @@
wg.Add(65536)
for i := 0; i < 6... | |
bed13b0916edd31ad1e85bd74bea71dd8b4276fb | ---
+++
@@ -1,9 +1,32 @@
package config
import (
+ "errors"
+ "fmt"
"os"
"syscall"
)
+
+type closedError struct {
+ flockErr error
+ fileErr error
+}
+
+func (ce closedError) Error() string {
+ return fmt.Sprintf("%s, %s", ce.fileErr.Error(), ce.flockErr.Error())
+}
+
+func newClosedError(flockErr, fileErr ... | |
72babd93910d2458ce8764451125e6642149392c | ---
+++
@@ -2,6 +2,7 @@
import (
"encoding/json"
+ "fmt"
"io"
"github.com/hackebrot/turtle"
@@ -13,8 +14,24 @@
}
// NewJSONWriter creates a new JSONWriter
-func NewJSONWriter(w io.Writer) *JSONWriter {
- return &JSONWriter{e: json.NewEncoder(w)}
+func NewJSONWriter(w io.Writer, options ...func(*JSONWri... | |
d5f261bf4aa0d589cce6d27662b9a313845600f8 | ---
+++
@@ -16,20 +16,17 @@
// Day returns a time.Time referencing the beginning of the next day
func Day(t time.Time) time.Time {
- t = t.AddDate(0, 0, 1)
- return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
+ return time.Date(t.Year(), t.Month(), t.Day()+1, 0, 0, 0, 0, t.Location())
}
... | |
cb82e4bba6b3e526ffdd7cf607474ce3ea9ab953 | ---
+++
@@ -1,31 +1,39 @@
package main
import (
- "math/big"
"testing"
)
-func sumOfPrimesBelow(x int64) int64 {
- var i int64
- var sum int64 = 0
- for i = 2; i < x; i++ {
- if i > 2 && i%2 == 0 {
+func sumOfPrimesBelow(x int) int {
+ sieve := make([]bool, x)
+ for i:=0; i<x; i++ {
+ sieve[i] = true
+ }
+... | |
5241cdb4403e99e6debd06c2d6ed2d8e4d1f3bfd | ---
+++
@@ -1,6 +1,9 @@
package main
-import "net/http"
+import (
+ "net/http"
+ "strings"
+)
// Wiki represents the entire Wiki, contains the db
type Wiki struct {
@@ -25,16 +28,21 @@
path := r.URL.Path
action := queryValues.Get("action")
+ isDir := len(wiki.store.GetPageList(path)) > 0 || len(wiki.stor... | |
fcf2e07e569963afcf198464186b423217f0294b | ---
+++
@@ -2,6 +2,7 @@
import (
"os"
+ "strings"
. "github.com/cloudfoundry/cli/testhelpers/io"
. "github.com/onsi/ginkgo"
@@ -10,10 +11,12 @@
var _ = Describe("io helpers", func() {
It("will never overflow the pipe", func() {
- str := ""
+ characters := make([]string, 0, 75000)
for i := 0; i < ... | |
213c80bc286672657ced52e03374b528f20a965e | ---
+++
@@ -7,7 +7,7 @@
func main() {
router := NewRouter()
- err := http.ListenAndServe(":8080", router)
+ err := http.ListenAndServe(":" + os.Getenv("PORT"), router)
if err != nil {
log.Fatal("ListenAndServe Error: ", err)
} | |
8a139b3b78298bca28de8e558297800413eaf186 | ---
+++
@@ -21,3 +21,17 @@
// mount_gcsfuse does not daemonize, and therefore must be used with a wrapper
// that performs daemonization if it is to be used directly with mount(8).
package main
+
+import (
+ "log"
+ "os"
+)
+
+func main() {
+ // Print out each argument.
+ for i, arg := range os.Args {
+ log.Print... | |
ba1e8ad5e4b20b92684f9b7c4bf3efb35a2fe0e1 | ---
+++
@@ -13,8 +13,7 @@
// are UPPERCASE, and any dashes are replaced by underscores. Environment
// variables additionally are prefixed by the given string followed by
// and underscore. For example, if prefix=PREFIX: some-flag => PREFIX_SOME_FLAG
-func SetFlagsFromEnv(fs *flag.FlagSet, prefix string) error {
-... | |
8fb49dc9153c4593b739a5950ae2bc8cbddc758f | ---
+++
@@ -1,19 +1,32 @@
package v1
import (
+ "net/http"
+ "time"
+
"github.com/codegangsta/martini"
"github.com/coopernurse/gorp"
"github.com/hackedu/backend/v1/model"
"github.com/hackedu/backend/v1/route"
"github.com/martini-contrib/binding"
+ "github.com/zachlatta/cors"
)
func Setup(m *martini.... | |
50c1804b294cfdebf84285c312124583867d3e34 | ---
+++
@@ -3,11 +3,12 @@
import (
"log"
"net/http"
+ "os"
)
func main() {
var g GMHook
- err := http.ListenAndServe("localhost:4000", g)
+ err := http.ListenAndServe(":"+os.Getenv("PORT"), g)
if err != nil {
log.Fatal(err)
} | |
c031a75a5033c732635f0d66032a2bb0d7f709ed | ---
+++
@@ -16,4 +16,9 @@
assert.Panics(t, func() { noGenerationKey.GetUID() }, "Panic expected if key is incorrect")
assert.Panics(t, func() { noGenerationKey.GetGeneration() }, "Panic expected if key is incorrect")
+
+ invalidGenerationKey := Key("72b062c1-7fcf-11e7-ab09-acde48001122$bad")
+
+ assert.Equal(t,... | |
50bcc11856a4cf4951234cb29a56993789d69c7e | ---
+++
@@ -20,6 +20,8 @@
func CheckAuth(req *f.Request, res *f.Response, next func()) {
auth := req.Get("authorization")
+ req.Map["_uid"] = -1
+ req.Map["_admin"] = false
if len(auth) == 0 {
res.Send("No authorization provided.", 401)
@@ -37,4 +39,5 @@
res.Send("Unauthorized", 401)
}
re... | |
68d16c936752d5c43f330b981bbd4b215654d13b | ---
+++
@@ -2,7 +2,7 @@
package version
const (
- version = "0.2.0"
+ version = "0.2.1"
)
// return the current application version | |
bb1c4db925a715716fdf7293051fa810858cd4a9 | ---
+++
@@ -6,6 +6,7 @@
"restrictSources",
"userToken",
"validUntil",
+ "referers",
); err != nil {
return err
}
@@ -20,6 +21,11 @@
case "validUntil":
if _, ok := v.(int); !ok {
return invalidType(k, "int")
+ }
+
+ case "referers":
+ if _, ok := v.([]string); !ok {
+ return invali... | |
ea9e6806e8f708aee08267b358de0cb6e9990925 | ---
+++
@@ -6,6 +6,9 @@
func Ue(data Interface) int {
len := data.Len()
+ if len == 0 {
+ return 0
+ }
i, j := 0, 1
// find the first duplicate
for j < len && data.Less(i, j) { | |
4d9393ae0de684f654ea0eb61e9712317b0dde3a | ---
+++
@@ -1,4 +1,8 @@
package schedule
+
+import (
+ "time"
+)
type ScheduleEntries int
@@ -11,10 +15,35 @@
TWO ScheduleEntries = 2
THREE ScheduleEntries = 3
FOUR ScheduleEntries = 4
+
+ NUM_WEEK_DAYS = 7
)
+// BuildCommitSchedule returns an empty CommitSchedule, where all fiels ... | |
66e0d54c023596c02e0a6e01a3a46d6e9ffcd295 | ---
+++
@@ -20,10 +20,11 @@
// Default parameter values.
const (
- DclMaxMemoCharacters uint64 = authtypes.DefaultMaxMemoCharacters
- DclTxSigLimit uint64 = authtypes.DefaultTxSigLimit
- DclTxSizeCostPerByte uint64 = 0 // gas is not needed in DCL
- DclSigVerifyCostED25519 uint64 = 0 //... | |
ce572432f91d48f35559925bfa4a15f8dbbce30a | ---
+++
@@ -14,6 +14,7 @@
COLLECTION Type = "<collection>"
CONTAINER Type = "<container>"
HASHER Type = "<hasher>"
+ ANY Type = "<any>"
/* Normal Types */
NUMBER Type = "<number>"
@@ -32,6 +33,10 @@
)
func is(obj Object, t Type) bool {
+ if t == ANY {
+ return true
+ }
+
if t == COLLE... | |
7e3d5535dde7ce18b28d3ee1b12ded170dcac792 | ---
+++
@@ -9,6 +9,7 @@
type Play struct {
NodeTemplate NodeTemplate
+ InterfaceName string
OperationName string
}
@@ -17,9 +18,9 @@
i := 0
index := make(map[int]Play, 0)
for _, node := range s.TopologyTemplate.NodeTemplates {
- for _, intf := range node.Interfaces {
+ for intfn, intf := range node... | |
f9a8c9a68124f765dbf727e286e4ff56b9d8b5b0 | ---
+++
@@ -1,9 +1,15 @@
package gstrings
import (
+ "fmt"
"github.com/wallclockbuilder/testify/assert"
"testing"
)
+
+func ExampleSize(){
+ fmt.Println(Size("hello"))
+ // Output: 5
+}
func TestSize(t *testing.T) {
assert := assert.New(t) | |
9262c5b32f99d677b6878984e35dbd6a5b31fbd8 | ---
+++
@@ -16,9 +16,10 @@
import (
"runtime"
+ "os"
+
"github.com/spf13/hugo/commands"
jww "github.com/spf13/jwalterweatherman"
- "os"
)
func main() {
@@ -28,4 +29,10 @@
if jww.LogCountForLevelsGreaterThanorEqualTo(jww.LevelError) > 0 {
os.Exit(-1)
}
+
+ if commands.Hugo != nil {
+ if commands.H... | |
fe764f09ca3f776eee1f5b5dfa680502f9ae4ede | ---
+++
@@ -6,6 +6,10 @@
)
func TestDefaultSessionConfig(t *testing.T) {
+ // Cleanup before the test
+ os.Unsetenv("AWS_DEFAULT_REGION")
+ os.Unsetenv("AWS_REGION")
+
cases := []struct {
expected string
export bool
@@ -19,10 +23,10 @@
exportVal: "",
},
{
- expected: "ap-southeast-1",
+ ... | |
1c03ff45cda99e5bf750797c2acbeb962b3a8e89 | ---
+++
@@ -10,10 +10,18 @@
"net/http"
)
+// ErrNotFound gets passed to a Router's ErrorHandler if
+// no route matched the request path or none of the matching routes wrote
+// a response.
var ErrNotFound = errors.New(http.StatusText(http.StatusNotFound))
-var StdErrorHandler = ErrorHandlerFunc(StdErrorHandler... | |
42f2186cd3ba22bec9d91fa8db313dce0fdc126a | ---
+++
@@ -10,9 +10,9 @@
// CreateUser creates a new user with keycloak
func CreateUser(ctx worker.Context, args ...interface{}) error {
fmt.Println("Working on job", ctx.Jid())
- err := keycloak.KeycloakCreateUser(args[0])
+ err := keycloak.KeycloakCreateUser(args[0].(string))
if err != nil {
- return ctx.Er... | |
87ce5635037d59ba58f6a66522b1c0083d06411b | ---
+++
@@ -19,7 +19,7 @@
for _, tt := range testCases {
actual := ToDecimal(tt.binary)
if actual != tt.expected {
- t.Fatalf("ToDecimal(%v): expected %d, actual %d", tt.binary, tt.expected, actual)
+ t.Fatalf("ToDecimal(%v): expected %v, actual %v", tt.binary, tt.expected, actual)
}
}
} | |
1fb1394e83bb05775e26440ae7b5d51dc4241a32 | ---
+++
@@ -25,6 +25,9 @@
if err := u.Authenticate(password); err != nil {
return errors.New("invalid password")
}
+ if u.IsDisabled {
+ return errors.New("disabled account")
+ }
session, _ := s.sessions.Get(r, sessionName)
session.Values[sessionUserID] = u.ID
session.Save(r, w) | |
a144fcfdb707ccb883a33a1e44473f51ca5f9843 | ---
+++
@@ -17,7 +17,7 @@
fmt.Println()
fmt.Printf("%d|", i+1)
for j := 0; j < 8; j++ {
- fmt.Print(" |")
+ fmt.Printf("%c|", Piece(Point{i, j}))
}
fmt.Println(i + 1)
} | |
9eb88c578b43a36fca89513f00e4b0cfe3fbbca7 | ---
+++
@@ -1,4 +1,54 @@
package main
+import (
+ "flag"
+ "fmt"
+ "io/ioutil"
+)
+
+var flag_profit int
+
+func init() {
+ flag.IntVar(&flag_profit, "profit", -1, "a min amount that you want to win")
+}
+
+func parseGames() <-chan []LottoGame {
+ parsedGames := make(chan []LottoGame)
+
+ go func() {
+ bytes, err... | |
8d436c8d2297250f8f25373156462eb633fe81f7 | ---
+++
@@ -3,19 +3,20 @@
package tv_test
import (
+ "time"
+
"github.com/appneta/go-traceview/v1/tv"
"golang.org/x/net/context"
)
-func ExampleBeginProfile(ctx context.Context) {
- defer tv.BeginProfile(ctx, "example").End()
- // ... do something ...
+func slowFunc(ctx context.Context) {
+ defer tv.BeginP... | |
69269e6470f0bf9bcd78770fea6b6c99945fd32f | ---
+++
@@ -23,15 +23,27 @@
if err != nil {
return "", err
}
+ _, err = exchangeCode(number)
+ if err != nil {
+ return "", err
+ }
return number, nil
}
func AreaCode(phoneNumber string) (areaCode string, e error) {
areaCode = phoneNumber[0:3]
if strings.HasPrefix(areaCode, "0") || strings.HasPrefix... | |
b99f21ab009fcc03f072921a11daf77e38a20be8 | ---
+++
@@ -1,6 +1,21 @@
-package main
+package dbr
import (
"fmt"
- "dbr"
)
+
+type EventReceiver interface {
+ Event(eventName string)
+ EventKv(eventName string, kvs map[string]string)
+}
+
+type TimingReceiver interface {
+ Timing(eventName string, nanoseconds int64)
+ TimingKv(eventName string, nanoseconds... | |
5e53e3dd7de0df7b2426d14aff333f0d940e1694 | ---
+++
@@ -2,7 +2,6 @@
import (
"net"
- "runtime"
"sync/atomic"
)
@@ -36,7 +35,6 @@
return
}
logger.Debugf("copied %d bytes from %s to %s", n, r.RemoteAddr(), w.RemoteAddr())
- runtime.Gosched()
}
}
| |
ee8f3f8991405d6fda391e883d4df5340cfb264a | ---
+++
@@ -6,11 +6,10 @@
Value float64
}
-// MakePair evaluates the input function f at the input x and returns
-// the associated (element, mass) pair.
-func MakePair(f func(interface{}) float64, x interface{}) *Pair {
+// NewPair creates a *Pair from the input interface and value.
+func NewPair(elem interfa... | |
93c5d4600dbb6f41a739a30004876cd70b19b2a5 | ---
+++
@@ -7,13 +7,10 @@
"github.com/lohmander/webapi"
)
-func handler(rw http.ResponseWriter, req *http.Request) {
- fmt.Fprintf(rw, "Hello there")
-}
-
func main() {
api := webapi.NewAPI()
api.Apply(Logger)
+
api.Add(`/subscriptions$`, &Subscription{})
api.Add(`/subscriptions/(?P<id>\d+)$`, &Subscrip... | |
0a45903563082932864f1e746a17a8e3f9a19a89 | ---
+++
@@ -8,7 +8,7 @@
// Setuid sets the uid of the calling thread to the specified uid.
func Setuid(uid int) (err error) {
- _, _, e1 := syscall.RawSyscall(syscall.SYS_SETUID, uintptr(uid), 0, 0)
+ _, _, e1 := syscall.RawSyscall(syscall.SYS_SETUID32, uintptr(uid), 0, 0)
if e1 != 0 {
err = e1
} | |
351e79a723d28b1ea9dc04e2813bd2be4f5b339e | ---
+++
@@ -1 +1,35 @@
package goat
+
+import (
+ "bytes"
+ "net/http/httptest"
+ "testing"
+)
+
+func TestWriteError(t *testing.T) {
+ // In
+ code := 500
+ err := "foo"
+
+ // Expected
+ json := `{
+ "error": "` + err + `"
+}
+`
+ buf := bytes.NewBufferString(json)
+
+ w := httptest.NewRecorder()
+ WriteError(w, ... | |
c8a502f5c1a9fae75095b776e04265bf8cc470a7 | ---
+++
@@ -10,7 +10,6 @@
// CreatePipe()
// DeletePipeline()
// DownloadCLI()
- // GetConfig()
// HijackContainer()
// ListContainer()
// ListJobInputs()
@@ -21,6 +20,7 @@
Build(buildID string) (atc.Build, error)
Job(pipelineName, jobName string) (atc.Job, error)
JobBuild(pipelineName, jobNa... | |
ab99ac551bd95e1c2c611e6af1f8a4d625497c42 | ---
+++
@@ -1,4 +1,8 @@
package main
+
+import (
+ "errors"
+)
var CmdCurrent = &Cmd{
Name: "current",
@@ -9,6 +13,11 @@
}
func currentCommandFn(env Env, args []string) (err error) {
+ if len(args) < 2 {
+ err = errors.New("Missing PATH argument")
+ return
+ }
+
path := args[1]
watches := NewFileTi... | |
aee2ec6a8097021180c3904c3201946294afe55c | ---
+++
@@ -8,7 +8,7 @@
// FindCompilerLanuncher probes compiler launcher if exists.
// Currently only probes SN-DBS launcher.
func FindCompilerLauncher() string {
- dir, ok := os.LookupEnv("SCE_SDK_ROOT")
+ dir, ok := os.LookupEnv("SCE_ROOT_DIR")
if ok {
lancherPath := filepath.Join(dir, "Common", "SN-DBS", ... | |
9682b7065c48648a63ec1822d376f8482a38671c | ---
+++
@@ -5,20 +5,20 @@
func TestDependencies(t *testing.T) {
container := &Container{Run: RunParameters{RawLink: []string{"a:b", "b:d"}}}
if deps := container.Dependencies(); deps[0] != "a" || deps[1] != "b" {
- t.Errorf("Dependencies should have been a and b")
+ t.Error("Dependencies should have been a and... | |
f740ab9b8c6801e16ec3f290a62a09df51045c8f | ---
+++
@@ -14,12 +14,13 @@
if pump.Error() == nil {
return
}
+ pump.SetError(nil)
log.Printf("waking pump")
const (
// Older pumps should have RF enabled to increase the
// frequency with which they listen for wakeups.
- numWakeups = 75
- xmitDelay = 35 * time.Millisecond
+ numWakeups = 100
+ x... | |
5ae158f91cef7c6e8889f0a9697ba5b18a858cd3 | ---
+++
@@ -6,10 +6,11 @@
// Client is the aptomictl config representation
type Client struct {
- Debug bool `validate:"-"`
- API API `validate:"required"`
- Auth Auth `validate:"required"`
- HTTP HTTP `validate:"required"`
+ Debug bool `validate:"-"`
+ Output string `validate:"required"`
+ API API ... | |
0e759c1e5ea129437368e00c70562ab3e9e3bc02 | ---
+++
@@ -4,7 +4,7 @@
"testing"
)
-func TestUncomment(t *testing.T) {
+func TestTrimComment(t *testing.T) {
tests := []struct {
name string
input string
@@ -25,7 +25,7 @@
`{"url": "http://example.com"} `},
}
for _, test := range tests {
- actual, err := Uncomment(test.input)
+ actual, ... | |
ad50209dd215f6324ec49fc22036af57d8f1e15b | ---
+++
@@ -1,9 +1,9 @@
package tools
import (
+ "fmt"
"log"
"strings"
- "fmt"
)
// UploadFile used to upload file by S3 pre-signed URL | |
a2b8d636f3207a7d27b2f9512c5185d269936e2d | ---
+++
@@ -6,7 +6,7 @@
func TestLex(t *testing.T) {
l := newLexer()
- res, errs := l.Lex("a **= (7 ** (3 + 4 - 2)) << 1.23 % 0.3")
+ res, errs := l.Lex("some_var123 **= (7 ** (3 + 4 - 2)) << 1.23 % 0.3")
expected := []tokenType{
IDENT, POW_EQ, LPAREN, INT, POW, LPAREN, INT, ADD, INT, SUB, INT,
RPAREN, R... | |
52268cfeb67eb48c79d77a539e8dc790d1a6a9bb | ---
+++
@@ -11,7 +11,7 @@
)
// The main version number that is being run at the moment.
-const Version = "0.12.0"
+var Version = "0.12.0"
// A pre-release marker for the version. If this is "" (empty string)
// then it means that it is a final release. Otherwise, this is a pre-release
@@ -21,7 +21,11 @@
// S... | |
00e788ad4469dbc25f09d8a5ac63295dd4bdde83 | ---
+++
@@ -11,7 +11,13 @@
// }
func (e APIError) Error() string {
- return fmt.Sprintf("sentry: %v", e)
+ if len(e) == 1 {
+ if detail, ok := e["detail"].(string); ok {
+ return fmt.Sprintf("sentry: %s", detail)
+ }
+ }
+
+ return fmt.Sprintf("sentry: %v", map[string]interface{}(e))
}
// Empty returns tr... | |
412dcc0e30ce3e137a67f445a9095ecd4bf1c190 | ---
+++
@@ -6,6 +6,10 @@
"syscall"
"unsafe"
)
+
+// #include <sys/ioctl.h>
+// enum { _GO_TIOCGWINSZ = TIOCGWINSZ };
+import "C"
type winsize struct {
ws_row, ws_col uint16
@@ -17,7 +21,7 @@
syscall.Syscall(syscall.SYS_IOCTL,
uintptr(0),
- uintptr(0x5413),
+ uintptr(C._GO_TIOCGWINSZ),
uint... | |
824911e61202060dfa41f012546faf0601776c4c | ---
+++
@@ -5,4 +5,7 @@
import ()
-type Account struct{}
+type Account struct {
+ Key string
+ Token string
+} | |
a0542b662899c105853eaebeef9a751ceb7af00f | ---
+++
@@ -36,4 +36,10 @@
if len(actual) != len(expect) {
t.Fatalf("%v does not much to expected: %v", len(actual), len(expect))
}
+
+ for i := range expect {
+ if expect[i] != actual[i] {
+ t.Fatalf("%v does not much to expected: %v", actual, expect)
+ }
+ }
} | |
021903d1ff70343a09e5cc8669c46a91187a68b7 | ---
+++
@@ -20,6 +20,10 @@
// Debug logging
debug bool
+
+ // version flags
+ version bool
+ buildVersion string
)
func init() {
@@ -27,6 +31,7 @@
flag.StringVar(&defaultConfig, "config", "", "default config file")
flag.StringVar(&stateConfig, "state", "", "updated config which reflects the interna... | |
e02909f004d1d83127a43dad74a5217f2445fafd | ---
+++
@@ -2,6 +2,7 @@
import (
"os"
+ "os/exec"
"path"
"path/filepath"
)
@@ -25,7 +26,7 @@
if err := os.MkdirAll(f.pathByParams(), 0755); err != nil {
return err
}
- return os.Rename(from, filepath.Join(f.pathByParams(), path.Base(from)))
+ return exec.Command("mv", from, filepath.Join(f.pathByPara... | |
b43683f05ba1453e302ffed77c04ed124bf330d4 | ---
+++
@@ -1,10 +1,55 @@
package dice
-import "testing"
+import (
+ "github.com/stretchr/testify/assert"
+ "testing"
+)
-func TestRollable(t *testing.T) {
- var attackDie AttackDie
- var defenseDie DefenseDie
- attackDie.Roll()
- defenseDie.Roll()
+func TestRollable_AttackDie(t *testing.T) {
+ asser... | |
9e5c624a5635e3b60623bbf033ebe13de6dc5733 | ---
+++
@@ -3,6 +3,7 @@
import (
"fmt"
"http"
+ "mahonia.googlecode.com/hg"
)
// support for running "redwood -test http://example.com"
@@ -27,4 +28,39 @@
fmt.Println(s)
}
}
+
+ fmt.Println()
+ fmt.Println("Downloading content...")
+ res, err := http.Get(u)
+ if err != nil {
+ fmt.Println(err)
+ r... | |
9fdf576f310d92d9465e8681ecec628628feb3ce | ---
+++
@@ -14,11 +14,9 @@
return []byte{}, err
}
- data, err := ioutil.ReadAll(resp.Body)
+ data, _ := ioutil.ReadAll(resp.Body)
defer resp.Body.Close()
- if err != nil {
- return []byte{}, err
- }
+
return data, nil
}
| |
376283d9b93d7e99a61a630c42b8feb9e60bb459 | ---
+++
@@ -24,7 +24,8 @@
resp.Write(part)
}
- w.WriteHeader(http.StatusOK)
+ multipartWriter.Close()
+
w.Header().Set("Content-Type", mime.FormatMediaType("multipart/mixed", map[string]string{"boundary": multipartWriter.Boundary()}))
w.WriteHeader(http.StatusOK)
buf.WriteTo(w) | |
b02341bcf440acf5f1a8c89e14de035e8da65946 | ---
+++
@@ -1,13 +1,26 @@
package main
import (
- "github.com/buchgr/bazelremote/cache"
+ "flag"
+ "strconv"
+
+ "github.com/buchgr/bazel-remote/cache"
)
-// TODO: Add command line flags
+func main() {
+ port := flag.Int("port", 8080, "The port the HTTP server listens on")
+ dir := flag.String("dir", "",
+ "D... |
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.