September 26th, 2008 by Doug
This post has been updated, see below
This morning I applied Apple’s Java for Mac Update 2 and discovered that it broke my favorite editor and most-used application, jEdit. Other people seem to be having the same problem but there were few solutions. I found one that involves recreating the Application Bundle using the Java Bundler that ships with the Developer Tools. Here’s how it works:
- Backup your original jEdit.app application bundle (I called mine jEdit.orig.app).
- Open up jEdit.app (right click and do “Show Package Contents”). Navigate to “Contents” > “Resources” > “Java” and copy the jedit.jar file to your Desktop.
- Open up /Developer/Applications/Utilities/Jar Bundler.app.
- Next to the text field that says “Main Class” click the “Choose…” button and navigate to the jedit.jar copy that you just made on the Desktop.

- Make sure “Use Macintosh Menu Bar” is checked and press the “Create Application Button” at the bottom. Call the application “myJedit” or something else that distinguishes it from the original.
- Open up your new jEdit application bundle (”myJedit.app”) using “Show Package Contents” and navigate to Contents/Mac OS. Inside here you should see a file called “JavaApplicationStub.”
- Copy “JavaApplicationStub” from your new jEdit bundle (”myJedit”) to the Contents/Mac OS directory in your original jEdit.app bundle.
- Inside the original Contents/Mac OS directory you should see an alias called “jedit.” Rename this “jedit.bad” or something similar.
- Go one level up in the jEdit.app bundle to “Contents” and open up the “Info.plist” file. This open up using the Property List Editor (it lives in /Developer/Applications/Utilities).

- Expand the tree and change the ‘CFBundleExecutable’ string from ‘jedit’ to ‘JavaApplicationLauncher’.
That’s it! Close up the jEdit.app bundle and double click on it. jEdit should start normally as it used to, complete with the Mac Menu bar. Additionally, if you’ve installed the jedit shell script for launching jEdit from the terminal that should still work as well.
It’s not the prettiest solution but it keeps me going for now until a better fix is released.
UPDATE:
Someone in the Apple forums pointed out that simply copying the destination of the jEdit.app/Contents/MacOS/jedit symlink, which points to
/System/Library/Frameworks/JavaVM.framework/Versions/A/Resources/MacOS/JavaApplicationStub
back into jEdit.app/Contents/MacOS/jedit (replacing the symlink with a copy) also makes the jEdit application bundle work again. This method has considerably fewer steps than mine.
Apparently this file is functionally the same as the one generated by Jar builder. It seems Java developers went for the symlink method specifically to avoid problems created whenever Apple would go and update Java. With this update the symlink doesn’t seem to work again.
Posted in Applications, Java, OS X | 2 Comments »
August 18th, 2008 by Doug
QGraphicsScene and QGraphicsItems use the QTransform class to move, scale, shear, and rotate objects in the view. For the most part, this works great. Things get a little tricky when you want to keep track of an item’s rotation in terms of a simple angular value. QGraphicsItem doesn’t have a method to get the “rotation,” and neither does QTransform. Instead we have to recover it from the transformation matrix.
The QTransform docs tell us that a rotation is measured in the clockwise direction. Rotation by an angle Θ is computed for a given point using the matrix:

