Discipline is one of the biggest things.
Motivation is not enough, everyone has good days and bad days like when you don't feel like coding.
Establish a goal for 3 months/6 months/1 year/10 years, something realistic (let's say you want to get a new car... that will be in the next 2 years or something ).
Take 10 minute breaks every 1-2 hours and move around during that time. Go grab a coffee or something, it will increase your dopamine levels.
When you take a new project always take 30% extra time from your initial evaluation (that's to make sure you don't end up with 12 hour coding push )...