Saturday, January 21, 2006

Goodbye Outlook 2003... Hello IMAP + Fastmail

I have started the preparations for the upcoming arrival of my MacBookPro. Right now email is by far my biggest worry. I use it every day, I've got lots of it, and the transition needs to be seamless. My email constraints:

  • I use Outlook 2003 on my laptop and frequently queue email while traveling.
  • In my main outlook.pst file I have 1/2 GB of email dating about 6 months.
  • In my archives, I have well over 4 GB. I keep the archives always open in Outlook so that Google's desktop search scans the archived email.
  • I currently use POP on my laptop and my office computer--and constantly delete the same SPAM and repeat organization tasks on each machine. (If I can kill this step in my transition, I will be VERY happy.)
  • I have 4 or 5 alias addresses, one main pop account on yahoo business (their spam filter has worked excellent for my needs), and a gmail account I use rarely.
This isn't the first PC to Mac transition I've orchestrated--my wife has a Powerbook and I used Outlook2Mac to take her 1000 or so Outlook emails (and contacts) to Mail.App on the Mac. The product worked great and I highly recommend it; however, I really don't want to maintain 4GB of my own email anymore. Computers break, hard disks crash, and my email is a record of my business (and personal) history that I can't imagine losing. I want a hosted solution, and making the switch now should make my transition to Mac all the easier. Like I say--I'm a rare user of GMail, but it has a very clean interface, snappy searching, and the google brand to boot. I thought it would be a good option for me, except for two reasons: (1) my GMail account currently has a 2.5GB limit (vs my 4GB of email), and (2) GMail only supports POP, so if I want to use a mail client, I'm going to either be organizing my email locally (and back into the managing my own email dilema), or making updates to both my local mail files AND on my google account. I figure with a little effort I could lose some large attachments and get my mail to fit in Gmail. That solves problem 1, but I'm still stuck clearing SPAM and moving messages from my inbox on both GMail and Mail.App/Entourage. The real issue (regardless of my switch to Mac) is that I am the ideal candidate for using IMAP. IMAP keeps mail on the mail server, and your mail client just provides an interface to the server's files. This means that moving an inbox message to "save" through my laptop client will cause the message to be moved when I open my desktop mail client or if I login to my mail provider's website. There is a bit of hidden sophistication here in that my mail client keeps some of the mail copied to my local computer for performance reasons, but should handle all of this behind the scenes. A digression here--Why wasn't I already using IMAP? I looked into IMAP through Outlook years ago and it was nearly unworkable. I hear it's much better today, and regardless, I now have much more choice in mail applications that support IMAP than just Outlook. OK--so without IMAP support, GMail is out. My main Yahoo account has 2GB and no IMAP support, so no better than GMail there. I did a few internet searches and Fastmail comes up as a big contender for hosted IMAP mail. I look in my saved emails and find a good friend has a fastmail account--and speaks well of them. In half an hour, I've signed up for their highest account which has IMAP and 2GB of access (expandable at a one-time $199/2GB). Their web interface is so-so, but workable. I get the account setup in Outlook 2003 and see the fastmail folders alongside my personal folders and start moving email. At this point, all hell breaks loose on my machine (see below), but in the end all my email is moved to Fastmail. I setup Fastmail to auto-pop my mail from my yahoo and gmail accounts and setup some really basic rules to emulate those I had on Outlook, and fastmail is looking really, really good. The final step is setting up IMAP to fastmail on my office computer and seeing the view to my email identical to my laptop's. It's now one day after my switchover and I really like the setup. I am already spending less time clearing spam and no longer duplicating my organizing. I still have a few unknowns--will fastmail be dependable? will my Mac IMAP client be workable? will I still need to make backups (a topic for another time)? but I have high hopes for making the setup work. ---------- The bump in the road: I'm in Outlook and try moving one mail item to fastmail. It works fine, so I grab 5000+ emails in my save folder and start them moving. A progress meter appears telling me things will take 3 hours. Two minutes later, I get the blue screen of death and my computer restarts... Now I've had blue screens so rarely on this computer, I can't remember even one of them. I assume it's some random instability and when my machine restarts, I try again. This time I select 10 emails to move. They go fine. I try 100, and somewhere in the process I get blue-screened again. Frustratingly, I try all sorts of permutations for moving mail--nothing seems specifically seems to trigger the reboots, but my confidence level drops substantially. I download Thunderbird and import my email from Outlook. I start Thunderbird moving my email and things look OK for 30 or so emails. Then I get a weird "no newlines in email" message and it aborts the move. I try again and WHAMMY! Blue screen of death. Tasting the success around the corner, I remote login to my office machine, and try sending some of the Outlook archive mail to fastmail. It works without a hitch! I copy my local mail files to my office computer and pretty soon 2GB of mail is on fastmail. My laptop works absolutley fine as long as I do not use any program that interfaces to IMAP. I would be happy to recreate for any eager Microsoft engineer out there ;-). In the meantime, I'm even more excited about being Outlook-free.

Sunday, January 15, 2006

Helpers + Partials = Partial Controllers

I am far enough along the Ruby on Rails learning curve to have strategic questions rather than syntax ones. These are generally harder to find out-of-the-box solutions to on the web, so I'll share a recent solution I've grown. My problem grew out of a webpage that was built from a number of reusable "widgets." I started to build the page by modularizing the widget view into a partial. For example--a calendar widget is stored in:

