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 datetime | |
import random | |
from collections import defaultdict | |
from elasticsearch import Elasticsearch | |
INDEX = 'test-top-books' | |
TYPE = 'book-sales' | |
today = datetime.date.today() |
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 threading | |
from django.conf import settings | |
from django.http import HttpResponseRedirect | |
# We used our own model to associate users with sites, but could use django.contrib.sites here. | |
from .models import Network | |
# List of allowed URLs if user isn't in the network | |
ALLOWED = [ | |
u'/accounts/register/', |
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 | |
import sys | |
from flake8.run import git_hook | |
ignore = [ | |
'E121', | |
'E123', | |
'E124', | |
'E125', | |
'E126', |
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
var lsCache = function() { | |
var TIMEOUT_DEFAULT = 60; | |
var self = { | |
set: function(key, val, timeout) { | |
var timeout = parseInt(timeout, 10) || TIMEOUT_DEFAULT; | |
var now = Math.round(new Date().getTime() / 1000); | |
localStorage.setItem(key, val); | |
localStorage.setItem(key + '.timeout', now * timeout); | |
}, |
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 CORSResource(object): | |
""" | |
Adds CORS headers to resources that subclass this. | |
""" | |
def create_response(self, *args, **kwargs): | |
response = super(CORSResource, self).create_response(*args, **kwargs) | |
response['Access-Control-Allow-Origin'] = '*' | |
response['Access-Control-Allow-Headers'] = 'Content-Type' | |
return response |
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
#!/bin/sh | |
if [ $(git diff HEAD@{1} HEAD --name-only | grep 'requirements/' -c) -ne 0 ] | |
then | |
$VIRTUAL_ENV/bin/pip install -r requirements/dev.txt | |
fi |
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
# Assumptions: | |
# | |
# Assumes boto is installed which comes with the s3put command | |
# | |
# Assumes your S3 keys are in ~/.boto in the form: | |
# | |
# [Credentials] | |
# aws_access_key_id = XXX | |
# aws_secret_access_key = XXX | |
# |
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 roll_release(version): | |
local('git flow release start %s' % (version,), capture=True) | |
local('sed -e "s/\'AWS_PREFIX\':.*$/\'AWS_PREFIX\': \'%s\', # cache bust/g" -i \'\' potluck/settings/base.py' % (version,)) | |
local('git commit -am \'Bumped media version to %s\'' % (version,)) | |
local('git flow release finish -m %s -p %s' % (version, version), capture=True) |
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 GPATicketErrorLogMiddleware(object): | |
@transaction.commit_on_success | |
def process_exception(self, request, exception): | |
import oauth2 as oauth | |
import sys | |
import traceback | |
create_ticket_url = 'http://%s.goplanapp.com/api/tickets/create' % ( |
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 datetime | |
from django.template import Library | |
from django.template.defaultfilters import stringfilter | |
register = Library() | |
@stringfilter | |
def parse_date(date_string, format): | |
""" |