Skip to content

Instantly share code, notes, and snippets.

@rgarcia
rgarcia / main.go
Created May 13, 2015 04:00
program that runs a mongo replset and periodically reconfigures it
package main
import (
"fmt"
"io"
"log"
"os"
"os/signal"
"syscall"
"time"
@rgarcia
rgarcia / main.go
Last active August 29, 2015 14:21
get a type definition from the result of an mgo query
package main
import (
"fmt"
"log"
"os"
"os/signal"
"syscall"
"github.com/facebookgo/mgotest"
@rgarcia
rgarcia / foo.go
Last active August 29, 2015 14:10
testing read-only interfaces
package foo
type Foo struct {
}
type DB interface {
Find(string) (Foo, error)
}
@rgarcia
rgarcia / supervisor.conf
Last active April 4, 2018 07:52
supervisord docker run
[inet_http_server]
port=0.0.0.0:9001
[supervisord]
logfile=out.log
loglevel=info
nodaemon=true
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
@rgarcia
rgarcia / test.go
Last active August 29, 2015 14:04
writes
package main
import (
"bytes"
"fmt"
"io"
)
// Job is used by gearman clients after a job is submitted
type Job interface {
@rgarcia
rgarcia / basic.go
Created June 11, 2014 17:27
golang basic auth transport
import (
"encoding/base64"
"fmt"
"net/http"
)
type BasicAuthTransport struct {
Username string
Password string
}

Keybase proof

I hereby claim:

  • I am rgarcia on github.
  • I am rg (https://keybase.io/rg) on keybase.
  • I have a public key whose fingerprint is 7E16 D413 A697 F986 DC01 811F BC59 BC47 D298 7D85

To claim this, I am signing this object:

@rgarcia
rgarcia / clone_gist.sh
Created March 28, 2014 20:23
clone a gist
#!/usr/bin/env bash
set -e
# Clones a gist locally
# usage: ./clone_gist.sh <gist id> <folder>
git clone [email protected]:$1.git $2
@rgarcia
rgarcia / run.md
Last active August 29, 2015 13:57
node heap wtf
$ node --expose-gc server.js

in another terminal:

$ curl localhost:5001

output in first terminal shows that req.foo is still sitting in the heap:

@rgarcia
rgarcia / db_stats.go
Last active August 30, 2016 09:42
mongo db stats
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"log"
"os"
"strings"
"text/tabwriter"