Archive for October, 2011

How lack of sleep turned my vision red (or: combating insomnia with science)

Saturday, October 22nd, 2011

If, like me, you tend to suffer from sleeplessness you will know it can be exhausting; being awake until the early morning, knowing the number of hours until the alarm buzzes is rapidly decreasing. Staying up late and waking up late might seem like a solution, but it only gets more exhausting. As it turns out, knowing the role a hormone named melatonin plays in your natural wake-sleep cycle enables you to take action to change some of your habits to induce better, more and healthier sleep.

Now, melatonin is the opposite of adrenaline. The latter has an effect of making you more aware, short-cutting the rational mind and switching back to your pre-historic instincts. Melatonin, however, is a hormone produced by the pineal gland somewhere in the middle of your brain and leads to calmness and sleepiness.

Normally, the production and re-uptake of melatonin is synchronous with sunset and sunrise. When the sun rises, the blue and to a lesser degree the green light (or more precisely, light with a wavelength above 530nm) on your retina will inhibit the production of melatonin. In the absence of such light, melatonin is produced and makes one sleepy.

Delayed inhibitation

Now, it is not as simple as stated above of course. For one, melatonin is produced from serotonin, a neurotransmitter that is associated with mood. Depression is caused by a lack of serotonin (in many cases because the serotonin re-uptake is too active or due to a lack of physical activity during the day), so it is no surprise that both insomnia and depression go hand in hand.

Some people also have a delayed inhibition, either by some internal cause but usually due to external light. Especially within IT, people tend to stay up late and sit behind their laptop screens. And guess what, these emit the green light inhibiting the production of melatonin!

Reprogramming the brain

There are various methods one could utilize to help the brain stay in sync with the day and night outside. In many countries, melatonin supplements can be bought (over the counter or in higher dosage with a prescription). Since melatonin is a hormone produced by the body, it is relatively safe to take synthesized melatonin from these supplements.

While these can be very effective (I have found very positive effects with a dosage of 3mg, although off-the-shelf dosage is usually around 0.1mg), there has been very little study regarding the long-term effects. Given that the role in the circadian rhythm is just one of many for melatonin, it might be wise to exercise some caution.

Reprogram your brain

A better and more natural way of resetting your biological rhythm is to pay attention to the light in your environment. This starts in the morning (yes, waking up properly is an important condition for a good nights rest). When you wake up, stare outside for 5 to 10 minutes and get a good dose of green light. This will reset your pineal gland, and stop the production of melatonin.

In winter, it might still be dark when you get up. In that case, you might want to consider getting a full-spectrum lamp, or at least a lamp that has as significant amount of greens and blues in its spectrum. Fluorescent lighting might also do the trick, but be aware that these normally produce very narrow spikes in the visible spectrum on the green, blue and red wavelengths and might therefore be less effective.

Software to make you sleep better

In the evening, a good start is to do the inverse: dim the light, use incandescent light which tends to lack greens and blues. But also take a look at your computer or laptop screen. This is a very rich source of green and blue light, so staying up late behind your laptop will inhibit the onset of melatonin production and delay your sleepiness.

One, quite ridiculous, suggestion is to stop working on your laptop an hour before you plan to get to sleep. I know, it’s heretic. Luckily, we can be a bit smarter about it by simply reducing the green and blue emitted from the screen!

Until recently I used the compiz compositing window manager for the sole reason that it let’s me apply a rendering function to my screen. Rendering functions are transformations applied within your graphics card that combine the red, green, blue and alpha value your software draws on the screen into the output you see.

Compiz has a ‘color filter’ plugin, which can be used to apply a rendering filter. I wrote a simple rendering function (in GPU assembly) that averages the red, green and blue channels and then writes this average to the red channel (leaving the blue and green channel dark). This has the effect of making your desktop monochrome, like a black-and-white tv but with red light instead of white.

This worked wonders. Next to dimming the roomlights in the evening, switching to this red view had a great effect on my ability to fall asleep.

But, recently I switched to xmonad; is a much more rudimentary and efficient window manager. It does support compositing somewhat, but only for useless effects such as transparent terminal backgrounds.

After discussing the matter at my hackerspace, I was put onto the path forward. To start with, one can use gamma correction to color-shift the image on the screen. This is a tedious process though, and getting it right requires some insight in how gamma-values actually influence color.

Luckily, there is software that takes care of all of that. The first I tried was f.lux, but it wasn’t optimal. For one, it was not open source, you could only get a binary. But more annoying, I tend to have at least 2 monitors and f.lux only works on one. So while my laptop screen would redshift, my external screen wouldn’t and the effect would be ruined.

