Skip to content

Instantly share code, notes, and snippets.

@prokizzle
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prokizzle/44bc14ea026785a4180c to your computer and use it in GitHub Desktop.
Save prokizzle/44bc14ea026785a4180c to your computer and use it in GitHub Desktop.
Sit or Stand Timer
gem 'timers'
gem 'terminal-notifier'
gem 'daemons'
# SitStand
require 'timers'
require 'daemons'
class Fixnum
def seconds
self
end
def minutes
self * 60
end
def hours
self * 60 * 60
end
end
class SitStand
def initialize
@timers = Timers::Group.new
@every_five_seconds = @timers.every(20.minutes) { notify }
@position = "sit"
notify
end
def sit_or_stand
@position = @position == "sit" ? "stand" : "sit"
end
def notify
%x{terminal-notifier -message "Time to #{sit_or_stand}!"}
end
def run
loop { @timers.wait }
end
end
Daemons.run_proc('SitStand') do
app = SitStand.new
app.run
end
@prokizzle
Copy link
Author

run with ruby sit_stand.rb start

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