Building an alarm clock with node.js

7,969
-1

Published on

My Sep 29 2011 talk at RejectJS.

Published in: Technology, News & Politics

Building an alarm clock with node.js

  1. 1. Building an alarm clock with node.js or Hacking vs. Engineering Felix Geisendörfer 29.09.2011 (v1)Donnerstag, 29. September 2011
  2. 2. Text Welcome to the Siesta right-after-lunch Session!Donnerstag, 29. September 2011
  3. 3. Building an alarm clock with node.js or Hacking vs. Engineering Felix Geisendörfer 29.09.2011 (v1)Donnerstag, 29. September 2011
  4. 4. @felixge Twitter / GitHub / IRCDonnerstag, 29. September 2011
  5. 5. My Problem • Getting up early in the morning • That means before 12:00 (noon)Donnerstag, 29. September 2011
  6. 6. This talk • How I solved this problem • Hacking vs. Engineering the solutionDonnerstag, 29. September 2011
  7. 7. Patient History • 23 years • Working from home • Can work any hoursDonnerstag, 29. September 2011
  8. 8. So why get up early? • To get more stuff done ...Donnerstag, 29. September 2011
  9. 9. Previous attemptsDonnerstag, 29. September 2011
  10. 10. Text Behavioral ConditioningDonnerstag, 29. September 2011
  11. 11. Text Flying alarm clockDonnerstag, 29. September 2011
  12. 12. Text Circadian rhythm app (Sleep Cycle)Donnerstag, 29. September 2011
  13. 13. Text Many alarmsDonnerstag, 29. September 2011
  14. 14. Nothing was workingDonnerstag, 29. September 2011
  15. 15. TextDonnerstag, 29. September 2011
  16. 16. Donnerstag, 29. September 2011
  17. 17. Donnerstag, 29. September 2011
  18. 18. Donnerstag, 29. September 2011
  19. 19. Donnerstag, 29. September 2011
  20. 20. VLCDonnerstag, 29. September 2011
  21. 21. pmsetDonnerstag, 29. September 2011
  22. 22. The Script https://gist.github.com/1a40a207cf6132f77efaDonnerstag, 29. September 2011
  23. 23. sudo ./alarm.js 7 30Donnerstag, 29. September 2011
  24. 24. Donnerstag, 29. September 2011
  25. 25. Result • Reliably waking up at any time • Get to choose different music every nightDonnerstag, 29. September 2011
  26. 26. Hacking vs. EngineeringDonnerstag, 29. September 2011
  27. 27. (Software) Engineering “Rigorous application of science”Donnerstag, 29. September 2011
  28. 28. Hacking “Playful cleverness”Donnerstag, 29. September 2011
  29. 29. Hacking vs. Engineering this projectDonnerstag, 29. September 2011
  30. 30. Tests? Engineering: Yes Hacking: MaybeDonnerstag, 29. September 2011
  31. 31. Airtunes? Engineering: Implement protocol Hacking: Piggyback on iTunes or VLCDonnerstag, 29. September 2011
  32. 32. Code var file = /my/music/file.mp3; var vlcPath = /Applications/VLC.app/Contents/MacOS/VLC; var vlc = spawn(vlcPath, [ -R, --sout=#transcode {acodec = alac channels = 2, samplerate = 44100}: raop{host=10.0.1.13,volume=255}, file ]); vlc.stdout.setEncoding(utf8); vlc.stderr.setEncoding(utf8); vlc.stdout.on(data, process.stdout.write); vlc.stderr.on(data, process.stderr.write); vlc.on(exit, function(code, signal) { console.log(vlc exit: %i %s, code, signal); });Donnerstag, 29. September 2011
  33. 33. Wakeup from Sleep? Engineering: pmset schedule wakeorpoweron <datetime> Hacking: pmset schedule wakeorpoweron MTWRFSU <time>Donnerstag, 29. September 2011
  34. 34. Code var powerCmd = sprintf( pmset repeat wakeorpoweron MTWRFSU %02d:%02d:00, powerHour, powerMinute ); exec(powerCmd, function(err) { if (err) throw err; process.setuid(felix); });Donnerstag, 29. September 2011
  35. 35. Turn off speakers? Engineering: Install speakers in unreachable place. Hacking: ?Donnerstag, 29. September 2011
  36. 36. Text Duct TapeDonnerstag, 29. September 2011
  37. 37. Duct Tape of Concurrent I/ODonnerstag, 29. September 2011
  38. 38. Engineering Solution for ConcurrencyDonnerstag, 29. September 2011
  39. 39. Why am I talking about this?Donnerstag, 29. September 2011
  40. 40. JS has a very hacker-driven cultureDonnerstag, 29. September 2011
  41. 41. Text Duct tape of the webDonnerstag, 29. September 2011
  42. 42. Text Duct tape of the DOMDonnerstag, 29. September 2011
  43. 43. • Hacking is lots of fun, go do it! • Hacking can be a good solution! • But be aware that many problems call for an engineering approach.Donnerstag, 29. September 2011
  44. 44. Where we need more engineering: • Libraries • Domain logic • PerformanceDonnerstag, 29. September 2011
  45. 45. TL;DL • Hack when in doubt • Engineer when clearDonnerstag, 29. September 2011
  46. 46. Hacking EngineeringDonnerstag, 29. September 2011
  47. 47. Questions? @felixgeDonnerstag, 29. September 2011

×