Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python2.7
import sys, os, time
def usage():
print 'Usage:'
print ' $ get_time_since [ (-f | --format) "format string"] /path/to/file'
sys.exit(0)
def get_time_since(event, format_string="%s"):
@ktravis
ktravis / dolast
Created August 6, 2013 15:54
A bash function to do the last $1 commands, and combine them in history.
#dolast - for the lazy
# usage: dolast <n>
# where <n> is a positive integer representing the number of commands to repeat.
#
# example:
# $ echo "foo"
# foo
# $ echo "bar"
# bar
# $ echo "baz"
@ktravis
ktravis / fdl (fish-do-last)
Last active December 20, 2015 17:08
Fish-do-last is dolast, for fish-shell.
# $ echo "kermit"
# kermit
# $ echo "fozzie bear"
# fozzie bear
# $ echo "miss piggy"
# miss piggy
# $ fdl 3
# kermit
# fozzie bear
# miss piggy
@ktravis
ktravis / vimrc
Last active December 20, 2015 17:08
vimrc
" basic --------------------------------------------------- {{{
" colors
set t_Co=256
syntax on
set nocompatible
set wrap " for long lines
set textwidth=80 " #
set formatoptions=qrn1 " #
@ktravis
ktravis / reel (up)
Created August 6, 2013 21:50
reel is an "up" command for fish, inspired by reddit.
function reel
if test -f $argv[1]
cd ..
else
if pwd | grep -q "$argv[1]"
set x (dirname $PWD)
while test -z (echo (basename $x) | grep "$argv[1]")
set x (dirname $x)
end
cd "$x"
@ktravis
ktravis / cookie-clicker-clicker
Last active December 23, 2015 22:29
A clicker for cookie clicker. Refresh to reset.
@ktravis
ktravis / gitc.sh
Last active December 24, 2015 08:39
function for git clone laziness
gitc () {
if [[ $1 == */* ]]; then
git clone https://github.com/$1 $2
else
git clone https://github.com/$1/$2 $3
fi
}
" basic --------------------------------------------------- {{{
" colors
set t_Co=256
syntax on
set nocompatible
set wrap " for long lines
set textwidth=80 " #
set formatoptions=qrn1 " #
@ktravis
ktravis / fish-gitc
Created March 30, 2014 01:23
gitc for the fish sell
function gitc
if set -q argv[2] # two args
git clone https://github.com/$argv[1]/$argv[2]
else # one arg
git clone https://github.com/$argv[1]
end
end
@ktravis
ktravis / pre-commit
Created August 27, 2015 15:33
git hook to run tests pre-commit
#!/bin/bash
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
RET=0
if [ "$CURRENT_BRANCH" != "gh-pages" ]; then
make test
RET=$?
fi
exit $RET