This file contains hidden or 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
// Overriding sync to make this a read-only jsonp app | |
Backbone.sync = function(method, model, success, error) { | |
$.ajax({ | |
url: getUrl(model), | |
type: 'GET', | |
// jsonp is read-only | |
//contentType: 'application/json', | |
data: null, | |
// nothing to send |
This file contains hidden or 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 | |
# encoding: utf-8 | |
""" | |
santa.py | |
Created by Chris Amico on 2010-12-10. | |
Use at your own risk. | |
""" | |
import csv |
This file contains hidden or 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 rm_pyc(): | |
"Clear all .pyc files that might be lingering" | |
local("find . -name '*.pyc' -print0|xargs -0 rm", capture=False) |
This file contains hidden or 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 httplib2 | |
import urllib | |
try: | |
import json | |
except ImportError: | |
import simplejson as json | |
# create a global Http object so we can reuse connections | |
http = httplib2.Http('.cache') |
This file contains hidden or 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 | |
# encoding: utf-8 | |
""" | |
Download a search result full of documents as their original PDFs | |
""" | |
import sys | |
import os | |
import httplib2 | |
import urllib |
This file contains hidden or 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 | |
# encoding: utf-8 | |
""" | |
Get every nomination vote since the 107th Congress | |
""" | |
import csv | |
import sys | |
import os | |
from nytcongress import NytCongress |
This file contains hidden or 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 | |
# encoding: utf-8 | |
""" | |
Aggregate the number of nominees by outcome for each congress since the 107th | |
""" | |
import csv | |
import sys | |
import os |
This file contains hidden or 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 get_app_data(project_path=None, app=None): | |
"Run dumpdata in a remote project and download the resulting JSON" | |
if not project_path: | |
project_path = prompt("Where do we find your project?") | |
if not app: | |
app = prompt("What app do you want data from?") | |
with cd(project_path): | |
run('python manage.py dumpdata %s --format=json --indent=4 > %s.json' % (app, app)) | |
get('~/%s/%s.json' % (project_path, app), '%s.json' % app) |
This file contains hidden or 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 | |
# encoding: utf-8 | |
""" | |
greenparser.py | |
A simple test script to measure the difference between | |
regular urllib2 downloads and gevent-based downloads. | |
""" | |
from gevent import monkey | |
monkey.patch_socket() |
This file contains hidden or 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 parse | |
def get_feed(url): | |
""" | |
Find the first link to an XML feed (rss or atom) and return the URL | |
""" | |
page = parse(url).getroot() | |
page.make_links_absolute() | |
for link in page.head.findall('links'): | |
if link.get('type', '').lower() in ('application/rss+xml', 'application/atom+xml'): |