Archive for June, 2009

Getting Notes to Sync in Mail from iPhone OS 3.0

One feature I am really excited about in the new iPhone 3.0 OS released on Wednesday is the ability to sync your notes with the Mail application in Leopard.  However, it took me a few tries to figure out how to get this to work exactly.  I realized that I ran into this problem because I had never created a note on my Mac in Mail, so this walkthrough assumes you are in the same position.  I’ve outlined the steps below:

  1. Enable Notes syncing in iTunes.  You can do this by going to the ‘Info’ tab when you have your iPhone/iPod attached to your computer.  Check the ‘Sync Notes’ checkbox about halfway down the page.notes-itunes
  2. If you go ahead sync your iPhone now, and you’ll notice that none of the Notes show up in mail.  If you have multiple mailboxes, they’ll be listed under the ‘Reminders’ heading in the Mail sidebar, with little note icons, but you won’t see any from your iPhone.  What you have to do is create a note in Mail now, by going to File > New Note.  Type something in and save it, and you’ll see a new note icon under ‘Reminders/Notes’ labeled ‘On My Mac’.  mailboxes
  3. Sync your iPhone one more time.  After its completed, you should see all your notes under the ‘On My Mac’.

2009 MacBook Pro Review

Got home yesterday and decided to buy a new computer – just quit my job on Friday and signed a new contract for Seabourne so I felt like I could use a newmacbook pro toy.  For the last three years I’ve been using a Core 2 Duo MacBook and a Lenovo Thinkpad T60 with Kubuntu.  I liked both computers, but have been feeling hindered by the lack of screen real estate, especially when coding.  About three months ago I almost bought a 15 inch MBP, but decided to wait until I had more money.  And boy am I glad I did!  The whole line of MacBook Pros were updated last week at WWDC 09, and they all just got a lot better, and a lot cheaper.  Here’s my quick review.

Unboxing
As usual, Apple has done a terrific job on packaging.  Even though the computer is a solid 2 inches wider than my MacBook, there is probably 1/3 less packaging total.  Rather than a soft sleeve, the MBP comes wrapped in a clear plastic, similar to what the iPhones now come in.  As usual, a small manual and restore CDs come in a box below the computer, along with the power supply.  However, Apple no longer includes a free Apple Remote with laptops.

Look and Feel
The computer is gorgeous.  No other way to put it.  If I could pick one adjective for the whole thing, it would be ’smooth’.  The aluminum has a beautiful satin finish that feels silky to the touch, but definitely has enough texture to make it grippable.  The screen has a glossy finish – I don’t mind, but I can see how this would bug some people as you really have to be careful not to touch it otherwise the fingerprints are glaringly visible.  The increased screen color gamut is obviously apparent when comparing this version of the MBP with any previous Apple laptop – the colors are much sharper.  I’ve noticed that the screen hinge seems much smoother than the MacBook.  It is easy to move the screen with one finger and have it stay in that position.

The keyboard is great, though the same chiclet style as all the Apple laptops are now (some people hate it).  The keys are much more firm than the MacBook, a big improvement.  I really enjoy the backlit keyboard, and there are some very handy function buttons to dim or brighten the lighting behind the keys.

Size & Screen
One of the major reasons I bought a new computer was to get more screen space.  I’ve enjoyed the size of the 13 inch MacBook, but just felt that I’d be more productive with a 15 inch notebook.  Given the width and weight are about the same for both models now, it turns out to be a gain without much of a loss.
Screenshot w terminals

The screen is vibrant and has what seems like twice the brightness of my old MacBook.  Honestly, I feel about twice as productive with the new setup (as you can see in the picture above, that’s probably because I can have two terminal windows open at once!)

This thing is thin!  Though significantly wider than a MacBook (obviously), it is probably 10-20% thinner.  The LCD has benefited from the LED backlights by dropping a few millimeters of width.

