This file contains 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
// | |
// NSURLConnection+Blocks.h | |
// SteveHolt | |
// | |
// Created by Eric Florenzano on 10/19/11. | |
// Copyright (c) 2011 Boilerplate Inc. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
This file contains 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 base64 | |
import httplib | |
import threading | |
import urllib | |
import tweepy | |
CONVORE_BOT_USERNAME = '' | |
CONVORE_BOT_PASSWORD = '' | |
CONVORE_TOPIC_ID = '7612' |
This file contains 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 subprocess | |
from django.conf import settings | |
from django.core.management.base import BaseCommand | |
from boto.s3.connection import S3Connection | |
from boto.s3.key import Key | |
class Command(BaseCommand): |
This file contains 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 | |
from twisted.internet import reactor | |
from twisted.web import proxy, server | |
from twisted.web.resource import Resource | |
class ProxyResource(Resource): | |
def getChild(self, path, request): | |
request.received_headers['x-forwarded-host'] = request.received_headers['host'] |
This file contains 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 hashlib | |
>>> import hmac | |
>>> digest_maker = hmac.new('0x24FEEDFACEDEADBEEFCAFE', '', hashlib.sha1) | |
>>> digest_maker.update('http://farm5.static.flickr.com/4116/4857328881_fefb8e2134_z.jpg') | |
>>> digest_maker.hexdigest() | |
'2731d77b436b8a78f4cbe3624d8088fd5262f996' |
This file contains 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
# Extracted from django-oembed, because I keep having a need for this snippet | |
import re | |
from heapq import heappush, heappop | |
def re_parts(regex_list, text): | |
""" | |
An iterator that returns the entire text, but split by which regex it | |
matched, or none at all. If it did, the first value of the returned tuple | |
is the index into the regex list, otherwise -1. |
This file contains 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.contrib.messages.storage.base import Message, BaseStorage | |
class JSONSessionStorage(BaseStorage): | |
""" | |
Stores messages in JSON-compatible format | |
""" | |
session_key = '_messages' | |
def _to_dict(self, message): | |
return { |
This file contains 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 simplejson | |
from django.contrib.sessions.backends.base import SessionBase, CreateError | |
from django_ext.redis_helper import get_redis | |
class SessionStore(SessionBase): | |
""" | |
A Redis-based session store. |
This file contains 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
# 00 prepended to filename so this shows up first in the list of gists. | |
import socket | |
import time | |
import simplejson | |
from django.conf import settings | |
def log_event(logger, event, request=None, data=None, |
This file contains 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
""" | |
jQuery templates use constructs like: | |
{{if condition}} print something{{/if}} | |
This, of course, completely screws up Django templates, | |
because Django thinks {{ and }} mean something. | |
Wrap {% verbatim %} and {% endverbatim %} around those | |
blocks of jQuery templates and this will try its best |