Why don't you submit this recipe at the PostgreSQL Cookbook? (http://www.brasileiro.net/postgres/cookbook/)
-Roberto