Skip to content

Instantly share code, notes, and snippets.

@jfhbrook
Created December 21, 2011 09:50
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfhbrook/1505432 to your computer and use it in GitHub Desktop.
Save jfhbrook/1505432 to your computer and use it in GitHub Desktop.
A hacked-together node.js alarm clock

BASICALLY I FORGOT TO FINISH DRYING MY SHEETS

so I'm sleeping on the couch

and I need an alarm clock

and my regular alarm clock is in the other room.

So, I wrote one.

var spawn = require("child_process").spawn;
var time = process.argv[2].split(':').map(Number);
function checkTime () {
var now = new Date();
// Formatting is garbage for single digit times
console.log(now.getHours() + ':' + now.getMinutes());
if ((now.getHours() >= time[0]) && (now.getMinutes() >= time[1])) {
spawn('google-chrome', [ 'http://www.youtube.com/watch?v=tqmid9MlFSw' ]);
setInterval(function () {
console.log("WAKE THE FUCK UP");
}, 1000);
}
else {
// I don't need that much granularity.
setTimeout(checkTime, 1000*60);
}
}
console.log("Setting alarm for: "+time[0]+":"+time[1]);
checkTime();
@mmalecki
Copy link

I usually just use at with mplayer. It Just Works (tm). But this one is pretty neat :).

Also, I like the third line. It somehow feels awesome.

@jfhbrook
Copy link
Author

I'd forgotten about at.

@Crystal-RainSlide
Copy link

I'd forgotten about at.

Then people started to write everything into JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment