Download Xcode 3.1.4 for Leopard
Nov 28th
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:
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.
How to serve a transparent 1×1 pixel GIF from a servlet
Nov 24th
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
Nov 23rd
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.
- Navigate to your hudson job,
- click Configure,
- scroll down to the Build section, and
- click the Advanced button.
- Enter this into MAVEN_OPTS:
-Xmx512m -XX:MaxPermSize=128m
OpenDNS updater for linux/ubuntu
Nov 15th
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.
How to Convert Your Book’s Images to Kindle
Nov 7th
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.
Simple Image Slideshow with jQuery and PHP
Sep 1st
I really liked Jon Raasch’s jquery-powered slideshow, but integrating it into a page requires a bunch of steps:
- Add the jQuery library
- Add the slideshow javascript function
- Add the CSS with opacity and z-layer set properly
- Upload the images for the slideshow someplace
- Enumerate the images’ URLs that you want to cycle through
Adding images is tedious (you have to upload AND update the image list), and there’s no clean support for multiple slideshows per page. I wanted a process that made integration into other pages trivial.
I decided that an IFRAME to host the slideshow would keep jQuery and the slideshow CSS partitioned away from the rest of the embedding page, and would let adding slideshows to new pages have an easy-to-follow recipe, no matter what was already going on in the existing page. The IFRAME needed the template HTML, and if I used PHP, I could generate the image list for the slideshow automatically from the images that live in the same directory as the PHP script.
Automatic disposable email addresses for Google Apps
Aug 29th
Plus Suffixing
There’s a pretty nifty feature with gmail that most people don’t know about. I’ve seen people reference it as the “plus hack” or “plus suffixing”. If you have username@gmail.com, you can add a “+” followed by any letters and numbers, and it will still be delivered to username@gmail.com.
I’ve been using this for corporate email forms — if facebook wants an email, they get matthew+facebook, for example. I can then add a precise filter on that “To:” address and delete all email from that company if it “goes evil.”
There’s a glitch in plus suffixing, though — most web forms don’t realize that the plus sign is a totally valid email character, and will reject your plus-suffixed hack.
So what to do?
Well, if you’re using gmail, you’re out of luck. But if you’re using a google apps account for a custom domain (say, your company or family), and you are an administrator for that domain, you can enable “minus suffixing”!
Installing Trac on Ubuntu
Aug 27th
Here’s the condensed version, using the installation guide for help:
Apache2, PHP, and MySQL on Mac OS X using MacPorts
Aug 24th
1. Install MacPorts
Follow the instructions here: http://www.macports.org/install.php.
2. Install apache2
sudo port install apache2
Note that the macports instructions suggest installing the launchctl script now, but we’ll do that after mysql and php are installed.
3. Install and configure MySQL
If you want 5.0.x, use mysql5-server. If you need 5.1.x, install mysql5-server-devel (at least as of August 2009).
sudo port install mysql5-server
As the macports instructions state,
In order to setup the database, you might want to run sudo -u mysql mysql_install_db5 if this is a new install.
It’s never a bad idea to set the root password, and as the document suggests, run:
/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
You also want to install a database configuration file — there are a bunch of templates in /opt/local/share/mysql5/mysql/, but for development, my-small.cnf should suffice:
sudo cp /opt/local/share/mysql5/mysql/my-small.cnf /opt/local/etc/mysql5/my.cnf
Once the config is in place, spin up mysql:
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
Check that mysql is up and running by connecting with the mysql client:
mysql -h localhost -u root -p
4. Fix your PATH
Note that the mysql binaries in /opt/local/bin all have a “5″ suffix, but /opt/local/lib/mysql5/bin has “normal” named binaries, so you probably want that in your PATH too. The apachectl in /usr/bin will spin up the mac os x version of apache (that we’re avoiding), and that lives in /opt/local/apache2/bin. So in your .bashrc (or .profile or whatever):
export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/lib/mysql5/bin:/opt/local/apache2/bin:$PATH
5. Install PHP5
sudo port install php5 +pear +apache2 +fastcgi +mysql5
Note that php5 has a lot of variants. If you think you want other goodness, run port variants php5 and cook up your own set of options.
Again, as the macports instructions state,
copy
/opt/local/etc/php5/php.ini-development(if this is a development server) or/opt/local/etc/php5/php.ini-production(if this is a production server) to/opt/local/etc/php5/php.iniand then make changes.
6. Install the PHP-MySQL driver:
sudo port install php5-mysql +mysql5
7. Configure apache2
The mod_php.conf from the php5 package is put into a directory that the apache2 configuration doesn’t read by default — so you need to add this line to the end of /opt/local/apache2/conf/httpd.conf:
Include conf/extras-conf/*
Hopefully this will be considered a packaging bug, and will be fixed at some point.
8. Run apache2
sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
Note that the logs, by default, are in /opt/local/apache2/logs.
If you change the PHP or Apache configuration files, run
sudo /opt/local/apache2/bin/apachectl restart
and watch the logs for errors.
How to pause crashplan on Mac OS X
Aug 17th
Crashplan on Windows has a taskbar icon that lets you put the backup daemon to sleep, but the Mac OS X port doesn’t seem to have this functionality.
You can’t just kill the backup daemon process. The OS X “launchd” superviser daemon will see the process go away, and immediately respawn the process. You have to tell launchd to stop the backup daemon by using the launchctl command:
sudo launchctl unload /Library/LaunchDaemons/com.crashplan.engine.plist
The crashplan daemon will start again after you reboot, or you manually restart it:
sudo launchctl load /Library/LaunchDaemons/com.crashplan.engine.plist