Trackpad and Gestures
One of my favorite things about the new laptop is the support for multi-finger gestures.  Three fingers side to side goes back and forward in the browser or the finder, four fingers up and down triggers exposé or shows the desktop.  This took a little getting used to, but now that it’s an ingrained habit, I find that it is really hard to go back to computers without these features.  I had to download the new Release Candidate of Firefox 3.5 to get the three finger gesture support.  The track pad itself is much larger than almost any other laptop, which is really great for scrolling both horizontally and vertically through large code blocks.  I have had no problem with the new integrated button.  Overall I’m pretty impressed with the selective sensitivity of the track pad; I can keep my thumb on the button part of the pad and use my finger for pointing, and everything works smoothly as it would with a dedicated button.

Battery Life
The biggest selling point for me on this laptop was the new lithium-polymer battery.  The downside is that it’s integrated tightly into the unibody enclosure so you can’t remove it yourself or swap out another battery for longer uses.  The upside is that the battery now gets about 5-6 hours of use per charge, more than twice what my old MacBook used to get.  I’ve tested it out for about a week now, and with standard use (wireless on, screen brightness at 50%, bunches of programs open) I can get 5.5 hours pretty consistently.  The battery is also now supposed to last up to 1000 charges, or three years of standard use, and is replaceable at an apple store for $129, the same price as a new battery for older laptops.

Summary
Overall, this is the best MacBook Pro ever, and I think the best Apple Laptop ever.  The 15 inch MBP is a great middle ground between portability and usability.  The new features make this a compelling computer to use, has increased my productivity, but most importantly, is a pure joy to use.

New Ruby Google Calendar API Gem: GCal4Ruby

I’ve written a few previous posts about using the Google Calendar API with Ruby and Ruby on Rails, but I’ve wanted to create my own library that includes the functionality I’ve had to monkey patch into others’.  So, I’ve gone ahead and created GCal4Ruby, a full featured Google Calendar API wrapper for Ruby available as a Gem.  You can download the source here or with ’sudo gem install gcal4ruby’.  Some of the features:

  • Clean, ActiveRecord style syntax and code structure
  • Full querying of calendars and events
  • Full calendar creation, editing and deletion
  • Setting public/private permissions for calendars
  • Event creation/editing/deletion
  • Support for full event recurrence
  • Support for event reminders
  • Support for event attendees

All of the major features have been implemented, and over the next couple of days I hope to complete the smaller outstanding todos.  Any help testing is much appreciated.  Below are some example uses.  For more information, check out the documentation.

Get all calendars for an account

       service = Service.new
       service.authenticate("user@gmail.com", "password")
       calendars = service.calendars

Create a new Calendar

       cal = Calendar.new(service)

Find an existing Calendar

       cal = Calendar.find(service, "New Calendar", {:scope => :first})

Find all calendars containing the search term

       cal = Calendar.find(service, "Soccer Team")

Find a calendar by ID

       cal = Calendar.find(service, id)

Create a new Event

       event = Event.new(calendar)
       event.title = "Soccer Game"
       event.start = Time.parse("12-06-2009 at 12:30 PM")
       event.end = Time.parse("12-06-2009 at 1:30 PM")
       event.where = "Merry Playfields"
       event.save

Find an existing Event

       event = Event.find(cal, "Soccer Game", {:scope => :first})

Find all events containing the search term

       event = Event.find(cal, "Soccer Game")

Create a recurring event for every Saturday

       event = Event.new(calendar)
       event.title = "Baseball Game"
       event.where = "Municipal Stadium"
       event.recurrence = Recurrence.new
       event.recurrence.start = Time.parse("13-06-2009 at 4:30 PM")
       event.recurrence.end = Time.parse("13-06-2009 at 6:30 PM")
       event.recurrence.frequency = {"weekly" => ["SA"]}
       event.save

Create an event with a 15 minute email reminder

       event = Event.new(calendar)
       event.title = "Dinner with Kate"
       event.start = Time.parse("20-06-2009 at 5 pm")
       event.end = Time.parse("20-06-209 at 8 pm")
       event.where = "Luigi's"
       event.reminder = {:minutes => 15, :method => 'email'}
       event.save

