Friday, October 28, 2011

Moving Thunderbird from a PC to a Mac

This was pure awesome sauce when I heard I could do it.

I had been using Thunderbird on a PC for about two years before needing to move over to a Mac, OS X Lion, to be specific. Thankfully, you can move your Thunderbird profile from a PC to a Mac with hardly any fuss at all.

1) Open up a terminal window. You should be in your user directory by default. If not, get there. The user Library directory is hidden now in Lion, so you have to unhide it with the following command. Once you run this, you can see it in Finder: chflags nohidden ~/Library

2) Exit Thunderbird if you have it running. In Finder go to Users/[user]/Library/Thunderbird/Profiles/[existing default profile]/. Copy the contents of your Windows profile directory into the existing default profile directory on your Mac.

Open Thunderbird and you're done! I had all my emails, my email server settings still worked, and all was well with the world.

As always, make sure you backup anything you're copying over.

Sources:

Thursday, October 20, 2011

Testing for an empty sequence in XQuery

In an XQuery code base I was maintaining recently, all external variables were strongly typed as strings (declare variable $input as xs:string external;). This saved some time and lines of code since we always knew the type of those variables and the code would fail fast if they were not strings.

Unfortunately, the writers of the calling code decided it was too hard to make sure an empty string was passed in for certain cases and they wanted to pass in null, which was translated to the empty sequence. Rather than make edits to many different functions, we edited the main modules to be more defensive.

For some reason I have a hard time remembering how to test for an empty sequence and I also wasn't sure if I could redefine a declared variable in a FLOWR so I wrote the little test snippet below.
xquery version "1.0-ml";
declare variable $input := ();

let $original-input := $input
let $input := if(fn:empty($input)) then "" else $input

return (
element results {
element original-input-empty { fn:empty($original-input) },
element revised-input-empty { fn:empty($input) }
}
)