I wouldn't call it a drug, but the root of Sweet Flag (
acorus calamus), chewed, has often helped me to get through a particularly vexing problem, be it in code or in life, in the cleanest and most rational manner. Calamus is an amazing little plant.
I don't recommend the entheogenic route that some young psychonauts have tried, as it's a sure-fire recipe for an exceptionally unpleasant experience.
Caffeine might keep me going, but it's often in the wrong direction. I might solve the problem at hand, but it's likely to be in some verbose, obtuse manner.