To Android or to iPhone?

I’ve wanted an iPhone for at least a year. Six to eight months ago I decided I was going to make the switch from Verizon to AT&T – just for the iPhone. Our Verizon contract expires next month. Now that December 8th is almost here I have begun counting the days. How exciting it will be to walk into the AT&T store and pick up my new iPhone.

I appreciate the quality of Apple products. From the beauty and elegance of the design to the simplicity of the user interface. It is obvious that they put great thought into the product as a whole. I wouldn’t call myself a “fanboy” but I’m pretty close. This is why it has come as a surprise that I have decided to go with the new Droid that Verizon just made available (http://phones.verizonwireless.com/motorola/droid/).
Continue reading

OutOfMemoryException in Maven

I came across a situation today where Maven threw an OutOfMemoryException. I didn’t think the process would have taken that much memory but it clearly did. I was trying to deploy. I then tried it again but skipped the tests. No good. I found out that by setting the MAVEN_OPTS environment variable to something like -Xmx512m I was good to go.

Comparing Hash Tables

I was recently asked in a comment how to compare 2 hash tables in Perl. Furthermore, the commenter mention that this would be use in a subroutine.

There is a module Data::Compare http://search.cpan.org/~dcantrell/Data-Compare-1.19/lib/Data/Compare.pm. I’ve never used this in any way other than to learn what it can do. From what I can tell it will not provide details. It will just tell you yes, the data structures are the same or no, the data structures are not the same.
Continue reading

Maven Commands

I’ve collected a short list of commands I use for maven and thought I’d share.

Install to Local Repository Compile Test Classes, Do Not Run Tests

mvn -Dmaven.test.skip.exec install

Install to Local Repository Do Not Compile Test Classes, Do Not Run Tests

 mvn -Dmaven.test.skip install

Generate Test Results in HTML Format (tests will be run)

mvn surefire-report:report

Generate Test Results in HTML Format (tests will not be run, source of reports will be last tests run)

mvn surefire-report:report-only

Run Specific Test Class

mvn -Dtest=MyTestClass test

Use Patterns to Run Specific Tests

mvn -Dtest=MyTest*lass test

Run Multiple Specific Test Classes

 mvn -Dtest=UnitTestClass,Accep*TestClass test

View Dependency Tree: output is a mono-spaced tree views of all classes in the current artifact

mvn dependency:tree

Download Sources: Usually when using Maven only the binary version of your dependency are fetched from the repository. This will tell Maven to download the sources of your dependencies.

mvn [goal] -DdownloadSources=true

Download Java Docs: Same as with sources, Maven doesn’t usually grab the JavaDocs.

mvn [goal] -DdownloadJavadocs=true

Show the Effective POM: This is the final pom that is used to perform the goal.

mvn help:effective-pom

Hash tables

I have found a number of potentially unconventional uses for hash tables (aka “associative arrays”). I suppose the first thing that comes to mind when thinking of hash tables is as a way to map a given value to another value. As a very simple example, say you have a list of items and want to keep track of how many of those items you have.

my %items = ();
$items{shoes} = 2;
$items{pants} = 1;
$items{dogs} = 5;
$items{cats} = 50;

We often refer to this arrangement as a “key/value” pair. Now, if you want to know how many shoes you have you can do so by referencing $items{shoes}. If you want to know just how crazy the cat person is, look at $items{cats}.
Continue reading