Thursday, 9 August 2007

Textmate "Open Require" mod for gems

I discovered a TextMate bundle menu item for Ruby that got me excited at first.

If you have, for example,

require 'rexml/document'

in your file, select rexml/document and hit Command-Shift-D.

It can also be found under Bundles -> Ruby -> Open Require. This will open a project for that item. It's great for looking under the covers to see the source for a library you are using.

I had tried it before, but it didn't seem to work. That's because it failed for any require that used a gem name. The following modification causes Open Require to open any file or gem:

1. Go to Bundles -> Bundle Editor -> Show Bundle Editor
2. Select Ruby -> Open Require
3. Paste the following, and then click on another bundle item so that it saves the change.


#!/usr/bin/env ruby
gems_installed = require 'rubygems'

file = STDIN.read.sub(/\A(["']?)(.*)(\.rb|["'])?\1/, '\2.rb')
dir = $:.find { |d| File.exist?(File.join(d, file)) }

if dir && file
project_root = File.dirname(File.join(dir, file))
elsif gems_installed
gem_spec = Gem::GemPathSearcher.new.find(file)
if gem_spec
project_root = gem_spec.full_gem_path
end
else
project_root = nil
end
if project_root then
ENV['FILE'] = project_root
%x{ "$TM_SUPPORT_PATH/bin/mate" "$FILE" }
else
puts "Could not find include: ‘#{file}’"
end


This is now one of my favorite Textmate bundle items!

Sunday, 1 July 2007

FINALLY!

My phone finally got activated this afternoon after I spent several hours on hold for AT&T and Apple support. Interestingly, the AT&T support people were super friendly and knowledgeable, and the Apple people I talked to were pretty clueless.

I'm not going to do an in-depth review on the phone's features because so many other people are taking care of that. I will say that the device is everything I hoped it would be and more. It is an absolute pleasure to use.

In my upcoming posts I will be focusing on the technical capabilities and challenges of developing applications for the device.

...and waiting...

It's now almost 36 hours since I tried to activate my iPhone. I called AT&T yesterday, and actually spoke to a live person, without being on hold or having to go through a menu system. So they are doing something right.

I got the following email from them this morning:


Saturday, 30 June 2007

iPhone plans deRailed

The Plan

I have a site I am working on that would be perfect for the iPhone. It is group.ogr.am, a Ruby on Rails site for scheduling spontaneous meetings that don't have organizers. I will be blogging about this from a technical point of view. Here was the plan:

  1. Get my iPhone at 6:00 pm
  2. Rush home.
  3. Activate the phone.
  4. Start coding, figuring out what the iPhone is capable of from a technical point of view.
  5. Release a prototype on Monday.
Plan Execution: Steps 1 and 2

I am currently in Oriental, NC, which is known as a "quaint little drinking town with a sailing problem." It is a technological desert, with limited cell phone service, and no Apple stores within 100 miles. At my parent's house, where we are living until the end of July, I can get one bar of service if I stand on the deck railing and face north. If I walk half a mile to the Oriental bridge, I can get two or even THREE bars of service.

I went to the nearest AT&T store in New Bern at about 3:30 pm. There were about ten people in line, so I did some shopping and came back to secure spot #15. When the line grew to about 30 people, the store manager came out, counted us, and said we should be okay. Someone in line had heard that this store had received 30 iPhones the day before, and this seemed to confirm this rumor.

After the doors opened at 6:00 we stood in frustration as the AT&T point of sale systems came to a screeching halt. Every AT&T store in the Eastern time zone was handling sales at that moment. It took about thirty minutes for the first two people to complete their purchases. I realized that at 7:00, the next time zone would hit, and the problem might get even worse. Fortunately things started moving again, and I walked out of the store with 'My Precious' iPhone at 6:55. Step #1 of plan was complete.

I rushed home, completing step #2.

Execution Plan: Step 3

I got home, updated iTunes, and plugged My Precious in. As with all things Apple, the out of the box experience was amazingly smooth until...


I checked my email every few minutes until I went to bed. The Apple support forums were lit up with irate people having the same problem. Of course the AT&T support phone lines were completely jammed, and eventually their switchboard crashed due to the overload.

This morning, I woke up, and checked on it. Same thing. I suspect it may be due to my limited service here, so I am going to walk to get some coffee in town at The Bean. This will take me over the Oriental bridge, where perhaps the service will be able to activate the phone.

Looks like a good day to go sailing...