Skip to content

Instantly share code, notes, and snippets.

@kattrali
Forked from cyberfox/whazzup.rb
Created January 26, 2011 11: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 kattrali/796601 to your computer and use it in GitHub Desktop.
Save kattrali/796601 to your computer and use it in GitHub Desktop.
Asks for status every 15-25 minutes to track where time goes. Traps USR2 to wake and prompt for status. Designed for Linux, works on OS X, needs tweaks for Windows. Uses JRuby, since it's the only easy-to-get cross-platform UI toolkit for Ruby.
require "java"
java_import javax.swing.JOptionPane
class Whazzup
def initialize(file = "#{ENV['HOME']}/snippets.txt")
@snippets ||= open(file, 'ab')
log('[Starting up (ruby)]')
thread_loop = Thread.current
# Use the USR2 signal as a 'wake up'.
Signal.trap("USR2") do
thread_loop.run
end
end
PROMPTS = ["What're you working on?",
"What'cha up to?",
"What's going on?",
"How goes it?",
"What's the plan?",
"Where are you at?",
"What's next?",
"What've you been up to?",
"Status:",
"Anything I can help with?",
"What's happening?",
"What's on your mind?"]
def log(msg)
@snippets << Time.now.to_s << ': ' << msg << "\n"
@snippets.flush
end
def ask
picked = PROMPTS[rand*PROMPTS.length]
answer = JOptionPane.showInputDialog(nil, picked)
answer = '...' if answer.nil? || answer.empty?
log(answer)
end
def run!
while true
ask
# Sleep between 15 and 25 minutes
sleep (((rand*10).to_i-5)+20)*60
end
end
end
whatsup = Whazzup.new
whatsup.run!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment