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 qualified Data.Map as M | |
data Direction = N | S | E | W deriving Eq | |
type Location = (Int, Int) | |
data Sticker = Red | Blue deriving Eq | |
data Widget = Widget Location [Sticker] |
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
""" | |
Convert markdown files containing Python code into working Python files. | |
Usage: python md2.py [markdownfile] | |
Example: | |
Flask is Fun | |
============ | |
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
""" | |
Covert html tables into csvs. | |
""" | |
import sys | |
import urllib | |
from lxml import etree | |
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
'''A module for converting xml into json.''' | |
import json | |
from lxml import etree | |
def xml_to_json(xml_input, json_output): | |
'''Converts an xml file to json.''' | |
dict_to_json(etree_to_dict(xml_to_etree(xml_input), True), json_output) |
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 Chess where | |
import Data.Map as M | |
import Test.HUnit | |
import Test.QuickCheck | |
type Pos = (Int, Int) | |
data Color = White | Black |
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 timeit | |
setup = """ | |
def primes(n): | |
'''Get all primes up to n.''' | |
if n < 2: | |
return [] | |
nums = range(n) | |
sieve = set(xrange(2, n)) |
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
import Text.ParserCombinators.Parsec | |
import System.Environment | |
data LispVal = Atom String | |
-- | List [LispVal] | |
-- | DottedList [LispVal] LispVal | |
| Number Integer | |
| String String |
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
""" | |
Palantir interview question. | |
The goal is to, given an elevation map of some land, print out a | |
list of basin sizes in descending order, where a basin is a set of | |
cells of land that all drain to a common point. One cell drains to | |
another if among the first cell and its neighbors (i.e. cells adjacent, | |
horizonatlly, vertically or diagonally) the second cell has the lowest | |
elevation. |
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 sys | |
import time | |
from sh import networksetup | |
DEVICE = 'en0' | |
NETWORK = u'AirPennNet' | |
NETWORK = u'Lovers&Madmen' | |