Skip to content

Instantly share code, notes, and snippets.

@jbalogh
jbalogh / httpd.conf
Created April 27, 2010 20:00
Our httpd.conf for zamboni as of right now!
# vim: syntax=apache
WSGISocketPrefix /var/run/wsgi
<VirtualHost *:80 *:81>
ServerName addons.mozilla.org
ServerAlias addons.update.mozilla.org addons-nl.stage.mozilla.com addons-cdn.mozilla.net
DocumentRoot /data/www/addons.mozilla.org-remora/site/app/webroot
SetEnv HTTPS on
Alias /media /data/amo_python/www/prod/zamboni/media
@jbalogh
jbalogh / git-url
Created April 28, 2010 19:28 — forked from davedash/gist:382311
git-url: helps you close bugs good
#!/bin/sh
# Usage: `git url` or `git url <commitish>`
#
# * copies the commit's github url to your clipboard
# * prints out the log message
# * opens the bugzilla page if it found a bug number
#
# Set up the github url with `git config github.url <url>`.
# Only for the Mac.
@jbalogh
jbalogh / omg-update-zamboni.sh
Created May 19, 2010 22:08
oremj's preview update script
#!/bin/bash
GIT=/usr/local/bin/git
DATE=$(date "+%Y/%m/%d %H:%M:%S")
AMO_PYTHON_ROOT=/data/amo_python
function update_previews {
DIR=$1
BRANCH=$2
@jbalogh
jbalogh / gist:423381
Created June 3, 2010 03:09
Generate tables of browser stats from webtrends json output
import collections
import json
import locale
import sys
import jingo
from babel.support import Format
KEY = 'Views'
import re
import sys
logs = {}
regex = re.compile('z.timer:INFO (?P<method>\w+) "(?P<url>[^"]+)" '
'\((?P<code>\d+)\) (?P<time>[\d.]+) :')
"""SMTP email backend class."""
from django.core.mail.backends import smtp
class EmailBackend(smtp.EmailBackend):
"""
A wrapper that manages the SMTP network connection.
"""
@jbalogh
jbalogh / gist:483424
Created July 20, 2010 19:29
An echo server so I remember how to use sockets.
import socket
def main():
server = socket.socket()
server.bind(('localhost', 9999))
server.listen(1)
print 'listening on :9999'
client = server.accept()[0]
while 1:
@jbalogh
jbalogh / hangserver.py
Created August 16, 2010 18:11
A server that accepts a connection and then hangs.
"""
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
#!/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
@jbalogh
jbalogh / crush.py
Created September 15, 2010 20:39
crush.py generates a lot of load for redis
#!/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