The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
A Simple Hack for Getting Things Done

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Britt

Posts: 1319
Nickname: jamesbritt
Registered: Apr, 2003

James Britt is a principal in 30 Second Rule, and runs ruby-doc.org and rubyxml.com
A Simple Hack for Getting Things Done Posted: Sep 4, 2005 9:38 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by James Britt.
Original Post: A Simple Hack for Getting Things Done
Feed Title: James Britt: Ruby Development
Feed URL: http://feeds.feedburner.com/JamesBritt-Home
Feed Description: James Britt: Playing with better toys
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by James Britt
Latest Posts From James Britt: Ruby Development

Advertisement

I'm not remarkably organized, but I'm much better than I was a year or so ago. independent contracting and consulting, plus being being part of a start-up, provides remarkable motivation to up the org skills.

I had been using Outlook as my calender application for some time, and while it does not use a nice, open, easily hacked text-file format, I liked (or got used to) the behavior, the UI, and assorted little details. Plus, I found it fairly easy to write some Ruby helper apps to manipulable entries.

However, since getting a new laptop, I've been trying to make peace with Sunbird. While it uses an open file format, I've yet to write anything as handy as my Outlook apps.

I tend not to keep too many applications running all the time, prefer to conserve CPU for actual development effort. I run Thunderbird every so often, but close it down after half an hour. With a calender app, though, I need to have up in order to have alarms pop up, so I use task scheduler to run to ten minutes before each hour. But to ad a new alarm means launching the app if it is not already running, and all sorts of clicking and typing.

Mostly this is tolerable, especially if I expect to be altering the task reminder and resetting the alarm. Often, though, I simply want something to pop up and tell it is time to do this or that (such as watch something in Book TV).

Despite being on WinXP, I spend much time suing the cmd shell, so I concocted a Ruby script that would write a little note, then use the at command to schedule the note to pop up at a given time. Now can easily (again) type remainders to myself at the command line, making it less likely I will forget to do something.

# File hey.rb
#
# First, simple help:

def help

puts "Need to pass a time and a message:" puts " d:\> hey 13:30 This is my message" puts " or some minutes and a message:" puts " d:\> hey 15 This is my message" puts "But if you leave out a time then it defaults to 60 minutes into the future" exit

end

 

help unless ARGV.size > 1

 

# Grab what is probably the time data

t = ARGV.shift

 

# But munge stuff if doesn't meet some criteria

if t =~ /\d/

unless t =~ /:/ t = Time.new + ( t.to_i * 60) t = "#{t.hour}:#{t.min}" end

else

ARGV.unshift "#{t}" t = Time.new + (60*60) t = "#{t.hour}:#{t.min}"

end

 

# Grab what remains, and make it one long string:

msg = ARGV.join( ' ' )

 

# Create a temp file name

fname = t.gsub( ':', '-') + '.' + rand( 400 ).to_s

 

# Write the message to a temp text file

File.open( "c !temp {fname}.txt", 'wb'){ |f| f.print msg }

 

# Write out a temp batch file for 'at' to call.

File.open( "c !temp {fname}.bat", 'wb'){ |f| f.print "start c:\temp\#{fname}.txt" }

 

# Now schedule the batch file

puts `at #{t} /INTERACTIVE "c:\temp\#{fname}.bat"`

 

I make no claims that this is the best way to do this sort of thing, but it was easy and it works.

BTW, one thing that was not obvious to me was the need to use the /INTERACTIVE switch. It seems that without that switch the commands will execute, but you never see anything, which is first puzzling, then useless.

Read: A Simple Hack for Getting Things Done

Topic: Funked Out Java+Ruby Aggregator Previous Topic   Next Topic Topic: Upgraded to Typo trunk

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use