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
var ParallelHttp = { | |
forkjoin: function(requests, join_handler){ | |
var results = []; | |
var identity = function(i){return i}; | |
$.map(requests, function(request){ | |
var old_success = request.success || function(){}; | |
var old_error = request.error || function(){}; | |
var old_complete = request.complete || function(){}; | |
request.success = function(data) { | |
old_success(data); |
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
"A good way to tackle such problems is to consider a simpler problem first. | |
There is, of course, no guarantee that solutions obtained for simpler problems | |
can be used directly in the problem which inspired them; they may only serve | |
to familiarise the solver with some of the features and difficulties involved. | |
Even so, the work is not wasted; familiarity with a problem is one of our most | |
important tools for solving it. And often we will be able to use the solution | |
directly or by adapting it." | |
!!! |
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
def generate_inverse_transformations(left,right): | |
#????? | |
return (lambda x: x, lambda x: x) | |
left_form = { | |
'key': 'abc123', | |
'name': {'first': 'joe', 'last': 'stein'}, | |
'triples': {1: 3, 2: 6, 3: 9, 4: 12, 5: 15}, | |
'opposites': [('low','high'),('big','small')] | |
} |
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
class CombinableFunction(object): | |
def __init__(self, function): | |
self.function = function | |
def __call__(self, *args): | |
return self.function(*args) | |
def __or__(self, other): | |
def new_function(*args): | |
return self.function(*args) | other(*args) |
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
statefulSequence state transformstate plop = plop state : statefulSequence (transformstate state) transformstate plop | |
fib = statefulSequence [1, 1] (\[first, second] -> [second, first + second]) (!! 0) | |
main = print $ take 9 fib | |
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
def make_adder(): | |
grand_total = 0 | |
def adder(to_add): | |
print "Grand total moved from: %s" % grand_total | |
grand_total += to_add | |
print "To: %s \n" % grand_total | |
return grand_total | |
return adder | |
adder = make_adder() |
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 Data.Bool | |
import qualified Data.Map.Lazy as Map | |
data Encoding = Encoding (Bool, Bool, Bool) deriving (Eq, Ord) | |
data Assignment = Assignment { initial::Encoding, subsequent::[Encoding]} | |
data Letter = A | B | C | D deriving (Show, Enum, Eq, Ord) | |
type Solution = Map.Map Letter Assignment |
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
<!DOCTYPE html> | |
<html lang="en" ng-app="temperature-converter" class="no-js"> | |
<head> | |
<meta charset="utf-8"> | |
<script src="./x.jquery-1.8.3.min.js"></script> | |
<script type="text/javascript"> | |
var TableController = function(search_box, table) { | |
this.search_box = search_box; | |
this.table = table; |
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
<!DOCTYPE html> | |
<html lang="en" ng-app="temperature-converter" class="no-js"> | |
<head> | |
<meta charset="utf-8"> | |
<script src="./x.jquery-1.8.3.min.js"></script> | |
<script src="./temperature.js"></script> | |
<script type="text/javascript"> | |
var TemperatureController = function(fahrenheit_input, celsius_input) { | |
var controller = this; |
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 random import shuffle | |
to_clump = [0, 0.2, 5, 9, 9.1, 100, 100.2] | |
shuffle(to_clump) | |
def clump_same(comparables, distance_threshold): | |
def do_clump(so_far, current): | |
last_clump = so_far[-1] | |
lowest_in_last_clump = last_clump[0] | |
if (current - lowest_in_last_clump) < distance_threshold: |