Skip to content

Instantly share code, notes, and snippets.

@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"
package main
import (
"fmt"
"sort"
"container/heap"
"rand"
)
type record struct {
@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"
var singleton = NewSingleton()
type Singleton struct {
S string
}
// 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 (
"bufio"
"encoding/binary"
"flag"
"io"
"os"
)