I used to play a lot of video games. I dread to count the hours spent doing this. Now, I don't play much anymore, though I have occasional bouts where I go on a
total gaming spree. Usually that leaves me pretty depressed afterwards.
I currently have a hope that this will not happen anymore, now that I view being able to learn programming as a fun 'hobby'. That is, when I'm working on science-related stuff now, and I lack motivation, I tell myself that "once you're done with this, you can learn more programming". And it seems to work.
At least for now. I have found that many of these motivational techniques are fleeting, so it remains to be seen whether this technique stands the test of time.
However, I do believe that the key to being productive is to combine several techniques that work for you. So if I combine the "learn programming once you're done" technique with some kind of variation on the Pomodoro technique mentioned in an earlier post, maybe the combination will yield good results.
In the end, though, I think it's a matter of teaching your brain to operate differently - to eke out new neuron patterns so that the brain have less resistance
in those directions I want it to go. The way there can be hard and painful, though!