Wednesday, November 26, 2008

Overriding java endorsed direcctory for maven unit tests.

I was testing a web application using jwebunit (which has great ajax support
because of htmlunit). The test was running fine in Eclipse, but when I wanted
to run it from maven as a unit test I got an exception that started like this


java.lang.NoSuchMethodError: org.apache.xpath.compiler.FunctionTable.installFunction(Ljava/lang/String;Ljava/lang/Class;)I
at com.gargoylesoftware.htmlunit.html.xpath.XPathAdapter.initFunctionTable(XPathAdapter.java:58)



Another blog posting helped me identify that root cause was the xalan that is
included with my Mac osx version 1.5 of java is older than what the htmlunit
package was using. I found an email

http://mail-archives.apache.org/mod_mbox/incubator-yoko-dev/200609.mbox/%3CE91104197DA2654DA833B6EB53B6C488DD6C7A@emea-ems1.dublin.emea.iona.com%3E

that told me how to add a argLine to the maven-surefire-plugin.

And below is how I fix this in the "build" section my pom.xml.

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>test-compile</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/endorsed</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- This needed because jwebunit uses newer version of xalan than regular java -->
<argLine>-Djava.endorsed.dirs=${basedir}/target/endorsed</argLine>
<systemProperties>
<property>
<name>java.endorsed.dirs</name>
<value>${basedir}/target/endorsed</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>


Now my tests are running fine.

Thursday, November 13, 2008

bash chooser

Note: I've found a better way here:
http://www.vim.org/scripts/script.php?script_id=2769

My friend hacked up a ruby script to enable some better use of the bash command line. The problem I was having was that sometimes I wanted the bash command line to be interactive so that could pick one of several outputs. For instance let's say I am hunting for a file to edit from bash

so I run:


jalvarado:~/bobo jalvarado$ find . -name "Have*"
./bobo-browse/src/com/browseengine/local/glue/HaversineGeoScoreAdjuster.java
./bobo-browse/src/com/browseengine/local/service/geosearch/HaversineFormula.java
./bobo-browse/src/com/browseengine/local/service/geosearch/HaversineWrapper.java


Well, the second file is the one I want to edit so to get to in the normal bash may I may have to write.


vi `find . -name "Have*" | head -n 2 | tail -n 1`


and that would open the second file, but that is alot of typing and if I then wanted to open a different file of that set I would have to modify the command line in two places. So he wrote a script that let's you use this type of syntax

jalvarado:~/bobo jalvarado$ choose vi `find . -name "Have*"`
[1] ./bobo-browse/src/com/browseengine/local/glue/HaversineGeoScoreAdjuster.java
[2] ./bobo-browse/src/com/browseengine/local/service/geosearch/HaversineFormula.java
[3] ./bobo-browse/src/com/browseengine/local/service/geosearch/HaversineWrapper.java

Then you type "2" and up comes your file. Even better would be syntax like

find . -name "Have*" | choose vi

but haven't figured that one out yet.

Here is the Ruby script.


#!/usr/bin/ruby

require 'Open3'

if ((ARGV.nil?) || (ARGV.size <> filename1 filename2 ...';
puts 'example: choose "cvs log" `find . -iname "*tokenizer.java*"`';
exit;
end

command = ARGV[0];
filenames = ARGV[1,ARGV.size];

filenames.each_with_index do | line, index |
puts '[' + (index+1).to_s + '] ' + line
end

selection = STDIN.readline

filename = filenames[selection.to_i-1]

Open3.popen3(command + " " + filename) do |read_stdin, read_stdout, read_stderr|
puts read_stdout.readlines;
end



Tuesday, November 11, 2008

VBDG is ready to roll

VBDG is the company behind Hercules Hooks, MyPlace, Zorbeez, and other As Seen On TV products. They will be releasing their 3rd quarter results this Friday after the market close. I have personally seen their products in CVS, Fry's, Rite-Aid, and Bed Bath and Beyond and they are reported to be in many other retailer stores. I expect this 3rd quarter report to push them into profitability and drive their share price up sharply.


UPDATE: Well they ended going almost to zero, ugh.

GOOG 411 is awesome

I just tried out Goog 411 and it works so well. I have tried out various speech recognition programs and some have been pretty good, but when I tried GOOG 411 it got almost everything I said simply and quickly. Also it gives you listings that you can browse using your voice and get details on. All that and it is free too. To build a truly great voice recognition system you need many voice fragments. This 411 system allows google to train a great voice recognition model. I'm sure you will start seeing this in other offerings from google. One application is to transcribe voices in videos and podcasts. They will be able to use voice recognition and search in the same way as everyzing.com

Saturday, May 3, 2008

Helicopter Ben and other stuff

See how many links come up with helicopter and Ben in them.
http://www.google.com/url?sa=t&ct=res&cd=2&url=http%3A%2F%2Fwww.federalreserve.gov%2FBOARDDOCS%2FSPEECHES%2F2002%2F20021121%2Fdefault.htm&ei=z9gcSMvZJIWIpAT5irHeCQ&usg=AFQjCNFfQbNglV50rWN7mALO6kFT3sWByA&sig2=Og-ac4-VFm4H5Ds-VyXEkQ

I think this is the famous speech from 2002 where he talks about a "helicopter drop" of money referring to the famous monetarist Milton Friedman's comments.
http://www.federalreserve.gov/BOARDDOCS/SPEECHES/2002/20021121/default.htm

Bernanke gave a speech in honor of Milton Friedman's 90th birthday here:

http://www.federalreserve.gov/BOARDDOCS/SPEECHES/2002/20021108/default.htm

"The best thing that central bankers can do for the world is to avoid such crises by providing the economy with, in Milton Friedman's words, a "stable monetary background"--for example as reflected in low and stable inflation.

Let me end my talk by abusing slightly my status as an official representative of the Federal Reserve. I would like to say to Milton and Anna: Regarding the Great Depression. You're right, we did it. We're very sorry. But thanks to you, we won't do it again.

Best wishes for your next ninety years."

He says that yes the Fed caused the great depression by contracting the money supply and we won't do it again. Meaning that he'll do whatever he can to avoid an economic crisis by printing money.


Here's Jim Rogers saying he is still short the financials and will short more if it rallies.

http://online.barrons.com/article/SB120795383008909011.html?mod=9_0031_b_this_weeks_magazine_main&page=sp

Switching to your old home, what are your thoughts on the U.S. credit crunch?

We had the worst credit bubble ever in American history, perhaps world history. I can't remember anytime in history when people were able to buy a house with no money down -- sometimes with no income. You don't clean out a bubble like that in six months to a year. I've been short the U.S. investment banks by using the Amex Securities Broker/Dealer Index [ticker: XBD], an exchange traded fund with exposure to many of those firms. I've also been short Citigroup [C] and Fannie Mae [FNM]. I'll short some more if we get nice rallies in any of them. I am still short some of the U.S. homebuilders like Lennar [LEN].

Here is a chart of the upcoming variable apr mortgage resets.

http://www.stocktradersdaily.com/News%20Release/News_release_TA_0004002908.htm

Wednesday, April 30, 2008

One liner for killing processes

Here is a handy one-liner for killing a bunch of processes, postgres in this case.
It also uses the perlesque qualities of ruby. Googling "ruby oneliners" finds a bunch of other
one-liners. I tried sed at first but the regular expression support is different than perl.

ps auxww | grep postgres | ruby -pe 'gsub(/[ \t]+/, " ")' | cut -f 2 -d ' ' | xargs kill -9