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 | |
from cStringIO import StringIO | |
from csv import DictReader | |
from sys import argv | |
from zipfile import ZipFile | |
from arrow import utcnow | |
import dateutil.parser |
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 casperjs | |
var casper = require('casper').create({ | |
logLevel: 'debug', | |
verbose: true, | |
viewportSize: { | |
width: 1280, | |
height: 800, | |
}, | |
pageSettings: { |
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 lxml.html import fromstring | |
from requests import get | |
def get_soups(): | |
'''Get today's soups at Pret. | |
Return a list in the format: | |
['Sausage Hot Pot', 'Lentil & Coconut Curry', 'Cream of Mushroom'] |
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 split_at_predicate(predicate, sequence): | |
split_sequence = list() | |
for item in sequence: | |
if predicate(item): | |
yield split_sequence | |
split_sequence = list() | |
split_sequence.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
from itertools import imap, izip | |
import datetime | |
import pandas | |
data = ( | |
{u'_id': u'770000000006', | |
u'value': {u'timestamps': [datetime.datetime(2012, 5, 11, 15, 19, 49, 695000), | |
datetime.datetime(2012, 5, 11, 15, 25, 51, 586000), | |
datetime.datetime(2012, 5, 11, 15, 40, 11, 206000), |
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 requests | |
from oauth_hook import OAuthHook | |
def oauth_session(consumer_key, consumer_secret): | |
hook = OAuthHook(consumer_key=consumer_key, consumer_secret=consumer_secret) | |
session = requests.session(hooks={'pre_request': hook}) | |
return session |
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 "idiomaitc" way to concat strings in Python is | |
characters = ('a', 'b', 'c') | |
string = ''.join(characters) | |
# What's nice is that we can store all the strings in a list | |
characters = list() | |
for codepoint in range(ord('a'), ord('z') + 1): |
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
U+0A3: £ (POUND SIGN) | |
U+2013: – (EN DASH) | |
U+2014: — (EM DASH) | |
U+2015: ― (HORIZONTAL BAR) | |
U+2122: ™ (TRADE MARK SIGN) |
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
░░░░░░░▄▄▄█████▄▄▄░░░░░░░ | |
░░░░░██░░░░░░░░░░░██░░░░░ | |
░░░██░░░░░░░░░░░░░░░██░░░ | |
░░█░░░░░░░░░░░░░░░░░░░█░░ | |
░█░▄▀▀▀▄░░░░░░▄▀▀▀▄░░░░█░ | |
░█▐░░▄██▌░░░░▐░░▄██▌░░░░█ | |
█░▐▄▄███▌░░░░▐▄▄███▌░░░░█ | |
█░░░░░░░░░░░░░░░░░░░░░░░█ | |
█░░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░░░░█ | |
█░░░█▒▒▒▒▒▒▒▒▒▒▒▒▒▒█░░░░█ |
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
require 'rubygems' | |
require 'redcarpet' | |
path = ARGV[0] | |
file = File.open(path, 'r') | |
contents = file.read | |
markdown_renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML) | |
html = markdown_renderer.render(contents) |
NewerOlder