Skip to content

Instantly share code, notes, and snippets.

View ashchristopher's full-sized avatar

Ash Christopher ashchristopher

  • Shopify
  • Toronto, Ontario
View GitHub Profile
#!/bin/sh
setup_brew () {
if ![-f "/usr/local/bin/brew"]; then
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
fi
}
setup_ipython () {
brew install readline
@ashchristopher
ashchristopher / track_data.py
Created July 26, 2012 17:46 — forked from dcramer/track_data.py
Tracking changes on properties in Django
from django.db.models.signals import post_init
def track_data(*fields):
"""
Tracks property changes on a model instance.
The changed list of properties is refreshed on model initialization
and save.
>>> @track_data('name')
@ashchristopher
ashchristopher / graphite-centos6-install.txt
Created May 24, 2012 15:18 — forked from dillera/graphite-centos6-install.txt
Install Graphite 0.9.9 and Statsd on Centos 6
# FOR CENTOS 6
# Andrew Diller Jan 2012
# Get EPEL Repo installed
rpm --httpproxy proxy --httpport 3128 --import https://fedoraproject.org/static/0608B895.txt
rpm -Uvh http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm
vi /etc/yum.repos.d/epel.repo
@ashchristopher
ashchristopher / mem_report.sh
Created April 28, 2012 04:20 — forked from epicserve/mem_report.sh
A quick script for printing out memory usage of various services
CELERY=`ps -A -o pid,rss,command | grep celeryd | grep -v grep | awk '{total+=$2}END{printf("%d", total/1024)}'`
GUNICORN=`ps -A -o pid,rss,command | grep gunicorn | grep -v grep | awk '{total+=$2}END{printf("%d", total/1024)}'`
REDIS=`ps -A -o pid,rss,command | grep redis | grep -v grep | awk '{total+=$2}END{printf("%d", total)}'`
NGINX=`ps -A -o pid,rss,command | grep nginx | grep -v grep | awk '{total+=$2}END{printf("%d", total/1024)}'`
OTHER=`ps -A -o pid,rss,command | grep -v nginx | grep -v celeryd | grep -v gunicorn | grep -v redis | grep -v grep | awk '{total+=$2}END{printf("%d", total/1024)}'`
websites=`ps -A -o user,pid,rss,command | grep gunicorn | egrep -o "[a-z_]+\.py$" | sort | uniq | perl -wpe 's|\.py$||;' | xargs`
printf "%-10s %3s MB\n" "Celery:" $CELERY
printf "%-10s %3s MB\n" "Gunicorn:" $GUNICORN
printf "%-10s %3s MB\n" "Nginx:" $NGINX
printf "%-10s %3s KB\n" "Redis:" $REDIS
@ashchristopher
ashchristopher / test.py
Created April 6, 2012 20:52 — forked from joestump/test.py
A drop-in replacement for Django's test mange.py command that uses coverage.
from django.conf import settings
from django.core.management.base import CommandError
from optparse import make_option
import re
import sys
try:
from south.management.commands.test import Command as BaseCommand
except ImportError:
@ashchristopher
ashchristopher / test-coverage.py
Created January 22, 2012 02:40 — forked from acdha/test-coverage.py
A custom Django test runner with support for coverage.py and graceful handling for app selection and various testing gotchas
#!/usr/bin/env python
"""
Run Django Tests with full test coverage
This starts coverage early enough to get all of the model loading &
other startup code. It also allows you to change the output location
from $PROJECT_ROOT/coverage by setting the $TEST_COVERAGE_OUTPUT_DIR
environmental variable.
"""
@ashchristopher
ashchristopher / README.rst
Created December 15, 2011 19:22 — forked from wolever/README.md
EMPMYMIP: Easily Maintain a PyPI Mirror of Your Important Packages!

EMPMYMIP: Easily Maintain a PyPI Mirror of Your Important Packages!

Status

EMPMYMIP seems to mostly kind of work for me. It might even do the same for you!

The implementation is kind of a huge hack, though, and it might very well

@ashchristopher
ashchristopher / jquery.500frame.js
Created August 12, 2011 19:35 — forked from defrex/jquery.500frame.js
pop-up any 500s in an iframe using jQuery. Especially useful for Django errors.
$(document).bind('ajaxError', function(e, jqXHR){
if (jqXHR.status == 500){
var erframe = document.createElement('iframe');
$('body').append(erframe);
$(erframe).css({
'position': 'absolute',
'top': '5%', 'left': '50%',
'width': '90%', 'height': '90%',
'marginLeft': '-45%',
'z-index' : '9999999'
@ashchristopher
ashchristopher / test.py
Created May 26, 2011 03:18 — forked from joestump/test.py
A drop-in replacement for Django's test mange.py command that uses coverage.
from django.conf import settings
from django.core.management.base import CommandError
from optparse import make_option
import re
import sys
try:
from south.management.commands.test import Command as BaseCommand
except ImportError:
#!/usr/bin/env python
"""
Use pip to get a list of local packages to check against one or more package
indexes for updated versions.
"""
import pip
import sys, xmlrpclib
from cStringIO import StringIO
from distutils.version import StrictVersion, LooseVersion