This file contains hidden or 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
;; Deriving something like generators, but I didn't really feel like | |
;; doing exactly that. | |
;; It doesn't, for instance, support sending back into the generator | |
;; This applys a function across a range from 0 to x. | |
(define (apply-to-range f i x) | |
(when (< i x) | |
(f i) | |
(apply-to-range f (+ 1 i) x))) |
This file contains hidden or 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
#Code from http://fmota.eu/, great! | |
class Monoid: | |
def __init__(self, null, lift, op): | |
self.null = null | |
self.lift = lift | |
self.op = op | |
def fold(self, xs): | |
if hasattr(xs, "__fold__"): | |
return xs.__fold__(self) |
This file contains hidden or 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 python2 | |
from itertools import combinations | |
def number_of_disc_intersections(A): | |
boundries = list() | |
for x, r in enumerate(A): | |
boundries.append((x-r, x+r)) | |
r = range(len(A)) |
This file contains hidden or 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
#simple decorators concept from... | |
#http://stackoverflow.com/questions/739654/understanding-python-decorators | |
def makebold(fn): | |
def wrapped(): | |
return "<b>" + fn() + "</b>" | |
return wrapped | |
def makeitalic(fn): | |
def wrapped(): |
This file contains hidden or 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
# grep.py | |
# | |
# A very simple coroutine | |
def grep(pattern): | |
print "Looking for %s" % pattern | |
while True: | |
line = (yield) | |
if pattern in line: | |
print line, |
This file contains hidden or 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 boto.mturk | |
import boto.mturk.connection | |
import boto.mturk.price | |
from boto.mturk.question import * | |
import sys | |
question = QuestionForm([ | |
Question( | |
identifier=1, | |
content=QuestionContent([ |
This file contains hidden or 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
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011 | |
* http://benalman.com/ | |
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */ | |
(function($) { | |
var o = $({}); | |
$.subscribe = function() { | |
o.on.apply(o, arguments); |
This file contains hidden or 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 java.io.*; | |
import java.util.*; | |
class Singleton { | |
private static Singleton _Instance; | |
private Singleton() | |
{ | |
} |
This file contains hidden or 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 pandas import DataFrame | |
from pandas.util.testing import set_trace | |
import os | |
import numpy as np | |
import matplotlib.pyplot as plt | |
dirs = [] | |
names = [] | |
lengths = [] |
This file contains hidden or 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
require 'sinatra/metal' | |
class SinatraMetal < Sinatra::Base | |
include Sinatra::Metal | |
get '/sinatra' do | |
'hello sinatra!' | |
end | |
end |
OlderNewer