I hereby claim:
- I am akheron on github.
- I am akheron (https://keybase.io/akheron) on keybase.
- I have a public key whose fingerprint is B5D6 953E 6D50 59ED 7ADA 0F2F D365 7D24 D058 434C
To claim this, I am signing this object:
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
} |
# From http://derblub.com/human-readable-and-by-size-sorted-disk-usage-in-bash | |
function duf { | |
du -sk "$@" | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done | |
} |
I hereby claim:
To claim this, I am signing this object:
# Keybindings | |
unbind C-b | |
set -g prefix C-z | |
bind z send-prefix | |
bind escape copy-mode | |
bind C-z last-window | |
bind p select-pane -t :.-1 | |
bind n select-pane -t :.+1 |
# Usage: | |
# Run the server like this (for example): | |
# DJANGO_SETTINGS_FILE=/path/to/settings.py ./manage runserver --settings=pythonpath.to.settings | |
# where pythonpath.to is the directory containing this file and is found in PYTHONPATH. | |
def load_settings(): | |
import os | |
del globals()['load_settings'] | |
path = os.environ.get('DJANGO_SETTINGS_FILE', |
-- PostgreSQL | |
SELECT | |
'ALTER TABLE ' || source_tbl.relname || ' ' || | |
'DROP CONSTRAINT '|| constr.conname ||'; ' || | |
'ALTER TABLE ' || source_tbl.relname || ' ' || | |
'ADD CONSTRAINT ' || constr.conname || ' ' || | |
'FOREIGN KEY (' || source_col.attname || ') ' || | |
'REFERENCES new_table_name (primary_key_name);' | |
FROM pg_constraint constr | |
INNER JOIN pg_class target_tbl ON constr.confrelid = target_tbl.oid |
# Automatically activate Git projects' virtual environments based on the | |
# directory name of the project. Virtual environment name can be overridden | |
# by placing a .venv file in the project root with a virtualenv name in it | |
function workon_cwd { | |
# Check that this is a Git repo | |
GIT_DIR=`git rev-parse --git-dir 2> /dev/null` | |
if [ $? == 0 ]; then | |
# Find the repo root and check for virtualenv name override | |
GIT_DIR=`\cd $GIT_DIR; pwd` | |
PROJECT_ROOT=`dirname "$GIT_DIR"` |
def eq_diff(a, b): | |
import json, difflib | |
from datetime import datetime | |
if a == b: | |
return | |
class DatetimeEncoder(json.JSONEncoder): | |
def default(self, o): | |
if isinstance(o, datetime): |
# Git repository configuration for a detached worktree. | |
# | |
# Create a bare repository: | |
# | |
# $ git init --bare | |
# | |
# Then change the config to match this file. | |
[core] | |
repositoryformatversion = 0 |
from tornado.ioloop import IOLoop | |
# Calls fn for all items of iterable, saves result to a list, and | |
# calls callback with that list. This is most useful when fn works | |
# asynchronously. | |
def async_map(fn, iterable, callback, io_loop=None): | |
ioloop = io_loop or IOLoop.instance() | |
def loop(): | |
try: |