This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import threading | |
import redis | |
def worker(): | |
print "starting thread..." | |
r = redis.Redis(db=9) | |
for i in xrange(2000): | |
r.incr('foo') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
pageTracker._trackEvent('Ads', 'Quest Shown', '{{quest.name|slugify}}'); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events { | |
worker_connections 1024; | |
} | |
http { | |
# Set cache dir | |
proxy_cache_path /var/nginx-cache levels=1:2 keys_zone=microcache:5m; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Redis(...): | |
def __init__(self): | |
# dictionary of "installed" scripts to sha's | |
self.loaded_scripts = {} | |
def load_script(self, name, code): | |
"Install a script, giving it a friendly name" | |
sha = self.execute_command('SCRIPT', 'LOAD', code) | |
# save the friendly name => sha | |
self.loaded_scripts[name] = sha |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################################### | |
# WARNING: This is very hacky! Use at your own risk. | |
# | |
# This assumes you have all keys in a single DB and | |
# want to move them all to DB 0. If you have keys | |
# in more than one DB, the first DB found will be | |
# rewritten to 0, with all others left alone. | |
#################################################### | |
import shutil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ~ | |
rm -rf redis | |
git clone https://github.com/antirez/redis.git | |
cd redis | |
make | |
cp src/redis-server /usr/local/bin/ | |
cp src/redis-cli /usr/local/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
====================================================================== | |
ERROR: Failure: ImportError (cannot import name SkipTest) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/Users/andy/.virtualenvs/tested/lib/python2.6/site-packages/nose/loader.py", line 390, in loadTestsFromName | |
addr.filename, addr.module) | |
File "/Users/andy/.virtualenvs/tested/lib/python2.6/site-packages/nose/importer.py", line 39, in importFromPath | |
return self.importFromDir(dir_path, fqname) | |
File "/Users/andy/.virtualenvs/tested/lib/python2.6/site-packages/nose/importer.py", line 86, in importFromDir | |
mod = load_module(part_fqname, fh, filename, desc) |
OlderNewer