Skip to content

Instantly share code, notes, and snippets.

View abrookins's full-sized avatar

Andrew Brookins abrookins

View GitHub Profile
@abrookins
abrookins / gist:1887230
Created February 22, 2012 21:00
Get the name of the class of a decorated method in Python 2.7
def print_class_name(fn):
"""
A decorator that prints the name of the class of a bound function (IE, a method).
NOTE: This MUST be the first decorator applied to the function! E.g.:
@another_decorator
@yet_another_decorator
@print_class_name
def my_fn(stuff):
@abrookins
abrookins / gist:1893856
Created February 23, 2012 17:14
Get the name of the class of a decorated method in Python 2.6
def print_class_name(fn):
"""
A decorator that prints the name of the class of a bound function (IE, a method).
This version works with Python 2.6.
NOTE: This MUST be the first decorator applied to the function! E.g.:
@another_decorator
@yet_another_decorator
@print_class_name
@abrookins
abrookins / gist:2346563
Created April 9, 2012 21:10
Add submodules to a git repo for every directory in the current directory
for dir in *; do cd $dir && git remote show origin -n | grep Fetch | awk '{split($0,array," ")} END{print array[3]}' | xargs -I {} git submodule add {} $dir && cd ..; done
@abrookins
abrookins / gist:2732551
Created May 19, 2012 22:09
Open a data file in the same directory as the current file
_, filename, _, _ := runtime.Caller(1)
f, err := os.Open(path.Join(path.Dir(filename), "data.csv"))
$ python --version
Python 2.6.5
In [1]: import dogapi
In [2]: quit()
Exception in thread Thread-2 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
$ python --version
Python 2.6.5
$ sudo /etc/init.d/datadog-agent restart
Stopping datadog agent: (using supervisorctl) collector: stopped
dd-agent.
Starting datadog agent: (using supervisorctl) collector: started
forwarder: ERROR (abnormal termination)
dd-agent.
@abrookins
abrookins / gist:3553617
Created August 31, 2012 14:32
Install django_notebook extension from within IPython
%install_ext https://raw.github.com/abrookins/django_notebook/master/django_notebook.py
@abrookins
abrookins / gist:3553655
Created August 31, 2012 14:33
Add django_notebook extension to IPython config
c.InteractiveShellApp.extensions = [
'django_notebook'
]
@-webkit-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#sVim-command {