Skip to content

Instantly share code, notes, and snippets.

View jordanorelli's full-sized avatar
👾

Jordan Orelli jordanorelli

👾
View GitHub Profile
@jordanorelli
jordanorelli / click.ck
Created July 17, 2011 14:23
polyrythm impulse to wave pair example
class Voice
{
1.0 => static float multiplier;
1.0 => static float spread;
float freq;
float pan;
Impulse imp;
Pan2 p;
fun static Voice Voice(float freq, float pan)
@jordanorelli
jordanorelli / nginx_args
Created August 21, 2011 18:13
nginx configuration options
--sbin-path=/usr/local/sbin --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-client-body-temp-path=/var/tmp/nginx/client_body --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --user=www-data --group=www-data --without-http_geo_module --without-http_ssi_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --with-google_perftools_module
@jordanorelli
jordanorelli / nginx
Created August 21, 2011 20:00
nginx init.d script
#!/usr/bin/env bash
# Adapted from the book "Nginx HTTP Server", by Clement Nedelcu.
# Original Author: Ryuan Norbauer http://norbauerinc.com
# Modified: Geoffrey Grosenbach http://topfunky.com
# Modified: Clement Nedelcu http://cnedelcu.blogspot.com/
# Modified: Jordan Orelli http://jordanorelli.com/
# source: https://gist.github.com/1161075
# Corresponds with the following compile-time options:
@jordanorelli
jordanorelli / python.vim
Created August 31, 2011 05:59
ftplugin/python.vim - python-specific vim settings.
" Python specific settings.
setlocal tabstop=4
setlocal shiftwidth=4
setlocal expandtab
setlocal autoindent
setlocal formatoptions=croql
nmap <F5> :w <CR> :!clear; python % <CR>
nmap <F6> :w <CR> :!python %
" set foldmethod=indent
let python_highlight_all=1
@jordanorelli
jordanorelli / colors.py
Created October 6, 2011 03:00
python color wrapping (adapted from Fabric)
def _mk_color_fn(code):
return lambda text, bold=False: \
'\033[%s%sm%s\033[0m' % (bold and '1;' or '', code, text)
_colormapping = {
'red': 31,
'green': 32,
'yellow': 33,
'blue': 34,
'magenta': 35,
@jordanorelli
jordanorelli / decorator.py
Created October 19, 2011 03:29
it's decorators all the way down.
import functools
from recurly.serialization import parse_xml
def injectcaller(fn):
"""
Attaches a "caller" attribute to a response object representing partial
function. The "caller" partial is a bound method that retains a
reference to its owner.
"""
@functools.wraps(fn)
@jordanorelli
jordanorelli / setup.py
Created October 21, 2011 16:20
hmm, the "requires" parameter is wrong.
import os
from setuptools import setup
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name = "recurlib",
version = "0.0.1",
author = "Jordan Orelli",
@jordanorelli
jordanorelli / mongrel2.conf
Created November 8, 2011 18:03
brubeck project structure concept
static_dir = Dir(
base='static/',
index_file='index.html',
default_ctype='text/plain'
)
brubeck_handler = Handler(
send_spec='ipc://run/mongrel2_send',
send_ident='039eba8a-e879-40fc-9d33-52afb318d4bc',
recv_spec='ipc://run/mongrel2_recv',
@jordanorelli
jordanorelli / getrecurly.sh
Created November 9, 2011 23:05
install python package conditionally in bash
#!/usr/bin/env bash
ARCHIVE_URL="https://github.com/recurly/recurly-client-python/tarball/master"
ARCHIVE_NAME="recurly.tar.gz"
if ! python -c 'import recurly' &> /dev/null; then
TMP_DIR=$(mktemp -d XXXXX)
pushd "$TMP_DIR"
wget "$ARCHIVE_URL" -O "$ARCHIVE_NAME"
tar --strip-components 1 -xf "$ARCHIVE_NAME"
@jordanorelli
jordanorelli / views.py
Created November 22, 2011 05:51
context form view
from django.views.generic import FormView
class ContextFormView(FormView):
def get(self, request, *args, **kwargs):
form_class = self.get_form_class()
form = self.get_form(form_class)
context = self.get_context_data(**kwargs)
context['form'] = form
return self.render_to_response(context)