But a bit of additional research led me to redshift. This is open-source and available in most linux distributions (for eg., apt-get install redshift in debian, or apt-get install gtk-redshift to get the applet as well).

I start it after I log in to an X session  (a windows version is available as well) and tell it where I am (by specifying latitude and longitude). It then knows when sunset and sunrise take place, and starts shifting the color of my display in small steps towards less green and blue and more red in the evening and back to the normal whiteness again in the morning.

Note that your phone also is a source of melatonin-production-inhibiting light. If, like me, you tend to check some rss feeds and maybe twitter in bed before you close your eyes, consider using something to redshift your phone display in the evening. Personally, I use an android phone with Cyanogenmod. This aftermarket firmware for your android phone already contains something called ‘rendering effects’. I placed a widget on my home screen that lets me choose between normal and ‘monochrome red’.

Good night, sleep well

The body is an intriguing complex of interacting processes, and while the above tends to work out really well it is not the panacea of sleep problems. There are many other interactions that may interfere with your ability to get a good healthy night of sleep.

For example, depression is known to cause a lack of serotonin and therefore may lead to decreased melatonin production. However, an unhealthy sleep rhythm (not in sync with planetary movement) has again a catalytic effect on depression.

I found that the above techniques (look into the light in the morning, redshift in the evening) greatly increased my ability to sleep at the right times and long enough, and be awake during the day without having to rely on stimulants. I feel more energetic and migraine has become a rare event as opposed to a weekly recurring disaster.

Your mileage may, of course, vary. But just give it a try. And let me know!

Ps: if you use caffeine to wake up in the morning or stay up late, disregard the above entirely; your circadian rhythm is too fucked up and the effects of my advice will likely be unnoticeable.

Flattr this

Hackers: vriend of vijand?

Friday, October 14th, 2011

On thursday October 6th I spoke to a diverse audience of ICT managers and engineers representing Dutch companies and governmental organisations to evangelize about hacking and the hacker community in The Netherlands on the Heliview Cyber Security conference. A recording of the audio and the slides are available for your viewing pleasure:

If your browser does not support video or ogg/theora, you can download the video directly. An overview of ogg/theora capable video players for various platform can be found on the Xiph wiki.

Flattr this

PostgreSQL conference Europe in Amsterdam

Wednesday, October 5th, 2011

PostgreSQL Conference Europe 2011 starts 2 weeks from today in the beautiful city of Amsterdam in the Netherlands. This is the fourth annual conference hosted by PostgreSQL Europe, following on from extremely successful events in Prato (Italy), Paris and Stuttgart, and is aimed at developers, DBAs, technologists and decision makers either using, or considering using the world’s most advanced Open Source database.

This year we have four days on the schedule, with a kick-off day of training sessions hosted by respected PostgreSQL developers such as Greg Smith, Bruce Momjian, Magnus Hagander, Guillaume Lelarge and more. Topics will cover performance tuning, application development, database administration, replication & high availability and geospatial. The training sessions are available on their own, or as part of a regular conference attendance at additional – but very reasonable – cost.

We had a record number of talk proposals submitted this year but we’ve resisted the urge to host even more sessions in parallel – in fact we’ve reduced the number of parallel sessions to three as we all know how frustrating it can be when more than one that you want to see are at the same time. Instead we’ve extended the conference by a day to accomodate over 40 different sessions, which has the added bonus of allowing an additional night of social activities – always a great way to discuss the latest technologies, trends and ideas with other Postgres users over a beer or two.

We’ve got a great range of topics for this year, covering new features in PostgreSQL 9.1 and beyond, developing applications, running Postgres in the cloud, hacking PostgreSQL internals, tools and add-on products and managing large databases, presented by a wide cross-section of users and developers, including a number of this year’s Google Summer of Code students who will talk about their work. You can view the complete schedule on the conference website: http://www.postgresql.eu/events/schedule/pgconfeu2011/

Our opening keynote this year will be presented by Ram Mohan, EVP and CTO of Afilias who manage the .info, .org and .mobi top level domains using Postgres. Ram will be discussing the business decisions and strategy around their use of PostgreSQL. Our closing keynote will be presented by Ed Boyajian, President and CEO of EnterpriseDB who will discuss PostgreSQL’s role in the post-Oracle era.

So, if you haven’t done so already, head on over to the website at http://2011.pgconf.eu/registration/ to register as an attendee to avoid missing out on what promises to be an outstanding conference in an fantastic location. See you in Amsterdam!

Flattr this