Skip to content

Instantly share code, notes, and snippets.

View zacharyvoase's full-sized avatar

Zack Voase zacharyvoase

View GitHub Profile
#! /usr/bin/env ruby
# -*- coding: utf-8 -*-
#
# exposure.rb => Break a position down into multiple spreads.
# Copyright (C) 2009 Zachary Voase
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# -*- coding: utf-8 -*-
import eventlet
import eventlet.api
import eventlet.coros
def call_cc(function):
ev = eventlet.coros.event()
function(ev.send)
return ev.wait()
# -*- 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
Index: django/db/models/base.py
===================================================================
--- django/db/models/base.py (revision 10088)
+++ django/db/models/base.py (working copy)
@@ -188,7 +188,11 @@
new_class._prepare()
register_models(new_class._meta.app_label, new_class)
-
+
@zacharyvoase
zacharyvoase / qmanager.py
Created April 21, 2009 11:20
Django Managers for pre-defined queries.
# -*- coding: utf-8 -*-
"""
Managers for pre-defined queries.
Example::
from django.db import models
from qmanager import QManager
# -*- coding: utf-8 -*-
"""
Models with signals.
Example::
from django.db import models
import modsig
class MyModel(modsig.Model):
@zacharyvoase
zacharyvoase / .gitignore
Created April 25, 2009 14:28
A utility class for operating on URLs.
*.pyc
-- An implementation of call-with-current-continuation in Lua.
-- (c) 2009 Zachary Voase
function callcc (fun)
function coro ()
-- The coroutine which will hold the value with which it is called, then
-- yield it back again later.
local val = coroutine.yield()
coroutine.yield()
The following shows how you might go about using the processed data which is
output from parse_humsavar.py.
We’ll begin by reading it out from JSON; this involves importing the JSON
library, opening the file, and then just using ``json.load()``::
# If you’re using Python 2.5, you probably have the bottom one (so you can
# just run `import simplejson as json`); if you’re using Python 2.6 then you
# definitely have the top one, so you can just do `import json`.
>>> import json
@zacharyvoase
zacharyvoase / django_pave.py
Created May 22, 2009 22:49
Run Django management commands with a Paver task.
# -*- coding: utf-8 -*-
# django_pave.py - Run Django management commands with a Paver task.
#
# It’s simple really; just run `paver manage syncdb`, or
# `paver manage runserver`, or indeed any Django management command. You can
# also define Paver tasks which load the Django settings before execution.
#
# Copyright (c) 2009 Zachary Voase <zacharyvoase@me.com>
#
# Permission is hereby granted, free of charge, to any person