Show HN: Code to wake me up after I ruined my mobile (only source of internet)
Hi HN, a week ago I was watching Netflix in the bathtub and well, water damaged my mobile beyond repair while doing so.
Issue:
a) my mobile phone is my only alarm clock
b) my only available source of internet
c) early very important business appointment
This is the code I wrote at 1 a.m. in the morning (without Google/Stackoverflow) on my Macbook Pro
https://scontent.fvie1-1.fna.fbcdn.net/v/t31.0-8/25073127_10...Since them I'm wondering, what would be the most elegant solution that you would come up with (without looking anything up on - or downloading anything from - the internet)!
Note: yes, I forgot where the milliseconds in setTimeout goes, so I put them everywhere.
12 comments
[ 3.1 ms ] story [ 32.5 ms ] threadHaving common sense would have prevented the event that caused the whole problem.
It has nothing to do with common sense. Accidents happen. Don't try to make out that preventable accidents never happen to you because you have "common sense".
I said, having common sense (ie not using a sensitive piece of electronics while literally sitting in a bathtub full of water) would have prevented the original problem.
Accidents absolutely happen all the time. That doesn't mean we shouldn't try to avoid them by applying common sense to our actions.
With your phone, have you tried anything to save it after it was damaged by water? If you want a technical challenge, I'd suggest focusing on that. There's advice on the web on how to repair a phone after dropping it in water.
Use a traditional alarm clock. For instance, I use one of those cheap Ikea alarms[1]. This means that, even when your phone is working, you don't have to have it near your bed, which lowers your incentive to quickly look at it if you can't sleep right away. That did wonders for my sleep quality.
---
On topic: If I had to come up with a quick hack because it's 2am and I have no alarm clock: I still have a mechanical time switch (for electrical power) somewhere, and I use an old analog Technics stereo. Combine that with a turntable and you've got yourself a fine alarm clock (although with a somewhat coarse granularity) in less than 5 minutes. That's honestly much easier for me than looking up media APIs I have never used without an internet connection :-)
[1]: https://m.ikea.com/Us/en/catalog/products/art/50187566/
but if you really need to "code" for whatever reason. The core logic is trivially simple. you need to 1) wait til the moment you want to wake up 2) generate some noise.
so just open mac terminal and type:
sleep 28800; while true; do say "wake up"; done