Skip to content

Instantly share code, notes, and snippets.

@streeter
streeter / port-update-notifier.sh
Last active November 22, 2017 22:22
Display notifications via Growl when updates to MacPorts are available.
#!/bin/bash
#
# Notify of MacPort updates via Growl on Mac OS X
#
# Author: Chris Streeter http://www.chrisstreeter.com
# Requires: Growl Notify Extra to be installed (but fails gracefully). Info
# about how to get the extra is at http://growl.info/extras.php
TERM_APP='/Applications/Terminal.app'
@streeter
streeter / gist:1163561
Created August 22, 2011 21:03 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job:
Co-founder at Educreations
Favorite Python project:
Django
Favorite Conference:
Google I/O (so far)
Python Experience Level:
@streeter
streeter / brew-update-notifier.sh
Last active November 18, 2015 17:21
Homebrew Package Update Notifications via Growl
#!/bin/bash
#
# Notify of Homebrew updates via Growl on Mac OS X
#
# Author: Chris Streeter http://www.chrisstreeter.com
# Requires: Growl Notify Extra to be installed. Install with
# brew install growlnotify
TERM_APP='/Applications/Terminal.app'
@streeter
streeter / redis_session.py
Created November 11, 2011 23:05 — forked from mikeyk/redis_session_backend.py
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
from redis.exceptions import ConnectionError
class SessionStore(SessionBase):
"""A redis-based session store."""
@streeter
streeter / pre-commit.py
Created November 18, 2011 16:02
Python .git/hooks/pre-commit hook
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
CHECKS = [
@streeter
streeter / runner.py
Created December 9, 2011 23:54 — forked from carljm/runner.py
Unittest2 test discovery and real dotted-path named test selection for Django
from django.conf import settings
from django.test.simple import DjangoTestSuiteRunner, reorder_suite
from django.utils.unittest import TestCase
from django.utils.unittest.loader import defaultTestLoader
class DiscoveryDjangoTestSuiteRunner(DjangoTestSuiteRunner):
def build_suite(self, test_labels, extra_tests=None, **kwargs):
if test_labels:
return super(DiscoveryDjangoTestSuiteRunner, self).build_suite(test_labels, extra_tests=extra_tests, **kwargs)
@streeter
streeter / brew-update-notifier.sh
Last active March 2, 2022 17:57
Homebrew Package Update Notifications on Mountain Lion
#!/bin/bash
#
# Notify of Homebrew updates via Notification Center on Mac OS X
#
# Author: Chris Streeter http://www.chrisstreeter.com
# Requires: terminal-notifier. Install with:
# gem install terminal-notifier
TERM_APP='/Applications/Terminal.app'
BREW_EXEC='/usr/local/bin/brew'
@streeter
streeter / slowqueryconvert.py
Created September 19, 2012 19:18
Convert RDS slow_query Table Log to text format
#!/usr/bin/env python
"""
Queries the slow_log database table maintained by Amazon RDS and outputs
it in the normal MySQL slow log text format for parsing by mk-query-
digest.
"""
import argparse
import _mysql
[streeter@mail]:~$ source /usr/local/bin/virtualenvwrapper.sh
Traceback (most recent call last):
File "/usr/lib/python2.6/logging/handlers.py", line 72, in emit
self.doRollover()
File "/usr/lib/python2.6/logging/handlers.py", line 129, in doRollover
os.rename(self.baseFilename, dfn)
OSError: [Errno 13] Permission denied
Traceback (most recent call last):
File "/usr/lib/python2.6/logging/handlers.py", line 71, in emit
if self.shouldRollover(record):
@streeter
streeter / arbiter.py
Created February 20, 2013 02:25
Properly reexec gunicorn's Arbiter
def reexec(self):
"""\
Relaunch the master and workers.
"""
self.kill_workers(signal.SIGQUIT)
fds = [l.fileno() for l in self.LISTENERS]
os.environ['GUNICORN_FD'] = ",".join([str(fd) for fd in fds])
os.chdir(self.START_CTX['cwd'])