Mac Automator tip of the day

So I was looking in TextMate for one of my most favorite tools from IntelliJ. It’s the “Compare with clipboard” action that takes whatever you have selected and runs a side-by-side diff with whatever is on your clipboard. I thought for sure it would exist in TextMate but I was disappointed so I built my own using Automator. See the pic below for the entire source. (There’s gotta be a better way to share Automator source but I’m in a hurry and lazy so there ya’ go.) This workflow depends on Xcode’s FileMerge but you can substitute whatever diff tool you’re comfortable with. To create it, start Automator and select System service from the “New…” action then copy in the actions from the image. Name it “Compare selection with clipboard” and then where ever you are in your Mac you will have access to the tool from the context menu (right clicking) of any selection.

Automator workflow
Compare selection with clipboard

When I first posted this there was a small bug. I changed the get clipboard step to an Applescript command “get the clipboard” since the built-in Automator task returns styled text instead of raw text.

Create Windows 7 Install Disc On a Macbook Pro

I was trying to install Windows 7 on my Mac this morning and it turned out to be an all day affair! My biggest issue was trying to create a Windows 7 install disc on a USB flash drive using Boot Camp. (Boot Camp is software included with OS X Lion so you can run compatible versions of Microsoft Windows on an Intel-based Mac.) For reasons known only to Steve and finally now me, the checkbox that enables this magic was greyed out and disabled under Boot Camp. I found a thread in a forum discussing the issue and was able to fix it. (I lost the link to the thread but I’ll repeat the important parts here.) The fix involves editing an “Info.plist” file under the Boot Camp application bundle. For those that are not Mac savvy, apps on the Mac are simply folders (commonly referred to as bundles) with a “.app” suffix which causes the “Finder” application to treat them differently. You can right click any “.app” bundle and chose to “Show Package Contents” to look inside them.

So showing the contents of the “Boot Camp” app located under “/Applications/Utilities” will expose a “Contents” folder which contains the “Info.plist” file. Edit this file using the Dashcode app (I believe this installs with Xcode which is included on the Lion/Snow Leopard install media under the optional folder) and look for the “USBBootSupportedModels” setting in the left hand pane. Clicking the little triangle will expose/unfold a bunch of models that support USB booting. According to Apple, these are the only models that support the feature but you can alter this file to include the model of the Mac you currently use. Click the Apple icon in the top most menu and find the “About This Mac” option. click “More Info” then “System Report”. This is where you look to find your Model Identifier. Mine was MacBookPro6,2 which would translate to a MBP62 string. There is also a Boot Rom version in the same report a little further down that you should pay attention to. Mine was listed as MBP61.0057.B0C. I took this to mean that I should also include a MBP61 string in the list of supported models as well. Clicking the little plus icon next to “USBBootSupportedModels” will allow you to add strings for both your model and boot model. Save the file to your desktop. I was very carefully to rename the original file to something like Info.old.plist before copying the modified file back in place from my desktop. I also went in and changed the ownership of the file to “root:wheel” after copying. Follow these steps then when you restart Boot Camp the option should be available to you. Happy “Boot Camping!”

OSX Tcl/Tk and snack

So I finally figured out how to install snack on OSX. I went down many different paths and ended up building from source and getting lucky. I’m sorry, what is snack? Apparently it’s some audio tool kit for scripting engines like Tcl, Python, and Ruby. Woah, I’ve probably lost you. Let me back up. Why am I messin’ with Tcl/Tk and snack? I’ve been trying off and on to build a custom voice for MaryTTS. It’s sortr of a pain b/c I don’t have time to mess with this in the office. I’d like to experiment at home but my development linux install is in the office and I haven’t figured out how to get audio over remote desktop on Linux yet. (I’ve gotten close but that’d take a whole ‘nother round of experimenting!) So I’m running OSX on my Mac of course for my MaryTTS tinkering but it’s difficult to get things intended for Linux to work the same way on Mac. I’ve installed Mac Ports which dumped a bunch of stuff somewhere on my hard drive. I managed to get sox from it. Wait, let me start over again! Hi, I’m Cliff. You’re here because you were having the same troubles installing snack on your Mac. I’m here because the prior sentence creates an interesting rhyme.

In experimentation with Mary custom voices I’ve learned that you can spend an entire month just getting the required dependencies for using the voice import stuff. The list of required tools is huge and I wish it could be simplified. To add on that, each tool spins its own dependency web. For eg, installing ehmm (or was it speech tools?) requires sox which requires Mac heads to go out and install Mac Ports or something similar. Running “./configure” for hts just to create the dumb make file requires tcl/and snack. God help you if you’re on modern 64bit hardware like I am. The web site for snack offers a PPC version of snack. It’s best (and painful) to build from source.

