Skip to content

Instantly share code, notes, and snippets.

View drj11's full-sized avatar

David Jones drj11

View GitHub Profile
@drj11
drj11 / augment.dot
Last active December 26, 2015 20:09
strict digraph {
l1 [label="[1, 2]" shape=box];
l2 [label="[2]" shape=box];
p -> l1;
op -> l1;
q -> l2;
label = "after p += q";
ordering = out;
}
@drj11
drj11 / gist:5917057
Last active December 19, 2015 07:09
Example of how to format dates in go.
package main
import (
"fmt"
"time"
)
func main() {
t := time.Now()
fmt.Println(t.Format("2006-01-02 15:04:05 -0700")) // works
@drj11
drj11 / gist:5636862
Last active December 17, 2015 16:09
generate username to uid number map
# this avoids picking some old empty unused directories that are owned by root
ls -n | sort -n -k 3 | awk '$3>0{print $NF ":x:" $3}'
<html>
<p>Hello <i>world</i></p>
</html>
#!/bin/sh
# execute with:
# curl https://raw.github.com/gist/3766130/ccc-gistemp-ushcn-minmax | sh
set -e
REVISION=1019
D=r${REVISION}-ccc-gistemp
svn co -r $REVISION https://ccc-gistemp.googlecode.com/svn/trunk $D
cd $D
mkdir -p input
drj$ cat fixture.js
nock=require('nock')
nock('www.google.com')
.get('/')
.reply(200, "<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n<TITLE>BOB</TITLE></HEAD><BODY>\n<H1>Hello from nock</H1>\r\n</BODY></HTML>\r\n", { location: 'http://www.google.co.uk/',
'content-type': 'text/html; charset=UTF-8',
date: 'Thu, 24 May 2012 15:08:01 GMT'
});
drj$ cat get.js
http.get({host:'www.google.com',port:80,path:'/',method:'GET'},function(res){res.on('data', function(chunk){console.log('chunk '+chunk)})})