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
# pip install growl-py | |
try: | |
import Growl | |
i = Growl.Image.imageFromPath('media/img/amo2009/logo-mozilla.gif') | |
g = Growl.GrowlNotifier(applicationName='z', applicationIcon=i, | |
notifications=['Info']) | |
g.register() | |
g.notify('Info', 'ZAMBONI', None) | |
except Exception, e: |
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
""" | |
Apply a decorator to a whole urlconf instead of a single view function. | |
Usage:: | |
>>> from urlconf_decorator import decorate | |
>>> | |
>>> def dec(f): | |
... def wrapper(*args, **kw): | |
... print 'inside the decorator' |
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
""" | |
A monkeypatch for ``django.dispatch`` to send signals asynchronously. | |
Usage:: | |
>>> import async_signals | |
>>> async_signals.start_the_machine() | |
``django.dispatch.Signal.send`` is replaced with an asynchronous version that | |
adds the signal to a queue processed on a background thread. The synchronous |
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
#!/usr/bin/env python | |
""" | |
./crush.py [host:port] | |
Runs a bunch of SADD and DELETE commands against Redis to see how it handles | |
high load. Do `./crush.py &` a bunch of times to generate a lot of | |
connections. | |
""" | |
import hashlib | |
import random |
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
#!/bin/bash | |
# Sets ~site_packages and tries to `cd ~/dev/<virtualenv`. | |
site_packages=$(virtualenvwrapper_get_site_packages_dir) | |
PROJECT=`basename $VIRTUAL_ENV` | |
DIR="$HOME/dev/$PROJECT" | |
if [ -d $DIR ]; then |
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
""" | |
A server that accepts a connection and then hangs. Pass a number to bind to a | |
specific port. | |
You need socket.settimeout. | |
""" | |
import socket | |
import sys | |
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 socket | |
def main(): | |
server = socket.socket() | |
server.bind(('localhost', 9999)) | |
server.listen(1) | |
print 'listening on :9999' | |
client = server.accept()[0] | |
while 1: |
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
"""SMTP email backend class.""" | |
from django.core.mail.backends import smtp | |
class EmailBackend(smtp.EmailBackend): | |
""" | |
A wrapper that manages the SMTP network connection. | |
""" |
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 re | |
import sys | |
logs = {} | |
regex = re.compile('z.timer:INFO (?P<method>\w+) "(?P<url>[^"]+)" ' | |
'\((?P<code>\d+)\) (?P<time>[\d.]+) :') |
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 collections | |
import json | |
import locale | |
import sys | |
import jingo | |
from babel.support import Format | |
KEY = 'Views' |