How to Sleep Good

Ismail Elouafiq
Aug 1, 2017 · 14 min read

I tried counting sheep as a kid, but the sheep usually falls asleep before me…

Insomnia is a gross feeder. It will nourish itself on any kind of thinking, including thinking about not thinking.
_ Clifton Fadiman

We all have things that scare us at night and I certainly did. Most days, however, it was not the monsters in the closet nor those hiding under the bed. It was the idea that I would spend hours in bed unable to sleep. With my mind wandering in thoughts about the things that happened, the things that never happened but could have and the other things that cannot ever be.

A conversation between me and my brain would usually look something like this:

  • Brain : Hey there, trying to sleep?
  • Me : Ummm, yeah…
  • Brain : BORING! How about parrots…
  • Me : What??!
  • Brain : YES! Parrots! If you had millions of them, you could teach them anything… and send them anywhere! what would you do?
  • Me : What?! That’s not even…
  • Brain : It’s cool though!
  • Me : I guess.
  • Brain : So…
  • Me : I am not responding to that…
  • Brain : Do you need to go the bathroom?
  • Me : Nope!
  • Brain : Are you suuuure?
  • Me : Dammit! Ok, sure…

Hours later I am still awake, trying to solve problems that exist and, eventually, make up other problems that don’t. I was a professional insomniac. And I know, I’m not the only one. According to the National Sleep Foundation, 48% of people living in the US report occasional insomnia while 22% experience it every or almost every night.

We don’t need to hear that a lack of sleep causes higher Cortisol or an increase in C-Reactive Protein (CRP, a common marker for inflammation) to be convinced that good sleep is good. When we sleep well, we do everything else better and we’ve all felt it at least once in our lives. When we wake up feeling refreshed we give better presentations, we are more compassionate and just happy overall.

So here are all the changes I made to sleep like a baby (and not any baby, a baby panda, because that my friend is the top level of sleep and relaxation).

I went from staying awake for more than two hours in bed to getting myself knocked out in less than 10 minutes. And going to sleep faster is only part of the equation.

Remember, the first rule is: do not be stupid. I am not an expert and I do not plan on playing one on the internets, these are the things I have tried and have had the greatest impact on me.

Have you tried putting plants in your room? Wearing red glasses that make you look like a douchebag? Taking a sauna or an extremely cold shower? Here are the ultimate changes that helped me improve the quality of my sleep and wake up feeling like a thousand bucks. The first chapter will contain the changes that had the biggest impact on my sleep quality. Then I will describe my exact sleeping routine and how I deal with less controllable situations like travel.

Start Here: The Little Things with a Big Impact

To begin let us keep things simple. Here are the small habit changes anyone can apply that have had the biggest impact on my sleep quality.

Notice how the quantity of sleep is not the goal here. It is not about how much you sleep but how well you sleep. Ever slept for 11 hours and woke up groggy or instead felt amazing after sleeping for only 7 hours? Exactly! What matters is getting enough deep sleep during the night but I will not go through the technical details nor the biochemistry of sleep.

I experimented by affecting both my environment, meaning what I can control in my surroundings, and my inner state, from both the biochemistry and the psychology. So the main variables that we’ll be affecting are: light, food and thoughts (I will talk about exercise too in the next chapter, for now, these are only the 20% that affect 80% of the results). Notice how we will put as much focus on the when (or the timing) as we do on the what and how. Also, we will start by identifying which things to delete or substract before going into which things to add

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
Antoine de Saint Exupery

Obviously, since I’ve been living in Sweden (where the winter days are short and it barely gets dark at all during the summer) these things can vary with the seasons. To make things simple we can assume that we’re in an average day for the rest of this article.

Variable Number 0 : Light

When you avoid exposure to artificial light from TV, movie screens, computer screens, phones and bright light, Melatonin starts to get released as the sky gets darker. Melatonin helps your body to sleep and recuperate, shut down the hyperactive monkey brain, allows for neuronal repair, pulls oxygen and needed hormones away from your muscle tissue and other cells, thus making it harder to perform physical activity and easier to sleep. It is much harder to sleep if you do not make enough melatonin [1]. Supplementing with melatonin does not unf

