December 26, 2008

CruiseControl Monitor

Posted by Sudhindra Rao

Just put CruiseControl Monitor project on github. It is very 0.1 but all the current features work. Thanks to the team in Pune who showed me this wonderful but extremely skinny application that brings lot of visibility. Special thanks to Nigel Fernandes. Extra special thanks to Thomas Czarniecki from the Australia office who was so open to sharing his project and allowing me to be in the driver seat.

This kind of a project already exists for CruiseControl.NET which can do much more than just CC Monitor. But there was nothing in the Java or Ruby.

From the Readme file:


CC Monitor as the name suggests allows you to monitor multiple Continuous Integration environments. Currently it can parse cc_tray compatible xml for CruiseControl.
CC Monitor collects all the build information and puts it on a dashboard. CC Monitor is different that the dashboard that comes with Cruisecontrol. With CC Monitor you can actually monitor different Cruisecontrol environments just by specifying the location of the cc_tray.xml file.

CC Monitor provides a big visible display which can be projected to the whole development room. Having a big visible display of Cruise builds can help the team monitor the health of the code all the time and they do not need to look at their local CruiseControl Monitors.

Currently it can display information that is part of the xml file. Apart from that it also displays the progress over a period of time to indicate how healthy the application has been.

Features to come:

1. Adding graphical display for health of application over time
2. Resetting graphs daily
3. Adding audible indications to the monitor
4. Better graphics to indicate the status of the build
5. Marking fix owners for broken builds
and many more....


To use just download and change the project url in controller/main.rb.

Type 'rake monitor:clean' - to setup the database
then type
'rake monitor:start'

PS: It uses amazing ramaze.

October 7, 2008

Quote for the day

Posted by Sudhindra Rao

Maven .... What is it good for?.. Absolutely nothing..

MySQL and Unsigned integer in Rails

Posted by Sudhindra Rao

Rails does not allow you to create unsigned integer in an intuitive way.
For example

t.integer user_id, :unsigned => true

will not work.

To make it work you will have to do

t.column user_id, 'integer unsigned'

or use

or use the patch.

On Linux you may get a /tmp/mysql.sock not found error to fix that locate mysql.sock(or mysqld.sock)
which should typically be found in /var/run/mysqld/mysqld.sock or /var/local/lib/mysql.sock or some place around. (whereis 'mysql.sock' should be of help here.).
Make sure you add a 'socket: /var/run/mysqld/mysqld.sock' entry in your database.yml for every instance of the database located on the
local machine.

On the network we are in we seem to get an 'EMULTIHOP' error accessing the local instance of mysql.
The fix for that is to add a 'host:'. I think this error appears only on networks that have something weird in their DNS.

September 11, 2008

Launchy, Windows, Environment Variables etc.

Posted by Sudhindra Rao

I am working on a project that is JRuby, Javascript, Java, Maven, Ant, Rake and lots of css fun. But the even more fun part of it is that we are developing on Windows. It is really heartening to find how, Windows and application development on Windows is getting more and more annoying.

To ease the pain I introduced a few tools on Windows.

  1. ProcExp - - is a very good task manager replacement. It is a free download and very light weight. It allows you to look at all processes(like doing a 'ps' or a 'top' on *nix) including system processes. You can kill a single process or a process tree. The benefit of looking at the tree is, you know how windows applications are spawning processes and how much memory/cpu they are eating up.
  2. Launchy for windows - Inspired by QuickSilver on the MacOSX - this is a decent application launcher. It works similar to QuickSilver is finding and launching applications. Worth a look and download if you are still a fan of 'Quick launch toolbar' and now you have run out of task bar space to add more applications to be on single click. This way you will also use the keyboard more often and take your hand off the mouse.

Now the reason I am giving a special mention to both these applications is as follows :

