It seems like the best way to get the mind off of hard times is to just pretty much maintain a positive attitude. For myself, I've learned to just flip on the switch to staying positive whenever I have to. I think it's just from having a ton of self-confidence while giving myself a hard time every once in a awhile and then grinding it out to the finish line. I believe that in time through hard work, it's going to happen sooner or later. What's so positive about this is that if I'm still working on something and end up dying for some reason sadly, then I'll still have been happy even though I didn't get anything done. This mentality of just pushing myself with a positive attitude is personally addictive for me.
Knowing my personality a bit more now, maintaining this strong and positive attitude really just came from learning to have acceptance. How did I obtain acceptance? I don't really know exactly. It feels like it just happened after I went to a guy's talk about having a positive mind after understanding a little neuroscience. This guy's PowerPoint seriously changed my life around and from that point on, it's like I'm used to it now and a whole lot better.
It looks like I've always had this optimistic feeling within me. I still have my slight struggles but I'm getting better at it. It's like having a major off day while playing online Poker and going through something rough as well. Just putting my hours in and committing to it while just learning to accept my outcome has helped massively. I've also learned that being happier can make you more productive and it's also easier to stay consistent with something.