Some bits of code I use regularly