How sleep deprivation can lead to creativity

8 minute read

Make yourself comfortable, dear reader, for I’m about to tell you a tale about my past self.

I love having side projects. I enjoy thinking about what thing I want to try out and setting a goal. This blog is one of them, in fact. These side projects are a great tool to learn something new, practice some of that acquired knowledge or create something that fits some arbitrary needs.

A while ago, back in 2015, we had some very noisy neighbors that prevented us from sleeping nicely for a year. Whether it was 1am, 4am on week days or 3pm on weekends didn’t matter. Sometimes it lasted for 10 minutes, sometimes for over 2 hours. Day after day we were more tired and angry. It even affected our professional performance.

This time, let me share with you how I turned this situation into an opportunity to have a new side project.

How it all started

Every story has a beginning, and so does this one.

When we moved to a new apartment in a new town, the landlord never mentioned anything about any neighbors. We visited the apartment, the house was just what we were looking for. We didn’t find anything wrong about it or the building. And it wasn’t… For a week.

One late night, a young kid started screaming and crying in the dark. It was like having a kid next door, but was in fact in the apartment just over ours. The crying lasted an hour. No problem, kids have nightmares and are afraid of darkness, he’ll grow up. We ended up learning this young kid was about 2 years old.

Days passed and the situation was repeating once every three days or so. Sometimes it lasted just a bit, sometimes it was over an hour. At 4am. When you get up at 7am. But it’s alright, it was a kid and we couldn’t control that. Not even the fact that his parents kept him in the bedroom right over us for the whole thing, day after day, instead of calming him somewhere else.

At times, in the silent night, we’d wake up and ask each other: Is the kid crying? I can hear him. Some of those times we weren’t sure whether it was happening or it was psychosis.

We got ourselves some earplugs. We tried several flavours: foam earplugs, silicone earplugs; you name them, we tried them. We weren’t even sure it was healthy using them so frequently, but we needed sleep.

Damn kid, we thought. But, was he the problem?

The root of all Evil

This continued happening from time to time, but then we started to pay attention to what happened upstairs. Okay, the kid was noisy, but he was just a kid, you can’t blame it on him. The problem were his parents, from the start!

We remember one day when his father woke up at 6am, went to the toilet and got a phone call. He started talking and I swear we could understand what his interlocutor was saying! He was using the speaker. In the toilet. At 6am! And that happened again some days later!

Then we realized our neighbors didn’t stand each other. He didn’t seem to give a damn about the kid, she didn’t seem to have any patience with none of them. You couldn’t even take a nap in the afternoon, the kid would be playing with his toys, running through the apartment making noise or being yelled at by his mother. Or maybe it was the mother yelling at the father.

For the record, they also laughed and seemed to have good times.

But then again, the father. Oh, the father. He had that characteristic smoker’s cough, trying to scratch the itch from his throat. Did I mention the kid could cry for an hour? He could cough for several hours. I don’t even think he let his wife and kid sleep.

We couldn’t.

With despair comes invention

Fast forward to 8 months after we moved. The noise continued and we were feeling so embarrased when we’d meet them in the elevator or the building. We were also noticing how irascible we were becoming because of the lack of sleep.

Some time before that I had watched this YouTube video:

And I loved how he managed to annoy his neighbors even when he wasn’t home. And best of all, it was reactive! I didn’t want anything this hi-tech, but I definitely wanted to build something for the same purpose. So I did.

Noisy Neighbors Karma Restorer

The idea was to build a program to play very noisy songs to our neighbors intermittently during the day. Something like:

Select a noisy song with a hard bass, play the first N seconds and then remain silent for M seconds. Repeat.

Then I could just leave home for work, leave it on and fulfill my vengeance. Say… play the first 50 seconds of AWOLNATION’s Sail, then stop for 15 minutes and repeat.

That would include placing our subwoofer very close to the ceiling and upwards. It surely would be a show to watch. And to listen to! I can tell you it was impossible to stay in the room while it played.

The tech

Okay, so I had a brand new side project. What did I want to learn?

