Skip to content

Instantly share code, notes, and snippets.

View jordanorelli's full-sized avatar
🎴

Jordan Orelli jordanorelli

🎴
View GitHub Profile
@jordanorelli
jordanorelli / somelines.pde
Created January 8, 2012 20:00
some, errr, lines.
size(400, 400); // the default size is too small
smooth(); // i don't know why you wouldn't use this for images.
background(128); // 50% gray background
int lineCount = 20; // number of lines to be drawn
int circleDepth = 10; // how "deep" the circle is said to be.
int lineSpacing = height / lineCount; // how far apart the lines should be from one another
/* the lines should be half as wide as they are far apart, such that the positive
and negative space is equal. */
@jordanorelli
jordanorelli / p084ex2.pde
Created January 15, 2012 21:40
page 84, exercise 2, "Processing: A programming Handbook..."
/* Use the data from the curve y = x ^ 8 to draw something unique */
size(640, 480);
smooth();
float expMax = 8.0;
float expStep = 0.0625;
for(int x = 0; x < width; x++) {
float xNorm = norm(x, 0, width);
noStroke();
@jordanorelli
jordanorelli / launchpad_0.ck
Created January 17, 2012 16:50
an early ChucK synth
MidiIn padIn;
MidiOut padOut;
MidiMsg msg;
1.059463094359295 => float halfStepRatio;
TriOsc mrNote => dac;
0 => mrNote.gain;
55.0 => float lowestFreq;
8 => int rowStep; // number of halfsteps between launchpad rows.
// set to 8 for a chromatic layout. Anything above
// 8 and you'll miss notes. Anything below and
void setup() {
smooth();
size(542, 475, P3D);
background(255);
stroke(0);
strokeWeight(3);
superQuad(new PVector(364.0, 235.0),
new PVector(314.0, 295.0),
new PVector(114.0, 272.0),
@jordanorelli
jordanorelli / fileview.py
Created February 10, 2012 18:45
A static file view for Django
from django.conf import settings
from django.http import HttpResponse, HttpResponseNotModified, Http404
from django.utils.http import http_date
from django.views.generic import View
from django.views.static import was_modified_since
import mimetypes
import os
class StaticFileView(View):
http_method_names = ['get']
@jordanorelli
jordanorelli / fabextras.py
Created February 19, 2012 00:00
runtime-generated fabric connection functions, yay
from fabric.api import env
import os
import string
_conf_root = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'conf')
_conf_dirs = [x for x in os.listdir(_conf_root)
if os.path.isdir(os.path.join(_conf_root, x))
and x != 'base']
def _mk_sethost_fn(host_dicts, context):
@jordanorelli
jordanorelli / iptables.test.rules
Created February 28, 2012 18:59
naive iptables rules
*filter
# Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
# Accepts all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allows all outbound traffic
# You could modify this to only allow certain traffic
@jordanorelli
jordanorelli / get_nouns.py
Created March 7, 2012 04:03
get all svgs from the noun project
from os import path
import re
import requests
url_template = "http://thenounproject.com/download/zipped/svg_%d.zip"
base_dir = path.dirname(path.abspath(__file__))
svg_dir = path.join(base_dir, 'svg')
pattern = re.compile(r'<svg.*/svg>', re.DOTALL)
for x in xrange(1, 300):
@jordanorelli
jordanorelli / main.go
Created March 12, 2012 04:03
stanley.
package main
import (
"fmt"
)
func main() {
fmt.Println(Stanley())
}
@jordanorelli
jordanorelli / simple_markov.ck
Created March 16, 2012 22:57
primitive markov chain (in chuck)
200::ms => dur beat;
"A" => string currentState;
ADSR env;
env.set(20::ms, 20::ms, 0.6, 20::ms);
env.keyOff();
SinOsc s => env => dac;
fun void enterState(string stateName) {
if (stateName == "A") {