Melatonin production is not only affected by the intensity of light but also by the wavelengths. Blue light (a spectrum of around 420 to 485 nm) is supposed to be predominant during the day, which explains why melatonin production gets affected by it. In [2], it is shown that white LED lighting can be five times more efficient at blocking melatonin production than incandescent light bulbs. An even more creepy fact, shining to the eyes is not necessary, a simple LED light is shown to bring changes in regulating melatonin production, body temperature and the amount of deep sleep [4].

Light is one of the ways your brain makes the difference between day and night. Unfortunately, modern artificial lights fly in the face of natural daily sunlight and natural evening darkness. This can throw your body clock way out-of-whack. From the production of hormones such as cortisol and melatonin or neurotransmitters such as serotonin and GABA, to the pulse rate, the blood pressure, the body temperature or even the activity in our guts, many functions in our body will depend on processes linked to the cycle of the day and known as Circadian Rhythms. As an example, jet lag can disrupt our perception of day and night. And as you might have guessed already, light does as well.

The first thing I changed is my screen lighting. As a computer scientist, most of my time is spent staring at my laptop.

So the first step was to install flux (a software that can reduce the screen’s blue light). While I had used flux before, I used to let it start only after sunset. Now, I use it during the whole day, which of course makes my screen look red and eventually ends up in making people think that: either my laptop is broken or that I am a maniac. Careful with this though, if you’re a designer you will get your colors mixed up, the good news is, you can disable it in case you need any design. The reason I keep flux on during the whole day and not just during the night (when it’s dark) is that getting exposed to blue light during the day is also shown to disrupt the circadian rhythm, a source of blue light needs to have a source of infrared or near infrared light coming from the same direction (which is the case for sunlight for example).

The next screen to take care of was my phone, I installed the Twilight app that acts in a similar way to flux.

Around two to three hours before bed I turn off all the lights. And I usually put on my douchebag glasses (or blue light blockers as known in the biohackers community).

Wait… What If I need to get something done? Or write something? Or just wash the dishes?

Easy, use a source of dim incandescent light or red lights that you can light up in a place a little far from you but just enough so you do not end up in the kitchen instead of your bathroom. Avoid LED lights at all costs. And if you want to go a step further you can use blue light blocking glasses for example: TrueDark and Daywalker glasses by Biohacked. The advantage of using glasses is that they can be useful in uncontrollable environments where you cannot decide which lights to turn on or off (e.g: coffeeshops, street lights, trains, airplanes etc.). This can get you sleepy though so I would not wear blue light blockers if I was driving (it’s harder to see with them anyway).

Now here are some light related things you can add to improve your sleep. Getting exposed to natural sunlight is an important factor in maintaining alertness and circadian rhythm. Having a look at the red light while the sun is setting (during which fatty acid metabolism hormones such as leptin and adinopectin tend to rise) can also improve sleep quality.

Variable Number 1 : Food

Food quality and timing are a big part of a good night sleep. You might already know that drinking a cup of coffee before bed is not an ideal strategy. Some might say: I have no problem sleeping even if I drink coffee… the truth is, even if you go to sleep fast, caffeine will disrupt your sleep. Remember, the goal is not how fast or how long you sleep, the goal is to sleep good, real good.

So before bed, I avoid every substance that can disrupt my sleep:

  • I avoid caffeine and caffeine rich foods (coffee, tea, chocolate, energy drinks, yerba maté etc.) in the afternoon.
  • Other substances I try to avoid are Theobromine and Theophylline (mainly found in Kola and Cacao) around 6 hours before sleep.

Alcohol is another substance that lowers REM sleep, fortunately, I do not drink alcohol anyway. Another suspect compound is Tyramine (a naturally occurring trace amine that can be found in cheese, eggplants and chocolate). Tyramine is shown to increase the production of noradrenaline (which boosts brain activity), however, I do not mind having foods that contain tyramine at dinner unless I’m experiencing headaches [3].

