Skip to content

Instantly share code, notes, and snippets.

View jordanorelli's full-sized avatar
👾

Jordan Orelli jordanorelli

👾
View GitHub Profile
@jordanorelli
jordanorelli / monitor.py
Created April 20, 2011 00:30
file change monitor for Django
import os
import sys
import time
import signal
import threading
import atexit
import Queue
_interval = 1.0
_times = {}
@jordanorelli
jordanorelli / django.wsgi
Created April 20, 2011 00:35
sample Django WSGI initialization script
import os
import sys
# If your project is not on your PYTHONPATH by default you can add:
path = '/path/to/project'
if path not in sys.path:
sys.path.insert(0, path)
@jordanorelli
jordanorelli / drums.scpt
Created May 16, 2011 19:28
a script for playing the drum set on ronwinter.tv/drums.html
--visit ronwinter.tv/drums.html, let the swf load, start the script, and then click inside the swf to put keyboard focus on Flash. The script will take control of your keyboard and play the drumset. The timing is really crappy.
global tempo
set tempo to 120
--establish quarter note delay time
global q
set q to 60 / tempo
--establish eighth note delay time
@jordanorelli
jordanorelli / main.ck
Created May 18, 2011 19:32
Controlling shreds with Midi messages
MidiIn min;
MidiMsg msg;
false => int activeShred; // store the id of the currently active shred.
// always be mindful of your starting conditions;
// in this case, the starting condition is that we
// have not yet launched any child shreds.
if(!min.open(0)) me.exit();
fun int reShred(string shredFileName, int currentShred) {
@jordanorelli
jordanorelli / wiimote_resolution_check.ck
Created June 2, 2011 03:35
helps determine WiiMote sampling rate as seen by ChucK for the user's system.
OscRecv recv;
6449 => recv.port;
recv.listen();
// osc message path used is the Osculator default.
recv.event("/wii/1/accel/pry/3,f") @=> OscEvent e;
time ti;
float dt;
1000000.0 => float smallest;
while(true) {
now => ti;
@jordanorelli
jordanorelli / open_editor.py
Created June 9, 2011 21:15
A Python script to open a temporary file in the user's editor, echo its contents, and delete the file.
# Jordan Orelli wrote it.
# Do what you want with it.
# June 9th, 2011
import os
import subprocess
import tempfile
if not os.environ.has_key('EDITOR'):
raise Exception('Unable to open editor; please set your EDITOR '
@jordanorelli
jordanorelli / django_cli.py
Created June 14, 2011 17:40
Load Django environment for CLI script
#!/usr/bin/env python
# Load the Django environment
from django.core.management import setup_environ
import os
import sys
try:
project_path = os.environ['DJANGO_PROJECT_PATH']
except KeyError:
raise Exception("Unable to locate Django project. Set your operating "
@jordanorelli
jordanorelli / query.py
Created June 14, 2011 18:33
Execute raw database queries from file in a Django project
#!/usr/bin/env python
# Load the Django environment
from django.core.management import setup_environ
import os
import sys
try:
project_path = os.environ['DJANGO_PROJECT_PATH']
except KeyError:
raise Exception("Unable to locate Django project. Set your operating "
@jordanorelli
jordanorelli / kboff.ck
Created June 15, 2011 20:45
Accepting keyboard input in ChucK. Pressing space disables keyboard entry (sometimes).
KBHit kb;
fun void kbListener(KBHit @ _kb)
{
while(true)
{
_kb => now;
while(_kb.more())
{
chout <= "ascii: " <= kb.getchar() <= IO.newline();
@jordanorelli
jordanorelli / urls.py
Created June 16, 2011 18:20
Django urlconf root
from django.conf.urls.defaults import patterns, include, url
from django.views.generic import TemplateView
urlpatterns = patterns('',
url(r'^$', TemplateView.as_view(
template_name='index.html',
), name='home'),
)