Adam Jarret

Blog

You should be using Coda

| Tags: coda, cyberduck, macfuse, opinion, smultron, web-dev, zend-studio

I have been hearing great things about Panic's Coda since it came out, but as a broke college student doing web sites on the side I was put off by the $99 price tag.

Up until now I have been using the fantastic and free Smultron and Cyberduck apps to handle my text editing and file uploading needs.

After starting my first full-time software development job last week, I found myself in need of a solution that would let me edit files directly on a development server. Connecting to the server via ssh in order to edit files in vi got old fast, so I tried mounting an SFTP volume using macfuse, but found editing files to be slow and occasionally unreliable.

It was then that my employer provided me with a license for Zend Studio and got me thinking about an all-in-one solution. Zend Studio is fine if a bit clunky, but I found myself wishing for features I missed from Xcode and for a more Mac-like experience in general.

Enter Coda, the app that promises "one window web development" and oh my god does it deliver. I won't go into the complete feature list here, but suffice it to say that I was blown away by how fluid and streamlined my work flow became while using it. The key commands I use in Xcode, cross-file find, fantastic code completion, it's all there.

I know I'm a little late to the party on this one, but I fully intend on plunking down my $99 when my two week trial is over. As far as I'm concerned the folks at Panic earned it.

Coda by Panic

Top

Setting the back button title of a UINavigationItem

| Tags: cocoa, iphone, iphone-dev

The following code will set the back button title of the current UINavigationItem:

Updated to fix memory leak. (Thanks Sam!)

1
2
3
4
5
6
7
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
    initWithTitle:@"Back"
            style:UIBarButtonItemStylePlain
           target:nil
           action:nil];
[self.navigationItem setBackBarButtonItem:backButton];
[backButton release];

The target: and action: parameters are definitely ignored (replaced by the default back button behavior) and the style also seems to be ignored because the back button retains its pointed left side.

This next block of code looks like it should do the same thing but does not work:

self.navigationItem.backBarButtonItem.title = @"Back";

This is because the back button is "owned" by the previous view on the stack (as pointed out in this thread). In other words, the setBackBarButtonItem method should be called on the view that the user is navigating away from, rather than the view above which this button is actually displayed.

UINavigationItem on Apple Developer Docs

Top

Avoid a UITableView headache

| Tags: cocoa, iphone, iphone-dev

When using a custom section header view on a grouped UITableView, remember to implement the heightForHeaderInSection delegate method.

I initially left this out of a recent project because the documentation for the UITableView delegate method viewForHeaderInSection states:

The table view automatically adjusts the height of the section header to accommodate the returned view object.

What actually happened is that my header view was being clipped at the top and bottom, even though it was a UILabel which was the same font, weight and size of a standard section header (for the curious: I was attempting to change the text color).

A quick perusal of the documentation revealed the existence of a heightForHeaderInSection delegate method which made the view display as expected and there was much rejoicing.

UITableViewDelegate on Apple Developer Docs

Top

WordPress iPhone app

| Tags: iphone, twitter, wordpress

I recently got an iPod touch on loan from a client that I'm using to debug an iPhone app for him.

Since I've never be in possession of an iPhone/iPod touch before, (I do most of my work with the iPhone simulator) I've been playing around with some of the free apps in the iTunes App Store.

After finally getting around to updating this blog to the newest version of WordPress, I stumbled across the WordPress iPhone app, and I must say I'm impressed. It's a little clunky to type HTML on the keyboard because letters, the / character and the < and > characters are on three different screens that you have to switch between.

Other than that, the app was ridiculously easy to set up to work with my blog and gives pretty complete access to all posted content. As cool as it is, I am running the app on an iPod touch instead of an iPhone so I have to be near a WiFi hotspot to post anything, which means I'll probably still just txt stuff to Twitter.

WordPress for iPhone on the App Store

Top

GMaps2MBTA Bookmarklet

| Tags: bookmarklet, google-maps, javascript, mbta, projects, web-dev

I moved to Brighton, MA at the beginning of September and as a result I no longer have much use for a car. I live right on the B line which - as a supplement to my old size 11s - gets me everywhere I need to be.

Since I'm new to the area, I have been using Google Maps a lot. While it's helpful to gain a general idea of where things are, it was becoming a frequent annoyance to cut and paste the start and end addresses from the Google Maps directions page into the MBTA Trip Planner.

To solve the problem I took my first stab at writing a Javascript bookmarklet.

The MBTA trip planner form submits "post" data, so my first approach was to create new a new form object in Javascript and submit it. This version worked fine in Safari and Chrome but did not work in Firefox for some reason.

Luckily, before I got too deep into debugging the script, I noticed that the MBTA trip planner would also accept "get" form data which allowed me to create a 3 line version of the bookmarklet that neglected creating objects entirely.

Both versions of the script are posted below. On a related note, I can wholeheartedly recommend the Bookmarklet Builder from subsimple.com to compress the script for use as a bookmarklet.

GMaps2MBTA

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
javascript:(function(){
var start = document.getElementById('d_d').value;
var end = document.getElementById('d_daddr').value;
var mbta_form = document.createElement("form");
mbta_form.action = "http://mbta.com/rider_tools/trip_planner/";
mbta_form.method = "post";

var sa = document.createElement("input");
sa.name = "sa";
sa.value = start;
mbta_form.appendChild(sa);

var ea = document.createElement("input");
ea.name = "ea";
ea.value = end;
mbta_form.appendChild(ea);

mbta_form.submit();
})()

GMaps2MBTA-FF

1
2
3
4
5
6
javascript:(function(){
var start = document.getElementById('d_d').value;
var end = document.getElementById('d_daddr').value;

document.location.href='http://mbta.com/rider_tools/trip_planner/?sa='+escape(start)+'&amp;ea='+escape(end);
})()
Top

LukeJarretMusic.com revision

| Tags: ajax, javascript, joomla, php, web-dev

My brother Luke is an avid musician who writes, performs, records and produces his own music - with very little equipment.

I rebuilt his web site using Joomla in an effort to gain some experience with Joomla 1.5.

My brother's main concern for the site has always been an uninterrupted listening experience for the visitor. I accomplished this by implementing a custom link behavior in Joomla's admin pages that allows me to create links that load HTML content into a <div> on the current page instead of opening a new page. This way the music player does not need to be restarted when a user navigates away from the page.

You can check it out at lukejarretmusic.com.

Joomla