A really easy way is to tell yourself that you'll write only one line of code. Go ahead and do that. Or that you'll do just one pushup or only one line of your blog... It works wonders.
This seems related to the smart/hard work attitude. If you think you solve problems because you are smart, then come across a problem that seems too difficult you are more likely to give up than if you think you solve problems by working through them. You can't just make yourself smarter but you can work harder.
Along the same lines, I think I have some control over procrastinating. Not so much over being lazy.
At that time I start a pomodoro timer so that I can keep making sure it's useful progress.
I'd like to believe that this is because it's something we love to do inherently but we fear the "setup costs" involved in actually doing the task.