The random musings of a software developer

Batch Image Processing Slides

Here’s the link to my slides from my presentation on “Batch Image Processing with Automator” at Macstock 2017. Had a blast there this year! Will definitely be back next year – do come and join us!

Alfred 2 is in the Mac

I just upgraded to Alfred 2 from the previous version. Seriously – get the Powerpack, you will not be disappointed. I’ve got Alfred 1.x and wrote a couple of nifty things with their extensions, such as mounting a remote Airport Extreme drive, launching various apps, and . While the support site is a little bare right now, their support forum is a hive of buzzing activity.

I’ve ported a number of the previous extension doo-dads I had cadged up using Alfred 2’s workflows. For instance I have a keyword shortcut which launches all my development tools (wrote that up in a previous post). Alfred 2 has a workflow specifically for that called “Launch file group from keyword” (Click on the + button at the bottom of the workflow list, it’s in Templates > Files and Apps. Drag and drop the apps I want to launch and that’s it. Would be nice if there was a + in the app / file list so I can search and select them, but no matter.

The one which was a little tricky was launching an Automator workflow. Turns out that doing a “Launch file group from keyword” did not work – it simply opened the Automator workflow in Automator itself. Figured I needed to run some command line script launcher (note: osascript does not work). So I consulted the man pages using the apropos command, apropos automator in to be exact and up popped the command I needed and it was (drumroll) automator.

Back to Alfred 2, create a “Keyword to Script” workflow, located in Templates > Essentials. Next, make sure that /bin/bash is the language, uncheck all the Escaping checkboxes, and enter

automator "full_path_to_automator_workflow.workflow"

in the Script text field. You want the full path starting at the root, i.e.:


And that’s just it!

I like the way in which Alfred 2 uses its workflows to achieve everything in Alfred 1.x’s extensions, and more, in a uniform representation. And it’s far more versatile, almost icon based programming. You can even pop up Notification Centre alerts!

Do read Federico Viticci’s review on MacStories – it’s good. In fact, read anything Federico writes.

PopClip Dash extension fixed

Just received a tweet from Pilotmoon Software that the PopClip Dash extension has been fixed.

Fix for Dash PopClip Extension

My favourite extension PopClip has an extension for my favourite developer reference application Dash. However, with the 1.7.7 update of Dash there has been a subtle change in the name of the OS X Service which allows search in Dash. This used to be “Look up in Dash” and is now “Look Up in Dash” – notice the slight change in case. Unfortunately OS X Services are case sensitive and as a result the PopClip extension does not work.

I’ve tweeted the developer of Dash @kapeli and they’ll be issuing a fix to the extension. In the meantime, to fix it yourself:

  1. Quit PopClip

  2. Go to ~/Library/Application Support/PopClip/Extensions

  3. Control- or Right-click on Dash.popclipext and select Show Package Contents

  4. Open Config.plist in TextWrangler or some other text plist editor and change:

    <key>Service Name</key>
    <string>Look up in Dash</string>


    <key>Service Name</key>
    <string>Look Up in Dash</string>

    with a uppercase U in “Up” and then save the file.

    If you’re using Xcode, change the key “Service Name” to “Look Up in Dash” with the same uppercase U.

  5. Restart PopClip

Image Title updated

I’ve put in an update to Image Title in my software page. It now shows both the Title and Alt text if they’re defined. Moved the source to my GitHub repository. Share and enjoy!

When Software Update doesn’t work…

Sometimes OS X Software Update might think it has downloaded and installed the update, especially for pre-Mac App Store applications such as the iLife programs. The way to resolve this is to go to Apple Support Downloads and download the individual update. You can also get the OS X Combo Updaters this way.

Where’s Subversion gone in Mountain Lion?

I tried to use the command line Subversion application svn in my recently updated installation of OS X 10.8 Mountain Lion. Couldn’t find the command at all. Hmm… used to be pre-installed in Lion and previous versions. Looked around the interwebs and found this reference: Where is SVN on OS X Mountain Lion?. You have to install Xcode from the App Store and then download the command line utilities. svn will get installed in /usr/bin and thus appears in the default PATH.

Unit Testing in Xcode 4

One of the nice things in Xcode 4 is the integration of the OCUnit, or SenTestKit, Unit Test suite into the environment. My last foray into unit testing was with JUnit in Eclipse. I’m currently working on an Objective-C library using JSON for data transmission and needed to test its methods.

Here’s a good guide on setting up a project to use OCUnit and OCMock for mock objects – Unit Testing in Xcode 4 Quick Start Guide | Ray Wenderlich. The article also mentions GHUnit which has some additional features over OCUnit – will have to look at that too!

So I’ve written my test cases and run them. I then see several test failures which seemed out of the ordinary. Now, the test cases are written in the order I expect them to run in the file, and I noticed that they were being run in an order other than the sequence in the file, which is what I was used to in JUnit. The Unit Test documentation on the Apple developer site Xcode Unit Testing Guide doesn’t mention anything about the order of test case execution, and I could not find anything relevant on the ‘net.

After scrutinising the test case run order, I came to the conclusion that it was in alphabetical order! And now I’ve taken to numbering the test cases thusly – test_0010_xxx and so forth – shades of BASIC line numbers!

And there’s more – unit tests are by their intent, tests for a unit. Each is a single entity which performs a set of operations as an independent standalone code segment. I had instead written test methods which were dependent on the previous method’s results – not a real unit test at all, and therefore a new lesson learnt! In fact, Apple documentation states: “When Xcode runs unit tests, it invokes each test case method independently.” Might not need those line numbers after all…

So chalk this one up to experience, and blog it for all to find out!

Markdown with MarsEdit

I found this neat technique to upload Markdown from MarsEdit to a WordPress site and have it automagically format the MarkDown as HTML. Here’s the link to Cek’s blog. You’ll need Markdown on Save Improved installed as a WordPress plugin. Activate it and vóila – you have that magical Markdown conversion – direct from MarsEdit. Enjoy!

Powered by WordPress