Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dickbrouwer on github.
  • I am dickbrouwer (https://keybase.io/dickbrouwer) on keybase.
  • I have a public key whose fingerprint is E6ED E0C4 7AAC 906A 57DF BC1F 12AB FFA5 C939 E941

To claim this, I am signing this object:

server {
listen 80;
server_name dev.websitename.com;
location / {
proxy_pass http://127.0.0.1:8000;
}
location /media/ {
root /var/django/websitename/;
@dickbrouwer
dickbrouwer / zmqcontext.py
Created September 27, 2012 19:01
ZMQ Context reset for Celery
from celery import signals
import zmq
import logging
log = logging.getLogger("app." + __name__)
ZMQ_SOCKET_LINGER = 100
context = zmq.Context()
context.linger = ZMQ_SOCKET_LINGER
@dickbrouwer
dickbrouwer / replace.sh
Created September 5, 2012 17:56
OSX sed replace a list of files
find . -type f -name '*.py' -exec sed -i "" "s/str1/str2/g" {} +
@dickbrouwer
dickbrouwer / clear_amqp-queue.py
Created August 24, 2012 00:03
Clearing AMQP queue
from amqplib import client_0_8 as amqp
conn = amqp.Connection(host="localhost:5672", userid="<user>", password="<passwd>", virtual_host="<vhost>", insist=False)
conn = conn.channel()
conn.queue_purge("<queue_name>")
@dickbrouwer
dickbrouwer / gist:2368787
Created April 12, 2012 16:19
Create singleton using dispatch_once_t
+ (UserManager *)sharedManager {
static dispatch_once_t once;
dispatch_once(&once, ^ {
_sharedManager = [[self alloc] init];
});
return _sharedManager;
}
@dickbrouwer
dickbrouwer / gist:2368756
Created April 12, 2012 16:15
iOS singleton using +initialize
+ (void)initialize {
static BOOL initialized = NO;
if (!initialized) {
initialized = YES;
_sharedManager = [Manager new];
}
}
from django.test import TestCase
from django.utils.importlib import import_module
from django.http import HttpRequest
from django.conf import settings
class SampleTest(TestCase):
def setUp(self):
# Create mock request object with session key
engine = import_module(settings.SESSION_ENGINE)
request = HttpRequest()
filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
filetype plugin indent on
set nocompatible
set modelines=0
let mapleader = ","
inoremap jj <ESC>
class EmailUserCreationForm(UserCreationForm):
'''
User login form class that replaces the 'username' field with
an 'emailfield' on registration, sets email = username in the
User object, and adds case-insensitive username verification.
'''
username = forms.EmailField(label=("Email Address"))
confirm = forms.BooleanField(error_messages={'required':
'Please read and accept the Terms and Conditions to continue'})