Skip to content

Instantly share code, notes, and snippets.

View bobpoekert's full-sized avatar
🗿
.

Bob Poekert bobpoekert

🗿
.
View GitHub Profile
@bobpoekert
bobpoekert / button.sass
Created May 22, 2012 00:03
Sass button
@mixin gradient($from, $to)
background-color: $from
background-image: -webkit-gradient(linear, left top, left bottom, from($from), to($to))
background-image: -moz-linear-gradient($from, $to)
background-image: -webkit-linear-gradient($from, $to)
background-image: -o-linear-gradient($from, $to)
@mixin button($color, $font-size)
font-size: $font-size * 2
padding: $font-size
@bobpoekert
bobpoekert / multi.py
Created April 18, 2012 22:09
Multi: A helper class for waiting on multiple asynchronous things happening in parallel
class Multi(object):
def __init__(self, callback):
self.callback = callback
self.counter = 0
self.fired = False
self.started = False
def enter(self):
assert not self.started
@bobpoekert
bobpoekert / monte_carlo_filter.py
Created April 7, 2012 04:20
Monte Carlo noise effect
import Image
import random
target = Image.open('target.png').convert('RGB')
target_distance = 10
def make_image():
return Image.new('RGB', target.size)
@bobpoekert
bobpoekert / test_gist
Created September 15, 2011 17:16
Testing twitter
This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long. This tweet is too long.
@bobpoekert
bobpoekert / js_catcher.js
Created July 22, 2011 20:55
Catch array of exceptions
var catcher = function() {
var fns = Array.prototype.slice.call(arguments);
var onerror = fns[0];
fns.splice(0, 1);
return function() {
var res = [];
var errors = [];
for (var i=0; i < fns.length; i++) {
try {
res.push(fns[i].apply(this, arguments));
@bobpoekert
bobpoekert / saw-chant.ck
Created June 25, 2011 16:18
My first Chuck instrument
MidiIn min;
MidiMsg msg;
if (!min.open(0)) me.exit();
SinOsc s => Gain g => DelayL d => dac;
s => Gain g2 => dac;
d => Gain g3 => d;
15::ms => d.delay;
0.1 => g.gain;
@after(getFromDatabase)
@after(getFromWeb)
def got_data(from_database, from_web):
...
@after(dataDependency)
def doThing(data, important, information):
...
@bobpoekert
bobpoekert / twisted.py
Created May 13, 2011 06:27
twisted Twisted
def doThing(important, information):
return dataDependency(important, information).addCallback(_doThing, important, information)
def _doThing(data, important, information):
...
@bobpoekert
bobpoekert / after.py
Created May 13, 2011 06:24
The @after decorator
from twisted.internet.defer import Deferred
def noop(*args):
return args
class proxy(object):
def __init__(self, fn):
self.defer = Deferred()
self.fn = fn