Sunday, September 14, 2008

Violence .. is it worth it ?

I still do not know whether I am the radical kind, those impatient groups of people who want the reforms to happen in just a wink of the eye, or those persistent groups of people who take the risk of waiting for the reforms to come their way to react. The recent bombings in Delhi, near Noida where I work and a movie made me write an entry in this blog. I normally am not a politics fan / fanatic and am least interested in some thing which depresses anyone who is outside ITS boundaries.

The movie I saw during my 1 week visit in Kerala was a movie named 'Thalappavu' (something which conceals the head). To talk about the movie as a critic I felt that the plot was pretty good. But the way it was told was not so digestive for a normal viewer. The movie frequently has flashbacks and further flashbacks which I think was a deliberate attempt by the director to be flashy. The story closely follows the life of a policeman who meets a extremist who works for the Wayanad farmers. The policeman is forced to kill this extremist by a higher official and that ultimately ruins his personal life. The point I liked about the movie is that the background music has been used very carefully. The characters are great and their portrayal has been immaculate. The torture by the landlords during those times and the corrupt police officials were factors which provoked these people to be extremists.

What I was think of was the cause here. Is the extremism justified any how and if yes are the blasts in Delhi justified by any chance.

'An eye for an eye makes the whole world blind' - Mahtma Gandhi

Friday, September 5, 2008

What a week !

This week was a long one. Lots of work to be done, or atleast was asked from us. Amit and Abhilash had to put in extra hours to get it done and the work still continues as I write this post. My work is some what done so I am calmly sitting at a corner so that no one notices me.

The bugs that I got were all bugs which arose as a result of some miscommunication. Sometimes I understood it wrong, otherwise they interpreted it differently. 'They' are obviously NOT wrong. The major bug that took most my time was the one related to the Sortable list not working in IE7. I tried juggling with those classes but reached no where. At last a simple ' ' solved my problem :). The next major one was that the auto-completer in scriptaculous kept on disappearing when the container div's scroll was clicked. This was obviously because all the browsers except Firefox interpreted this as a valid auto-complete text field blur. The work around done was to entirely take off the onBlur event and be entirely dependent on the keypress(ESC key) and the selection of the element inside the autocomplete list.

Coding for the browser was also something we learned here. Amit had lots of problems uploading flv files via Safari. As I understand Safari gives a String Object instead of a StringIO object and therefore checking the content type becomes impossible. The attachment_fu plug-in therefore bombs and gives errors. Kudos to Amit for solving this bug.

To top it all up, I was to travel home today and my flight got canceled. Can't still believe it. This guy calls me up early in the morning to say that the flight has been canceled. He asks me the mode of refund and pleasantly says thanks. I had to spend a thousand rupees more to get a ticket home and am 'supposed' to go tomorrow. Let's hope that works out.

Saturday, August 30, 2008

Travel On !

Its been some time since I have posted. I had some work to do, never leave the stuff that feeds you, and we had also a petty good trip to Jaipur. Sam, Jacob, Amit, Vivek, Abhilash and his two brothers also with some cousins of his started the onward journey to Jaipur on friday night. Amit drove his car where as Abhilash too his Santro. The ride was a mind boggling 300 odd kilometers but Amit chose to drive his Honda City all the way. I would have preferred the bike ride as it would have been adventurous like the Mukteshwar trip we had.

The Pink City was awesome ! The old buildings, the palaces were awesome. Chokhi Dhani was also great. To see all those ethnic craftsmanship, the delightful Rajasthani Food, especially Dal Bhatti, were excellent. We took a hell lot of pics, had lots of liquids as it was very humid. We managed to find a great hotel near Chokhi Dhani and stayed there for 2 days in whole. We managed to see Amer, Jaipur forts. We went through the straightest and best road ever while going to Ajmer. We visited the Ajmer Sharif and Pushkar as well. These religious places did not seem to be religious or pious to me in any way as the people there were more concerned about the money they got from the tourists rather than the sanctity of the place. This was disgraceful and discerning according to me.

I am due to travel home and spend some quality time with family starting the 5th of September and I am thrilled about that. Its been some time since I went home and I intend to have nice fish dishes this time around. Lets see how that goes.

Saturday, August 9, 2008

Asynchronous access via Ruby On Rails

Over the last month we have been pondering upon a major problem that needed to be implemented in a Ruby On Rails application. The statement of the problem is simple. I have a procedure/algorithm which takes two input sets, gets each element in the set and using a combination of the elements in the sets calculates a rating. As the problem it self suggests, this is a tedious process. Database access is evident and the procedure is also lengthy. I decided to write the algorithm implementation in the lib folder, so that it is accessible inside the application, and then call it inside the controllers.

If the algorithm was called inside the controller, the response would stall until the whole algorithm was completed. This is NOT what I wanted. The user should not be affected by the time the algorithm took to complete. The requirement here was to run this process as another thread/process at another place. To replicate the application environment in another server dedicated to this did not seem to be a great idea.

Thats when background process was suggested. Running the algorithm as another thread was another option. As the algorithm only required the sets, it could be run as a different thread. But the environment that the server provides must still be loaded. Ap4r came to the rescue here. Asynchronous Processing For Ruby could be used by any rails application to route all those tedious and time consuming accesses. This I thought was a smart way of doing a background process, although it is NOT a background process. It is just another url access. The Gem must be installed along with the plugin and the server must be started and wallah !! You are in ! Simple as that.

Next comes the trigger, ie the part where you actually need to start the background process. I had two places which acted as triggers. One was in the controller part and the other was from a model. Triggering from the controller part was easy as the plug-in's init file actually added the ap4r method with the Action Controller. Triggering from the model was tricky. As far as I know there is no way to actually call a url/controller method from a model. Theoretically this is wrong as the controller is supposed to be the base and the model does not need to know the controller which is accessing it, if it is accessing it.

I took the easy way out of this by firing a system command which did a wget to the url. This method (corresponding to the url) written in the controller does an asynchronous access thus returning immediately. Thus the system command does not stall the execution of the model method when it is called. The ap4r server is still called and the algorithm is run asynchronously thus serving our need.

The algorithm had many stages of executions/ filters along with database accesses. I managed to use message passing by calling the send method for the objects and lots of array operations. I thought I did a pretty good job in writing the algorithm. The vast thought that has been gone in developing a language like ruby must be praised here. Kudos to Yukihiro “matz” Matsumoto.