Hardy

I have finally taken the effort to upgrade my Dapper 6.06 LTS to Hardy 8.04 LTS. I’ve been waiting for Hardy for quite some time, mainly because its an LTS and it’ll be more popular and supported. The experience is pretty good so far, I’m actually evaluating it from the perspective of a Windows user, so its about bringing the Windows pattern to Ubuntu and running the corresponding software here. The steps to get stuff set up will be documented in “The Ubuntu Experience“.

The improvements from Dapper was tremendous, in particular novice usability and software support. In Dapper I often had to get down to the terminal to hack stuff and get things working, but stuff in Hardy just works. Out of the box that is. For example, these were quite important to me:

  • Wireless adapter support
  • WPA (saw but not verified)
  • Bluetooth enabled by default
  • SCIM (although no Chinese input by default)
  • NTFS read/write

Installation was a breeze, no more fumbling with custom partitions, the LiveCD installer takes care of it for me. Also since all the software was available through Synaptic, so far it all works pretty stably. I’ve added in aMSN, SCIM Chinese, Compiz, JRE, and desktop customizations. Next to explore will be CD/DVD writing, media player, start button and VMWare.

In Dapper all those were quite painful, and I didn’t manage to get VMWare working. Also because of Compiz I could not shut down normally, and had to use a script every time. VMWare would still be critical this time, for my VPN client and alternatives when the software or website only supports Windows.

On the bleeding edge

Case 1

We use JRuby with Mongrel and Derby, developing in Eclipse. We wrote many custom scripts to ease development, to start/stop servers, run rake scripts. We hack Mongrel because it couldn’t work with JRuby then. We patch ActiveRecord JDBC manually to make Derby behave correctly. Eclipse RadRails wouldn’t play well because we’re not using CRuby.

Few months after the release of our product, Aptana releases an Eclipse IDE with RadRails that completely supports JRuby, therefore run rake scripts, supports running the Rails app in Mongrel, and supports the Derby database.

Case 2 (today)

Deployment test of a new JRuby app on a new machine. During gem install we realize a new version of ActiveRecord 2.1 (from 2.0.2). Rake migration wouldn’t run after it because the SQL statement generated a “DEFAULT NULL NULL” in a CREATE TABLE statement.

Traced the code, found issue to be likely in activerecord-jdbc. Looked at JRuby Extras, and activerecord-jdbc-adapter had 0.8.1, release June 4, 2008 (today). Checked the SVN source, Nick Sieger checked in barely 6 hours ago at 5:19am to “Fix problem with AR 2.1 and Derby with ‘DEFAULT NULL NULL’ in column defs” (as per SVN commit comment).

