Skip to content

Instantly share code, notes, and snippets.

@patrys
patrys / abstract.py
Created September 17, 2010 11:59
Parametrized apps for Django
class AbstractMixin(object):
_classcache = {}
@classmethod
def contribute(cls):
return {}
@classmethod
def construct(cls, *args, **kwargs):
attrs = cls.contribute(*args, **kwargs)
#!/bin/bash
# To run do:
# wget https://gist.github.com/raw/850359/ea02e22f021b7ebf2f602811461677ab4a3f2a9e/bootstrap.sh && chmod +x bootstrap.sh && ./bootstrap.sh && source ~/.profile
#
# Based on Amazon EC2 AMI ID ami-ccf405a5 Ubuntu Server 10.10
# This script will:
# * install/config apache2
# * install mod_wsgi
# * install/config nginx
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
@ericflo
ericflo / send_template_mail.py
Created March 23, 2012 21:12
Send a templated mail
from django.conf import settings
from django.template import Context, loader
from django.core.mail import send_mail
def send_template_mail(slug, context, recipient_list, from_email=settings.DEFAULT_FROM_EMAIL):
if isinstance(recipient_list, basestring):
recipient_list = [recipient_list]
if not isinstance(context, Context):
context = Context(context)
subject_tmpl = loader.get_template('mail/%s/subject.txt' % (slug,))
@akrito
akrito / 60_dropbox
Created April 27, 2012 16:33
.config/byobu/bin/60_dropbox
#!/bin/sh
s=$(/usr/bin/dropbox status)
case "$s" in
"Dropbox isn"*)
echo '💣'
;;
Idle*)
echo '💤'
language: python
python:
- "2.6"
- "2.7"
env:
- DJANGO=1.2.7 SUITE=tests
- DJANGO=1.3.1 SUITE=tests
- DJANGO=1.4 SUITE=tests
- DJANGO=1.4 SUITE=lint
install:
@jpallen
jpallen / gist:2762417
Created May 21, 2012 13:49
Add a .findOrBuild() method to Backbone Models
// Finding and creating models
// ===========================
//
// We might need to get a reference to a model from anywhere in our code
// and we want to make sure that these references all point to the same model.
// Otherwise updates to one copy of the model won't affect another.
//
// The methods here let you get models through a wrapper that will either
// create the model if it doesn't exist anywhere, or return a reference to
// the existing model. E.g.
@brianglass
brianglass / gist:2884627
Created June 6, 2012 20:42
postgres ramdisk
Create ramdisk:
sudo mkdir <foo>
Add to /etc/fstab:
tmpfs <foo> tmpfs size=4G,mode=1700,uid=114,gid=125 0 1
Mount the ramdisk:
@juanriaza
juanriaza / gist:2929272
Created June 14, 2012 09:24
DjangoCon EU 2012 videos
# brew install rtmpdump
print ' && '.join(['rtmpdump -r "rtmp://streamcloud.klewel.com/cfx/st/v0/djangocon-2012-flash-%d.flv" -o djangocon-2012-flash-%d.flv' % (i, i) for i in xrange(1, 45 + 1)])
@adamfast
adamfast / requiredreading.txt
Created July 6, 2012 15:20
Preserved for #lawrence history, this was the "required reading" list of totally-non-work-related inside jokes of the World Online crew.
DJ Ango, yo!
http://railsenvy.com/2007/9/10/ruby-on-rails-vs-django-commercial-7
The Whistles
[now broken] http://www.youtube.com/watch?v=ccgXjA2BLEY
http://www.youtube.com/watch?gl=US&hl=en&client=mv-google&v=Nnzw_i4YmKk
Do it live!
http://www.youtube.com/watch?v=2tJjNVVwRCY
REMIX: http://www.youtube.com/watch?v=5j2YDq6FkVE&NR=1