Skip to content

Instantly share code, notes, and snippets.

from nose.tools import eq_
from patch import Patch
from unittest import TestCase
class SampleOld:
SETTING = None
def __init__(self, msg):
@lentil
lentil / patch.py
Created April 18, 2011 21:09
Control monkey-patch scope with a context manager
from __future__ import with_statement
from types import ClassType, MethodType, TypeType
class Patch(object):
class Missing:
pass
def __init__(self, obj, **kwargs):
@lentil
lentil / gist:810399
Created February 3, 2011 22:55
PEP8 pre-commit hook in Python
#!/usr/bin/env python
from __future__ import with_statement
import os
import re
import shutil
import subprocess
import sys
import tempfile
# paths
export PATH="/usr/local/bin:/usr/local/pgsql/bin:/usr/local/git/bin/:/usr/local/redis:$PATH"
export MANPATH=/usr/local/man:/usr/local/pgsql/man:/usr/local/git/share/man:$MANPATH
# history
HISTFILE=$HOME/.zhistory
HISTSIZE=100000
SAVEHIST=100000
setopt INC_APPEND_HISTORY
setopt HIST_IGNORE_DUPS
function! MakeSession()
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
if (filewritable(b:sessiondir) != 2)
exe 'silent !mkdir -p ' b:sessiondir
redraw!
endif
let b:filename = b:sessiondir . '/session.vim'
exe "mksession! " . b:filename
endfunction
function! LoadSession()