some useful code snippets.