On my community site I have set adsense to appear under the title of every post. Adsense is playing nice and only showing three ad blocks and ignoring the rest. I want it to do this, as I don't want to break any TOS rules. However, is having more than three pieces of _adsense code_ allowed, even if only three are showing ads?
No, it is actually against their policy to have more than 3 ads on each page. https://www.google.com/adsense/policies?sourceid=asos&subid=ww-ww-et-resource_box&medium=link reads
Everytime google's show_ads.js included it counts ads already embedded in the document, so code if(a.google_num_ad_slots > 3 && h == "") return Code (markup): just interrupts showing more than 3 ads. What about TOS compliance, I almost certain if you'll ask them, they answer "it is against TOS". So I recommend to control adsense inclusion on the server side.