app/views/modular/_calendar.rhtml
and included in my view with:
<%= render :partial => 'modular/calendar' %>
However, I found that I kept pushing more and more logic into the partial view. This was not good MVC design and didn't seem to be "the right way" to do things. I thought about putting the logic into my controller, but I use the module on many pages, which would mean duplicating the logic in each controller. I looked around the net, but the only simliar solution I found was to write the calendar as a helper, and generate the view HTML within the helper with TagHelper or Builder. This meant converting the HTML in calendar.rhtml into hard-to-modify programmatic statements. This seemed just as contradictory to MVC as my solution. What I really wanted to do was to have some sort of pairing between the partial view and its associated code--like a "partial controller". This would allow my HTML to stay in a view template, without any of the cumbersome code present. I thought about what Rails mechanism would support this concept and decided to see if the helper system would be a good fit. First I moved all of my calendar logic into the helper for one of my pages (dashboard_helper.rb). Then I needed to make one call to the helper (prepare_calendar) before displaying it. Since helper code is only available from views, I put a <% prepare_calendar %> above the render :partial statement and it worked. With this encouragement I wanted to repeat the integration on other pages that included the calendar. I needed to make the helper code accessible to the other pages and moved the code into my application_helper.rb. This was a workable solution, but I felt my application_helper.rb was being misused. I decided to look for outside support and wrote to the mailing list for the upcoming Pragmatic Studio I'll be attending. Dave Thomas gave me a quick response that I could relocate the helper code into a new helper (calendar_helper.rb) and include it in any controller with:
helper :calendar
I moved the code again and everything looked even better. Adding a calendar to a page now required: 1) in the page controller add helper :calendar 2) in the page view add <% prepare_calendar %> 3) in the page view add <% render :partial => 'modular/calendar' %> This was good, but I felt I could do better. Every time I called prepare_calendar, I then called render :partial. I thought, why not put the render :partial call right into calendar helper and save myself an extra call for each render? Now this may not be a big leap for many, but for my knowledge of rails, I wasn't sure if this would even work. As it turns out--it does. My final code looks like:
---- app/helpers/calendar_helper.rb
module CalendarHelper
 def calendar(args)
    # Ready the view vars like:
     @calendar_highlighted_day = Time.now.to_date
    # Display the template view:
     render :partial => 'modular/calendar'
 end
end

--- app/views/modular/calendar.rhtml

The day is: <%= @calendar_highlight_day %>

--- app/controllers/dashboard_controller.rb
class DashboardController < ApplicationBase
  helper :calendar
end

--- app/views/dashboard/index.rhtml
<%= calendar %>
Now all my views (dashboard.rhtml and calendar.rhtml) stay logic-free, and my code goes into one widget-specific location (calendar.rb). I've now used this technique on several of my widgets and have not run into any difficulties as of yet. I'm interested to hear if this is a valuable solution to anyone else--or if there is a better approach I could be using.

Saturday, January 14, 2006

MacBook Pro = My VAIO replacement...

I have been considering the switch to Mac and the new machines have won me over. I am amazed at Apple's ability to innovate and continue to deliver excellent--both esthetically and technically--products. I bought my mini PCG-TR3AP sub-notebook VAIO which has a 12" screen for its 8 hour life on its extended battery. I've ordered my MacBook with an extra battery, so I should be able to match the 8 hours I get today (rated 4 hrs each)--and a cool Mac-only feature is the reserve power in the laptop. This allows the computer to stay alive in sleep mode during a battery-swap. That plus Mac's instant sleep equal a good experience from my point of view. The MacBook will be much bigger since they are only selling the 15" version as of today. But I'm looking forward to using it as an occasional media device. Front Row is the "right way" for a media computer to become useful in my house. The DVI out is also a nice option compared to my Sony's VGA. As far as productivity on is concerned: I do a considerable amount of development work--generally using Putty to my linux boxes--which will be no problem on the Mac. I've also been migrating off of MS-specific tools for some time--I'm using hosted applications where possible (Outlook -> Yahoo Mail). The last mile will be finding replacement for those few apps with no matching Mac equivalent MS Project, MS Money and Visio immediately come to mind, but I'm sure there will be more. I think making these trade-offs for an integrated Unix-based OS is a good one. I plan to migrate most (if not all) of my development work locally to the Mac. Besides performance, I'll be able to development offline and hopefully adopt some of the richer tools (that Cocoa MySQL front-end in the Ruby on Rails video looks slick) built for the Mac GUI. I will post anything interesting I discover on my transition. By the way, that does mean I have for sale one SONY VAIO notebook PC. Post a comment if you are interested in the details...

Ruby console...

I've had the pleasure of working on a large lisp project years ago and became tied to using the console to do interactive development. Ruby on Rails' console (./scripts/console) is very similar and I've found it to be a great tool for my RoR projects. Lisp & emacs work together seemlessly to allow source editing and iterative debugging and I'm striving to find (or create) a similar ruby environment. My basic solution has been to keep one copy of the console running and frequently reload my sources. I was banging my head against the wall using require as it only reloads a source file once, then refuses to load the same file again: >> require 'app/models/user.rb' => true >> require 'app/models/user.rb' => false Instead I found using load will continue to reload the file (allowing me to update successive changes): >> load 'app/models/user.rb' => true >> load 'app/models/user.rb' => true This has worked well when I make a change in one source, but often I want to reload all the sources without losing the local variables I've readied in the console. I have not yet found a way to do this and would love to hear any thoughts on a solution. Today I just quit the console and restart it, and then start over readying my in-memory variables for testing/debugging.