Skip to content

Instantly share code, notes, and snippets.

View bjinwright's full-sized avatar

Brian Jinwright bjinwright

View GitHub Profile
"""
@author Jay Taylor [@jtaylor]
@date 2010-11-01
Copyright Jay Taylor 2010
"""
#import socks
import socket
@beaufour
beaufour / language.py
Created November 30, 2012 16:00
Django Middleware to choose language based on subdomain
import logging
from django.utils import translation
class SubdomainLanguageMiddleware(object):
"""
Set the language for the site based on the subdomain the request
is being served on. For example, serving on 'fr.domain.com' would
make the language French (fr).
@dokterbob
dokterbob / validators.py
Created August 31, 2011 15:03
Validator for files, checking the size, extension and mimetype.
from os.path import splitext
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.template.defaultfilters import filesizeformat
class FileValidator(object):
"""
Validator for files, checking the size, extension and mimetype.
@girasquid
girasquid / s3store.py
Created February 9, 2010 19:46
Turn S3 into a key/value store for JSON objects.
import simplejson
from boto.s3.connection import S3Connection
from boto.s3.key import Key
class S3KeyStore(object):
def __init__(self, access_key, secret_key, bucket):
self.conn = S3Connection(access_key, secret_key)
self.bucket = self.conn.create_bucket(bucket)
def get(self, key):