- Turn off e-mail.
- Turn off chat.
- Don't check hacker news. Or any website that is not for your current task.
- Don't let coworkers interrupt you.
- Get noise canceling headphones.
- Have a goal to get through, and apply yourself to it completely.
- Get very good at evaluating 3rd party code, then before you write code, see if there's a library/native code that will do the work for you.
- When you write code, if you _know_ the right way to do something, do it right the first time.
- If you're not _sure_ you know the right way to do something, then just get the code out into the editor. After it's functional, take a look at the code later and decide how it can be refactored. Refactor it immediately.
- Don't write any tough code when you're not at your best mental capacity. When you feel yourself mentally drifting on a hard task, put the code away and go work on easy features. Work on your hardest problems during your best hours.