When you set Environment variables on Windows by navigating as follows 'My Computer ->Right Click -> Properties -> Advanced -> Environment Variables OR Control Panel -> System -> Advanced -> Environment Variables(please let me know if you can do this without touching your mouse - that would be just brilliant) - we all know that you need to restart the Command Prompt for it to be able to load these new directories that you have added to the path. Except in this situation :

When you have Launchy and if you launch command prompt through launchy. Restarting Command Prompt will not help in this case, because the command prompt that was launched by Launchy receives its context from Launchy. And if Launchy was started before you made the changes to the Environment Variables, Launchy will pass on this old context to Command Prompt. In this case you will have to restart Launchy so that the Environment Variables are updated and all the applications that are started by Launchy will have the updated Environment variables.
I could trace this because of ProcExp - as it showed the tree of processes and their parent-child relationship.

So if you have Launchy - restart Launchy after you change Environment Variables on Windows.

Another thing that I was hurt by and my colleague Chris Kozak* rightly attributed to being a windows problem is - when you add a new Environment Variable - it is not available till you restart Windows. Whosoever said that a registry was a good idea and doing it Windows style is better must have been looking at the stars.....

I am glad that I have a *nix system on my personal machine. Its just more logical.

*No developer Chris Kozaks were harmed in the making of this post.

August 13, 2008

Testing randomness in your application

Posted by Sudhindra Rao

I was involved in writing an application which involved pairing participants up for activities. One thing we had to limit was that every participant was paired with 4 other participants. That way the burden would be even on all participants and the distribution of activities would be fair.

Another aspect of this story was to make sure we could do this repeatedly and ensure that a participant is not paired with the same one in the next cycle.(We wanted to come up with a way to do this automatically every so often.)

When we went ahead and analysed this story we found out that, pairing similar to this was being done manually where someone would pick names and assign them. Fairness was verified manually.

This process of throwing pieces of paper and picking names worked for small groups and it became a nightmare once we wanted to do this multiple times. Often we would come across repeated pairs and confusion about what is fair and what is not. The randomness of the whole thing was arbitrary and error prone.

Having known all that we starting designing this story. Figuring out the tests was our next task. We started writing tests but all we ended up with was something that said "test_random_numbers_are_generated" and the body of the test could only go about white box testing the fact that the randomization method was called. Writing different variations gave us something we already knew about. We also went about testing the math behind randomization - which we dropped after initial attempts - since it was clearly testing implementation.

Intrigued with the idea of using random numbers the inherent difficulty of testing random numbers Paulo(who I was working with then) asked how could we test randomization - its almost untestable - he said.

Stepping back and looking at the problem from a the business requirement looking at the desired behavior we started rethinking about our tests and moving away from testing random numbers. What we found was the application as such never cared about randomization. All that the administration was interested in was with the fairness of the pairing. Another thing that was implicit in this requirement was that a person cannot be paired with self. Randomness was our implementation detail and it was how we were thinking about implementing this. Also we did not even need the random numbers provided by ruby. All we needed was

def test_association_with_parity
parity = 2
set = [1,2,3,4,5,6,7,8,9,10]
relations = Relation.associate_with_parity(set, parity)
relations.each do |index, value|
assert_equal parity, value.size
assert_equal false, value.include?(index)

def test_should_ensure_parity_with_no_duplicates

In both these tests the acceptance criteria do not care about randomness of the result. Also it does not matter how this randomness if at all is implemented. What matters is the fairness of the pairing and that there is no one who pairs with self.

In summary I would say that if you are thinking about testing randomness - your application may need another look.

Try asking the question - Does my domain care about the randomness(implementation)? - More often than not your answer would be NO and you will be able to figure out better functional tests for your application. Once you start thinking in terms of behavior of the system instead of the implementation, you will end up with better tests.

July 29, 2008

Java 5.0 and Junit 4

Posted by Sudhindra Rao

While working on some Java code and working with Java 5.0 and Junit4.4 I started by writing some examples and tests.

