This article outlines how I use a pre-commit hook and cog to keep my blog stats updated automatically.
The 2 hardest problems in programming are naming, cache invalidation, and off-by-one errors.