Skip to content

Instantly share code, notes, and snippets.

View zacharyvoase's full-sized avatar

Zack Voase zacharyvoase

View GitHub Profile
@zacharyvoase
zacharyvoase / faceoff.py
Created May 25, 2009 20:44
faceoff.py - A fun module for playing games.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Zachary Voase <disturbyte@gmail.com>'
__version__ = '0.1'
"""
faceoff.py - A fun (non-serious) module for playing games.
Example:
@zacharyvoase
zacharyvoase / pavement.py
Created May 26, 2009 05:02
pavement.py file for Melange.
# -*- coding: utf-8 -*-
"""
Example Usage
=============
The following commands can be run from the root directory of the Mercurial
repo. To run ``paver``, however, you'll need to do ``easy_install Paver``.
Most of the following commands accept other arguments; see ``command --help``
for more information, or ``paver help`` for a list of all the valid commands.
@zacharyvoase
zacharyvoase / pipes.py
Created May 28, 2009 23:42
pipes.py - Command-piping syntax for generators/coroutines in Python.
# -*- coding: utf-8 -*-
# pipes.py - Command-piping syntax for generators/coroutines in Python.
"""
pipes.py - Command-piping syntax for generators/coroutines in Python.
Example:
>>> from pipes import *
>>> chain1 = counter(5) | adder(2)
# -*- coding: utf-8 -*-
from decimal import Decimal
import random
def montecarlo(choices):
"""
It's easier for me to explain this with an example.
@zacharyvoase
zacharyvoase / buildurl.py
Created June 4, 2009 12:55
Django template tag for building URLs.
# -*- coding: utf-8 -*-
# Copyright (c) 2009 Zachary Voase
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
@zacharyvoase
zacharyvoase / daterange.py
Created June 21, 2009 16:29
Like xrange() for datetime objects.
# -*- coding: utf-8 -*-
"""
Example Usage
=============
>>> import datetime
>>> start = datetime.date(2009, 6, 21)
>>> g1 = daterange(start)
@zacharyvoase
zacharyvoase / pyprowl.py
Created July 6, 2009 23:23
Post to Prowl (https://prowl.weks.net) from Python
# -*- coding: utf-8 -*-
# pyprowl.py - Post to Prowl (https://prowl.weks.net) from Python.
#
# Copyright (c) 2009 Zachary Voase
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
@zacharyvoase
zacharyvoase / tailr.py
Created July 18, 2009 15:03
Simple tail recursion.
# -*- coding: utf-8 -*-
# Copyleft 2058 Zachary Voase
# Licensed under the WTFPL. Google it.
from functools import wraps
class call(object):
__slots__ = ('function', 'args', 'kwargs')
@zacharyvoase
zacharyvoase / graph.py
Created July 19, 2009 10:05
First stab at implementing graphs in Python.
# -*- coding: utf-8 -*-
# First stab at implementing graphs in Python.
# Horrifically undocumented.
import operator
import textwrap
class SimpleStruct(type):
@zacharyvoase
zacharyvoase / adminutils.py
Created August 4, 2009 18:22
adminutils (for django.contrib.admin)
# -*- coding: utf-8 -*-
"""
Usage:
from django.contrib import admin
class MyModelAdmin(admin.ModelAdmin):
list_display = ('trunc_name', 'value')