November 22, 2009

Getting the most Development from your Mac (RIA Unleashed: Boston 2009)

Shannon Hicks

Misconceptions
* You are not just using a Mac
* You are not immune

Finder
* Verbose boot using CMD-V
* Use the Go menu (Go to Folder)
* Keyboard Shortcuts (Screenshots)
* Show Hidden files
* Hidden preferences: secrets.blacktree.com
* Spotlight
* Quick View (space to preview)

Terminal
* Can be faster than the finder
* The Tab key is your friend
* Use nano for editing instead of vi
* Copy and paste work in the terminal
* Reference: ss64.com/osx/

Ports
* Most applications for Linux also exist on the Mac
* MacPorts www.macports.org (Requires Dev Tools developer.apple.com)

GUI Tools
* Console
* File Merge
* iCal/iChat

www.iotashan.com/WWSU

Backups
* Time machine is handy
* Off-site backups are critical (JungleDisk)

Passwords
* 1Password

Virtualization Software
* VMWare Fusion
* Parallels Desktop
* Sun VirtualBox (Free!)

Source Code Control
* Versions (best out there, but still bad)
* Cornerstone (okay, but still bad)
* Everyone misses TortoiseSVN

Services
* MAMP Pro
* xampp or MAMP are free alternatives
* Navicat as MySQL GUI

Editors
* TextMate

Demos
* Camtasia
* Jing (free/cheap alternative)

Tags: mac riaunleashedboston2009

October 24, 2009

Tangent City

I blame Dave for wasting most of my day... He sent out a message saying that the URL of his site had changed. As part of that the URLs for his RSS feeds changed. I'm currently using Google Reader and wanted to update the feed URLs. I'm on a Mac and use Safari for my browsing needs. By default in Safari when you click on a link that is a feed it opens in Safari's RSS reader, not what I wanted. Off to investigate other options.

A quick Google search led me to a menu bar Google Reader tool that can also act as Safari's RSS reader. More than I wanted but a great option if I wanted to stay more on top of my RSS feeds. Not something I need to be doing.

At this point I'm vague on how I went down the path but I thought I'd create my own application to do what I wanted with an RSS feed. I really wanted to duplicate the "Add to Google" button behavior so I tracked down the documentation and then wrote a short Perl script to take an arbitrary URI and use that feature. For those interested the script is:

#!/usr/bin/perl -T

use strict;
use URI::Escape;

# verify that a URI exists to add
if (scalar(@ARGV) < 1)
{
    die "No URI passed.";
}

# untaint the path as exec is used
$ENV{"PATH"} = "";

# uri_escape_utf8() used in this context effectively untaints the data
# but given how it operates it doesn't satify Perl's untaint
# requirements. Since the PROGRAM LIST version of exec is used, a
# fairly liberal regexp can be used to untaint the uri.
my $uri = uri_escape_utf8($ARGV[0]);
if ($uri =~ /^([A-Za-z0-9\-_.!~*'()\%]*)$/)
{
    $uri = $1;
}
else
{
    die "URI is not safe : $uri\n";
}

exec("/usr/bin/open", "-a", "/Applications/Safari.app", "http://fusion.google.com/add?source=atgs&feedurl=$uri") || die "Unable to exec /usr/bin/open : $!\n";

It was only after writing the script that I realized one can't have a script act as an application on a Mac. Turns out there are two great options for packaging a script as an application. The first is DropScript and the other more fully feature one is Platypus. Turns out neither one worked for me. Despite twiddling all the knobs that I could with each program, my script never got passed the URI of the feed when I clicked on it in Safari.

Back to searching some more and I ran across a very light weight application called reader-helper that did most of what I wanted. As noted though there is a little bug in the program that causes Google Reader to freak out a little when clicking on a link. A quick scan of the program's source let me see that it would be easy to change the code to use the other URL for adding the feed and fix the Google Reader issue. Along the way I also fixed some missing URI reserved characters that should be encoded when passing a URI as a query parameter. The patch ended up being:

Index: GoogleReader.m
===================================================================
--- GoogleReader.m      (revision 8)
+++ GoogleReader.m      (working copy)
@@ -13,8 +13,8 @@

 +(void)subscribeToFeed:(NSString *)feedURL
 {
-       NSString *apiStr = @"http://www.google.com/reader/preview/*/feed/";
-       CFStringRef feedStr = CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)feedURL, NULL, (CFStringRef)@";/?:@&=+$,", kCFStringEncodingUTF8);
+       NSString *apiStr = @"http://fusion.google.com/add?source=atgs&feedurl=";
+       CFStringRef feedStr = CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)feedURL, NULL, (CFStringRef)@":/?#[]@!{{content}}amp;’()*+,;=", kCFStringEncodingUTF8);
        NSString *cmdStr = [apiStr stringByAppendingString:[NSString stringWithFormat:@"%@", feedStr]];
        NSLog(cmdStr);
        [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:cmdStr]];

