Concentrate of fostering positive outcomes instead of fighting the negative ones. What do you want to accomplish?
Say, you want to write a new mobile app. Your desire itself will consist of rational analysis and emotional drive, the former being required to make it a sound business and the latter required to plow through to the finish line. Before you start, ask yourself - how much will this project take? one month? Let's make it three months - a good estimate for overruns. Do you have enough drive to plow through it without distraction? If the answer is a resounding, enthusiastic form-the-top-of-your-lungs yes, go right ahead - you will not be distracted because the shining beacon of the goal will pull you in the right direction.
If the answer came up short of "super yes", you need to plan a set of activities that will replenish your enthusiasm. Early user feedback works best for me (and if you can't get it your business itself is iffy). Peer encouragement is second best, if you can get it(that's a good reason to apply to YC). Quality business metrics themselves are motivating in an addictive way, just make sure to get addicted to the right metrics. Lastly, try something that your family and non-techie friend can relate to. If you keep telling everyone in your social circle what you do and they keep staring blank in return it will get to you one day, underminign your motivation. Plan ahead and don't let that happen.
And finally, remember back to what motivated you in the past and do more of that. When you sit right now in front of the computer reading this post you might not remember much right away, but as you spend more time thinking about "what really gets me going" in the coming days, things will start coming to the surface. Write them down as they do.