Well, there really isn’t any way to prevent shooting yourself in the foot while programming but this funny article explains how to do it in almost every language.
http://www.fullduplex.org/humor/2006/10/how-to-shoot-yourself-in-the-foot-in-any-programming-language/ (via digg)
I especially like the UNIX example.