This is based solely on my personal opinion and what works for me. Everyone has something different but if this helps just one person then I will be happy.

1# The Right Music

Everyone has a different taste in music and it's important that you find yours. Personally, I think music without lyrics is the best when trying to concentrate on what you are programming.

The right music programming effective

2# Podcasts

70% of the time I listen to music when programming but the other 30% is filled with podcasts. I try not listen to podcasts to do with programming in any way. I find listening to something funny or informative is best but once again this is down to personal preference.

3# Take a Shower or Bath

Every now and again when I'm about to take on a big programming task or project I take a shower or even better, a bath. This gives me the right environment to relax and think about the best way of tackling the task or project I need to complete. 

4# Have a big Desk

I find having a big desk helps me significantly. If you are cramped into a tiny desk with a computer, keyboard, snacks and various other things then it might get uncomfortable and even distracting at times.  I have a big enough desk to put my laptop, speakers, light and secondary monitor on as well as miscellaneous stuff like food, books, and toys to occupy myself when I'm bored.

5# Toys and Gadgets

Keep a small toy close by to occupy yourself with when you need to take a quick break. A lot of people use a Rubik's cube or simply their phone. I do find using my phone can be overly distracting because I see a new video I want to watch or someone I want to chat with for a while.

toys and gadgets programming rubiks

6# Breaks

Take regular breaks every 45 minutes or every hour. Eat food, watch TV, hang out or go for a run. No one can write code or crush bugs for straight hours. 

7# Excercise

This is so important, it's the most important thing on this list. Go to the gym, go for a run, play some football, literally any sport will help clear your head which will make you perform at your highest.

8# No when to Stop

You are going to reach that point in the day when you cant accomplish what you want. You might get frustrated and angry, that's when you might need to stop and call it quits for the day.