various code snippets which I found useful