1. CSS
  2. Flash
  3. HTML
  4. Illustrator
  5. Java
  6. JavaScript
  7. Maya
  8. Photography
  9. Photoshop
  10. PHP
  11. Ruby
  12. Ruby on Rails
  13. 3ds Max

Ruby: Track your computer open/shutdown times

  1. Clicks today:
    0
  2. Clicks this month:
    1
  3. Overall rating:
    0.00/5

Ruby » Best Practices — over 3 years ago
Track your computer open/shutdown times #!/usr/bin/env ruby # Author : Emad Elsaid (https://github.com/blazeeboy) FILENAME = 'db.txt' OPEN, CLOSE = 1 , 0 file = File.open(FILENAME, 'a') file.write "#{OPEN} : #{Time.new}\n" file.flush begin loop { sleep 60 } # sleep for an hour in an endless loop rescue SystemExit, Interrupt # on exit file.write "#{CLOSE} : #{Time.new}\n" file.close end

Comments

Your Comment

You must be logged in to post a comment.