Skip to content

Instantly share code, notes, and snippets.

View jcarbaugh's full-sized avatar
🍳

Jeremy Carbaugh jcarbaugh

🍳
View GitHub Profile
@jcarbaugh
jcarbaugh / tweets.py
Last active September 26, 2015 23:08
Very simple, basic access to the Twitter API
"""
A very simple client for basic access to the Twitter API.
import tweets
client = tweets.TwitterClient(CONSUMER_KEY, CONSUMER_SECRET)
client.get_access_token() # complete authentication and enter PIN
client.get('statuses/home_timeline')
Requirements:
@jcarbaugh
jcarbaugh / tumblr2s3.py
Created August 26, 2011 17:48
Generate an RSS feed from your Tumblr dashboard and push it to S3.
"""
Create an RSS feed from your Tumblr dashboard and write to S3.
Run with -x command to write to stdout instead of pushing to S3.
Requirements:
boto
python-s3file
PyRSS2Gen
"""
@jcarbaugh
jcarbaugh / html5spec.py
Created August 26, 2011 18:12
Can a div be used inside a figure in HTML5? Based on an older version of the spec.
METADATA_ELEMENTS = ('command', 'link', 'meta', 'noscript', 'script', 'style')
PHRASING_ELEMENTS = ('a', 'abbr', 'area', 'audio', 'b', 'bdo', 'br', 'button',
'canvas', 'cite', 'code', 'command', 'datalist', 'del', 'dfn', 'em', 'embed',
'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark',
'meter', 'noscript', 'object', 'output', 'progress', 'q', 'ruby', 'samp',
'script', 'select', 'small', 'span', 'strong', 'sub', 'sup', 'textarea',
'time', 'var', 'video')
FLOW_ELEMENTS = ('address', 'article', 'aside', 'blockquote',
@jcarbaugh
jcarbaugh / nestedkeys.py
Created September 2, 2011 19:16
Create a nested dict from a dotted-key dict
def rejigger(src):
dst = {} # dict to hold new structure
# iterate over keys and values in source dict
for key, value in src.iteritems():
set_value(dst, key.split('.'), value)
return dst
@jcarbaugh
jcarbaugh / frederickco-feed2ical.py
Created September 20, 2011 15:12
Convert Frederick County, VA events feed to iCalendar
""" Generate an iCalendar file from the Frederick County, VA Government
RSS feed of events.
Requirements:
feedparser
icalendar
"""
from datetime import datetime
import sys
@jcarbaugh
jcarbaugh / memory.js
Created April 2, 2012 16:06
memory card game
$().ready(function() {
var images = [
'gingrich',
'huntsman',
'obama',
'paul',
'romney',
'santorum'
];
@jcarbaugh
jcarbaugh / mediasync.py
Created April 6, 2012 21:25
mediasync-style storage backend using django-storages
import base64
import hashlib
import mimetypes
import os
import threading
from boto.s3.key import Key
from django.conf import settings
from django.core.files.storage import get_storage_class
from storages.backends.s3boto import S3BotoStorage
@jcarbaugh
jcarbaugh / gist:3995708
Created November 1, 2012 18:54
sfapp base template
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="static/css/bootstrap.min.css">
<link rel="stylesheet" href="static/css/sfapp.css">
<script type="text/javascript" src="http://use.typekit.com/tab6neo.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
</head>
@jcarbaugh
jcarbaugh / highfive.py
Created November 4, 2012 18:43
High five, bro!
#!/usr/bin/env python
import logging
import os
import random
import sys
import time
import urllib
import urllib2
logger = logging.getLogger("highfive")
@jcarbaugh
jcarbaugh / mmmsaucebrush.py
Last active December 11, 2015 06:08
An example of using python-saucebrush with legislators.csv from the Sunlight Foundation Congress API bulk download.
from saucebrush import emitters, filters, sources, stats
import saucebrush
import us
CHAMBERS = {"House": "Rep", "Senate": "Sen"}
STATES = [s.abbr for s in us.STATES]
TERRITORIES = [t.abbr for t in us.TERRITORIES]
class StateFilter(filters.ConditionalFilter):