snippets of useful js code