Skip to content

Instantly share code, notes, and snippets.

View beaumartinez's full-sized avatar
😂
I don't use GitHub

Beau beaumartinez

😂
I don't use GitHub
View GitHub Profile
@beaumartinez
beaumartinez / twitter2ebooks.py
Created December 28, 2014 15:34
Print the tweets in a Twitter archive that are younger than a year, useful for heroku_ebooks
#!/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
#! /usr/bin/env casperjs
var casper = require('casper').create({
logLevel: 'debug',
verbose: true,
viewportSize: {
width: 1280,
height: 800,
},
pageSettings: {
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']
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)
@beaumartinez
beaumartinez / pandas_issue.py
Created August 8, 2012 11:54
Pandas data issues
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),
@beaumartinez
beaumartinez / requests_oauth.py
Created June 1, 2012 09:48
requests-oauth demo
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
@beaumartinez
beaumartinez / concatting-strings.py
Created March 22, 2012 20:48
Concatting strings
# 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):
@beaumartinez
beaumartinez / gist:1241940
Created September 26, 2011 09:37
Useful Unicode codepoints
U+0A3: £ (POUND SIGN)
U+2013: – (EN DASH)
U+2014: — (EM DASH)
U+2015: ― (HORIZONTAL BAR)
U+2122: ™ (TRADE MARK SIGN)
@beaumartinez
beaumartinez / emoticons
Last active September 27, 2015 06:39
Emoticons and shit
░░░░░░░▄▄▄█████▄▄▄░░░░░░░
░░░░░██░░░░░░░░░░░██░░░░░
░░░██░░░░░░░░░░░░░░░██░░░
░░█░░░░░░░░░░░░░░░░░░░█░░
░█░▄▀▀▀▄░░░░░░▄▀▀▀▄░░░░█░
░█▐░░▄██▌░░░░▐░░▄██▌░░░░█
█░▐▄▄███▌░░░░▐▄▄███▌░░░░█
█░░░░░░░░░░░░░░░░░░░░░░░█
█░░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░░░░█
█░░░█▒▒▒▒▒▒▒▒▒▒▒▒▒▒█░░░░█
@beaumartinez
beaumartinez / markdown.rb
Created September 8, 2011 19:53
Render the passed file with GitHub's Markdown renderer
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)