January 20, 2009

SQL by created on

Posted by Sudhindra Rao

Model.find(:all, :conditions => ["date(created_on) = date ( ? )", Date.today.to_s(:db) ])

January 19, 2009

Views and Boolean query methods

Posted by Sudhindra Rao

Code smell: a Boolean query method in your views like a has? Or is?
Solution : move it to a helper or better yet the model

January 16, 2009

Using github pages

Posted by Sudhindra Rao

Started using github pages for this blog. Made a couple of posts.

Find out how easy it is to blog on github

Also released accordion.js that is much simpler and completed tested. Check it out here.
accordion.js announcement

January 4, 2009


Posted by Sudhindra Rao

The idea of block structure originated with the programming language Algol 60. It appears in most advanced programming languages and is an important tool for helping to organize the construction of large programs. - SICP

* Block Structuring is a way for a procedure to have internal definitions that are local to that procedure. This prevents name collision at minimal and provides simplification. Along with this it also allows the user to unclutter their minds and think in terms of details they are interested in. Splitting a program into smaller procedures and internalising a lot of details leads to good *encapsulation* and better understanding of the overall program.

Inspite of it being such an old idea why do I still come across code that has 300 lines of if_else, case_switch statements in a single big method.

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 http://dev.rubyonrails.org/ticket/5219

t.column user_id, 'integer unsigned'

or use http://brentrubyrails.blogspot.com/2007/11/assigning-custom-data-types-to-new.html

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 - www.sysinternals.com - 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.