 recipe originally posted to ActiveState Recipes by Raymond Hettiger,
and released under the MIT license.
