From http://www.mesuva.com.au/blog/concrete5/useful-concrete5-coding-snippets/