Skip to content

Instantly share code, notes, and snippets.

package main
import (
"bufio"
"encoding/binary"
"flag"
"io"
"os"
)
// Two binary trees may be of different shapes,
// but have the same contents. For example:
//
// 4 6
// 2 6 4 7
// 1 3 5 7 2 5
// 1 3
//
// Go's concurrency primitives allow us to neatly
// traverse and compare the contents of two trees.
package main
import "fmt"
var singleton = NewSingleton()
type Singleton struct {
S string
}
@nf
nf / macpaint.p
Created March 4, 2011 02:46
MacPaint Pascal Source
PROGRAM MacPaint;
{ BitMap Painting Program by Bill Atkinson }
{$D- }
{$R- }
{$X- }
USES {$U obj:HeapZone } HeapZone,
package main
import (
"fmt"
"sort"
"container/heap"
"rand"
)
type record struct {
@nf
nf / cat.coffee
Created September 10, 2011 09:48 — forked from anonymous/cat.coffee
Go and CoffeeScript examples of writing a file to stdout
fs = require 'fs'
class File
constructor: (@name) ->
read: (cb) ->
fs.readFile @name, (err, code) ->
throw err if err
cb code.toString()
file = new File "file.txt"
{
"KeyName": "icecloud-key",
"Server": [
{
"Kind": "master",
"Location": "Tokyo",
"Username": "ubuntu",
"ImageID": "ami-40b40041",
"Size": "m1.small",
"NumClients": 100, "NumSources": 5
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
@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;
}
@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) {