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 uncompress_string(c): | |
from io import BytesIO | |
from gzip import GzipFile | |
zbuf = BytesIO(c) | |
with GzipFile(mode='rb', compresslevel=6, fileobj=zbuf) as zfile: | |
return zfile.read() | |
class ForceDebugJSONMiddleware(object): | |
def process_response(self, request, response): | |
"""Add html, head, and body tags so debug toolbar will activate.""" |
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 pprint | |
def nested_tree(edges): | |
nested = {} | |
for from_, to in edges: | |
value = {} | |
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 multiprocessing.pool import ThreadPool | |
import logging, os, threading | |
from StringIO import StringIO | |
import boto.s3 | |
logger = logging.getLogger('s3upload') | |
class MultiPartUploader: | |
upload_part = 0 |
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 cookielib | |
import json | |
import re | |
import random | |
import unittest | |
import requests | |
from wordpress_xmlrpc import Client, WordPressComment, WordPressPost |
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 types | |
from django.conf import settings | |
from urllib import urlencode | |
from django.core.cache.backends.base import BaseCache | |
from django.utils.encoding import smart_str | |
#future-proofing against any Django upstream additions of new cache methods. | |
# If we didn't do this, we'd silently use the base class's methods, which wouldn't | |
# use the prefix as required. | |
_expected_methods = set(['__contains__', '__init__', 'add', 'close', |
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 socket | |
def sockrecv(sock): | |
d = '' | |
while not d or d[-1] != '\n': | |
d += sock.recv(8192) | |
return d | |