Moving Your Cygwin Installation

I was running out of space on one drive so I decided to move my Cygwin installation to another drive.

It turned out not to be too difficult thanks to this article Hints for Setting up Cygwin. This is how I did it though there might be a simpler way.

  1. In a bash shell save the mount points as a batch script.
    $ mount -m > /c/cygwin-mount.bat
  2. Close the bash shell.
  3. Move the cygwin folder from one drive to the other. In my case that was from C:\cygwin to D:\cygwin.
  4. Update all the short cuts for Cygwin in the Start Menu to use the new drive.
  5. Update cygwin.bat, which is in the top level of your Cygwin installation, to use the new drive.
  6. Update your Windows environment variable to use the new Cygwin bin path, e.g. D:\cygwin\bin.
  7. Open a DOS cmd prompt. Run umount to unmount the old Cygwin mounts.
    > umount
  8. Next run the mount points script.
    > C:\cygwin-mount.bat
  9. Open a Cygwin bash shell to make sure everything is working correctly.

Do Not Return From a Try Block

Practical Java(TM) Programming Language Guide (Addison-Wesley Professional Computing Series)In Peter Hagar’s book, Practical Java, he recommends that you do not return from a try block.  This is because the finally block may change the return value.

Traditionally, programmers think that when they execute a return statement they immediately leave the method they are executing.  In Java, this is no longer true with the usage of finally

To avoid this pitfall, be sure you do not issue a return, break or continue statement inside of a try block. If you cannot avoid this, be sure the existence of a finally does not change the return value of the method. This particular problem can arise during maintenance of your code, even with careful design and implementation. Good comments and careful code reviews ward it off.

Practical Java Programming Language … – Google Book Search

URL.equals and hashCode make blocking Internet connections

Who knew that something as innocent as and hashCode would make blocking Internet connections?

The javadoc of URL.equals says: “Since hosts comparison requires name resolution, this operation is a blocking operation.”, but who reads the documentation of equals?  There is a general contract around equals.  Joshua Bloch writes in Effective Java: “Don’t write an equals that relies on unreliable resources” (Chapter 3, page 34). Hey Sun, as far as I know, the Internet is not reliable 😉

Eclipse and Java Blog by Michael Scharf: and hashCode make (blocking) Internet connections….

WordPress Impressive Permalink Functionality

A long time ago I enabled the WordPress permalink functionality so that the links for my blog articles were somewhat human readable.  I used my own custom format, /%category%/%year%/%monthnum%/%day%/%postname%/.

Awhile ago I began regretting that format because if I changed the category of the article then the URL would change and any bookmarks to that article would be broken.

Today I started reorganizing a lot of categories and decided it was time to bite the bullter.  I changed the permalink format to the standard /%year%/%monthnum%/%day%/%postname%/.   What was so impressive is that the old URL’s still worked, they redirected to the new URL.  WordPress rocks.

Mac Hibernate

I tried to make the Mac hibernate based on this article, Make my Macbook Pro Hibernate. Unfortunately it did not work and I am wondering if it is because this article is older and maybe it does not work for Mac OS X Leopard.

In the end I have gotten used to not having hibernate on the Mac since start up and shutdown are so fast.