Reading through these posts there are many solutions, most of them are vague -- no clear method of implementation. I'll offer an actionable strategy which I have been using to progress from a depressed late 20something dependent on family charity, to graduating a competitive coding bootcamp and building prototypes for a startup.

The key is to exercise those proper faculties of mind -- a few simple exercises are cold showers, long-distance running, and meditation.

Cold showers have taught me how to overcome the initial difficulties; to continuously put oneself into a position of discomfort, then use powers of consciousness to develop acceptance is a powerful practice. There are various methods to implement this habit -- at the end of my shower, I set a timer for 5 minutes and progressively drop the temperature whenever I acclimate to the current state. The game I play is to spend the longest amount of time in the coldest water by dropping progressively quicker during those 5 mins. Challenging yourself is a reward within itself.

Where cold showers build mental strength in the domain of environmental changes, long-distance running builds endurance. As a side-effect, there is a strong correlation between mental health and cardio exercise, aerobic exercise generates BDNF which acts as a precursor for neurogenesis. Depressed people often have smaller hippocampi, and BDNF literally grows neurons in the hippocampus, where we store memory. There are many other evidence-based positive side effects. For implementation, I would suggest the Maffetone method, which teaches users to never push to hard, as it leads to burnout; but instead to progressively build up endurance by exercising at a comfortable rate. The only tool necessary is a heart-rate monitor, and any type of cardio activity can be substituted. His method is used successfully by ironmen and triathlete winners. It's a method to learn patience.

Samadhi is a state characterized as intense one-pointed concentration established through meditation. It is impossible to practice meditation without practicing those steps which lead towards a meditative mind. The yoga sutras of patangili provide a programmatic method towards this state. What is practiced by most popular western yoga is the practice of asana, or preparing the body for meditation. Following asana is pranayama, which is the regulation of breath through various practices. It is thought that breath control is the vector which enables us to manage the rest of our autonomic system, which enables our own internal state to control how we react to events -- the fundamental basis for freedom. It is difficult to discover teachers for these practices. Practically, I would suggest searching for Wim Hof's breathing method as a good introduction or entertaining exercise. Michaël Bijker is for those more serious.

Overall, implementing any one exercise should help you towards your goal, together they provide a strong basis. I've found scheduling to be effective for consistency. I would be lying if I did not mention I received help from a pharmaceutical as well. Having developed non-productive habits in the past, the pharmaceutical helped as a motivational catalyst, although medicine in relation to mental health is not magic, it requires effort and consistency to develop healthy habits.