Skip to content

Instantly share code, notes, and snippets.

package main
import (
"bufio"
"log"
"fmt"
"os"
"regexp"
)
@nf
nf / conv.go
Created January 23, 2013 23:47
// Before pulling the latest changes from the go repository, first
// run this tool:
// cd go-tour
// go build -o conv conv.go
// ./conv < static/index.html
// It will create tour.article and a prog directory full of .go files.
// Read over tour.article and check that it makes sense.
// You will probably want to:
// hg pull -u
// go get -u code.google.com/p/go.talks/pkg/present
@nf
nf / gist:4255933
Created December 11, 2012 04:44
new playground api interpreter
<input type="button" value="Stop" id="stop">
<div id="log"></div>
<script src="go/doc/jquery.js"></script>
<script>
var script = [
{"Delay": 0, "Message": "Hello, "},
{"Delay": 1000000000, "Message": "World!\n"},
{"Delay": 2000000000, "Message": "That's it!"}
];
function playback(root, script) {
@nf
nf / conv.go
Created November 2, 2012 13:25
script to convert go tour html to present file format
package main
import (
"bytes"
"exp/html"
"fmt"
"io/ioutil"
"log"
"os"
"regexp"
@nf
nf / gist:3896766
Created October 16, 2012 01:27
A journey from Sydney Domestic Airport to Central Station illustrated with ping
% ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
64 bytes from 8.8.8.8: icmp_seq=0 ttl=54 time=3980.438 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=54 time=2979.361 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=54 time=1978.766 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=54 time=978.429 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=54 time=114.190 ms
@nf
nf / gist:3896660
Created October 16, 2012 00:51
A journey from Sydney Domestic Airport to Central Station illustrated with ping
% ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
64 bytes from 8.8.8.8: icmp_seq=0 ttl=54 time=3980.438 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=54 time=2979.361 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=54 time=1978.766 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=54 time=978.429 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=54 time=114.190 ms
@nf
nf / hello-node.js
Created July 6, 2012 21:14
Hello world web server that scales across multiple processors
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
@nf
nf / index.tmpl
Created April 5, 2012 01:26
whereis app engine app
<html>
<head>
<title>Where's adg?</title>
<style>
th {
text-align: left;
}
td, th {
padding-right: 10px;
}
13:23 <@adg> :)
13:28 < skelterjohn> always good to see a smiling face in here
13:35 < AndrewBC> Always? What if it's JUST a smiling face?
13:36 < skelterjohn> you mean as in this case?
13:37 < skelterjohn> it'll do
13:38 < AndrewBC> D'oh. I meant more like horror movie gore, but you win this
round
13:39 < skelterjohn> lol
13:39 <@adg> :)
13:39 < skelterjohn> OH GOD
{
"KeyName": "icecloud-key",
"Server": [
{
"Kind": "master",
"Location": "Tokyo",
"Username": "ubuntu",
"ImageID": "ami-40b40041",
"Size": "m1.small",
"NumClients": 100, "NumSources": 5