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 django.shortcuts import render_to_response, get_object_or_404, get_list_or_404 | |
from django.http import HttpResponseRedirect, Http404, HttpResponse | |
from django.template import RequestContext | |
from django.core.cache import cache | |
import iso8601 | |
from pollster import Pollster | |
def presidentmatch(request): |
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/python | |
# -*- coding: utf-8 -*- | |
import os | |
import shlex, subprocess | |
import logging | |
from django.conf import settings | |
logger = logging.getLogger('pagetracker.grabber') | |
def grab_page(url, outfile): |
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
class CachedModelResource(ModelResource): | |
def create_response(self, *args, **kwargs): | |
resp = super(CachedModelResource, self).create_response(*args, **kwargs) | |
resp['Cache-Control'] = "max-age=600" | |
return resp |
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 django.core.files.temp import NamedTemporaryFile | |
def save_image_from_url(self): | |
""" | |
Save remote images from url to image field. | |
Requires python-requests | |
""" | |
r = requests.get(self.image_url) | |
if r.status_code == 200: |
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/python | |
# -*- coding: utf-8 -*- | |
import re | |
import requests | |
def get_page_tag(url, title_re=re.compile(r'<title>(.*?)</title>', re.UNICODE )): | |
""" | |
Retrieves the title tag from a given url (or actually any tag if you want..) |
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 django.conf.urls.defaults import * | |
from timelineit.views import * | |
from django.views.decorators.cache import cache_control,never_cache | |
urlpatterns = patterns('timelineit.views', | |
url(r'^desk/(?P<slug>[-\w\d]+)', | |
never_cache(timeline_preview), | |
name="timeline_preview"), | |
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/python | |
# -*- coding: utf-8 -*- | |
import xlrd | |
import xlwt | |
from optparse import OptionParser | |
import datetime | |
""" | |
Merges excel files with multiple sheets with identical header lines into |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="http://propublica.github.com/timeline-setter/public/stylesheets/timeline-setter.css" rel="stylesheet" /> | |
<script src="http://propublica.github.com/timeline-setter/public/javascripts/vendor/jquery-min.js"></script> | |
<script src="http://propublica.github.com/timeline-setter/public/javascripts/vendor/underscore-min.js"></script> | |
<script src="http://propublica.github.com/timeline-setter/public/javascripts/timeline-setter.js"></script> | |
<script src="../js/date.js"></script> | |
<style> | |
#timeline_setter .TS-item_label a { |
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/python | |
# -*- coding: utf-8 -*- | |
import os | |
import subprocess | |
import logging | |
from django.conf import settings | |
logger = logging.getLogger('pagetracker.grabber') | |
def grab_page(url, outfile): |