My trick was to figure out the environment in which I love to work and then emulate it.
I love coding in coffee shops where there are a bunch of little things that can push or pull you away from yourself; like the background noise of the people around you, the typical bustle of the caffeine business, and the aroma of coffee. There is a certain flow that I seem to get into that, while not completely disruptive to my focus, allows me to feel the motions of my thoughts while otherwise allowing myself to get distracted every now and then to give my mind some space to "compile." It is random and it is addictive.
Unfortunately, recent changes in my career have prevented me from going to coffee shops to work. I now work at an office with closed cubicles wherein the design aesthetic is bent towards the functional rather than the arresting. So I made do with what I could. I bought a coffee machine that I use every now and then in the mornings to "set the scene." I have a tumbler named Kevin with a sunflower sticker on it, assuring me that I am in fact a sunflower. And best of all, I've discovered lo-fi hip-hop to drown out the harsh echoes of someone's speaker blaring out anime music with the softer tunes of rain, chatter, and some jazzy piano (I have nothing against anime music but I really just can't listen to it being boomed allover the place eight hours a day).
So yeah, my suggestion is figure out what sets you on the mood. It doesn't have to be the sugar-fueled, caffeine-injected adrenaline rush you feel after drinking 8 cups of coffee. It can be as little as whispers of strangers in the next cubicle or a tumbler named Kevin with a sunflower sticker or, you know, 8 hours of blaring anime music. It might be different for each and every one of us, but the point is that some introspection and understanding of "what makes you go" could go a long way in your productivity.
tl;dr I turned my office into a pseudo-coffee shop and this encourages me to work productively.
Happy coding guys!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.