So I download the source tar and carefully follow the steps in the README which are incorrect. According to the README the tcl framework should be located in “/Library/Frameworks/Tcl.framework/Headers”. On my system I found it under “/System/Library/Frameworks/Tcl.framework/Headers”, though this might vary depending on how you install Tcl. And that’s the problem. With all the different paths for frameworks and libraries it’s a wonder you can get anything to work! After getting no satisfaction after running “make install” from the source bundle and many failed attempts to copy the libraries into the different Tcl and Tk framework folders I stumbled across a post somewhere that hinted that Tcl extensions should be found/loaded in “/Library/Tcl”. You would never know this unless you were a Tcl veteran. There wasn’t even a “/Library/Tcl” folder on my system! I created the structure and voila! Where was I? Oh yeah, I was trying to install the hts package. Now I’m struggling with a another dumb error that complains it “can’t find swab of SPTK”. What in blue blazes is SPTK and why do I need a swab of it? In conclusion, to build your own voices in Mary you have to be Tcl’ish, have a snack, get a swab of SPTK, oh and make sure you’re wearing sox! That’s only scratching the surface.

WhoLockMe Mac OSX

Who's locking Me?
From time to time I find myself working across a bunch of programs. Because I have a new Mac I’m very conscious of moving files around, organizing and keeping my trash bin empty. Every so often I run into a locked file. On the PC I got comfortable with WhoLockMe, a program that would hunt down the process locking the file and give you the option to quit it. Today I thought I’d look for an OSX equivalent. I found one. Going to try it out now…

Idea OSX And Maven

So I got a custom install of Maven because I’m trying to share configs with other people in my company. And I use multiple machines which all have the custom Maven install in a different path. It’s on a C drive for windows, under a java-apps folder on OSX, and under ~/Programs/JavaApps on Linux. Everytime I open the same project from different machines I have to set the location of Maven’s home folder. so then I accidentally run a Maven goal without setting the home folder one day under the later Idea build and it prompts me to either set the home folder for Maven in the config dialog or set a M2_HOME environment variable. (It never prompted in the earlier 7.x- releases, mind you.) Cool! I set the env var in Windows and Linux and forget completely about Mac because I mostly use XCode there. Tonight I attempted to point my Mac to an ‘.ipr’ on a network drive since my Linux box was cuttin’ up and it hits me again. But wait! How do I set the env var on OSX? (In Windows/Linux IU cheated and edited the ides batch/shell scripts.) I browse the Info.plist in the ‘.app’ bundle to no avail. Then I turn to Google. I found a tip that explains that you can set global env vars in OS X by creating/editing an environment.plist file under ~/.MacOSX. Using classing plist XML speak you describe key/string tags which become the environment variables when you log out and log in again. Here’s what I have in ~/.MacOSX/environment.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">

BTW, that tip probably just saved you 32 hours of dev time which, at your salary, is the equivalent of my stuffing over $640 in your shirt pocket… your welcome!

iChat breaks, Apple Keynote and more

I work with a remote team. As such we need remote management software. Things like net meetings, screen sharing, web based whiteboards, etc. We used to rely heavily on WebEx until company mandate pushed us to another Cisco based Meeting Place thing. Meeting Place is kinda cool but here’s the thing. It doesn’t work on the Mac. I mean it’s supposed to work on the Mac. It’s advertised to work on the Mac. Hell, we even have a couple people in our company who have it working on the Mac. Still, a good plenty of us cannot make it work on a Mac. The It that I’m talking about is screen sharing. It doesn’t work on a Mac. In fact, it has been working only sporadically in a variety of Mac forms. OSX screen sharing, screen share over iChat, VNC from finder… all different approaches to the same thing. All of these approaches give me trouble in one way or another.

Just yesterday I figured (well not just me but me and my QA buddy who shall remain shameless/nameless) out the problem with broken screen sharing in iChat. We have wireless in our offices but to use it you have to log in through a proprietary VPN client. The VPN, it seems, gets in the way of iChat screen sharing. I assume there’s more to the story.

That’s only one of my iChat woes. I’ve been seeing crazy behavior when logging into one of my AIM accounts. It probably won’t affect most people since it this is a corporate account but the problem only happens with iChat and it only happens under certain circumstances with this one account. However it happens frequently enough to drive me crazy. So in my mind iChat and OSX is in a horribly broken state while everyone else sees it as one of the world’s most wonderful creations.

Speaking of Apple’s wonders, I just watched the Keynote 2009 on and things are looking really good in iLife. I just recently upgraded to iLife ’08 to start playing with the reduced functionality in iMovie ’08 and now I feel like I need to race to the Apple store, checkbook in hand so that I can lay down several thousand dollars for every product mentioned in the keynote. They do an awesome job at marketing but then again I’m an easy sell. I love the ideas around face detection in iPhoto. I was both blown away and disappointed by the places feature. Blown away because it’s amazing but disappointed because they pull their maps from the wrong place.

