The power of ack

ack homepage

This is a super useful tool for searching through all of your source code. It searches recursively by default, ignores revision control directories, and aggregates/presents the search results in a very readable format. Makes software development just that much easier.

Here’s a quick example:

$ ack -C 5 –java “ProductVersioner” /usr/local/src/apache-oodt/asf-latest/trunk

“search for all code written in Java recursively under the specified directory and provide 5 lines of context… all the while ignoring all .svn, .cvs, and other irrelevant directories”


Problem with OODT CAS-Filemanger’s Lucene query tool when using underscores

When using the OODT CAS-FileManager “query” tool [1], the standard query format needs to adhere to Lucene’s query syntax.

A simple query often used is a query to obtain all products of a given product type:

./query_tool --url http://localhost:9000 --lucene -query CAS.ProductType:GenericFile

The above query works fine, and returns productIDs for all products matching the product type ‘GenericFile’ if products exist. However, if the productType (or any other metadata key for that matter) has an underscore in it, the result will not match the intended product type.

ie. below will come back empty:

./query_tool --url http://localhost:9000 --lucene -query CAS.ProductType:My_Custom_ProductType

The reason the above command fails is because Lucene treats all keywords separated by underscores “_” as separate search strings. This is akin to replacing the underscore “_” with an “AND”. Documentation for this issue is available at [2].

So it seems the problem lies with Lucene’s parsing syntax. Fortunately, there is a way around this issue: use sql querying instead.


./query_tool --url http://localhost:9000 --sql -query "SELECT CAS.ProductId FROM My_Custom_ProductType"


Changing text font-size and color for jQuery qTip popups

Found this really awesome Javascript library to enable context-sensitive help popups appear on webpages. With just a few lines of code, it becomes really easy to add context-sensitive help.

Changing the font-size and color took me a while to figure out. The documentation made it seem I would need to modify the ‘content’ property of the style object, but alas that does not work. Below is a working example:

$.fn.qtip.styles.tipStyle = {
name: 'cream',
tip: true,
border: {
width: 2,
radius: 4
'font-size': 12,
'color': 'red',
width: 450

content: "Please type a decimal fraction inside the below box",
position: {
corner: {
target: 'topMiddle',
tooltip: 'bottomMiddle'
style: 'tipStyle'

You’ll notice two things:

  • The ‘$.fn.qtip.styles’ object is used to declare a global style, which can be reused. The name of my style in the above example is tipStyle
  • The ‘font-size’ property must be an element of the style object, and not the content object within the style (as I had previously tried to make work)

Computing T-Distribution Cumulative Probability Density Function

I’ll be the first to admit, its been a long time since I was in Statistics class, but it’s really one of the most useful classes out there, even the esoteric parts of it.

Recently, I had to write code to compute bias estimation for climate change data, and one of the key stats used in computing bias estimation along with its summary statistics is: the t-distribution cumulative probability density function, or tcdf for short.

In Java land, we are fortunate to have the Apache Commons Math library, which allows computation of tcdf and inverse-tcdf: 

Something like the following, using Apache Commons Math, will allow calculation of an inverse tcdf:

TDistribution t = new TDistributionImpl(degreeOfFreedom);
a = (t.inverseCumulativeProbability(0.975))

Avoiding the terminal error: xterm-color: Unknown terminal type

Using a Mac terminal to connect to a machine not supporting the xterm-color terminal type can result in tools like vi not working.

One can get the error: xterm-color: Unknown terminal type

The solution to this problem is to identify the terminal types supported on the remote machine.

In my case, it was vt100

Steps (on remote machine running Solaris):

> export TERM=vt100

> vi anyfile.txt


Using Flex Hero SDK with FlexBuilder 3

Trying to compile a library project requiring Flex 4.0+ (or Hero) SDK in FlexBuilder 3 should be straightforward: just point Flex to the new SDK. However, like many things Flex, this simple task yields an error:

“unable to open ‘/Applications/Adobe Flash Builder Burrito/sdks/4.5.0/frameworks/libs/player/9.0”

The key is to add a compiler argument like: “-target-player=10.1". For library projects, we have to set a compiler argument since the Flex GUI does not allow for specifying flash player versions.

Check out this post for the full directions:

Sending e-mail in Java via SMTP protocol

I was attempting to send e-mail, using the following code, in Java but was receiving SMTP protocol errors. I thought perhaps I required authentication or some other type of initilization, but turns out the problem was just missing jars.

Java code:

Properties emailProps = new Properties();
emailProps.setProperty("", "<YOUR_SMTP_HOST>");
emailProps.setProperty("mail.debug", "true");

Session session = Session.getInstance(emailProps);
Message msg = new MimeMessage(session);

try {
msg.setSubject("<YOUR MESSAGE>");
msg.setSentDate(new Date());
InternetAddress.parse("<TO_ADDRESS>", false)[0]);
} catch (MessagingException e) {

Exception I was getting:
javax.mail.NoSuchProviderException: Unable to locate provider for protocol: smtp

Include the following dependencies (maven2 example):