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
""" | |
Generating all valid clauses of a CFG specified as BNF | |
Copied from here http://www.reddit.com/r/Python/comments/20x61y/share_the_code_youre_most_proud_of/ | |
""" | |
from itertools import chain, product | |
from re import match, findall | |
GRAMMAR = ''' | |
<sentence> ::= <noun phrase=""> <verb phrase=""> | |
<noun> ::= "boy " | "troll " | "moon " | "telescope " |
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 collections import defaultdict | |
from collections import Counter | |
from itertools import izip | |
from itertools import islice | |
from operator import itemgetter | |
import datetime | |
import random | |
event_length = 1000000 | |
WIN_SIZE = 3 |
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 fabric.api import env | |
# from fabric.api import serial | |
from fabric.api import task | |
from fabric.api import run | |
from fabric.task_utils import state | |
env.hosts = ['addv3.redbeacon-inc.com', 'addv4.redbeacon-inc.com'] | |
env.parallel = True | |
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
""" | |
The theoretical order-of-growth is N ^ (29/12) = 2.42 | |
The empirical order-of-growth is N ^ (log_2 ratio) | |
log_2 | |
N seconds ratio ratio | |
--------------------------------------- | |
256 0.000 - - | |
512 0.001 - - |
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
-module("folding_funs"). | |
-export([transform_something/1]). | |
transformations() -> | |
[fun trans1/1, fun trans2/1, fun trans3/1]. | |
transform_something(A) -> | |
lists:foldl(fun(Fun, Acc) -> Fun(Acc) end, A, transformations()). |
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 httplib | |
def patch_send(): | |
if hasattr(httplib, 'is_patched'): | |
print 'httplib is already patched' | |
return | |
httplib.is_patched = True |
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
""" | |
Inner function performance test | |
Result: | |
direct call = 0.335001945496 | |
with wrapper = 0.700292110443 | |
""" | |
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
#!/bin/bash | |
# -*- tab-width:4;indent-tabs-mode:nil -*- | |
# ex: ts=4 sw=4 et | |
# | |
# This script downloads and compiles publicator | |
# | |
# USAGE: | |
# To build master branch: | |
# $ ./compile_publicator.sh | |
# To build specific tag provide tag number as argument |
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
-module(file_index). | |
-export([clean/1]). | |
-export([getWord/1]). | |
-export([tokenize/1]). | |
-export([get_line/1]). | |
-export([enumerate/1]). | |
-export([parse_string/1]). | |
-export([invert/1]). | |
-export([get_sequence/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
-module(funs). | |
-export([compose/1]). | |
-export([twice/1]). | |
-export([iteration/1]). | |
-export([make_list/2]). | |
-include_lib("eunit/include/eunit.hrl"). | |
compose(Funs)-> | |
fun(Arg) -> |
OlderNewer