I find short term goals and check list help me focus. I like the feeling for completing something, and I can often get on a roll of checking things off the list. Also, in terms of coding I like to try and write what I need, even if I know it isn't optimal or complete; I usually figure out the solution midway through.