Skip to content

Instantly share code, notes, and snippets.

Dick Brouwer dickbrouwer

Block or report user

Report or block dickbrouwer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

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:

View nginx_dev.conf
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 Sep 27, 2012
ZMQ Context reset for Celery
View zmqcontext.py
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 Sep 5, 2012
OSX sed replace a list of files
View replace.sh
find . -type f -name '*.py' -exec sed -i "" "s/str1/str2/g" {} +
View clear_amqp-queue.py
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 Apr 12, 2012
Create singleton using dispatch_once_t
View gist:2368787
+ (UserManager *)sharedManager {
static dispatch_once_t once;
dispatch_once(&once, ^ {
_sharedManager = [[self alloc] init];
});
return _sharedManager;
}
@dickbrouwer
dickbrouwer / gist:2368756
Created Apr 12, 2012
iOS singleton using +initialize
View gist:2368756
+ (void)initialize {
static BOOL initialized = NO;
if (!initialized) {
initialized = YES;
_sharedManager = [Manager new];
}
}
View unit_test_1.py
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()
View vimrc.vim
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>
View auth_forms.py
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'})
You can’t perform that action at this time.