various code snippets and algorithms