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
<!-- See: https://docs.djangoproject.com/en/1.1//topics/templates/#template-inheritance for more information --> | |
<html> | |
<head> | |
<link href="main_styles.css" media="screen" rel="stylesheet" type="text/css" /> | |
{% block extra_header_stuff %} | |
{% endblock %} | |
<head> | |
<body> | |
<!-- Body content goes here --> | |
</body> |
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
RED, GREEN, YELLOW, BLUE = range(1, 5) | |
def as_color(color, text): | |
COLOR_SEQ = "\033[%dm" | |
return "%s%s%s" % (COLOR_SEQ % (30 + color), text, COLOR_SEQ % 0) | |
print "FOO" | |
print as_color(RED, "AHH!") |
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
set ruler | |
set lazyredraw | |
set mouse=a | |
set number | |
set expandtab | |
set hlsearch | |
set incsearch | |
set shiftwidth=4 | |
set smartindent | |
set smarttab |
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 itertools import ifilter | |
class Step(object): | |
"""Sequential step in nfa. for branch to continue, the match | |
defined here must be successul at this point in the string.""" | |
__slots__ = 'match', 'nfa' | |
def __init__(self, match, nfa=None): |
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 functools import partial | |
from pprint import pprint | |
from pymongo import Connection, ASCENDING | |
DATABASE_NAME = 'index_test' | |
def setup(): |
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.List (sortBy) | |
import Data.Monoid (mconcat) | |
import Data.Ord (comparing) | |
-- | Our very own multiSort, in two words! | |
sortByMany :: [a -> a -> Ordering] -> [a] -> [a] | |
sortByMany = sortBy . mconcat | |
-- Now let's see it in action! | |
myList = [('a', 3), ('a', 2), ('b', 1), ('b', 0)] |
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
data Tree a = Empty | |
| Node a (Tree a) (Tree a) | |
deriving (Show) | |
-- | Add a value to our binary search tree. (Hard work is done here) | |
addValue :: Ord a => Tree a -> a -> Tree a | |
addValue t@(Node v left right) x | |
| x < v = Node v (addValue left x) right | |
| x > v = Node v left (addValue right 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
"""Mock cassandra object. A poor-man's model of it's interface.""" | |
class ColumnFamily(object): | |
def __init__(self, name): | |
self.name = name | |
self.data = {} | |
def get_row(self, row_id): |
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
# Here are some functions we'd like to simplify (find the abstraction) | |
def sum(numbers): | |
result = numbers.pop(0) | |
for x in numbers: | |
result += x | |
return result | |
def min(numbers): | |
result = numbers.pop(0) |
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
-- You'll need to "cabal install http" before this will work | |
import Network.Browser | |
import Network.HTTP | |
main = do | |
result <- getPage "http://www.google.com/" | |
putStrLn result | |
getPage url = do |