-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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