useful code snippets and algorithms