Archive for the 'Software' Category

Page 2 of 11

Someone at work recently wanted an easy way to get the path of a file in a format he could paste into an IM or an email. I wrote up a quick applescript and bundled it into a service which enables a user to easily copy the path of a file to the clipboard. The package also includes a service that copies the directory path of a given file to the clipboard.

The biggest use case for this service is for an office environment where many people are connected to the same drive externally via VPN or internally via ethernet. It is challenging to easily point a colleague to a specific file if your shared drive is badly organized (which, odds are, it probably is). This tool mitigates most of that issue and works consistently across machines.

Average Rating: 4.8 out of 5 based on 241 user reviews.

I’ve had to do quite a bit of email newsletter design recently and I’ve become very familiar with premailer, an awesome open source email preprocessing library that makes developing emails a little more sane.

My workflow is a bit different than what premailer expects out of the box, and there are a couple of improvements that I wanted to add to the project. I’ve forked the project, merged in some other users’ improvements, ¬†and made a couple customizations:

  • In plain text mode, links and the parentheses surrounded the links, will not be broken up onto separate lines
  • Images will be replaced by their alt text
  • Instead of using the remote CSS file <link />ed in the HTML when using –base-path premailer will search for the local CSS file based on the path of the input file and use that if available. This is helpful when you have a local CSS file that you want to use to ‘compile’ the email newsletter HTML but have a different CSS file on the server that you want to use to display the email on your website.
  • Unmergable styles will be written into the body (makes a little easier for copying output into iContact and other ESPs)
  • The MailChimp reset styles will be preserved

Just an FYI for anyone looking for similar modifications to the default premailer.

Average Rating: 4.9 out of 5 based on 298 user reviews.

I’ve detailed this problem before but yet again I’ve encountered the infamous iconv compile error. This bug is not new yet it still has not been fixed in the latest PHP release.

When compiling a custom version of PHP with libraries such as libxml and iconv the


process results in a linking error relating to the iconv library. The problem arises because I have two versions of iconv installed – the macports version in addition to the standard installation. A linking conflict arises and to eliminate the error a linking search order change (which is detailed in my previous blog post) must be made. In addition to the makefile modification, the previous workaround for the bug also included using


instead of the standard


. Either the latest PHP (5.2.11) or OS X update has caused that workaround not to function correctly, now only


should be used.

I’ve posted a script that I’m now using to keep my PHP installation up to date.

Average Rating: 5 out of 5 based on 253 user reviews.

I’ve come to love developing in PyObjc. Sure, it has its quirks, isn’t the fastest, and isn’t the easiest to debug when something goes really wrong (aka imperfect integration with the xcode IDE); but it is fast to develop in. Almost every seemingly complex task that has come my way has been 50% completed by some open source python module that I can include in a commercial app without any licensing trouble.

However, the other day I came across a bug (at least, what I thought was a bug) that seemed very blaringly obvious and for a production version of a scripting bridge. When implementing the NSTableView delegate’s method


I was getting an error when simply returning an NSString (

 TypeError: tableView:toolTipForCell:rect:tableColumn:row:mouseLocation:: Need tuple of 2 arguments as result

) and for the life of me I couldn’t figure out why. Apple’s documentation states that I should return an NSString and I couldn’t find any information about a special case in pyobjc for this specific method.

I guess I did not search hard enough through the uncentralized incomplete documentation spread across the web since one of the PyObjc devs was kind enough to respond with a simple explanation:

This is not a bug, the ‘rect’ argument is a pass-by-reference argument that
can be modified, hence you have to return two values: both the return value
itself and the (possibly updated) value of rect:

return (aToolTip, aRect)

Average Rating: 5 out of 5 based on 293 user reviews.

I’ve already posted some notes about compiling PHP 5.2 on OS X 10.5, but I came across a couple more issues today as I recompiled the binary with soap support. After searching around a bit I finally remembered that I needed to manually edit the make file in order to get PHP compiling correctly, I found the edit that needed to be made here. I’m reposting it here for my own future use:



With this:


Note the separation of the command into three separate lines, with the 2nd line having one tab character at the beginning of the string.

And here is my updated configure string command (with soap and iconv):

./configure --prefix=/usr --sysconfdir=/private/etc --with-libxml-dir=/opt/local --with-icu-dir=/opt/local --with-iconv=shared,/opt/local --enable-intl --with-config-file-path=/etc --mandir=/usr/share/man --infodir=/usr/share/info --with-apxs2=/usr/sbin/apxs --with-zlib-dir=/usr --with-mysql-sock=/var/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-dblib=/opt/local --with-mysql=/usr/local/mysql --with-pear --with-pdo-mysql=/usr/local/mysql/bin/mysql_config --enable-sockets --enable-exif --enable-wddx --enable-ftp --enable-cli --enable-mbstring --enable-mbregex --enable-sockets --with-curl --with-sqlite --enable-soap --with-libxml-dir=/usr

Another interesting note about PHP 5 is that compiling it with the readline extension (using




) allows it to be a interactive scripting environment (a PHP console of sorts) just like python, ruby, or bash. Just run it from the command line with the -a option (info thanks to madmac).

Average Rating: 4.7 out of 5 based on 198 user reviews.

Grep has long been considered the de-facto regex command line tool for unix developers, but I’ve never really liked it. Grep has always seemed slow, buggy, and limited in its regex capabilities; I always resorted to using the built in regex functionality of TextMate or Python’s built in regex abilities.

As great as Python and TextMate are, they are not a clean solution to a simple problem and do not play nicely with shell scripting. Thankfully I’ve finally found a regex tool that fulfills my expectations: ack. There is an even a “Ack in Project” TextMate Plugin (so long Grep in Project) which works blazingly fast. Combine ack with the fixed and fully functional macports gsed (aka GNU sed) and I my command line text processing facilities are finally what they should be.

On a quick side note, I’ve come across another nice plugin for TextMate: ProjectPlus. ProjectPlus adds some nice UI as well as functional additions to the standard project drawer, it’ll help hold me over until TextMate 2.0 comes around.

Average Rating: 4.5 out of 5 based on 245 user reviews.