How to recover the angular rotation from this matrix? One way is to apply the same matrix to a point at x=0, y=1 and use some simple trig to figure out the angle between its original and new positions.
Enter the excellent atan2 function. Written in python, the math looks like this:
rotation = 180./math.pi * math.atan2(-xform.m21(), xform.m11())
Where xform is our QTransform object (the transformation matrix).
I wrote a little program, “Xformer,” in PyQt that demonstrates the relationship between an object’s QTransform matrix and its corresponding transformation, rotation, scale, and shear values.
Download Xformer and try it out. It also requires the UI file and a working copy of PyQt4.
Posted in Python, Qt | No Comments »
June 27th, 2008 by Doug
I downloaded and built the excellent Qwt widget collection on my Mac. When I built the examples I had trouble getting them to find the libqwt dynamic library. They built and linked just fine, but unless I added the path to the qwt install dir to my DYLD_LIBRARY_PATH environment variable launching the application fails with a dyld: Library not loaded: libqwt.5.dylib error.
On Linux the solution would be to add a -Wl -rpath /usr/local/qwt-5.0.2/lib to my LIBS directive in my projects’s .pro file (in this case the relevant line is in the examples/examples.pri config file). This should add the path to qwt’s dylib to my application’s runtime search path. Unfortunately this doesn’t work in Mac OS X. As it turns out, the library itself has to know its full install path.
Read the rest of this entry »
Posted in OS X, Qt | No Comments »
May 27th, 2008 by Doug
A few years ago I wrote a little Perl script called ‘timesScraper’ that grabs the top stories from the New York Times’ RSS feeds. The idea was I could use it to download local copies of the day’s news for reading on my laptop when I was away from an internet connection.
More details and the download after the jump.
Read the rest of this entry »
Posted in Downloads, Perl | No Comments »
May 4th, 2008 by Doug
I used to render UML graphs using the excellent GraphViz—writing out the graphs in dot formatted files by hand as GraphViz doesn’t have any GUI for graph editing. This worked pretty well until I started needing more fine control over the organization and appearance of my graphs. I resorted to ugly dot constructions like
{ rank=same ringbuffer inputproc; } // put two nodes on the same level
and
buffer_a [label="buffer"] // give two nodes the same name
buffer_b [label="buffer"]
Recently a coworker alerted me to the existence of yEd, an awesome free graphing program written in Java. It creates GraphML-format files using a slick, well-designed interface. It has powerful graph-organizing tools and supports SVG symbols as graph nodes. The graphs look great when printed, too.
Posted in Applications, OS X | No Comments »
April 21st, 2008 by Doug
WordRecorder was a program I wrote for my friend Matt to help him record hundreds of spoken names for his video e-card site. It’s a pretty specialized program and I doubt more than a handful of people out there will actually have a need for it, but the source code may be of use to people trying to figure out how to use Apple’s CoreAudio Frameworks and the Qt Interface Toolkit.
I’ll try to post more details about its design and how it works in the coming days. For now, visit the main WordRecorder page here.
Posted in Applications, Audio, Downloads, OS X, Qt, WordRecorder | Comments Off
April 20th, 2008 by Doug
When trying to build a Universal version of my WordRecorder app I discovered that I could not view the properties window for my executable target, the project itself, or the project’s SCM options. Xcode gave me the following lovely error:

I don’t know what this is about, but through some hacking and tinkering with the Xcode file I came up with the following messy workaround:
- Make your Xcode project using qmake -spec macx-xcode if you haven’t already.
- Open/reload the resulting project in XCode 3. Trying to edit the project properties will yield the above error.
- Save the Project. This step is necessary as it makes Xcode totally reformat the file making the edit we’re about to do much easier.
- Open the project’s “project.pbxproj” file in your text editor. It lives inside the “.xcodeproject” folder so you’ll have to do a “Show Package Contents” to see it in the Finder.
- Find the following comment (”hello_world” will be the name of your own target)
/* Build configuration list for PBXNativeTarget "hello_world" */
- Beneath this comment you’ll see the following list of build configurations (the actual IDs will be different):
isa = XCConfigurationList;
buildConfigurations = (
2F9BD7250DBC2F9500BBEE4F /* Debug */,
2F9BD7260DBC2F9500BBEE4F /* Release */,
2F9BD7270DBC2F9500BBEE4F /* Default */,
);
- Remove the entire line containing the identifier with the name ‘Default’ and save the file. The result will look like this:
isa = XCConfigurationList;
buildConfigurations = (
2F9BD7250DBC2F9500BBEE4F /* Debug */,
2F9BD7260DBC2F9500BBEE4F /* Release */,
);
- Go back to Xcode. It should prompt you to reload the project from disk. Reload it. You should now be able to edit your project’s properties again. Unfortunately you will have to repeat this step whenever you rebuild your project using qmake.
I don’t know why this fix works, but it beats having to recreate our Xcode project by hand, and everything still seems to build without incident after the fix.
I’m not sure if this is Apple or Trolltech’s problem as I can’t remember if this worked in Qt 4.3.3 / Xcode 2. Xcode 3 probably isn’t officially supported by qmake yet, anyway.
Posted in OS X, Qt | Comments Off
December 2nd, 2007 by Doug
So a while ago I bought an HP 6800 Inkjet Printer with the double sided printing option. It’s great, but the default HP drivers don’t support the double sided printing, so the extra money spent on that hardware is essentially wasted if you use a Mac.
A solution comes from the Open Printing Workgroup at the Linux Foundation. By first installing the ESP Ghostscript and Foomatic RIP packages on their website, you can install the hpijs package—too many names, yes. This gives you the hpijs driver for the Deskjet 6800 (and many other printers) with the double-sided option enabled.
I’ve found the hpijs driver isn’t as crisp as the HP drivers (HP Inkjet 3.3.1), and it’s even failed miserably when I’ve tried to print some more complicated PDF files, but otherwise it’s a great way to save paper when printing things like receipts and news articles where quality isn’t my highest priority.
UPDATE: A recent upgrade of the HP Printer Drivers for OS X has fixed this problem. The specific driver is called “HP Inkjet Version 3.3.3”.
While the standard print dialog still has the “Two Sided:” option grayed-out under the Layout tab, a new “Two-sided Printing” tab has appeared in the dropdown list. This one is enabled and actually seems to work properly. 
Posted in OS X, Printing | Comments Off