My favourite code snippets

A compilation of code blocks I find useful.