This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM stackbrew/ubuntu:saucy | |
| # | |
| # Install Oracle Java 7 | |
| # | |
| # Update initial package listing | |
| RUN apt-get update -qq | |
| # Install add-apt-repository |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # !!! 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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//&/&}; mkdir "$lecture"; else (cd "$lecture" && wget "$line"); fi; done) |