Now, what if I told you that the voice in your head when you’re sleeping is not yours?

What if it was the bacteria in your gut having a party?

Sounds too creepy to be true? The gut is sometimes considered as a second brain due to the fact that the microbiome can largely affect our neurochemistry, emotional behaviour and brain physiology [5] [6]. Having a healthy gut prevents your bacteria from disturbing you while you try to sleep. Hence, having a healthy diet that uses real good quality foods instead of its processed low quality alternative and keeping a healthy gut will not just make you achieve your fitness goals but will also help you feel better and sleep better. Another threat to your gut are intestinal parasites which can cause restlessness, a difficulty to rest and affect the central nervous system and block your body from performing its normal sleep routines. Parasites are generally more active during the night and can also be the reason you’re not getting deep in your sleep.

Around three hours before bed is when I finish having dinner, then I would drink a cocktail (lovender tea or the baby panda cocktail as we’ve named it with my roommate) around two hours before bed. My dinner would usually consist of a good source of fat (such as olive oil, olives, almonds, avocados, eggs, walnuts, fish) along with some slow carbs (example: sweet potatoes, chickpeas, lentils) or occasionally some not-so-slow-but-pretty-low carbs (such as rice or quinoa)

To avoid going back and forth to the bathroom at night I make sure to drink around 1h30m prior to bed and have cyclic water intake during the day instead of ingesting a cup of water every now and then.

“Oh, you have so many rules, why are you so strict with yourself?” This is far from being strict and most of the changes I made diet-wise came very gradually. I personally prefer having real foods and being in a state where I am performing better. Plus, if I don’t sleep well I will be a douchebag to everyone else, so… let’s move on.

The Love-nder Tea (or the Baby Panda Cocktail) Recipe

This cocktail recipe will knock you the hell out :

  • Lavender (the main ingredient as the name suggests). You can optionally add oat flower and valerian.
  • Chamomille (or good quality Kava, it works like Chamomille on steroids but does have some side effects on the liver if used too often).
  • Make sure the water is not at boiling temperature to not ruin the flavonoids in the teas.
  • After the tea is ready, add a teaspoon of honey with a tablespoon of apple cider vinegar. I do know that honey will help restore glycogen stores during the night [7] and that apple cider vinegar can be beneficial to the gut but I have no idea how these two combined are effective in putting you asleep. One thing I know for sure: it works.

Variable Number 2 : Thoughts, and how to tame the monkey mind

Things are about to get cheesy, weird and extremely hipster.

Here’s the first trick I use when I go to sleep. Since the goal is not to sleep faster but better and since if I just lie down and relax for about 7 hours I will get at least 80% of the benefits of sleep, I consider this : The goal is not to sleep for seven hours but rather to stay in bed for seven hours, and just relax. Whether I sleep or not, I am just here taking this time to relax and chill.

Now let’s get into some deep hipster habits. When I have something important coming up, I usually get a sudden anxiety that prevents me from easily relaxing. In general, on days where I have huge amounts of stress, be it physical or psychological, or even if I’m having something I consider to be important the day after meditation is mandatory before bed. But what if it’s too late? Remember it’s about sleeping better, not more. For this reason, I would take the time to meditate sometimes for around 3 to 5 minutes just enough time to calm the monkey mind.

The fear of a presentation or a test coming up the next day is not helpful in any way especially if it stops you from getting the most of your night. If this happens, I would start by focusing on relaxing the body as I mentioned earlier and accept the fact that I might not sleep and be Ok with it. The reason being that when we usually try Try not thinking about elephants and your mind starts shouting ‘ELEPHANTS! ELEPHANTS!’… What a troll… Resisting thoughts only makes them come back stronger. Accept thoughts and they will fade away, imagine a girl trying to make her jerk boyfriend go away, the easiest way is if she tells him “Let’s get married” which will make him disappear into non-existence. Your fears are the same, instead of resisting them try giving them more love, more acceptance, more contentment.

