I just read this quote from Steve Jobs:
Also a quote from that article:
He was hardly alone among computer scientists in his appreciation of hallucinogenics and their capacity to liberate human thought from the prison of the mind.
Although I am aware of the fact that Jobs was not a programmer, this quote got me thinking if there's any evidence to support the theory that drugs can help make a "better" programmer.
- Has there ever been a study where programmers have been given drugs to see if they could produce "better" code?
- Is there a well-known programming concept or piece of code which originated from people who were on drugs?
So I did a little more research and it turns out Dennis R. Wier actually documented how he took LSD to wrap his head around a coding project:
At one point in the project I could not get an overall viewpoint for the operation of the entire system. It really was too much for my brain to keep all the subtle aspects and processing nuances clear so I could get a processing and design overview. After struggling with this problem for a few weeks, I decided to use a little acid to see if it would enable a breakthrough, because otherwise, I would not be able to complete the project and be certain of a consistent overall design
There is also an interesting article on wired about Kevin Herbet, who used LSD to solve tough technical problems and chemist Kary Mullis even said
"...that LSD had helped him develop the polymerase chain reaction that helps amplify specific DNA sequences." 
Sadly the question was closed again but there was a great discussion on HackerNews.
From HN user pchivers:
From what I understand there is only one study on the relationship between creativity and LSD: Psychedelic agents in creative problem-solving: a pilot study. Harman WW, McKim RH, Mogar RE, Fadiman J, Stolaroff MJ. Psychol Rep. 1966 Aug;19(1):211-27. http://en.wikipedia.org/wiki/Psychedelics_in_problem-solving... The results suggested that LSD has a positive effect on creative problem solving. I think it is a shame that no follow-up experiments have been conducted.