My next problem was recompiling the source to incorporate my change. Thankfully all I had to do was wait for the newest XCode to download. Once I installed XCode creating a new binary was a snap. A ran into one last little issue in that Reader Helper doesn't exit after being launched. I had to manually kill the executable before my new binary was recognized.

While this wasn't how I thought I was going to spent my day it felt really good to just hack around on a little problem that was bugging me. It feels even better to have found a solution.

Tags: code hack mac

November 17, 2008

Nude Riding a Bicycle and In Bed with Google

It feels like ages ago that I made a post even though its only been a few weeks. I've been a little busy and writing a blog entry was fairly low on the list. After last night's activities I feel compelled to fill the gap.

Awhile ago Allurent moved and in the process I acquired a mannequin. At the time I solicited suggestions but nothing inspired me. Earlier this week Annalisa sent me information about a Halloween Bike Ride that was taking place around Boston. Given that I hadn't come up with any other Halloween plans it sounded like a grand idea. It also served as the inspiration for decorating my bike, with what else but, a mannequin. Given the reactions I got while bringing it home on my back I figured a more elaborate setup (and one that I could ride with for the night was in order).

TR gave me the idea of mounting it to my bike rack which would better support the weight than strapping it to my bike like I did in order to get it home. The tricky part was figuring out how to get it on the bike so that it made some sense and could still be ridable. Thankfully with some help from Clara, 3M Packaging Tape, and a little ingenuity it came together. Hence was born "Nude Riding a Bicycle". The ride itself was a blast with over 240 riders starting it off. Some dropped off as the route meandered around Boston but there was a strong presence to the end. My hats off to the organizers for a great night and to New England weather for making the night tolerable.

In other news I've gotten in bed with Google more than I thought I ever would. For a long time I've been running this little neck of the Internet known as NeoPhi including my own web server, mail server, etc. It's given me the freedom to do just about whatever I want. This month I changed some of that. In particular I changed my mobile phone. While for some this maybe a common occurrence, it isn't for me. This is only my third mobile phone, ever. My previous two were each with me about 5 years. It's not that I haven't thought about getting a new phone I just didn't find anything worth switching to.

I seriously considered the iPhone but couldn't justify the price and frankly wasn't that interested in switching from T-Mobile. I looked into some other 3G phones that debuted in European markets but T-Mobile's 3G service either wasn't compatible (since it used a different spectrum) or didn't exist were I would have been using it. Flash forward to a couple of months ago when the G1 was announced. A form factor that was close to my old phones, a platform I could easily develop for if I wanted to, it worked with my provider of choice, and had some cool apps. Without ever seeing one in person I pre-ordered it and picked it up the night of Oct 21.

My impressions so far have been very favorable! My biggest complaint is that with only some of the features turned on the battery drains pretty quickly. My last phone would last at least 3 days between charges while with the G1 I'm having to charge it every night. The touch screen is great and having access to a full physical QWERTY keyboard has made working with it a breeze. The web browser has handled various sites I've thrown at it and I've already downloaded and used some other applications from the Android Market.

In order to start using the phone though you must tie it to a Google account. While I do have a GMail account, it isn't my primary email address. I mostly created it to get access to Google features before they let you sign up with any email address. Given the tight integration between the phone and Google I thought it worth considering what life with Google would be like. I previously used a Palm to track my calendar and contacts (those details that my phone couldn't handle like addresses). With my new smart phone it felt like overkill to carry around both devices. The biggest hurdle though was email.

I figured my insistence on using procmail, SpamAssassin, and Pine to read me email while serving me well for the past 13 years may have been due for an update. To enact the change I signed up for a Google Apps Premier account. Which means that Google and Postini now handle email for my domain. The premier account also lets you import old mail via IMAP which made migrating 13 years and a couple gigs of email a breeze. Well not an entire breeze. My local cataloging system didn't directly translate into Google's label system so after all of my email was in my GMail account I did have to spend a few hours massaging labels to make it work. Now that it's all done though I must say GMail is a reasonable replacement for my old system. More importantly I have complete and easy access to all of it from my new phone.

My contacts and calendar on the other hand are an on going effort to migrate them to Google. In particular getting the data out of Palm Desktop into a format that could be imported into Google was not straight forward. While there are some applications that can synchronize between the two, I didn't want to shell out the cash for them since I wasn't planning on continuing to use my Palm once the transition was done.

