I found some code snippets on Stack Overflow, but found the Custom Post Limits plugin did everything we needed, with an impressive amount of granularity.