I would say it was a very pleasant experience working on the new JUnit with Java 5. Parts of code became a lot clearer and easy to read. Lot of clutter was hidden behind more aptly named annotations(For the critics of everything annotated - "Right now we are just talking about good things").

I ran across a lot of issues when using Junit4(most of it was my ignorance.) Some of the following links helped me understand how Junit4 was different.
Junit FAQ
Junit 4 Basics
What's new in Junit 4.4

NoClassDefFoundError with Junit 4.4 (This was the first error I had to deal with when running tests using the command line or ant)
Converting tests from Junit 3.8 to JUnit 4.4

When using Junit4 on command line the following JUnit3 command

java -classpath lib\junit.jar;build\prod\com\MyProject\;build\test\com\MyProject junit.textui.TestRunner com.MyProject.MyTest


java -classpath lib/junit-4.4.jar;build org.junit.runner.JUnitCore com.MyProject.MyTest

Note the change of runner class in Junit4. Happy Testing with Junit4.

June 20, 2008

Installing jRuby on Mac OS X

Posted by Sudhindra Rao

I was trying to install and run jruby on my mac(Jruby 1.1.2). After downloading and unzipping the installer I tried to run jruby.
But all I was getting was an exception

Exception in thread "main" java.lang.NoClassDefFoundError: org/jruby/Main

Googling did not yield anything useful.
So I started debugging and I found that the CLASSPATH had not been specified correctly in the
jruby file.
All I was getting was an empty string for the CLASSPATH which is why it was not able to find the jruby.jar(which contains the org.jruby.Main class)

To fix this I added


before CLASSPATH was being used in the jruby file.

Looks like CLASSPATH has not been defined in the jruby.bat file too. So jruby won't work on Windows either.

Hope this tip helps someone.

March 13, 2008

Somethings I did not expect from a Mac

Posted by Sudhindra Rao

I got a Mac (the new and shiny Mac Book Pro with 2.4Ghz processor and 2GB RAM and 120GB harddisk). I was very
excited and feeling very cool about my new possesion(thanks to a couple of secret angels in the world).
I was becoming excited about doing things differently(or doing them more intuitively as it were), with my Mac.
And so I did - it started when I began experiencing the sleekness of the product.

  • Its weight way under the bulkiness of my old Dell Latitude D620.
  • The keyboard has just the number of keys you normally use - also the multi-function function keys (especially the F9-F12 set.)
  • The comfort of using one click trackpad and the clever use of programmability to add on the right click functionality of the track pad. - I am more of a mouse user though.
  • The presence of the apple key(ohhh it so much looks and sometimes works like the Windows key on my Dell- but more about that in a bit.)
  • MacOSX packed with the power of Unix under the hood - thats just brilliant - Now anything I want to setup is just a hack/script away. - Best thing to happen to Operating Systems since Windows(just kidding...)
  • Placement of speakers as well as the camera is just right.

Some pain points on my Mac (or how Mac missed the bus on some of the key aspects of usability for a developer)

  • Leopard when launched in December had this bug - the keyboard freezes occasionally. For about 2 months the only solutions were - wait till Mac unfreezes the keyboard on its own or try restarting it(Windows contributed this elixir to software - if it does not work reboot) Thankfully the newest firmware release is supposed to take care of that(fingers crossed). (Another fix I heard was to press on the area between the space bar and the track pad with your thumb for a bit - let me know if it works) - latest update is that on some machines the keyboard firmware update did not fix this. So cross your fingers.
  • Finder does not show you the hidden files - thanks to all the programmers out there who wrote TinkerTool which helps you do just that. (whereas on windows there is a setting for this - how thoughtful of you Bill)
  • The applications on Mac are under the Applications folder as Applications/ this a mac.. having a macOS directory under each one of these is just redundant - especially when you install this application through the dmg installer.)
  • The Menu items are not mapped to keys - Alt+F+O does not open a new file or Alt+F does not take me to the File menu ...
  • An important annoyance that comes to mind when using a Mac - they mapped the apple key to do what Control key does on any other OS - Windows, linux, Solaris -
    all respond to Ctrl+C and Ctrl+V for copying and pasting. Why would Mac want to be different? Why are they not following the convention?
