Instantly share code, notes, and snippets.

# Ceasar BautistaCeasar

• Sort options
Created Feb 20, 2014
View fabfile.py
 """ fab -H [hostname] [command] """ from fabric.api import run HOME = '/Users/ceasarbautista' def authorize():
Created Feb 20, 2014
View connect.py
 import sys import time from sh import networksetup DEVICE = 'en0' NETWORK = u'AirPennNet' NETWORK = u'Lovers&Madmen'
Created Jan 13, 2014
View basins.py
 """ 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.
Created Jul 27, 2013
View Lisp.hs
 import Text.ParserCombinators.Parsec import System.Environment data LispVal = Atom String -- | List [LispVal] -- | DottedList [LispVal] LispVal | Number Integer | String String
Created Jul 26, 2013
Propositional logic.
View Logic.lhs
 > 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
Created Jul 26, 2013
Speed test.
View speed_primes.py
 import timeit setup = """ def primes(n): '''Get all primes up to n.''' if n < 2: return [] nums = range(n) sieve = set(xrange(2, n))
Created Jul 26, 2013
View Chess.hs
 module Chess where import Data.Map as M import Test.HUnit import Test.QuickCheck type Pos = (Int, Int) data Color = White | Black
Created Jul 26, 2013
Convert xml to json.
View xml2json.py
 '''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)
Created Jul 26, 2013
Scrape tables off a web page.
View scrape_tables.py
 """ Covert html tables into csvs. """ import sys import urllib from lxml import etree
Created Jul 18, 2013
View md2.py
 """ Convert markdown files containing Python code into working Python files. Usage: python md2.py [markdownfile] Example: Flask is Fun ============
You can’t perform that action at this time.