Tuesday, November 3, 2009

Photos taken from air by Uddhav Thackeray

I liked these photos taken by Uddhav Thackeray - It includes forts in Maharashtra, some places in Mumbai and some places of worship in India.

http://www.uddhavsphotos.com/photos.html

Sunday, October 25, 2009

Are you still carrying her ... ?

Two monks were travelling in the rain, the mud sloshing under their feet. As they came to a rivulet crossing, they saw a beautiful young girl, finely dressed, unable to cross because of the mud. Without a word, the older monk picked up the girl and carried her to the other side.

The younger monk was agitated for the rest of their journey and could not control himself once they reached their destination. He exploded at the older monk, "How could you, a monk, even consider holding a woman in your arms, much less a young and beautiful one? It is against our teachings. It is in very bad taste."

"I put her down at the roadside", said the older monk, "Are you still carrying her ... ?"

Thursday, October 1, 2009

Ruby treemap

I came across ruby treemap library and tried simple example with it. RubyTreemap is a library for generating treemaps in ruby in multiple formats such as png, svg and html.

Treemaps are for visualizing data sets and are commonly used to display hierarchical data.

Some good links :-

http://rubytreemap.rubyforge.org/

http://www.oreillynet.com/ruby/blog/2006/07/treemap_on_rails.html

A Node in the treemap has a size and a color. The size can be any value and is specific to your data set. So for example, in a treemap of the book sales, a given node's size could be equal to it's total sales for the day. For all non-leaf nodes the size value must be equal to the sum of the sizes of it's children. If the size is nil it will be calculated by recursively summing the size of the child nodes. The color for a node can be either a value usually a percentage (a rate of change) or a hex string color.

Installation and dependencies :-

-- ruby script/plugin install http://github.com/rails/acts_as_tree.git

-- ruby script/plugin install http://code.qnot.org/svn/projects/acts_as_treemap

-- RMagick (rmagick.rubyforge.org/)
Download and extract RMagick-2.10.0-ImageMagick-6.5.3-10-Q8.zip from
http://rubyforge.org/frs/?group_id=12 :-

gem install rmagick --local (installing rmagick-2.10.0-x86-mswin32 )

-- gem install ruby-treemap --source http://gems.rubyforge.org

Our simple Book Model :-



Here is the table that represents books as treemap :-



and here is the generated treemap :-



You can render the treemap in your view by :-


where @root is the parent treemap node.

We can also override the methods in the Treemap::HtmlOutput class to modify the label names, making lables as hyperlinks, etc.

If we want the rate of change of color, we can modify the model entry as below :-

acts_as_treemap :label => :name, :size => :total, :color => :total

So the rate change of color of blocks will be proportionate to the size of the book sales.

Thursday, September 24, 2009

Old man and death

An old labourer, bent double with age and toil, was gathering sticks in a forest. At last he grew so tired and hopeless that he threw down the bundle of sticks, and cried out: "I cannot bear this life any longer. Ah, I wish Death would only come and take me!"

As he spoke, Death, a grisly skeleton, appeared and said to him: "May I help you? I heard you called me just now."

"Please, sir," replied the woodcutter, "would you kindly help me to lift this faggot of sticks on to my shoulder?"

We would often be sorry if our wishes were gratified.

Friday, June 26, 2009

Playing with Prawnto - Ruby PDF generator plugin

I recently watched Ryan's railscast PDFs with Prawn and tried it on tool version tracker application's index page (Please see my previous blog - Tool Version Tracker )

It was a good experience of writing text, image, table to pdf document with clean and neat code. I was able to generate the pdf document I intended to display in less than 20-25 minutes. (installing prawn gem, prawnto plugin, understanding some API and making code changes :-)

Prawnto is a rails plugin leveraging the Prawn library to produce compiled pdf views. The plugin adds a new template handler class that will process any views with a .prawn extension. These .prawn views are evaluated as ruby code and are provided an instantiated Prawn::Document object as 'pdf'. The pdf object gives you complete access to all of prawn's capabilities.

I added the following line to my index.rhtml page :-

link_to 'PDF Format', tools_url(:pdf)

Then I created index.pdf.prawn file :-



Clicking 'PDF Format' link on index page generated inline pdf for tools as below :-



There are many things that you can do with prawnto. (http://www.cracklabs.com/prawnto/demos) I plan to try these different options.

Have a nice pdf ! :-)

