This has to be done the night before.
I always quit all online work at least 2 hours before bedtime and print whatever I'm working on.
Then I go into any other room with program listings, blank paper, and pens (especially red!) and plan out all of tomorrow's work.
All analysis, design, and refactoring must be done at this time. I do not allow myself to sleep until the next day's work is laid out. I also do not allow myself to get back onto the computer. The idea is to have a clear "vision" of what I am going to accomplish the next day. The clearer the better.
This does 2 things. First, I think about it all night (maybe even dream about it). Second, I can't wait to get started the next day.
I always wake up and start programming immediately. Once I get going, it's easy to keep going. Any difficulties are probably because I didn't plan well enough the night before.
Not sure if that's the answer you're looking for, but whatever gets the work done...
The next day I can't help but work on it.
Kurzweil: ...When I go to sleep, I assign myself a problem.
Interviewer: For example?
Kurzweil: It might be some mathematical problem or some practical issue for an invention or even a business strategy question or an interpersonal problem. But I'll assign myself some problem where there's a solution, and I try not to solve it before I go to sleep but just try to think about what do I know about this? What characteristics would a solution have? And then I go to sleep. Doing this primes my subconscious to think about it. Sigmund Freud said accurately that when we dream, some of the censors in our brain are relaxed, so that you might dream about things that are socially taboo or sexually taboo, because the various censors in our brain that say "You can't think that thought!" are relaxed. So we think about weird things that we wouldn't allow ourselves to think about during the day.
There are also professional blinders that prevent people from thinking creatively. Mental blocks such as "You can't solve a signal processing problem that way" or "Linguistics is not supposed to be done this way." Those assumptions are also relaxed in your dream state, and so you'll think about new ways of solving problems without being burdened by constraints like that. Another thing that's not working when you're dreaming is your rational faculties to evaluate whether an idea is reasonable, and that's why fantastic things will happen in the dream, and the most amazing thing of all is that you don't think these fantastic things are amazing. So, let's say, an elephant walks through the wall, you don't say, "My God, how did an elephant walk through the wall?" You just say, "OK, an elephant walked through wall, no big deal." So your rational faculties are also not working.
The next step is in the morning, in this half-way state between dreaming and being awake, what I call lucid dreaming, I still have access to the dream thoughts. But now I'm sufficiently conscious to also have my rational faculties. And I can evaluate these ideas, these new creative ideas that came to me during the night, and actually see which ones make sense. After 15 to 20 minutes, generally, if I stay in that state, I can have keen new insights into whatever the problem was that I assigned myself. And I've come up with many inventions this way. I've come up with solutions to problems. If I have a key decision to make, I'll always go through this process. And I'll then have a real confidence in the decision, as opposed to just trying to guess at the answer. So this is the mental technique I use to try to combine creative thinking with rational thinking.