Publicly available geodata for national and subnational boundaries

At long last, it is finally feasible to get good-quality geodata online for:

  • Level 0 a.k.a. international borders
  • Level 1 a.k.a subnational or first level administrative borders (e.g. states or provinces)
  • Level 2 a.k.a. second-level administrative borders (e.g. districts or counties)

This has been the holy grail for a while, and can be assembled fairly easily in Quantum GIS (QGIS) or some other suitable geospatial viewer. (Some familiarity with QGIS is assumed below.)

  1. International borders. Many options here… I just downloaded this shapefile from Bjørn Sandvik’s Thematic Mapping page and imported into QGIS as a vector layer.
     
  2. Subnational borders. Go to the United Nations Food and Agriculture Organization’s GeoNetwork website , drill down into the “Administrative and Political Boundaries” category and find the dataset called “RWDB2 Subnational-AD2 Linear Boundaries.” Hit the download button to obtain the shapefile, and import into QGIS as another vector layer.
     
  3. Second-level borders. This gets a little trickier as there is no simple zip file or tarball you can download. Instead you will have to import this WMS url into QGIS as a WMS layer: http://geonetwork3.fao.org/cgi-bin/wms?map=/GeoNetwork_data/12600-12699/12691/wms/12691_2level.map. (This required a little reverse engineering since the published data distribution links didn’t seem to work. The full metadata can nonetheless be found at the FAO website as well.

For best results, make sure the z-ordering is like this, from top to bottom: international, subnational, and finally second-level all the way at the bottom. You might also want to fiddle with the symbology for all these layers.

Getting git clone to work between MacPorts installations

If you use MacPorts to install git, then the various git programs (git, gitk, etc.) will be installed in MacPorts’ usual /opt/local/bin directory. This, however, seems to screw up the git clone operation which complains about not finding the git-upload-pack binary.

Trying the --upload-pack option to pass in a nonstandard location for the upload-pack binary on the remote end doesn’t seem to help — I get errors saying that “git-pack-objects died with error.”

What finally worked in the end was following the workaround from Paul Johnston.

$ cd /usr/bin
$ sudo ln -s /opt/local/bin/git* .

Now the binaries are symlinked from the expected location and that seems to make git clone behave.

Getting a PHP build which supports GD under OS X 10.5

Obtain Liyanage’s PHP5 module with built-in GD (etc.) support:

  1. curl -O http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz
  2. tar xvfz php5-5.2.5-6-beta.tar.gz
  3. sudo mv php5 /usr/local/
  4. sudo chown -R root:admin /usr/local/php5

Edit /etc/apache2/httpd.conf to ignore the Apple-installed module and load the new Liyanage module:

# LoadModule php5_module        libexec/apache2/libphp5.so

LoadModule php5_module        /usr/local/php5/libphp5.so

 

Monitoring Rails’ log output while using Mongrel

If you install the Mongrel web server for Ruby, Rails is smart enough to start using it by default when you invoke script/server. However neither script/server nor mongrel_rails start (the recommended way to invoke Mongrel for a Rails project) will tail the rails logfile at log/development.log and give you the debug output you are accustomed to.

Solution: this small shell script, which simply invokes mongrel and immediately starts tailing the logfile, and upon receiving a Ctrl-C signal, stops tailing and shuts down the server. This is probably the behavior you were expecting, and presumably will be added by the Mongrel folks sooner or later.

#! /bin/bash

trap "{ mongrel_rails stop; exit 0; }" SIGINT

mongrel_rails start -d
tail -f log/development.log

I keep it in script/mongrel and then it acts as a no-fuss replacement for script/server.

A recipe for IMAP with Gmail and Mail.app

In Firefox

In Gmail

  • Enable Imap
  • Use shortcuts and macros for yanking/labelling:
    • “e” archive
    • Shift-”3″ trash
    • +”L0″ respond (-”B0″)
    • +”L1″ action (-”B1″)
    • +”L2″ hold (-”B1″)

In Mail.app

  • Install Mail Act-on
  • Configure Mailbox Behaviors
    • DO store drafts (and “Use This Mailbox” ‘Drafts’ for drafts)
    • DON’T store sent
    • DO store junk (and “Use This Mailbox” ‘Spam’ for junk — I think)
    • DON’T move deleted to Trash
    • DON’T store deleted
  • Re-map or create Mail Act-on actions to use Gmail’s IMAP folders
    • Remap Ctrl-0, Ctrl-1, Ctrl-2, Ctrl-3 to new Gmail labels (?)
    • Remap Ctrl-A, multiple times if need be, to capture different kinds of archiving behavior (e.g. if sent to non-gmail account, copy it to Gmail All Mail, then delete original)
    • Delete to move out of Inbox but leave in All Mail
    • Ctrl– to move to Trash
    • Ctrl-G to move back to Inbox
  • To eliminate duplicate local search results
    • Set Spotlight NOT to search: Library/Mail/[...]/All Mail.imapmbox