I chose Node.js because I wanted to build a REST API to control it from an Android app. I’d open the app, hit a big Play button with some pre-selected values and then leave for the day. Then came home, open the app again and press the big Stop button. Simple! Or was it?

First difficulty

I started browsing for Node packages that allowed MP3 playback. I read some of the README files, tried to test some of them, and finally selected player.

It even came with some examples, ready to try out!

npm install player --save
node main.js

But it was stuck as soon as I used require("player");. I remember wasting a day on that. I ended up installing a fresh Ubuntu and trying there. It worked first try. I had my prequisite working.


First of all, I installed Express to build the server and bind the API. I’d allow the following services:

GET /songs
POST /play
POST /stop

Nothing special here, just wanted the basic controls. These would be some example request/response for each service:

> GET /

< 200 OK
  "running": false
> GET /songs

< 200 OK
  "Sail - AWOLNATION.mp3",
  "Dark Horse - Katy Perry.mp3"
> POST /play
  "song": "Sail - AWOLNATION.mp3",
  "duration": 50,
  "interval": 900,
  "timeToEnd": {
    "hours": 22,
    "minutes": 15

< 201 Created
> POST /stop

< 200 OK

Did you notice the timeToEnd field in the POST /play call? That field would be used to stop the playback when the given time in the day was reached. Suppose I was coming home late in the night and it was still playing.
I’m not a monster.

So, I created a couple of new services to allow some extra tuning:

POST /limit_time
POST /volume

Testing the API

I installed a nice browser add-on called Postman, now turned into a native app. It has improved over these years, but even back then it had everything I needed to test my project.

It would allow performing calls to a given URL with the parameters I wanted, showed the responses nicely formatted and had a way to save those calls for later use.

What’s even better, I could hear what was happening when I performed the calls! I could test the play 10 seconds, wait 10 seconds, repeat scenario, the stop playing at 19:00 one, etc.

And no, I didn’t build a whole lot of unit tests to ensure it was working in all scenarios.


Some stories have a premature end. This was one of them.

I’d have loved to tell you I built an awesome Android app to control the whole thing. With its learning process, the fragments, the layouts, manifest permissions and so on.

However, Postman was fitting my needs and I was losing interest in the project myself as the main goal (playing song fragments in fixed intervals) was already working.

The Good

I’m glad to say, though, that I was somewhat dilligent and created a GitHub repository for the project as I developed it. I kept it private all this time, but I guess it’s time to open it for the public. You can find it here:

Noisy Neighbors Karma Restorer’s GitHub

I would’ve loved to review it, update it to use my current programming style and preferences, naming and the like. But I preferred to leave it untouched so I could also reflect on how I have evolved in those aspects as well.

In any case, it was a nice way to focus on something else with a goal in mind. I also learned one or ten things while building it, so I’m happy that I did it.

The Bad

Because I didn’t manage to make player work on Windows, I had to go through the process of installing a fresh version of Ubuntu. After it was installed it wasn’t a bad thing per-se, but that also took away some of the interest on the project.

Also, I’m afraid the noise never stopped and we ended up moving to another town. Not only because of the neighbors, but they were one of the main reasons. Luckily for us, we moved to a very quiet apartment and never needed to use this project again (for now).

The Ugly

I only put this project into practice twice. One with AWOLNATION’s Sail and one with Katy Perry’s Dark Horse. I don’t think it was of any help. At most, it irritated our neighbors even more and contributed to hurt their relationship.

I wish them the best. But, please, not next to our bedroom.


When I was checking the project to write this post I tried to make it work on Windows. I hadn’t gave up on it.

Luckily, a user had opened a Pull Request on player, the module I was using, to update one of its dependencies (speaker) to a newer version that did work on Windows.

Sadly, player hadn’t been updated in a long while and this Pull Request hadn’t been merged.

So I forked the repository, updated it myself and modified NoisyNeighborsKarmaRestorer’s dependency to my forked version. Thanks to it, now I know you can install a node module with npm install github_user/repository#branch.