I ended up using Apple's Address Book and Calendar to read in vCal and vCard exports from Palm Desktop. I then used a 3rd party utility to export my address book into a Google friendly format and iCal's native export format. Like my email the translation process isn't perfect and I suspect there will be a couple hours of cleanup for each data set before it's Google friendly. In retrospect though it's also prompting me to do some house cleaning of the data which is sometime I've been trying to do in general.

In the process of moving my digital life to Google I also moved my computing life to a new Mac Book Pro. While trying to do the development on PPE the speed of Java on my old G5 PPC was really starting to annoy me. Conveniently the rumor mill said that Apple was about ready to release new some Mac laptops. Turns out the rumors were true and on Oct 14th that happened. I'm very pleased with the new solid case design. While at first I lamented about the lack of a matte finish for the screen, given when I most often use my laptop it hasn't been something that has bothered me as much as I thought it would.

Needless to say between the new laptop, phone, visiting Elissa, having the house de-leaded, and migrating my digital life to Google, my free time has been minimal. For me busy is happiness which has made these past few weeks fly by nicely. I'm hoping to get back to PPE as I really want to move that along so it doesn't become an abandoned project of mine. My closing hint is that when copying files from a Mac with rsync be sure to add the -E flag. Thankfully I had backups and you should to. Time capsule is overpriced but the convenience of wireless piece of mind backups is great.

Tags: android g1 google life mac neophi

August 27, 2008

Patching iTerm

When I went searching for different terminal application for the Mac I found iTerm and have been very happy with it. It offers enough preferences to suit customization to my taste and it offers I couple of features I fell in love with from SecureCRT. In particular it offers a right-click open in browser option. I'm a luddite when it comes to working with email and prefer to use procmail, SpamAssassin, and Pine versus any of the various other email clients.

The problem with text only email is HTTP links that span multiple lines or get formatted with line breaks and spaces. Highlighting such a link and trying to launch it with the iTerm browser hook does nothing. I decided to "fix" this and as such created a small patch to iTerm Build 0.9.5.0611 that removes all white space from the highlighted text before handing it off to the browser. It seems to be working! Prior to this I've done no Objective-C programming so for all I know I've created a big memory leak. For anyone interested rough notes on what I did are below.

1. Getting the source
The latest CVS source doesn't build, so I pulled what seems to be the source for the last released version available for download

cvs -d:pserver:anonymous@iterm.cvs.sourceforge.net:/cvsroot/iterm login
cvs -z3 -d:pserver:anonymous@iterm.cvs.sourceforge.net:/cvsroot/iterm co -D "2007-07-01" -P iTerm

2. Patching PTYTextView.m
The _openURL method in PTYTextView.m handles launching the browser for the selected text. I modify the string prior to the protocol check. Since I'm still running on 10.4 I couldn't use some of the newer string manipulation methods.

3145c3145,3153
<
---
>
>     NSMutableString* tempString = [NSMutableString stringWithCapacity:[trimmedURLString length]];
>     [tempString setString:trimmedURLString];
>     [tempString replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [tempString length])];
>     [tempString replaceOccurrencesOfString:@"\t" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [tempString length])];
>     [tempString replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [tempString length])];
>     [tempString replaceOccurrencesOfString:@"\r" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [tempString length])];
>     trimmedURLString = tempString;
>

3. Compiling and Installing
From a terminal I ran make Deployment and then copied the resulting build/Deployment/iTerm.app over the existing version I had in my Application directory. The one change was that the preferences file name changed so I also ran:

cp ~/Library/Preferences/iTerm.plist ~/Library/Preferences/net.sourceforge.iTerm.plist

Tags: iterm mac

May 31, 2006

DVR and a Mac

Lately I've been playing with what can be done with my DVR and my Mac. It turns out the firewire port on the back of my Motorola DCT6412 III can be easily used to pipe video to the Mac. There is a great step-by-step manual at macteens. The only problem is that I can't seem to find a way to capture a program that I've already recorded. I start the playback and see the traffic on the Mac but nothing gets recorded. I suspect that some special flag is being set that prevents recording the program. Which is a bummer since I wanted to extract a news segment that a friend asked me to record. If you have any ideas, let me know.

Tags: mac video

April 30, 2006

Flash 8.5 Beta 2, Firefox, Mac OS, and Sleeping

Since installing the Flash 8.5 Beta Firefox has been crashing on a fairly regular basis when my Mac is coming out of sleep mode. I'm going to try reverting back to Flash 8 and see if that makes the problem go away. I've also recently upgraded Firefox due to recent security issues and I'm fairly certain the latest round of Mac OS patches got pushed out also, so the blame may not be squarely on Flash but given that it's the only beta product in that mix I'm going to try that first.

Tags: bugs flash mac