Skip to content

Instantly share code, notes, and snippets.

View rgarcia's full-sized avatar

Rafael rgarcia

View GitHub Profile
@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 git@github.com:$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"
@rgarcia
rgarcia / gist:7917826
Last active December 31, 2015 01:59
salt + docker
FROM salted
# /etc/hosts and /etc/hostname are read only. so change minion config
RUN HOSTNAME=`hostname` && sed "s/#id:/id: container-{{ name }}-$HOSTNAME/" -i /etc/salt/minion
ADD {{ salt_dir }} /srv/salt
ADD {{ pillar_dir }} /srv/pillar
RUN rm -f /etc/salt/minion_id
RUN salt-call --local state.highstate
@rgarcia
rgarcia / output.txt
Created November 6, 2013 07:03
string objectMode
{Readable,Transform} = require 'stream'
crypto = require 'crypto'
report = (stream) ->
int = setInterval ->
console.log "#{stream.constructor.name}(#{stream._writableState?.length or ''} #{stream._readableState?.length or ''})"
, 1000
stream.on 'end', -> clearInterval int
# generates a bunch of strings
@rgarcia
rgarcia / main.coffee
Last active December 27, 2015 13:18
node: dangers of mixed objectMode
{Readable,Transform} = require 'stream'
crypto = require 'crypto'
report = (stream) ->
int = setInterval ->
console.log "#{stream.constructor.name}(#{stream._writableState?.length or ''} #{stream._readableState?.length or ''})"
, 1000
stream.on 'end', -> clearInterval int
# generates a bunch of bytes
@rgarcia
rgarcia / eat_bytes.sh
Last active December 27, 2015 04:59
memmon test
#!/usr/bin/env bash
# create a string of "a"s that is length $1
longstr=$(head -c $1 < /dev/zero | tr '\0' '\141')
sleep 1200