Skip to content

Instantly share code, notes, and snippets.

View macu's full-sized avatar

Matt Cudmore macu

  • Halifax, NS
View GitHub Profile
@macu
macu / interrupt-confirm-exit.go
Created May 22, 2013 22:50
Example of listening for interrupt signal and confirming exit in the shell
package main
import (
"fmt"
"os"
"os/signal"
)
func main() {
@macu
macu / anim.coffee
Last active December 12, 2015 03:09
Basic utility to simplify html5 animation. Exports the `start` function.
define ->
rAF = window["requestAnimationFrame"]
cAF = window["cancelAnimationFrame"]
# based on polyfill by Erik Möller,
# with fixes from Paul Irish and Tino Zijdel.
# https://gist.github.com/1579671
if !rAF or !cAF then do ->
for v in ['ms', 'moz', 'webkit', 'o']
@macu
macu / nilmaps.go
Last active December 11, 2015 06:39
Go language tips
package main
import "fmt"
func main() {
var m map[int]string
fmt.Printf("m = %v; m == nil? %t\n", m, m == nil)
// it is safe to range over a nil map
for i, v := range m {