Thursday, June 18, 2009

Code Reading – The Open Source Perspective

The book 'Code Reading' has been written by Diomidis Spinellis.

This book is the first one to exclusively deal with code reading as a distinct activity. It primarily emphasizes on developing and improvising the Code Reading or comprehending skills of a programmer. The simplest way to learn to write great code is by reading good code. For that, one needs to make a distinction between a good and bad code.

The level of abstraction the programmer can hit upon given a section of code to analyze, depends on his/her code reading skills and perception about the problem. This book helps to enhance these skills.

At the beginning, it briefly introduces the commonly used programming structures and explains how to extract semantic meaning out of them. It talks about different nifty code reading techniques that may be used in the following scenarios –

- Analyzing large bodies of code
- Adding new functionality
- Fixing bugs
- Integrating into new environments
- Code Reuse

It further talks about understanding project build process, following coding standards and conventions, effectively using software documentation to supplement code reading efforts and getting architecture overview from a code in terms of design patterns.

It also describes some of the code reading and browsing tools which can enhance the code reading efficiency. (e.g. Regular expressions, grep for search, diff for difference in files, source navigator for browsing, code beautifiers, runtime tools like profiler – gprof in unix, etc.)

Reading this book will definitely spur interest into the programmers to learn a lot from the existing open source code and make valuable contributions to the open source world in future.

Wednesday, June 17, 2009

RailRoad - RoR diagram generator

Thanks to Javier Smaldone for developing this gem!

http://railroad.rubyforge.org/

This gem generates model and controller diagrams in RoR application. Javier has built on top of the original idea by Matt Biddulph. I mentioned Matt's idea in one of my earlier posts - Shaping models in RoR.

We should play with RailRoad in all our RoR applications to understand the complexity of the relationships that we have developed.

Tuesday, June 9, 2009

Making a difference !

This is a very nice story which I liked the most !

A man was walking along a beach when he saw a woman picking up starfish off the sand and tossing them into the waves. Curious, he asked her what she was doing. The woman replied "When the tide goes out it leaves these starfish stranded on the beach. They will dry up and die before the tide comes back in, so I am throwing them back into the sea where they can live."

The man then asked her "But this beach is miles long and there are hundreds of stranded starfish, many will die before you reach them - do you really think throwing back a few starfish is really going to make a difference?"

The woman just smiled. She picked up a starfish and threw it into the waves. "It certainly makes a difference to this one" she said.

In our day to day life, we come across many things that we consider very difficult to tackle with. There are many poor people, many mentally and physically retarded people, very old people, really needy people, etc. How can we make a difference in their lives ? Is it practical ? Certainly not. There are definitely some limitations.

But can we take inspiration from the above starfish story and step into making difference to at least one really needy person? Don't you think that will certaily make a difference in his/her life ?

Can we donate our valuable eyes to blind person after our death ?
Can we donate our blood ?
Can we adopt one orphan child for his/her education ?
Can we adopt a child completely ?
Can we help someone to start with small business ?


Actually there are many things that we can do .... we need to start with at least one though !

Tuesday, June 2, 2009

The big fire and the little water

Long time ago there was a great fire in the forests that covered our Earth. People and animals started to run, trying to escape from the fire. One of the eagles, was flying away also when he noticed a small bird hurrying back and forth between the nearest river and the fire. He headed towards this small bird.

He noticed that it was a small sparrow, flyinging to the river, picking up small drops of water in his beak, then returning to the fire to throw that tiny bit of water on the flame. The eagle approached the sparrow and yelled at him: "What are you doing brother? Are you stupid? You are not going to achieve anything by doing this. What are you trying to do? You must run for your life!"

The sparrow stopped for a moment and looked at the big eagle, and then answered:
"I am doing the best I can with what I have."

Sunday, May 24, 2009

Learning from mistakes

Thomas Edison tried two thousand different materials in search of a filament for the light bulb. When none worked satisfactorily, his assistant complained, "All our work is in vain. We have learned nothing."

Edison replied very confidently, "Oh, we have come a long way and we have learned a lot. We know that there are two thousand elements which we cannot use to make a good light bulb!"

Moral: Always take things positively. You can learn a lot from the mistakes you commit. Actually by commiting mistakes, you are laying a strong foundation before the world. So even if you think you have wasted a big time for that, you have actually saved a huge time of others in future...