Read P.J. Eby's "Thinking Things Done". It's unfinished, but chapters 1-7 are very good. You have to sign up for his mailing list to receive them. I found out about this from http://lesswrong.com/lw/21r/pain_and_gain_motivation/
Consider spending a lot of time alone, or at least outside any institution for a while. Hell is other people. It's hard for me to think clearly when other people's thoughts are an important part of my day.
Consider meditating. (See the recently posted "Mindfulness in Plain English"). I just started, but I'm already getting the same euphoric level of concentration that I get from programming.