This is a funny area. I feel quite confident giving prescriptive advice about strategies for software development, but not so much about strategies for dealing with psychological issues like depression and helplessness.
What I can do is share my own experience, and tell you where to find the resources that helped me. Thus... I would say that if anything in the post feels like something that is bothering you or has bothered you in the past, go and read about Learned Optimism, the rough opposite of Learned Helplessness:
https://en.wikipedia.org/wiki/Learned_optimism
And especially Seligman’s self-help book on the subject: http://amzn.to/1zFQXcr
The book claims that “optimism” can be measured, and that there are strategies for improving it, and discusses those strategies. I personally found that they did help me, and further that Cognitive Behavioural Therapy (CBT) under the supervision of a professional helped me even more.
I also wrote a post directly about Optimism a while back, it outlines Seligman’s strategies:
http://braythwayt.com/homoiconic/2009/05/01/optimism.html
There was lively HN discussion at the time, you may find it informative: