The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
There are a lot of things to try, thankfully. One thing is to make sure you're not eating too close to when you're going to bed. Another is (as others have suggested) to get some exercise during the day, which is good for both stress and sleeping. Put bluelight filters on your screens (though I've heard this might not work) or eliminate screen time at least an hour before bed. You could try meditation, not everyone's thing, but it's an option: Before Sleep | Beginners Spoken Guided Meditation | Chakra Alignment |How to Chakra Balance - YouTube[^]. Make sure the bedroom is dark and cold. I've heard you should have warm feet, but I don't know if that's true.
If none of that works (or you could do it in tandem) consider going for a sleep study. You could have something like sleep apnea.
Everyone has there own method, nothing works for everyone and nothing works every time.
I've found a useful technique which have worked on most occasions.
First off make sure you have a good amount of water content, not hungry, not overly fed.
Make sure you don't have to go to the bathroom, cause you will have to just when you are about to doze off.
Eat a good 3 - 4 hours before sleep time.
Take a walk for 1 KM or at least 200 steps after dinner.
Try not to lie on mattress, use something like yoga mat or one of those expensive mattresses that are good for your back.
When lying on the bed, close your eyes think of all the different things that are coming to mind. Let the proverbial thoughts flow. Now paint all those thoughts on the (imaginary) canvas in front of you. And then paint everything white.
Once your head is clear along with a white background noise (I have found a sound with pattern relaxes me, like that of an old ceiling fan, one of those that look like they are about to fall off), or start counting one and two on inhale and exhale.
If you are spiritual by nature and Muslim try replacing one with Allah and two with Hoo, or YAH and WEH if you are a Christian.
Eat a healthy meal, drink water and go for a 30 minute walk. Listen to music while you do and don't really think about anything important.
It's important to let go of your stress and not hold onto it for days on end.
Developers often use stress as a motivator to get stuff done, but that's also super unhealthy.
My own appendix exploded because I did that too and I nearly died.
If you're still in your early 20's you should be fine though.
Last time I had that problem, it was because my boss was pushing me to finish a project well ahead of time. After working Friday morning through Sunday night with no sleep, I finished the project. He still complained.
So after a good nights sleep, I waited until payday, got my check, cashed it at the local branch of the back it was drawn on, then turned in my resignation. The company had a habit of keeping your last check if you quit, so I turned that around on them. I also handed over evidence to the customer (a state Corrections agency) where billing for my team had been padded by my boss with a lot of extra hours that no one worked. After all, sooner or later, it would have been discovered, and I did not want to be blamed for it.
I moved on and they paid a hefty fine to avoid prosecution.
I use audiobooks (or podcasts, youtube streams etc.)
I started out trying a self-hypnosis cd from Paul McKenna which sort of worked and then discovered just having an audiobook on at a lowish volume worked - I still wake up during the night but quickly fall back asleep. The only issue is losing your place in the book and so you end up listening to the same chapters over and over LOL
I am a dev and I read the article (I did not go as far as downloading more) and still know 1/10th of SFA about parsers. Fortunately I guess I have never needed to know.
In an earlier post one of our cohort was describing his trouble getting to sleep. With no disrespect intended to you for your stellar work, if he knows nothing of parsers (like myself) I suggest he go to your page and completely concentrate on your documentation. I am sure he will either render himself safely asleep or get overly enthused on parsers and algorithms such that he forgets that he is tired.
So, just seconds ago, I pulled the trigger and deleted permanently all my deleted mail. Funny to think about how rare an event that is. I mean, I did delete it - I didn't want it and didn't think I ever would because, if I did, I'd shove it in some folder and forget it there, instead.
Do you others also hesitate to complete this tension-fraught job?