Upgraded the gem from 0.8 to 0.8.1, but we got an “undefined method `true?’ for false:FalseClass” right at the line of Nick’s fix.

Filed my second JRuby (ActiveRecord) bug.

* We did force versions during gem install, but we didn’t expect the new version to screw up so much.

Intel Core

Haven’t been following up on hardware. I’ve actually read these numerous times but keep forgetting. I needed to look up some PC specs today, so its now here for my own reference.

Intel Core is the series of Intel’s 32-bit dual-core processors. Intel Core Duo is the one with the dual core, and the Intel Core Solo is the one with dual core, but only one active. According to Wikipedia, it’s so that Intel can sell those with manufacturing defects on one core but not the other. Sounds logical to me, but can’t find supporting information elsewhere.

Intel Core 2 is the 64-bit series. So Intel Core 2 Duo means a 64-bit dual core processor, and Intel Core 2 Quad are the 64-bit quad cores.

On the other side, there was this (old) HyperThreading technology by Intel, which also have a “dual-core” impression because it shows up as 2 processors on XP. However its actually just one processor that simulates an additional one for doing useful work during otherwise idle cycles.

AMD’s naming is 64 means 64-bit, and X2 means dual core. So you have series like Athlon 64, Athlon 64 X2, Turion 64, Turion 64 X2.

Combine physical disks into one logical drive

Got asked this interesting question today. Usually I hear one big physical disk split into multiple logical drives, but this time a single logical drive made up of smaller physical disks is desired.

I think RAID 0 fits this scenario, but to store a piece of file equally in 2 places for personal use (not a server) looks pretty useless to me. If one disk breaks, you’re left with half of every file, which is no different from breaking both. As compared to if you had two logical drives on two disks, if one disk break, you have the other disk with some complete files.

Are there other alternatives?

Unlocker

Fed up with the Windows Explorer message that I can’t delete a folder, because it’s locked. By who? I closed my Firefox and Eclipse and it’s still there. Short of killing my explorer.exe process like I always tool, I checked out a freeware tool called Unlocker.

Right-clicking the offending folder from Explorer and selecting Unlocker showed me it was really Explorer, but I had an option to “Unlock” it instead of killing the process. Quickly done.

Note: Remember to uncheck all other options when you install the tool (such as eBay shortcuts). I’m not sure what Assistant does, I unchecked it too.

The geek is not idle

The geekblog hasn’t been updated, but the geek has not been lazing. We’ve been looking at:

ExtJS –[JSON over HTTP]–> Apache/Lighttpd –[FastCGI/HTTP]–> Mongrel/Thin/etc -> Ruby on Rails –[WebService]–> Java –[etc]–> etc

Why? Because:

  1. We have a set of Java API that we’d like to expose, even to other languages, as a service.
  2. We previously use Mongrel, Rails with JRuby, as we want to invoke Java from within, as well as use JDBC. This restricts us to pure-Ruby libraries or those that has a JRuby port.
  3. Most servers and cluster options are written for Unix. We need an easier Windows solution to run a ruby-server cluster. The cluster is necessary as Rails is single threaded.
  4. We previously had PrototypeJS (came with Rails) implementing a “rich client” on the client side, and communicated in a mixture of data and presentation. We struggled with many features, including drag and drop, resizable layouts, split panes, spinners, trees (plus lazy loading, icons), toolbars (plus icons, dropdowns, disabling highlight), tables (plus sorting, selection, multi-select, column hiding, pagination), tabs, right-clicks, and more. All these seem to be handled by ExtJS. At the same time it allows easy customization by extension and even hooks. This was important as the given widgets may not fit requirements.

This is all interesting to the geek, maybe because it looks like an ‘architecture’.

Shallow Clone

A typical way of cloning an object is to use super.clone() to shallow-clone it, then modifying/cloning any members to create a complete clone.

Extra care must be taken if the original contains members that reference back to itself, e.g.


public class Model implements Cloneable {
  private PropertyChangeSupport support;
  private String name;

  public Model(String name) {
    support= new PropertyChangeSupport(this);
    this.name = name;
  }

  public void setName(String newName) {
    String oldName = this.name;
    this.name = newName;
    support.firePropertyChange("name", oldName, this.name);
  }
}

When this object is cloned the support member variable still references the original object (due to Object’s direct member assignment), thus the listeners would receive a wrong reference.

To fix this, implement a custom clone() method to take care of it. Make sure a new instance is created for it. If you simply change the reference inside the PropertyChangeSupport object, it will screw up the original object instead.


  public Object clone() {
    Model clonedModel = (Model)super.clone();
    clonedModel.support = new PropertyChangeSupport(clonedModel);
    return clonedModel;
  }

An Array of a List of Strings

I needed to create an Array of a List of Strings (actual problem anonymized). With generics I declared the variable:


List[] typedListArray;

Then I proceeded to create it.


typedListArray = new List[4]; // compile error

I needed to create the array first, like how I create new int[4];. But no matter how I moved the syntax, it wouldn’t compile. Read the JLS and searched the web, and finally found this explanation. It was not even a solution.

The reason the creation was disallowed was due to type erasure. Java’s implementation of generics only applies at compile time to ensure that the correct types are used. During runtime, the type information is erased. By creating a concrete parameterized array type, the runtime is unable to ensure that the correct items are added to the list. It is therefore senseless to allow the creation. The ways “around” it were to live with the warning, or to suppress it with annotations.

Then why allow the declaration?