Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am willist on github.
* I am timwillis (https://keybase.io/timwillis) on keybase.
* I have a public key ASDJSN0rdiHyd1rtsz4BI41h3NE29zKt954AWftP5WwrfQo
To claim this, I am signing this object:
@willist
willist / .gitconfig
Last active August 29, 2015 14:05
Useful git aliases
[alias]
g = grep --break --heading --line-number
purr = pull --rebase
disp = log --left-right --graph --cherry-pick --oneline @{u}..
@willist
willist / retry_decorator.py
Created June 4, 2013 15:41
A retry decorator which swallows exceptions until the retry limit is reached.
import time
import math
import logging
retry_logger = logging.getLogger('retry_logger')
# Retry decorator with exponential backoff
def retry(tries, delay=3, backoff=2):
'''Retries a function or method until it completes or the retry limit is reached.
@willist
willist / chunky.py
Last active December 15, 2015 13:09
Chunkify your iterable.
"""
Chunk a sequence similar to the itertools grouper recipe, but without the filler.
>>> list(chunky(range(10), 0))
[]
>>> list(chunky(range(10), 1))
[(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,)]
>>> list(chunky(range(10), 5))
@willist
willist / tricks.rst
Last active December 14, 2015 15:49
Unix tricks

Bash

  • ctrl-r searches your command history as you type
  • Add set -o vi in your ~/.bashrc to make use the vi keybindings instead of the Emacs ones. Takes some time to get used to, but it's fantastic!
  • Input from the commandline as if it were a file by replacing command < file.in with command <<< "some input text"
  • '^' is a sed-like operator to replace chars from last command ls docs; ^docs^web^ is equal to ls web The second argument can be empty.
@willist
willist / sqlserver_setup.rst
Created May 23, 2012 14:14
Configuring SquirrelSQL and MSSQL