Created
December 21, 2011 09:50
-
-
Save jfhbrook/1505432 to your computer and use it in GitHub Desktop.
A hacked-together node.js alarm clock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Then people started to write everything into JavaScript.