My Iphone
My iPhone was something that I bought just after I got the Mac and I am very proud to say that I have an unlocked iphone with the latest firmware(1.1.3 - I know the unlocking software works with 1.1.4 but I haven't had the time to update) thanks to Zibri(, thanks to GeoHotz( and thanks to all those who strived days and nights to get all the iphones to unlock and make numerous iphone owners proud.

I am very happy with the unlocked iphone especially with the OSX under the hood.
All the software that I can install on it(when I last checked I could put VNC and ssh on it.. ) - hackers prevail.
The usability is splendid (thanks Steve Jobs) - except the well known annoyances (viz. cannot forward messages, cannot send messages to a list, no zoom/video on camera) - apparently
there are softwares available which can fix all of these in some way.
The biggest problem is with the Camera part - where I need to use iPhoto to download pictures.
I have found out since then that on Windows the iPhone shows up as a disk and pictures and songs can be transferred
like on a USB key. - But on a Mac I cannot do it. The iphone is not mounted as a volume either.How annoying???????

I am sure even with all this I will still prefer my Mac. But the Mac by no means is the best in usability. I am going to collect all these annoyances(maybe there can be a to compete with ) and keep an updated list.

January 4, 2008

Using Verizon EVDO card on Windows and Linux

Posted by Sudhindra Rao

I am using the Verizon Wireless EVDO card on my Dell D620 and it has been a life saver a number of times. It connects and keeps the connection without any hiccups. What I did not like was the bundled software that came with it(which required me to enter so much information about the card and configure it to be used). The bundled software also adds features(that u don't like) like monitoring and controlling all of your wireless networks - thus taking over control of the other wireless options on my machine - 802.11g and bluetooth.
It also adds a useless(irritating) feature of compressing data transfer with Venturi.

I was trying to use the card on my linux partition and found out that all that the EVDO card does is adds itself as a modem for dialup using PPP. I found quick and easy instructions for using EVDO on Ubuntu Linux. I can do all this on linux through a shell command.
For getting the same smooth usability there is a little more work required on windows.

Windows does detect the card as a Modem(Curitel PC Card) and can be easily configured
to use PPP dialing.

Here is how you do it.

From Network Configuration

  • Select "Create a new connection"
  • Choose "Connect to the Internet"
  • Choose "Setup my connection manually"
  • Choose "Connect using a dial-up modem"
  • Choose "Modem - Curitel PC Card(COM4)"
  • "Enter an ISP name" (this is your name for the connection and has nothing to do with the ISP)
  • Phone number to enter would be "#777"
  • Uncheck "Use this account name and password when anyone connects to the internet from this computer"
  • Uncheck "Make this the default connection"
  • Click "Finish"
The newly created connection starts dialing immediately and will
will open a prompt to enter Username and Password -

Click "Properties" on the prompt

Verify that
In the "General" tab
  • "Modem - Curitel PC Card(COM4)" is checked
  • Phone number shows as "#777"
  • Check "Show icon in notification area when connected"

In "Options" tab
  • Check "Display progress while connecting"
  • Uncheck "Prompt for username, password, certificate, etc."
  • Uncheck "Prompt for phone number"

In Networking ensure
  • "Type of dialup server I am calling" is set to "PPP: Windows 95/98/NT, Internet"

  • "This connection uses following items" shows Internet Protocol (TCP/IP) as checked, QoS Packet Scheduler as checked, Deterministic network enhancer as checked

Now from you Network Configuration double click to connect using these connection settings.
You can create a shortcut and save it on the desktop for faster access.(Standard Windows operating procedure)

You should see the balloon in the notification area(system tray) indicating that you are connected.