Create an event with attendees

       event = Event.new(calendar)
       event.title = "Dinner with Kate"
       event.start = Time.parse("20-06-2009 at 5 pm")
       event.end = Time.parse("20-06-209 at 8 pm")
       event.attendees => {:name => "Kate", :email => "kate@gmail.com"}
       event.save

Homemade Taco Seasoning

Hard-shell taco with meat, cheese, lettuce, to...

I love tacos.  They are one of the few perfect foods – both delicious and handy.  I used to buy the packaged taco seasoning at whole foods to add some flavor to the ground beef, but after a little experimentation, I’ve come up with a recipe for a damn good taco seasoning you can make at home for much cheaper.

Ingredients

  • 1 pound ground beef (preferably no more than 16% fat)
  • 3-4 tablespoons chili powder
  • 1 tablespoon garlic powder
  • 1 tablespoon onion powder
  • 1/2 tablespoon salt (may use more to taste)
  • 1 teaspoon dried cayenne pepper
  • 1 teaspoon red pepper flakes
  • 2 tablespoons salsa (any kind will do)
  • 1 tablespoon chipotle pepper sauce
  • 1/4 cup warm water

Instructions

  1. Heat a large skillet over medium-high heat.
  2. Add the ground beef and saute until the meet is cooked.
  3. Add the spices and the water to the pan and stir to combine with the meat.
  4. Continue cooking and stirring until the water has cooked off, about 5 minutes.  Serve immediately.

Creating a Ruby Gem

Ruby Gems are a the most common mechanism for extending the functionality of the Ruby language through plug-ins.  Similar to CPAN or PEAR, the Gem infrastructure allows users to download additional libraries from a central online repository and install it locally.  All you need to do is start a project at rubyforge.org, upload your finished Gem, and it will automatically appear in the central gem listing. As I was researching the steps for creating a gem, it was pretty clear that there wasn’t much of a comprehensive guide out there for beginners.  I’m hoping this article will help out those who are interested in creating gems, and save you some time as well.

Background
Building a Gem is actually pretty straightforward.  A gem is basically just a package of ruby code that has been assembled using the ‘gem build’ command.  If you’ve developed debian packages or RPMs, you are already familiar with this concept.  Essentially, the gem builder assembles the package, compresses it, and adds some metadata to help with the organization and installation of  your code onto any computer.

Getting Started
To create a gem, you’ll need some code (which I’m assuming you’ve already developed as a module), a pretty basic folder structure and a gemspec file.  First, lets take a look at a folder structure:

booksearch/
  README
  demo.rb
  lib/
    booksearch.rb
    booksearch/
      base.rb
      search.rb
  test/
    unit.rb

The folder structure above is for a gem called BookSearch.  Under the root directory, there is a README file, a demo.rb file and two directories, lib/ and test/.  The test/ directory contains a unit test file to verify the gem, and the lib/ directory is where all the code for the library is stored.  Directly in the lib/ directory is a file called booksearch.rb which is the file that is run when calling ‘require’ to load the gem.  All this file needs to do is load/require the correct files under the lib/booksearch/ directory.  Obviously then, the booksearch/ directory contains the actual code for the gem.  In the example above, there is the base.rb and search.rb files.  You can, of course, add other files and change the directory structure to suit your needs, but every gem will have a structure basically similar to this.

The Gemspec File
The core of the gem build process is the gemspec file.  This files contains all the metadata about the packaged gem, in additional to basic build instructions, similar to a configuration file.  Below is the gemspec file for my BookSearch gem:

