"I had a "gift" of being really creative and having my best ideas just before sleep, just waking up, and during insomnia episodes."
This is called Hypnogogia http://en.wikipedia.org/wiki/Hypnogogia
The only way I can definitely replicate it is to stay up all night. The next day I will feel a lot more creative, but at the same time a lot less coordinated, frequently tired and not able to concentrate on doing something complicated. Also it's super easy to forget things, so you need to write down all your ideas.
I dunno if you often for instance stay up very very late with friends talking about things, but I think there is a similar effect at some point.