Skip to content

Instantly share code, notes, and snippets.

@leif
leif / hammertime.go
Created December 2, 2013 04:18
mostly written by mischief on 2013-11-25
package main
import (
"bytes"
"encoding/binary"
"fmt"
"math"
"os"
)
#!/usr/bin/env python
"""
This is a quick hack for downloading albums from Bandcamp.
This functionality should really be added to youtube-dl, but I'm lazy and just
wanted to listen to an album on a computer without flash so I wrote this. Somone,
please add bandcamp support to youtube-dl!
Instructions: give this a bandcamp album's HTML on stdin, and it gives you a
bash script on stdout which will download it. There is no sanitization of the
@leif
leif / bahnplot.py
Last active December 21, 2015 11:19
#!/usr/bin/env python
"""
A very simple plotting tool.
"""
__license__ = """
This software may be freely used, modified, and redistributed without any
restrictions except one: you agree to pay the author $1M if you ever tell him
there will be wifi on a long train ride and it turns out that there actually
@leif
leif / spiral.py
Created December 5, 2012 10:04
spiral matrix walk
#!/bin/python
"""
>>> list(unrollSpiral( [[ 1, 2 ],
... [ 3, 4 ],
... [ 5, 6 ]]))
[1, 2, 4, 6, 5, 3]
>>> list(unrollSpiral( [[ 1, 2, 3],
... [ 4, 5, 6]]))
[1, 2, 3, 6, 5, 4]
>>> list(unrollSpiral( [[ 1, 2, 3],
@leif
leif / timekeeperville.py
Created September 9, 2012 07:42
timekeeperville
"timekeeperville is a game where you must keep time"
# by Leif Ryge, September 2012, WTFPL
from time import time
from collections import deque
results = []
while True:
adj = raw_input("Use default settings? [Yn] ") == "n"
bpm = int(adj and raw_input("Initial BPM? [120] ") or 120)
level = int(adj and raw_input("Initial level? [1] ") or 1 )
limit = int(adj and raw_input("Initial time limit? [15] ") or 15 )
"""
Wolfram 1-dimensional cellular automata
"""
__author__ = "Leif Ryge"
__license__ = "WTFPL"
import sys
if len(sys.argv) != 4:
print "Usage: %s rule width count" % (sys.argv[0],)