The new MacPro is looking tight too. My only problem with it is the return of the Apple over-design. Non-removable batteries!!! WTF???!!! C’mon, if you can’t solve the battery life issue without fusing it to the machine then give us the regular 300 recharge model so we can blissfully overcrowd our landfills with NiCad, Lithium, or whatever the material DeJour is today. Could we have possibly sacrificed a millimeter or two reducing life from 1000 to maybe 725 recharges just so we can pull the darn thing out on our 600th powering where the thing still fuels up but begins discharging at double the rate? I’m sorry but there’s a bit of arrogance in thinking your product is so good that nobody should ever need to dig the battery out. That’s because it’s accompanied by the thought that your company is so JohnBlazed that if there ever is a need to claw the battery away from your pristine product then the customer (me) should/would be ever so pleased to beg you to perform the clawing while paying premium $$$ to help finance your specialized Mac battery removal claw that is only ever used by the rare 25 customers that are dumb/rich/[insert adjective describing a human with too many greenbacks on hand here]/wasteful enough to pay. This is and will always be my pet-peeve with Apple. Practicality goes out the window too early with their engineering team.

I wonder what would happen if some of the lead engineers spent a month or so in the hood? Y’know, where you have to live exclusively on practicality and people don’t generally have an extra $650 to pay for battery claw services on their $2700 Mac pro that they bought a few years back. These are the same people that will/have figured out how to extend the life of the original Macintosh Power books well beyond the 90s and into modern times where they have them not only hooked up to DJ equipment but also the non-cable-ready 1982 Zenith in the living room, Who is Jerrold? that manual push button cable converter box (you know the black box with the brown trim and the little lever on the side that switches three ways stolen from Comcast and rigged to pick up extra stations? Don’t act like it’s just me…) and the latest media toasters pushing Blu Ray copies of Hancock to the homies ’round the way. These are the same people that practically invented Bluetooth headsets.
Bluetooth Wireless
They won’t get any credit for it though, it’s all good.

Apple’s Mail Locked Up?

Happened to me this morning. The symptoms are: launch mail, click anywhere in the windows and watch the spinning pinwheel mock you constantly… spinning and mocking you. If Mail on your Mac hangs or stops responding then here’s a 1 minute fix that may or may not work for you. Backup and delete (just drag them out of their locations to another folder or your desktop) the following:
~/Library/Mail/Envelope Index

(The tilde “~” is shorthand for your home directory or /Users/YourUserName)

GroovyConsole From Quicksilver gotcha

A quick post tonight because I ain’t been doin’ my due dilligence with keepin’ y’all informed. Do you got a Mac? I do. Do you like Groovy? I sure as heck do! try installing Groovy then running groovyConsole from QuickSilver. It works like a charm! Looks really lovely. But wait! Now try launching Firefox, or iTunes, or anything else. After reading that sentence, if you’re anything like me you immediately tried your quicksilver hot-key sequence to Launch Firefox or iTunes or Safari or whatever. If you didn’t launch from quicksilver try it now. See what I mean???!!! WTF???!!! Where’s QuickSilver? Now kill GroovyConsole. What the heck is Quicksilver doing? Playing catchup? For what it’s worth, this is not necessarily a Groovy bug, more like a QuickSilver Feature. It doesn’t spawn processes and forget about them. It runs them inline and blocks/waits for them to complete. I got bit by this before and thought I’d give a heads up.

Build Native Blackberry apps natively on a Mac… using Maven!

Click here for the Maven Blackberry code behind this post.

Aight, I can’t help it! I’ve been itching to get this done for sooo long. If you’re into Blackberry development then you’ll understand just how absurd the above title sounds. Let me just throw intelliJ Idea into the mix as well then you’ll begin to see the big picture. Starting to do J2ME development, an experienced Java guy like myself has naturally gravitated towards a certain set of tools. Maven2 is hands down the only acceptable build system for a Java project, while Idea beats the pants off of Eclipse, and Windows boxes…? Forget it! Java runs practically double speed on a *Nix OS plus with the flash of OS X there’s no question as to what boots on a typical knowledgeable hard working Java developer’s box. All of these tools work well, and most of them work well together. BUT… BUT!!! Doing J2ME implies Windows and Ant all around so there’s gonna be either a divorcing of the toolchain or a boatload of integration issues. This weekend I fought through the biggest of the integration issues. And this morning I finally managed to build a Blackberry .cod deployable program… completely without Windows… using a Maven2 pom… natively on my Mac! I’ve been updating my blog incrementally with all of the individual pieces so I won’t go into too much detail here. At a high level I’ll explain the tools involved.

  • One Apple Macintosh (iBook, MacPro, MacbookPro, MacAir, whatever…)
  • One Blackberry (Preferably not Verizon because I don’t think they support J2ME)
  • One Windows install (I know, but this is only to extract the Blackberry tools! You can throw the whole thing away once you got the goods out of the JDE downloads. If you have a buddy that already has the JDE just steal it from him and skip this piece all together.)
  • One install of the Blackberry Java Development Environment (JDE).
  • One bottle of scotch (or wine) for to celebrate with.
  • One install of Maven2
  • Two tablets of asprin (to handle the hangover after you’ve spent the entire rest of the day celebrating with scotch or wine.)

I think that’s everything in the ingredients list. I’ll post back later with the recipe as time allows.