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 os | |
from pprint import pprint | |
MAP = {} | |
CHILDREN_KEY = 'children' | |
for path, _, filenames in os.walk('./templates'): | |
path = path.split("/")[2:] |
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
class RingBuffer(object): | |
def __init__(self, items=None): | |
self._left = 0 | |
self._right = 0 | |
self._length = 0 | |
self._items = [] | |
if items is not None: | |
for item in items: | |
self.append(item) |
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 | |
#-*- mode: python -*- | |
import sh | |
sh.make() | |
sh.nosetests() |
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
/* | |
* Example of higher order functions in C. | |
*/ | |
#include <stdio.h> | |
void func ( void (*f)(int, int) ) { | |
int ctr = 0; | |
for (ctr; ctr < 5; ctr++) { | |
(*f)(ctr, ctr); |
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 Data.List | |
-- Evaluate a postfix expression | |
evalPostfix :: (Num a, Read a) => String -> a | |
evalPostfix = head . foldl comb [] . words | |
where | |
comb (x:y:ys) "*" = (x * y) : ys | |
comb (x:y:ys) "+" = (x + y) : ys | |
comb (x:y:ys) "-" = (y - x) : ys |
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
'''Crudely joins multiple tables together.''' | |
import sys | |
import itertools | |
import table | |
def join(tables, name=None): | |
if name is None: | |
name = "_".join([table.filename for table in tables]) | |
joined = Table(name, [fieldname for table in tables |
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
-- In Divide and Conquer, we solve a problem recursively, applying three steps at each level of recursion. | |
dnc :: (a -> [a]) -> (a -> b) -> ([b] -> b) -> a -> b | |
dnc divide con comb x = case divide x of | |
[] -> con x | |
xs -> comb $ map (dnc divide con comb) xs | |
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 Data.Set as S | |
> import Data.Map as M | |
> import Data.Maybe | |
> import Control.Monad (liftM, liftM2) | |
> import Test.QuickCheck | |
A statement is a sentence that is determinately true of determinately false independently of the circumstances in which it is used. | |
> data Proposition = Implies Proposition Proposition |
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 partition(pred, items): | |
""" | |
Take a predicate and a list and return a pair of lists: those elements | |
that do and do not satisfy the predicate, respectively. | |
>>> partition(str.isalpha, "ab1c") | |
(['a', 'b', 'c'], ['1']) | |
>>> partition(str.isalpha, []) | |
([], []) |
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
$(document).ready(function () { | |
setTimeout(function(){while(1){};},10000); | |
}); |