Archive for November, 2009

How to bounce an application with Applescript

Say, for whatever reason, you want to bounce iphoto once an hour. You can do that with AppleScript and cron.

More >

Macports fails to compile p5-perlmagick

If you need PerlMagick on a Mac, there was (and still is) a p5-perlmagick package. If you try to install that package now, you’ll find it doesn’t compile (!!). You don’t have to resort to compiling from source, though.

More >

How to fix your ubuntu 9.10 console

After upgrading my server (that isn’t running X) to Ubuntu 9.10 (Karmic Koala), I found that the console on my LCD monitor was cropping out several characters from the left and right sides. It wasn’t hard to fix, though, given the magick incantations:

More >

Download Xcode 3.1.4 for Leopard

Apple’s developer website only links to the latest version of Xcode, which requires Snow Leopard (Mac OS X 10.6).

If you’re still running Leopard (10.5), you need to go to this alternative developer website:

http://connect.apple.com/

Log in with your ADC credentials, click “Downloads”, then click “Developer Tools” in the right sidebar, and then search the page for “3.1.4″. You might also want to check the wikipedia list of xcode versions to see if 3.1.4 is still the latest version.

(reference)

How to serve a transparent 1×1 pixel GIF from a servlet

The first issue was how to build the smallest possible byte array that represents a 1×1 GIF. Using ImageMagick piped to base64 made it easy to embed into java code:

convert -size 1x1 xc:transparent gif:- | base64

At servlet load time, un-base64 the gif back into the byte array:

import org.apache.commons.codec.binary.Base64;
...
private static final String PIXEL_B64 = "R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";
private static final byte[] PIXEL_BYTES = Base64.decode(PIXEL_B64.getBytes());

in your handle method, then write those bytes to the output stream:

httpServletResponse.setContentType("image/gif");
httpServletResponse.getOutputStream().write(PIXEL_BYTES);

How to increase maven heapspace in hudson builds

If your maven-built project fails in hudson (especially when you’re using the assembly plugin) and it isn’t a compile or test failure, check the console output. If it says “java.lang.OutOfMemoryError: Java heap space”, you need to configure your hudson job to add heap space to the maven process.

  1. Navigate to your hudson job,
  2. click Configure,
  3. scroll down to the Build section, and
  4. click the Advanced button.
  5. Enter this into MAVEN_OPTS: -Xmx512m -XX:MaxPermSize=128m

More >

OpenDNS updater for linux/ubuntu

The OpenDNS service is great — it provides anti-phishing and the ability to filter out some of the less desirable detritus from the internets.

OpenDNS needs to be periodically notified about what your IP address is, and I don’t have a windows or macintosh box that’s always on. I do have an ubuntu box, though, but there weren’t any instructions on OpenDNS’ site to do this properly.

More >

How to Convert Your Book’s Images to Kindle

Taking your painstakingly typeset book and shoving it through the kindle “conversion” meatgrinder was an exercise in wincing. Most of the images were corrupted, there was whitespace sprinkled randomly throughout the copy, and it was a general mess.

Kindle supports direct upload of an html version of your book, but there’s a lot of finessing you need to do before it all goes smoothly. One of the tasks you’ll need to do is convert your book’s images to greyscale, and reduce their size to something Kindle-friendly. There are free tools to help you do this if you aren’t afraid of the terminal.

More >