This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Number to guess: How large of a prime can we find, | |
# using a naive algorithm, in a second? | |
import sys | |
import itertools | |
import math | |
from libc.stdlib cimport malloc, free | |
cimport libc.stdio as stdio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.web.client import getPage | |
import json | |
@after(getPage, key=lambda channel: "http://api.justin.tv/api/stream/list.json?channel=%s" % channel) | |
def viewer_count(response, channel): | |
data = json.loads(response) | |
return data[0]['stream_count'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet.defer import Deferred | |
def noop(*args): | |
return args | |
class proxy(object): | |
def __init__(self, fn): | |
self.defer = Deferred() | |
self.fn = fn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def doThing(important, information): | |
return dataDependency(important, information).addCallback(_doThing, important, information) | |
def _doThing(data, important, information): | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@after(dataDependency) | |
def doThing(data, important, information): | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@after(getFromDatabase) | |
@after(getFromWeb) | |
def got_data(from_database, from_web): | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Image | |
import random | |
target = Image.open('target.png').convert('RGB') | |
target_distance = 10 | |
def make_image(): | |
return Image.new('RGB', target.size) |