Skip to content

Instantly share code, notes, and snippets.

View andymccurdy's full-sized avatar

Andy McCurdy andymccurdy

  • San Francisco, CA
View GitHub Profile
events {
worker_connections 1024;
}
http {
# Set cache dir
proxy_cache_path /var/nginx-cache levels=1:2 keys_zone=microcache:5m;
@andymccurdy
andymccurdy / gist:891956
Created March 29, 2011 07:43
FU Django ORM
#good
Foo.objects.get(fk=45)
#not good
Foo.objects.get(fk_id=45)
#good
Foo.objects.create(fk_id=45)
#not good
Foo.objects.create(fk=45)
@andymccurdy
andymccurdy / crier.py
Created December 11, 2010 01:09
Crier: simple introspection for long-running Python processes
import pprint
import os
import sys
import threading
import time
import traceback
_crier = None
def init_crier(temp_dir='/tmp'):
"Initialzies Crier, ensuring it's only created once in the process"
<script type="text/javascript">
   pageTracker._trackEvent('Ads', 'Quest Shown', '{{quest.name|slugify}}');
</script>
import time
import threading
import redis
def worker():
print "starting thread..."
r = redis.Redis(db=9)
for i in xrange(2000):
r.incr('foo')
import threading
import Queue
q = Queue.Queue()
def worker():
while True:
msg = q.get(block=True)
# do stuff with the message
t = threading.Thread(target=worker)