Skip to content

Instantly share code, notes, and snippets.

View mastensg's full-sized avatar

Martin Stensgård mastensg

View GitHub Profile
@mastensg
mastensg / whereis.py
Created September 9, 2013 20:23
Tabular git-annex whereis
#!/usr/bin/env python
import subprocess
import sys
repos = {}
paths = []
command = ["git", "annex", "whereis"] + sys.argv[1:]
output = subprocess.check_output(command)
@mastensg
mastensg / whereis2.py
Created September 9, 2013 21:08
whereis alternative
#!/usr/bin/env python
import subprocess
import sys
repos = {}
paths = []
command = ["git", "annex", "whereis"] + sys.argv[1:]
output = subprocess.check_output(command)
@mastensg
mastensg / ctrlz.sh
Last active January 6, 2016 03:58
Use Ctrl-Z to resume
bind '"\C-z":" \C-u fg\C-j"'
trap "stty susp '^z'" DEBUG
PROMPT_COMMAND="stty susp ''"
#!/bin/sh
CACHE="/tmp/p2k12_users"
update_cache() {
curl -s https://p2k12.bitraf.no/users |
awk '{printf $NF ":" $1; for(i=2;i<NF;++i){printf " "$i;}print ""}' | sort > $CACHE
}
test -f $CACHE || update_cache
#!/usr/bin/env python3
import psycopg2
import tornado.ioloop
import tornado.web
import tornado.options
LISTEN = 2000
~ $ cat .vim/ftplugin/python.vim
function! PythonFormat()
let l:w = winsaveview()
:%!autopep8 -
call winrestview(l:w)
endfunction
nmap <buffer> :call PythonFormat()<CR>
~ $