The Humanness of Modern Man

The dual loss of Christopher Hitchens and Václav Havel this week have left the world intellectually poorer. Hitchens would be the first to disavow any comparison between the two of them, but there is a line in Disturbing the Peace that I believe speaks to the essential struggle of both:

If the world is to change for the better it must start with a change in human consciousness, in the very humanness of modern man.

ZopeEditManager 0.9.7 Universal

If you do a lot with Zope and don’t like to have to use Zope’s ZMI editor, external editing is a godsend. Unfortunately the ZopeEditManager application for Mac OS X hasn’t been updated in quite a while. This is fine because it still functions well, but the problem is the most recent binaries are not universal. I don’t have anything else using Rosetta, so I’d prefer not to have to install it.

Thankfully because it’s open source you can download the source. I’ve done just that and built a quick universal binary. I’ve made no other changes, and it seems to work quite nicely.

ZopeEditManager 0.9.7 Universal
MD5: 5bd3e6497ec0d65d21c60e138c8d6fa5
SHA1: da5f5e216d518727d6f95fe2af32c0db2c6039f9

This is primarily written for myself for posterity, but maybe others might find it useful. I find myself wanting to play with Railo, an Open Source ColdFusion engine. Java on FreeBSD can be quite un-fun, but I’m going to assume a working JDK to start off with.

First thing is to get Apache and Tomcat installed:

cd /usr/ports/www/apache22 && make install
cd /usr/ports/www/mod_jk-apache2 && make install
cd /usr/ports/www/tomcat6 && make install

Next is to create the /usr/local/etc/apache22/workers.properties file. The mod_jk port gives you a sample to start from. Mine contains:

worker.list=default          # The name of the tomcat server
worker.tomcat.port=8009       # The port of the tomcat server
worker.tomcat.host=127.0.0.1  # The host of the tomcat server
worker.tomcat.type=ajp13      # The type of the connection
worker.tomcat.lbfactor=1      # The weight of the tomcat server

Then mod_jk needs to be added to httpd.conf:

LoadModule jk_module libexec/apache22/mod_jk.so    # Load the mod_jk module

# mod_jk basic configuration
<IfModule mod_jk.c>
    JkWorkersFile etc/apache22/workers.properties # Set the worker.properties file
     JkLogFile  /var/log/jk.log                   # Set the jk log
     JkShmFile  /var/log/jk-runtime-status        # Set the status file
     JkLogLevel error                             # Set the log level
</IfModule>

That was successful in getting Tomcat up and working. Now for Railo. Thankfully, that’s the easy part. Railo provides a WAR file that can easily be dropped into Tomcat’s webapps directory. After that it’s a simple matter of telling Apache what to do about it. I simply added the following to my mod_jk.c’s IfModule:

JkMount /*.cf* default
DirectoryIndex index.html index.cfm index.cfml

And hey presto. I also added a <Host> entry for a particular domain I wanted to use Railo with:

<Host name="domain.com" appBase="/path/to/domain.com">
    <Context path="" docBase="www"/>
</Host>

And simply extracted the Railo WAR file there instead of in Tomcat’s webapps directory and used it as the basis for the particular site. The only thing is to make sure the web server has appropriate permissions on the WEB-INF directory.

Rounding DateTimes in Cocoa

Let’s see here, what’s the currently supported way to round a datetime to the nearest hour in Cocoa?

// Round the current date to the nearest hour
NSDate * currentDateTime = [NSDate date];
NSCalendar * currentCalendar = [NSCalendar currentCalendar];
NSDateComponents * dateComponents = [currentCalendar components:NSEraCalendarUnit |
                                                                NSYearCalendarUnit |
                                                                NSMonthCalendarUnit |
                                                                NSDayCalendarUnit |
                                                                NSHourCalendarUnit |
                                                                NSMinuteCalendarUnit
                                                       fromDate:currentDateTime];
if ([dateComponents minute] >= 30)
    [dateComponents setHour:[dateComponents hour] + 1];
[dateComponents setMinute:0];
NSDate * roundedDate = [currentCalendar dateFromComponents:dateComponents];

The API seems a little excessive. I can appreciate what Apple has tried to do in making dates more flexible and easier to internationalize, but should basic manipulation really be that cumbersome?

Transforming XAR files with XSLT

One of the more interesting things about xar is the representation of the the Table of Contents (toc) in XML, with the ability to store “subdocs”, or additional XML trees, within the toc. You can easily add your own metadata to a xar file, in addition to its support for a variety of new metadata, including Extended-Attributes, both POSIX and Mac OS X’s.

Anyway, I’ve been playing with prototyping a package manager based on XSL transformations of xar files. Basically registering extension functions that can perform the necessary actions on the xar file as it is transformed. It’s a very interesting concept, and one I’m looking forward to exploring in greater detail.

I’ll write some more about this as I have time to play with it.