Show HN: Code to wake me up after I ruined my mobile (only source of internet)

7 points by franze ↗ HN
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 ] thread
Having a decent IDE would basically solve the "no internet" problem, as it'll have code hints for the standard library of your language(s).

Having common sense would have prevented the event that caused the whole problem.

> "Having 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 didn't say accidents never happen to me.

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.

(comment deleted)
Your Mac literally has an app for that called Calendar.
I tried it, could not bring it to alert me. And well, "Google it" was not an option.
Best solution would be to always carry a plastic bag in the bath.
The most elegant solution is just to buy an alarm clock or watch. They're cheap to buy (you may even be able to get a second hand one for free depending on where you lived), and would cut your electricity usage compared to running your MBP as an alarm clock.

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.

"Look ma, no code!"

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/

like the other guys said, 1) use a alarm clock, 2) there's a freaking calendar app builtin.

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

(comment deleted)
When I was a student I felt like the time had come for some modern way of being woken up. I had a Philips CD-player and a Commodore 64. On the back of that CD-player was an RCA connector marked 'remote control'. I sent a letter to Philips with a request for information on that protocol and some kind soul sent me some pages of timing definitions and encodings. I made an adapter to go between the C64 user bus and that CD-player, wrote an alarm-clock program which could be told to 'play track X at time Y' and off I went...