Gem::Specification.new do |s|
   s.name = %q{booksearch}
   s.version = "0.1.0"
   s.date = %q{2009-06-02}
   s.authors = ["Mike Reich"]
   s.email = %q{mike@seabourneconsulting.com}
   s.summary = %q{A full featured Book Search API}
   s.homepage = %q{http://xxx.rubyforge.org/}
   s.description = %q{A full featured Book Search API}
   s.files = ["lib/booksearch.rb", "lib/booksearch/base.rb", "lib/booksearch/search.rb", "test/unit.rg", "demo.rb" "README"]
   s.rubyforge_project = 'booksearch'
   s.has_rdoc = true
   s.test_files = ['test/unit.rb']
end

There are a few key elements worth mentioning.  The ‘has_rdoc’ setting will alert Gem to the fact that your source code is commented to support RDoc documentation.  When a user installs your gem, RDoc will then be run on the source automatically to generate the documentation.  The ‘test_files’ setting is an array that should point to your unit test files, so that a user can choose to run the unit tests associated with your project through the gem command line tool.  You can see all the possible values of a gemspec file in the documentation.

Building Your Gem
Building a gem is a one step process.  You’ll want to place the gemspec file in the root directory of your gem, and then enter the command

gem build booksearch.gemspec

where ‘booksearch’ is the name of your gem.  The output of that command will be the fully constructed gem that you can install with the command

sudo gem install booksearch-0.1.0.gem

At this point, you can choose to distribute your gem any number of ways.

Conclusions
Overall, creating a Ruby Gem is much less complicated that creating a Debian package or RPM package.  The tools are well documented and clean, and the resulting package can be a powerful way to distribute your code to the world.

Kubuntu 9.04 Review: 2 Steps Back

Kubuntu logo

So I’ve now had a couple of weeks of use with Kubuntu 9.04 (Jaunty).  I did a standard update from 8.10, which thankfully went very smoothly.  However, I must say that generally I think this version is a step down (well, two very big steps in fact) in functionality and usability.  Here are the main areas I’ve run into trouble:

Bluetooth
If bluetooth was troublesome before, it is now practically unusable.  I’ve got a Microsoft bluetooth mouse and keyboard, both of which worked fine under 8.10 Intrepid, and which now work none only some of the time.  The mouse has a success rate of about 70% connecting to my computer and staying connected.  My keyboard has a 0% success rate.  The built-in KDE bluetooth manager is now completely useless, and does nothing as far as I can tell.  The default Gnome bluetooth-wizard works some of the time, but I can’t get my keyboard to keep a constant connection even when I’m using it.

Word on the street is that this is all due to the upgraded Bluez stack.  But, I can’t understand how functionality that existed and worked really well in the previous version has totally tanked in the current version.  I’ve basically given up using my bluetooth peripherals until a fix comes out (hopefully soon!).

Wireless
Again, the Kubuntu developers have delivered a downgrade in functionality and preformance with wifi in 9.04.  What used to be a manageable, if not quite elegant, solution in KNetworkManager has been replaced by a completely useless KDE 4 native plasma widget.  It looks pretty but is mostly broken.  First off, the new network manager has no way to connect to an unbroadcast SSID.  Second, it rarely remembers to reconnect to existing networks, usually prompting you to enter the password about 3 times before giving up in a confused befuddlement.  Third, the graphical elements are all fucked up.  The list of available networks in the panel is usually cut off so you can only see the first 1.5 entries.  You have to drag it off the menu and onto the desktop for the full list to display.  The proximity display view is even worse – all the networks are just overlayed on top of each other so as to make it illegible.

Both of these may seem like small issues, but they concern the two biggest uses of a computer: typing and using the internet.  What’s all the more disappointing is that the release has been out for over a month, and there have been no patches to address bluetooth, which is barely functional, or the network manager, which is in little better shape.

Upsides
There are a few upsides to this release.  First, KDE looks generally more polished with each release.  There has been a fix to font rendering so that now the font size doesn’t get all screwed up if you use a second monitor.  The fonts in previous versions of KDE 4.x were much too large and bold faced.  Kde 4.2 seems to have fixed this.  And FINALLY the display bugs in Firefox seem to be fixed.

Summary
In summary, there are some new features to make this release worthwhile, but overall there is clear lack of polish in key areas.  I’m still stumped as to how the Kubuntu developers thought it a good idea to issue release with a non functioning bluetooth stack and a really, really crappy network manager.  And I’m even more baffled that its been over a month since this release and there are still no bug fixes to address the display issues in the network manager (not to mention the crippling lack of features) or the non-functioning bluetooth stack.