I would avoid things that would cause my brain to start firing such as reading emails, writing or studying. Instead, I might read or listen to either fiction, poetry or anything that would have a sedative effect rather than a stimulating effect.

The Han #Yolo Techniques Okay, so we just talked about how it can be useful to shift focus from trying to sleep to simply relaxing for the next hours. So here are a couple jedi mind tricks to relax :

  • Alternate nasal breathing: close the left side of your nose using your finger and breathe in from the right side, try to breathe in slowly for around 4 seconds. Then hold your breathe without effort, now close the right side of your nose and breathe out from the left side and hold the lungs while empty for a little while. Follow by breathing in again from the left side, keeping the right side of the nose closed and repeat…
  • Box breathing: Fancy name, simple concept. Breathe in for around 4–20 seconds, hold your breathe in for around the same amount of time, breathe out slowly for around 4–20 seconds and try to hold the empty lungs for around 4–20 seconds. And, repeat.
  • While doing any of the above exercises, I also try to go through every part of the body and feel if there is tension, and usually feel it fade away as I breathe out. The goal of course is not to try to make the tension fade away, but to just observe it, accept the fact that it is there, which usually ends up making it fade away. Remember, tension is like a douchebag partner, the more you love them the faster they run away.
  • Making sure that the breathing is deep by lying on the side instead of the stomach, breathing horizontally (instead of vertically as many of us do) while keeping the shoulders relaxed.

These techniques, or deep breathing in general, will calm your mind and sync the sympathetic and parasympathetic nervous systems giving you an optimal Heart Rate Variability and knocking you out when you least expect it. Simply breathing like this for a long time will not only make you more relax but can also have huge therapeutical and physical benefits. And as I will mention below other things such as using lavender essential oil and magnesium can also have relaxing effects.

My exact routine for Improved Sleep Quality

For my exact sleeping routine and bonus tips you can keep reading this article in here.

THANKS FOR READING! 🙂 Hit that ❤️ Button below if you loved this. It means a lot to me and gets the message spread.


  1. Scheer, F.A.; Wright, K.P.; Kronauer, R.E.; Czeisler, C.A. (2007). “Plasticity of the intrinsic period of the human circadian timing system”. In Nicolelis, Miguel. PLoS ONE 2 (1): e721.
  2. Falchi, F. & Cinzano, P. & Elvidge, C. & Keith, D. & Haim, A. (2011). Limiting the impact of light pollution on human health, environment and stellar visibility. Journal of Environmental Management 92 (10): 2714–2722.
  3. National Headache Foundation’s low Tyramine Diet:
  4. Absence of circadian phase resetting in response to bright light behind the knees.
  5. Indigenous Bacteria from the Gut Microbiota Regulate Host Serotonin Biosynthesis
  6. Eight year prognosis of postinfectious irritable bowel syndrome following waterborne bacterial dysentery
  7. Effect of honey on nocturnal cough and sleep quality: a double-blind, randomized, placebo-controlled study.
  8. Mednick, S. & Nakayama, K. & Stickgold, R. (2003). Sleep-dependent learning: a nap is as good as a night. Nature Neuroscience
  9. Scheer, F. & Buijs, R. (1999). Light affects morning salivary cortisol in humans. The Journal of Clinical Endocrinology & Metabolism 84 (9): 3395–3398.
  10. Light affects morning salivary cortisol in humans.
  11. Health Effects Associated with Exposure to Airliner Cabin Air
  12. Montakab, H. (1999). acupuncture and insomnia Forsch Komplementarmed. , February(6), S29–31

Original Post Source:

THANKS FOR READING! 🙂 Wanna give me a hand? Hit those CLAPS below if you loved this. It means a lot to me and gets the message to spread.

Ismail Elouafiq

Written by

I eat chocolate, drink tea and write about data... find me at

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade