View gist:1887230
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): |
View gist:1893856
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 |
View gist:1933635
{ | |
"folders": | |
[ | |
{ | |
"path": "django_project_dir" | |
}, | |
{ | |
"path": "lib/python2.7" | |
} | |
], |
View gist:2346563
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 |
View gist:2732551
_, filename, _, _ := runtime.Caller(1) | |
f, err := os.Open(path.Join(path.Dir(filename), "data.csv")) |
View gist:2998268
$ 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 |
View gist:2998280
$ 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. |
View gist:3440646
from django.db import models | |
# Assuming this model. | |
class Example(models.Model): | |
image = models.ImageField(upload_to="somewhere/special") | |
# You want to set this field to point to an existing image (in a script, or a view, etc.). | |
example = Example.objects.get(id=1) |
View gist:3553617
%install_ext https://raw.github.com/abrookins/django_notebook/master/django_notebook.py |
OlderNewer