Skip to content

Instantly share code, notes, and snippets.

@jhrr
jhrr / gol.py
Created June 5, 2014 10:51
Jack Diederich's implementation of Conway's "Game of Life"
import itertools
def neighbors(point):
x, y = point
yield x + 1, y
yield x - 1, y
yield x, y + 1
yield x, y - 1
yield x + 1, y + 1
yield x + 1, y - 1
@jhrr
jhrr / hstore.md
Last active August 29, 2015 14:02
hstore install issue

Error:

"hstore type not found in the database. "
django.db.utils.ProgrammingError: hstore type not found in the database. 
please install it from your 'contrib/hstore.sql' file

Fatal error: local() encountered an error (return code 1) while 
executing 'python manage.py syncdb --noinput'
@jhrr
jhrr / template_ipdb.py
Created June 17, 2014 11:21
django template debugger
"""
Source: http://www.djangosnippets.org/snippets/1550/
Notes
=====
This allows you to set up a breakpoint anywhere in your template code,
by simply writing {% pdb_debug %}.
You can then access your context variables using context.get(..) at the pdb
prompt. Optionally, install the ipdb package for colors, completion, and more (easy_install ipdb).
@jhrr
jhrr / object_list.py
Last active August 29, 2015 14:02
object list total hack
from django.generic import ListView
def object_list(request, queryset, extra_context=None, template_name='', paginate_by=None):
"""list_detail.object_list replacement.
This allows you to avoid having to refactor any of your function-based
views that used object_list into class-based views because of the
deprecation of object_list in >= django 1.5. If you must.
@jhrr
jhrr / tmux.md
Created July 23, 2014 14:45 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@jhrr
jhrr / makelog.sh
Created July 27, 2014 17:09
log the commands run by a makefile
# captures a complete list of the commands run by a makefile
make clean && make -j1 > log.txt
@jhrr
jhrr / ssh.completion.bash
Last active August 29, 2015 14:06
you complete me
#!/usr/bin/env bash
# Bash completion support for ssh
# Source: https://github.com/revans/bash-it
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
_sshcomplete() {
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
if [[ ${CURRENT_PROMPT} == *@* ]] ; then
local OPTIONS="-P ${CURRENT_PROMPT/@*/}@ -- ${CURRENT_PROMPT/*@/}"
@jhrr
jhrr / fabric.completion.bash
Created September 26, 2014 13:02
you complect me
#!/usr/bin/env bash
#
# Bash completion support for Fabric (http://fabfile.org/)
#
#
# Copyright (C) 2011 by Konstantin Bakulin
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@jhrr
jhrr / quiet_irssi.txt
Created October 7, 2014 18:30
Quiet irssi. Dammit I really hate irssi
/IGNORE * JOINS PARTS NICKS QUITS