Anxiety and insomnia have been with me for a long time, and this is due to my hard-driving personality, which keeps me motivated, keeps me in a sense of crisis, keeps me learning new skills, and at the same time does some damage to me, like a frog boiled in warm water, all quietly.

If you have anxiety, take it seriously. This article tells the story of an old programmer who became aware of anxiety and overcame it in his own unique way: by writing a program and adjusting his mind. I hope it helps.

In fact, anxiety is very harmful

I would have thought I was in good health if it hadn’t been for the agonies of drunken visits this year. However, the reality was that my Cousins all had rosy cheeks and fat hair, while I looked like a thin ash.

Later I reflected: meaningless anxiety led to insomnia, insomnia brought irregular work and rest aggravating anxiety, brain nerves can not get enough rest, inexplicable heart arrhythmia, making people more anxious, round and round. It’s a ticking time bomb that could go off at any moment. It’s not a joke.

I resolved to overcome my anxiety: without medication.

What am I going to do

As a programmer, the first thing I wanted to do was turn to the Internet. I googled it and someone suggested meditation or yoga, and I thought it was a good idea. But how do you get yourself into the zone? Music is needed!

Search relevant music software again, have the bird call of nature, water flow sound, white noise and so on.

After a long search, I finally found a betterSleep app that offers a lot of audio, mixed playback, and very good sound quality. For a fee, you can try it for a week.

After trying it for a week, I feel quite good. The power of music is really not to be underestimated. So, not used to paying, I thought: can I make one myself?

We need to investigate the technical options.

Do some technical preparation

First of all, I don’t have any audio and video development experience, and my understanding of audio playback is limited to setting the resource path with an Audio tag and controlling the DOM playback sound.

I searched and researched relevant materials:

  • How to play multiple audio files at the same time
  • How to protect their resources from being downloaded or stolen by others (cloud service providers are to support anti-theft chain)
  • How does NetEase Cloud Music play audio (audio element is not visible in DOM)
  • , etc.

After a bit of searching, I decided I was ready: to develop a small web music player

UI

Due to the use of a lot of music software, the layout of the main page also have a general understanding.

Using an app called Figma, it looks something like this:

Resources to prepare

With the UI, you also need to find some audio files. I am laborious, through the mobile phone recording + computer playback of the way to make more than 10 audio, I am tired of half dead, first make do with it, later have time to record other.

Then convert the recorded M4A to MP3

Finally, the resources are hosted on the cloud server.

To start developing

I heard there’s a new framework called Svelt that makes developing experiences faster. Like to taste new I decided to adopt SVELt development. With official scaffolding, the initial program was up and running.

In this way, I watched the tutorial while implementing the interface, and a website came up:

Research + design + implementation took 3-4 days in total. Fortunately, I didn’t stay up late to do it.

How to deploy

Since the application is purely static, I used it as a Github page, which is convenient and automatically triggers publishing by submitting code, automatically integrating CD functionality.

The disadvantage is that the access speed is sometimes poor (want to get a CDN, domain name record and very troublesome, so give up), but because other resources such as pictures and audio are used cloud services, so to Github request is only basic JS, HTML, CSS.

The last

Now, I try to sleep early every day, nothing to close my eyes, listen to their development of the program, empty my mind.

In fact, most anxiety from their own excessive desire, too much expectation of things. In fact, too much desire is not very meaningful, but increase trouble.

Don’t act like superman if you’re not superman.

Finally, post a link to the App: SleepBetter.