What are some methods you use to "trick" yourself into being productive and keeping up your focus?
If you smoke pot, omit indicas when you need to get stuff done. Microdose some sativa (ie: enough for an effect, not enough for a buzz) and you'll be far more focused and not as likely to doze off or space out in the middle of your best coding runs.
If you drink tonnes of coffee, stop that, too. The problem is coffee tends to give you 10 minutes of fire power, and then a half-hour of brain fog. If you "need" the caffeine, choose black tea since it is milder and doesn't result in that inevitable coffee crash.