Skip to content

Instantly share code, notes, and snippets.

@akrito
akrito / gist:1137394
Created August 10, 2011 16:53
Packing

Clothes

  • 2 pair underwear
  • 1 t-shirt
  • 1 oxford
  • 1 pair slacks
  • 1 pair sandals
  • 1 pair sunglasses
  • 1 rain jacket
import re, sys
to_find = sys.argv[1]
def find_closing_paren(string, start):
current = start
num_open = 1
for c in string[start:]:
current += 1
ansi_hash () {
# Colors a string based on a hash of its contents
# Usage: ansi_hash [-s style] [-o offset] text ..
style=0 # default is normal, 1 is bold, 4 is underline
offset=30 # default is normal, 90 is high intensity
OPTIND=0
while getopts s:o: a
do case "$a" in
s) style="$OPTARG";;
@akrito
akrito / gist:897054
Created March 31, 2011 19:30
All together
ps1_venv () {
if [ -n "$VIRTUAL_ENV" ]; then
printf ' (%s)' `basename $VIRTUAL_ENV`
fi
}
ps1_err () {
errcode=$?
local prompt=$1
printf "$(ansi_hash ${prompt})"
ansi_hash () {
# Colors a string based on a hash of its contents
# Usage: ansi_hash [-s style] [-o offset] text ..
style=0 # default is normal, 1 is bold, 4 is underline
offset=30 # default is normal, 90 is high intensity
OPTIND=0
while getopts s:o: a
do case "$a" in
s) style="$OPTARG";;
@akrito
akrito / gist:877692
Created March 19, 2011 18:36
Rdio force close on MIUI 1.3.18
device_model:supersonic
build_version:1.3.18
condition:1
processName:com.rdio.android.ui
pid:602
uid:10046
tag:null
shortMsg:java.lang.RuntimeException
longMsg:java.lang.RuntimeException: <internal>: You must supply a layout_height attribute.
stackTrace:java.lang.RuntimeException: <internal>: You must supply a layout_height attribute.
http://pinboard.in/u:blturner
http://pinboard.in/u:akrito/
http://pinboard.in/u:jacobian/
http://pinboard.in/u:nathan/
http://pinboard.in/u:jefftriplett/
http://pinboard.in/u:adamfast/
http://pinboard.in/u:daniellindsley/
http://pinboard.in/u:blturner/
http://pinboard.in/u:mcroydon/
class C(B):
def __init__(self, *args, **kwargs):
B.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs):
super(C, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs):
super(type(self), self).__init__(*args, **kwargs)
try:
from ipdb import Pdb
except ImportError:
from pdb import Pdb
import sys
class PdbTraceback(object):
"""
Drops into pdb or ipdb if a view raises an exception. Should be the last
thing in MIDDLEWARE_CLASSES
"""
/home/alex/v/ellington/src/django/django/middleware/cache.py(116)process_request()
114 """
115 if self.cache_anonymous_only:
--> 116 assert hasattr(request, 'user'), "The Django cache middleware with CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True requires authentication middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the CacheMiddleware."
117
118 if not request.method in ('GET', 'HEAD') or request.GET:
/home/alex/v/ellington/src/django/django/contrib/auth/middleware.py(9)__get__()
7 if not hasattr(request, '_cached_user'):
8 from django.contrib.auth import get_user