This file contains 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
# Just a prototype of a JSON API framework that I thought up because it'd be nice to have | |
# for API work I've done before - feedback very much welcome. | |
# | |
# all models have a 'short' and a full version | |
@canonical_url('/users/:id') | |
class User(Model): # this model is both an ORM-style model and a REST resource. | |
id = ModelField.Integer(unique=True) | |
name = ModelField.String(length=25) | |
email = ModelField.String(length=55, in_short=None) |
This file contains 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
# Put in .bashrc | |
# By Matt Croop, but originally by Jon McCaffrey or Ryan Gormley or something. | |
# Usage: seasprint foo.pdf | |
function seasprint() { | |
cat "$1" | ssh [email protected] lpr -P169 | |
} | |
#Usage: listprinters | |
function listprinters() { |
This file contains 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
# IE, resume_filter.py resumes.tsv 10gen mongodb mongo | |
# creates 10gen.tsv, which has all participants who mentioned they were | |
# excited about 10gen (however they called it) and removes the last column | |
# (which lists companies that participants are interested in) | |
import fileinput | |
from sys import argv | |
sponsor_names = argv[2:] | |
output = file(argv[2] + ".tsv", 'w') | |
reading_from = fileinput.input(argv[1]) |
This file contains 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
### possible_moves = ['e':0, 'n':0, 'w':0, 's':0, 'halt':0] | |
### extra = {} # pass info to others if needed | |
class Strategies: | |
INITIAL_MOVES = dict([(m, 0) for m in AIM.keys()]) | |
@classmethod | |
def best_option(cls, moves): | |
return max(list(moves.keys()), key=lambda d: moves[d]) |
NewerOlder