Skip to content

Instantly share code, notes, and snippets.

View AlexeyMK's full-sized avatar

Alexey Komissarouk AlexeyMK

View GitHub Profile
@AlexeyMK
AlexeyMK / valentine.py
Created February 14, 2012 05:35
JSON API Design Prototype
# 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)
@AlexeyMK
AlexeyMK / seasprint.sh
Created January 19, 2012 18:18
Seasprint (free printing from the command line on eniac)
# 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() {
@AlexeyMK
AlexeyMK / gist:1266808
Created October 6, 2011 08:05
sponsor filterer
# 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])
@AlexeyMK
AlexeyMK / gist:1240101
Created September 25, 2011 01:41
Strategy Decorator for Ants AI challenge
### 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])