Skip to content

Instantly share code, notes, and snippets.

@themattrix
themattrix / Bamboo.dock
Created November 6, 2013 19:25
Dockerfile to run a Bamboo continuous integration server. Uses the default database. Requires a license key.
FROM stackbrew/ubuntu:saucy
#
# Install Oracle Java 7
#
# Update initial package listing
RUN apt-get update -qq
# Install add-apt-repository
def onecall(f):
"""
Decorator to ensure a function is only called once.
"""
@wraps(f)
def wrapper(*args, **kwargs):
if not wrapper.called:
wrapper.called = True
return f(*args, **kwargs)
# !!! Completely untested and probably doesn't work !!!
def memoize(f):
mem = {}
@wraps(f)
def wrapper(*args, **kwargs):
key = (tuple(args), frozenset(kwargs.iteritems()))
if key in mem:
@themattrix
themattrix / btc_ticker.py
Created April 10, 2013 18:58
BTC last price ticker (extremely simple). Polls BTC-e every 60 seconds.
import requests
import time
def get_ticker():
return requests.get('https://btc-e.com/api/2/btc_usd/ticker').json()
def print_last(ticker):
last = ticker['ticker']['last']
@themattrix
themattrix / btc_ltc_ticker.py
Last active December 16, 2015 00:49
BTC/LTC last price ticker for BTC-e (extemely simple).
import requests
import time
def get_ticker():
return requests.get('https://btc-e.com/api/2/ltc_btc/ticker').json()
def print_last(ticker):
last = ticker['ticker']['last']
@themattrix
themattrix / get_cs193p.sh
Last active March 29, 2022 11:31
Download all PDF and zip files from the Stanford iOS Development Course (cs193p) and file them under the appropriate lectures
(mkdir cs193p 2> /dev/null; cd cs193p; lecture=.; curl http://www.stanford.edu/class/cs193p/cgi-bin/drupal/downloads-2011-fall 2> /dev/null | sed 's/href=/\nhref=/g' | sed -r -n -e 's/.*href="([^"]+.([Pp][Dd][Ff]|[Zz][Ii][Pp]))".*/\1/p;t;s/.*<h3>Title: (Lecture .*)<\/h3>.*/\1/p' | while read line; do print "$line"; if [[ "$line" == Lecture* ]]; then lecture=${line//\//, }; lecture=${lecture//&amp;/&}; mkdir "$lecture"; else (cd "$lecture" && wget "$line"); fi; done)