Comparing Hash Tables

August 11, 2008

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.

Read the rest of this entry »


Maven Commands

August 11, 2008

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 JavaDocs: Same as with sources, Maven doesn’t usually grab the JavaDocs.

mvn [goal] -DdownloadJavadocs=true

Hash tables

April 23, 2008

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}.

Read the rest of this entry »


Converting from Apache Ant to Apache Maven

April 5, 2008

At work (http://www.monsanto.com/) we’re converting all projects from Apache ant to Apache maven. The architecture team came up with the POM which all our applications would extend and set up the company-wide repository. I spent about a week and a half converting our project. Everyone thought that conversions would go smoothly. However, I haven’t heard of any project taking less than a week. A colleague wrote an application called “mavenizer”. The mavenizer helps analyze your project and generates a POM for each artifact. We had to determine how to split our application into artifacts but using the mavenizer app helped us figure out the dependencies and got us started with an initial POM.

I can’t speak for other projects but probably the most time consuming part of the process was weeding out the dependencies. We had some production code that had interdependencies but the majority was located in the test code. For instance, we have a TestHelper class that provides methods setting up the data environment prior to running a test and for tearing it down once the test completes. This class was used in a couple of leaf artifacts (domainpos and batchprocess).

When working with maven each, for lack of a better word, installable module is packaged in what’s known as an artifact. An “installable” would be something like a jar or war or ear or some other unit. We have a “common” artifact that’s a jar and can be used by all other artifacts. Then there is an “appdao” jar which contains all database-related code. Finally there are 3 leaf artifacts which can depend on the common and/or appdao but should not depend on each other: domainpos (war that is our point-of-service); plugin (jar that is a plugin for the company-wide GUI framework); batchprocess (jar that runs on a schedule for batch processing).

I’ll post here more about the conversion process and about things I learn about maven.



February 25, 2008

I have been working on a computer since 1982 when my father brought home an Apple ][+. It was a new world and I spent many long hours exploring how to control the system. At first, I wrote programs in Basic. I then went on to explore machine language (anyone remember call -151). My dad bought a language card that boosted the system from 48KB up to 64KB. Now I was able to explore Integer Basic. Later he added a second disk drive and I could then play around in Pascal. Yes, you could work with Pascal with just the language card but you’d be constantly flipping disks when you’d go to compile so 2 disk drives made it much easier. I wrote a program that would quiz me on Latin vocabulary. I wrote another one that my dad used for looking at stock market data in a variety of ways. Dad picked up a dot matrix printer (Epson, I think) and I also typed in papers for my mom’s classes for her B.S. and M.S. degrees as well as some of her work related documents (my first computer related job for real money).

As an undergrad studying Russian I didn’t do much with computers other than word processing and playing around with fonts. My roommates were comp-sci majors so I had some interaction with computers but not as much as before. As a graduate student in Slavic Linguistics, I took a course on programming for teaching foreign languages. The final project was a HyperCard stack intended to help students learn the Russian language using a new methodology called “Basic Sounds”. The Prof in charge of Russian language teaching at the time, Natalia Pervukhina, liked the idea and made the stack available to all students of Russian.

Read the rest of this entry »


Synchronizing Databases

January 5, 2006

I’ve not done much personal coding for a few days. Just work stuff. Our company works with another company (for clarity, I’ll call them “Company C”). Business needs require both companies have a copy of the data. We have the data in a MySQL databases and “Company C” has the data in an Oracle database. The structures of the databases are very different. In addition, we both have processes that modify the data in different ways. The challenge was to come up with a way to keep the data synchronized.

Initially as users modified data using “Company C”‘s interface their process would call a web service I wrote (using Axis, Hibernate, and Tomcat) and our data would get updated. As users modified the data on our end, our processes would perform a similar call to their web service.

Read the rest of this entry »


Clarification and Games

January 5, 2006

I should have been more clear in my last post. I am looking for a dictionary with words that are not so often used (like those presented by AWAD). I don’t need to be tested on words like “car” but words like fumarole are another matter.

Hey, we bit the bullet and bought an XBOX 360! We found a core system and hard drive at one of the Walmart stores around here and grabbed it. I still need to get a cable so the system can display properly to our HD TV but so far we’re happy. We bought Quake 4 and Project Gotham Racing. My wife wanted Call Of Duty 2 but we couldn’t find a store with them in stock (and believe me, we looked). To bad the XBOX 360 cannot play the older XBOX games without an emulation program. We’ve got a number of those and it would be nice to not have so many systems taking up so much space (we have an XBOX, a PS2 and now an XBOX 360 – the old PS is sitting in the garage since PS2 can play the PS games).