modafinil at a very low dose might help you stay on task. But be sure not to get stuck on some random useless task. I've found that I get super focused on the details of something. But I don't think that is really the right mindset for writing good code.