Generate HTML elements with Java

I was looking for a ASP.NET equivalent in Java for generating HTML elements.  I found a nice Apache package to do this.  It is called the Element Construction Set.

Javadocs for the package can be found here:

This will greatly simplify generating HTML, particularly in a struts tag library or anywhere not in a jsp.

Example usage from

Document doc = (Document) new Document()
              .appendBody(new H1("Demo Header"))
              .appendBody(new H3("Sub Header:"))
              .appendBody(new Font().setSize("+1")
                         .addElement("The big dog & the little cat chased each other."));
// or write to the outputstream directly

Generates the equivalent to:

out.println("<H1>Demo Header<H1>");
out.println("<H3>Sub Header:<H3>");
out.println("<FONT SIZE=\"+1\" FACE=\"Times\" COLOR=\"#FFFFFF">);
out.println("The big dog &amp; the little cat chased each other.");

How to compare two JavaScript objects for equality

The Javascript === operator compares references to JavaScript objects and not the ‘deep’ data inside of them. With some searching, I found a useful utility function that will recursively evaluate 2 JSON objects for equality.  jQuery should have a utility function that does this.  I couldn’t find one.

var Utility = {
   areEqual: function(x, y) {
        for (var p in y) {
            if(typeof(y[p]) !== typeof(x[p])) return false;
            if((y[p]===null) !== (x[p]===null)) return false;
            switch (typeof(y[p])) {
                case 'undefined':
                    if (typeof(x[p]) != 'undefined') return false;
                case 'object':
                    if(y[p]!==null && x[p]!==null && (y[p].constructor.toString() !== x[p].constructor.toString() || !y[p].equals(x[p]))) return false;
                case 'function':
                    if (p != 'equals' && y[p].toString() != x[p].toString()) return false;
                    if (y[p] !== x[p]) return false;
        return true;


var a = {'a':2, 'b':{}};
var b = {'a':2, 'b':{}};

if(Utility.areEqual(a,b)) {
    alert('It worked!');

NTFS Free Software File Recovery

I had a NTFS drive crash on me, and I did not want to pay to get my files back.  The Windows world is full of free software, so I looked for weeks to try and find a program to bring my files back.  I found dozens of programs that show you your files, but you can’t get them back without buying the full version which ranges from $30 – $120 or more.  I finally came across Scrounge NTFS. It is a console based app, but it works and it works well. The only downside is that you have to know where your Master File Table(MTF) is located. I used one of the demo recovery programs that I downloaded to tell me where the MTF was and then plugged that into Scrounge and it started pulling files off my crashed drive. It took some time to recover, but it worked and was completely free. I want to write a GUI interface for Scrounge NTFS and change it over to C#. The world deserves a freeware NTFS recovery tool.

Partition Master

If you want to change your NTFS partitions in Vista, Windows partitioner won’t do the trick. It is limited on what kind of partitions can be shrunk or expanded. The all-star freeware software to do the trick is Partition Master. It was easy to use, would let me change whatever partitions I wanted, and it did everything pretty fast. Now our My Book 500GB external drive has 3 partitions, 2 of which are NTFS which will allow me to put large virtual drives on there.  Some say Partition Magic is good, but I found no need to try it after using Partition Master.