Skip to content

Instantly share code, notes, and snippets.

@niku
Created October 4, 2012 10:57
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 niku/3832946 to your computer and use it in GitHub Desktop.
Save niku/3832946 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rufus/scheduler'
require 'eventmachine'
require 'pebbles-productivity10x-switch_hosts'
switch_hosts = Pebbles::Productivity10x::SwitchHosts.new
if((Time.parse('09:00')..Time.parse('12:00')).cover?(Time.now)) ||
(Time.parse('13:00')..Time.parse('18:00')).cover?(Time.now)
switch_hosts.deny
else
switch_hosts.allow
end
EM.run {
scheduler = Rufus::Scheduler::EmScheduler.start_new
scheduler.cron '0 9 * * 1-5' do
switch_hosts.deny
end
scheduler.cron '0 12 * * 1-5' do
switch_hosts.allow
end
scheduler.cron '0 13 * * 1-5' do
switch_hosts.deny
end
scheduler.cron '0 18 * * 1-5' do
switch_hosts.allow
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment