Tuesday, December 29, 2009

Formatting rules for UseModWiki

Here are some formatting rules and how to use guide for UseModWiki :-

- Creating a new page
Every Wiki page has an edit button. Click on the edit button and type a wiki word. A wiki word starts with a capital letter and has at least one more capital letter in it. Between the capitals there must be lower case letters. There cannot be two capitals in a row.

e.g. MyWord will bw displayed as MyWord?
Now click on the ? to go to the wiki page

- See the Recent Changes
Type in the URL as http://localhost/cgi-bin/wiki.pl?RecentChanges

The Recent Changes page shows the dates on which the individual pages have been updated.

- Editing Content
Click the edit button on a wiki page. Input the contents in the text field and press the save button.

- Create Links
Page Link: wiki words are treated as links to the corresponding wiki pages.

External Link : use the corresponding URL e.g. http://c2.com

- Search content
Enter the key word that needs to be searched in the text field labelled search at the end of the wiki page.

- Creating Inter Wiki
Our wiki can refer to pages in other Wikis. Edit intermap file in cgi-bin folder and add the entry for the mapping. It contains the mapping for the key word and the corresp URL.

e.g.: UseMod? is the key word and the URL is http://www.usemod.com/cgi-bin/wiki.pl?. Now if we want to refer to a page WhatIsaWiki? in the wiki http://www.usemod.com/cgi-bin/wiki.pl, we just need to refer it as follows: UseMod:WhatIsaWiki

- Having a non-wiki word as a link
[http://c2.com/ppr/about/author/martin.html Martin Fowler] will be displayed as [Martin Fowler]

- Sub Pages
The [SubPage] - [http://www.usemod.com/cgi-bin/wiki.pl?SubPage SubPage] idea allows every main page to contain its own wiki universe of subpages. The subpages can be used to help refactor a large page without the problems /LongPrefixBeforeEachPage?.

Monday, December 28, 2009

Are you Wiki ?

I gave a try to UseModWiki (an implementation of the original Wiki concept created by Ward Cunningham) and found it simply superb! We can use this internally across the teams for sharing information :-)

The name wiki comes from the Hawaiian word wiki wiki, which means quick/fast. There is a famous quote by Glen Wilber: "Knowledge grows faster than the way to organize it !". Wiki does provide an efficient and simpler way to organize and spread the ever growing knowledge across the entire team. It enables easy collaboration and sharing of information across the network.

Why wiki ?
- Similarity to HTML
- Instant Feedback Mechanism
- Accessible anywhere
- Easy Searching
- Easy to learn and use
- Open Source
- Tracking of pages

Installation steps on Windows :-

- Install active perl (http://www.activestate.com/activeperl/)
- Install Apache Web Server (http://httpd.apache.org/download.cgi)
- Extract usemod10 (http://www.usemod.com/wikicode/usemod-1.0.5.zip.)
- Copy wiki.gif from extracted usemod directory to apache htdocs folder.
- Copy wiki.pl from extracted usemod directory to apache cgi-bin folder.
- Edit the first line of wiki.pl so that it shows the right path to perl.exe. (say c:/perl/bin/perl)
- Edit wiki.pl to change the value of $DataDir so that it points to "wikidb" folder (say d:\usemodwiki\wikidb )
- Edit wiki.pl to change the value of $FullUrl so that it points to 'http://localhost/cgi-bin/wiki.pl'
- Start the Apache server.
- Open a browser and type in the url : http://machine-name/cgi-bin/wiki.pl where machine-name refers to the name of your local machine.
e.g. http://localhost/cgi-bin/wiki.pl

Once installed, the wiki is accessible across all machines in the same domain.

This is the simple page that I created on my local machine :-



And clicking on 'RailsTips' link navigates to other page that I created as :-



I will be writing more on formatting rules in my upcoming blog ...

Enjoy being wiki ... :-)

Friday, December 25, 2009

Gitanjali - Poor Heart

" I had gone a-begging from door to door in the
village path when thy golden chariot appeared in
the distance like a gorgeous dream and I wondered
who was the king of all kings!

My hopes rose high and I thought my evil days
were at an end, and I stood for alms to be
given unasked and for wealth scattered on all sides in the dust.

The chariot stopped where I stood. Thy glance
fell on me and thou camest down with a smile, I felt
that the luck of my life had come at last. Then
of a sudden thou didst hold out thy right hand
and say "Why hast thou to give me?"

Ah, what a kingly jest was it to open thy palm
to a beggar to beg ! I was confused and stood
undecided and then from my wallet I slowly
took out the least little grain of corn and gave it to thee.

But how great my surprise when at the day's
end I emptied my bag on the floor to find a least
little grain of gold among the poor heap. I bitterly
wept and wished that I had had the heart to give
thee my all. "

- Rabindranath Tagore

Thursday, December 24, 2009

Seven wonders

A group of students were asked to list what they thought were the present "Seven Wonders of the World." Though there were some disagreements, the following received the most votes:

Egypt's Great Pyramids
Taj Mahal
Grand Canyon
Panama Canal
Empire State Building
St. Peter's Basilica
China's Great Wall

While gathering the votes, the teacher noted that one student had not finished her paper yet. So she asked the girl if she was having trouble with her list. The girl replied, "Yes, a little. I couldn't quite make up my mind because there were so many."

The teacher said, "Well, tell us what you have, and maybe we can help." The girl hesitated, then read, "I think the 'Seven Wonders of the World' are:

to see
to hear
to touch
to taste
to feel
to laugh
and to love."

The room was so quiet you could have heard a pin drop. The things we overlook as simple and ordinary and that we take for granted are truly wondrous!

A gentle reminder -- that the most precious things in life cannot be built by hand or bought by man.

Tuesday, December 22, 2009

Patanjal Yogadarshan

I recently read a very intuitive and scientific book written by Dr. P.V.Vartak -"Patanjal Yog - Vidnyananishtha Nirupan" (Scientific explanation)

Dr. Vartak has explained the Yoga Sutras (threads) in a very scientific language in Marathi with real life examples. He has also established the date of Patanjali as around 5000 BC from reference of Brihadaranyaka Upanishad.

Patnjali was an authority on Yoga and had written way to enlightenment through Yoga (Yoga darshan - vision of Yoga). The Yoga system of Patanjali or the ancient Hindu doctrine of concentration of mind, ways to achieve it, are called Yoga-sutras, of Patanjali.

The Yoga Sutras consist of four chapters (called padas - Pada means 1/4th) :-
1. Samadhi Pada
2. Sadhana Pada
3. Vibhuti Pada
4. Kaivalya Pada

- Samadhi refers to a blissful state where the yogi is absorbed into the One.

- Sadhana is the Sanskrit word for "practice" or "discipline". The author explains karma yoga and ashtaanga yoga.

- Vibhuti is the Sanskrit word for "power" or "manifestation". 'Supra-normal powers' (Sanskrit: siddhi) are acquired by the practice of yoga. e.g. becoming invisible, travelling with a speed much more than a speed of light, reading minds, enter into foreign bodies (parakaya pravesh), etc.

- Kaivalya literally means "isolation", but stands for emancipation, liberation and used interchangeably with moksha (liberation), which is the goal of Yoga.

Here is the link for whoever is interested in reading Patanjal Yogasutras -
http://www.santosha.com/samadhi-pada1.html

But only reading would not help, every one needs to practice this as it is a practical knowledge !

Really great work done by Dr. Vartak ! Hats off to him for bringing this true ancient knoweldge in a very simple and heart touching language !

Monday, December 21, 2009

Display SQL queries in ruby script/console

Whenever we use ruby script/console during development, we often would like to see the SQL queries instantly that get being generated at the backend. Those queries can be a result of method calls on model, named scope, etc.

We just need to execute the below 2 lines to have this enabled on console.

ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.clear_active_connections!


And now whenever we will interact with ActiveRecord object method calls, the SQL query will get displayed immediately in the console.

e.g.

Saturday, December 19, 2009

Focus on solutions

When NASA began the launch of astronauts into space, they found out that the pens wouldn't work at zero gravity (Ink won't flow down to the writing surface). In order to solve this problem, they hired Andersen Consulting (Accenture today). It took them one decade and $12 million. They developed a pen that worked at zero gravity, upside down, underwater, in practically any surface including crystal and in a temperature range from below freezing to over 300 degrees C. And what did Russians do ?

The Russians used a Pencil !!!

So, learn to focus on solutions not on problems

"If you look at what you do not have in life, you don't have anything. If you look at what you have in life, you have everything... ! "

Thursday, December 17, 2009

Faith...

Once a priest had been on a long flight. The first warning of the approaching problems came when the sign on the airplane flashed on: "Fasten your seat belts." Then, after a while, a calm voice said, "We shall not be serving the beverages at this time as we are expecting a little turbulence. Please be sure your seat belt is fastened."

As he looked around the aircraft, it became obvious that many of the passengers were becoming apprehensive. Later, the voice of the announcer said, "We are so sorry that we are unable to serve the meal at this time. The turbulence is still ahead of us." And then the storm broke. The threatening cracks of thunder could be heard even above the roar of the engines. Lightening lit up the darkening skies, and within moments that great plane was like a cork tossed around on a celestial ocean. One moment the airplane was lifted on terrific currents of air; the next, it dropped as if it were about to crash.

The priest confessed that he shared the discomfort and fear of those around him. He said, "As I looked around the plane, I could see that nearly all the passengers were upset and alarmed. Some were praying. The future seemed ominous and many were wondering if they would make it through the storm.

And then, I suddenly saw a girl to whom the storm meant nothing. She had tucked her feet beneath her as she sat on her seat and was reading a book. Everything within her small world was calm and orderly. Sometimes she closed her eyes, then she would read again; then she would straighten her legs, but worry and fear were not in her world. When the plane was being buffeted by the terrible storm, when it staggered this way and that, as it rose and fell with frightening severity, when all the adults were scared half to death, that marvelous child was completely composed and unafraid."

The priest could hardly believe his eyes. It was not surprising therefore, that when the plane finally reached its destination and all the passengers were hurrying to get off, he stayed back to speak to the girl whom he had watched for such a long time.

Having commented about the storm and behavior of the plane, he asked why she had not been afraid.

The sweet child replied, "Sir, my Dad is the pilot, and he is taking me home..."

Saturday, December 5, 2009

How much land does a man need ?

The physical desires can never be satiated. The more one attempts to satisfy them, the more intense they grow, even as fire blazes instead of going out when oil is poured into it.

Tolstoy has written a very instructive story under the title "How much land does a man need ?"

- A man was promised free all land he could run round from sunrise till sunset. In his sheer greed to cover more and more land, he ran so far that he never got back to the starting place before sunset, and in utter exhaustion, he died. Only a strip of land, 7 feet, was needed to bury him !

Friday, November 27, 2009

Build your self confidence like a leader

This is an article by Marshall Goldsmith in which he states 5 points to build one's self confidence as a leader.

1. Don't worry about being perfect
2. Learn to live with failure
3. After you make the final decision - commit!
4. Show courage on the outside
5. Find happiness and contentment in your work

Here is the link to the article :-
http://blogs.harvardbusiness.org/goldsmith/2009/10/build_your_self_confidence_lik.html

Tuesday, November 3, 2009

Search for Bhavani Sword of Chhatrapati Shivaji Maharaj ...

I recently read a marathi book 'Shodh Bhavani Talvaricha' (Search for Bhavani sword) written by Indrajit Sawant. The author has done M.A. in History and is having a collection of different types of historical weapons. (especially swords of Chhatrapati Shivaji's era).

Chhatrapati Shivaji Maharaj was the greatest warrior of 17th century who established Hindavi Swarajya. He brought revolution in traditional maratha weapons. He developed Maratha swords. This type of sword has a unique comfortable hilt with a unique pommel.

Description of different parts of a typical Maratha Sword :-



The author's passion towards the swords and history motivated him to investigate into the real swords of Chhatrapati Shivaji Maharaj and study different types of swords.

There are different types of swords - Dhop, Khanda, Phirang, Latti, Samsher, etc.

The swords belonging to Shivaji Maharaj are of Phirang type. i.e. the blade is of European (Portuguese) made and they are straight and hilt of the sword is of Maratha type. In the historical records,we can find that Shivaji Maharaj was having many swords like Tulaja, Bhavani, Jagadamba, etc.



In this book, the author has given many references / evidences to find out where these swords are located now.

"Jagadamba", one of the swords of Shivaji Maharaj is now in London, in Royal Collection Trust of Royal family of Britain. This sword was presented by Shivaji IV of Kolhapur to Prince of Wales in 1875 AD. (The Royal Collection London - Address: Clarence House, St James's Palace, London, SW1 1BA)

The catalog at Royal collection has the following entry about this sword :-

" Sabre : Maratha: Straight, one-edged old European blade with two grooves on each side, in one of which I.H.S. is stamped three times; the raised steel supports at the hilt are damascened with gold in floral designs; the guarded hilt is iron with a broad knuckle guard and a circular pommel, terminating in a spike and encrusted with heavy open-work Floral decoration of gold thickly set with large diamonds and rubies. Presented by H.H. the Maharaja of Kolhapur as a relic of the Maratha chief Shivaji, to whom it formerly belonged."

Jagadamba sword in Royal collection :-



Efforts are being made to bring back this sword from London back to India. This sword is indeed a source of inspiration to all of us.

Please refer this link for more pictures and information :- http://swordofshivaji.blogspot.com/

I would recommend everyone to read this book.
Many thanks to Indrajit Sawant for doing this excellent research !

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...

Saturday, May 23, 2009

Obedient Disciples

One day while they were on their way to a distant town, Guru Gampar fell asleep in the bullock cart they were travelling in. His head rolled from side to side and suddenly his turban slipped from his head and fell on to the road. But as their guru had told them never to do anything without his permission, none of the disciples made a move to get down and pick it up.

When the guru woke up and was told about the loss of his turban he was furious. "Next time anything falls off pick it up at once!" he thundered.

Some time later the bullock dropped its dung and the four foolish disciples leaped down and picked it up. Guru Gampar was horrified. He made a list of the things that could fall off from a moving cart. "Pick up any of these things if they fall," he told them, handing them the list. "Don't pick up anything that is not mentioned here."

Just then the cart lurched violently and Guru Gampar was thrown headlong into a ditch. Guru Gampar yelled to his disciples to pull him out.

"We can't, guruji," said his disciples, sadly. "Your name is not on the list you gave us." Guru Gampar pleaded with them to pull him out, but in vain.

"We know you are testing us, guruji," they told him. "But you can rest assured that we will never disobey you. You told us not pick up anything that was not mentioned in your list and we will not do so."

"Give me the list!" yelled Guru Gampar. They threw him the list and the pen and the guru hastily scrawled his name on it.

Then and then only did the obedient disciples pull their beloved guru out of the ditch and put him back into the cart !

Moral : Obedience has to be backed with Conscience and Prudence, otherwise it becomes just a silly act.

Friday, May 22, 2009

What is Unobtrusive javascript ?

In simple words, it is separation of behaviour from the html structure.

Consider the following example :-



The style of this button element, to include the font of its caption, is provided by CSS rules loaded via a stylesheet. But while this declaration does not mix style with structure, it does mix behavior with structure, by including the JavaScript
that is to be executed when the button is clicked as part of the markup of the button element (which in this case, turns something named xyz red upon a click of the button).

For all the same reasons that it is desirable to segregate style and structure within an HTML document, it is also becoming recognized that separation of behavior from structure has just as many, if not more, benefits.

This movement is known as Unobtrusive Javascript.

jQuery is a javascript library which supports this movement. It aims to change the way that web developers fundamentally think about creating rich functionality in their pages. jQuery is generally useful for any page that needs to perform anything but the most trivial of JavaScript operations, but is also strongly focused on enabling page authors to employ the concept of Unobtrusive JavaScript within their pages. With this approach, behavior is separated from structure in the same way that CSS separates style from structure, achieving better page organization and increased code versatility.

Thursday, May 21, 2009

Who moved my cheese ?

The book 'Who moved my cheese?' has been written by Spencer Johnson. It's an amazing way to deal with change in our work and in our life. Many people have reported that what they discovered in the story has improved their careers, businesses, health and marriages.

I found this book very interesting as it correctly identifies human thinking patterns.

Cheese is a metaphor for what you want to have in life - whether it is a good job, a loving relationship, etc.

Maze is where you look for what you want - the organisation you work in, or the family or community you live in.

There are four imaginary characters depicted in the story. They intend to represent the simple and complex parts of ourselves, regardless of our age, gender, race or nationality.

Sniff :- who sniffs out change early
Scurry :- who scurries into action
Hem :- who denies and resists change as he fears it will lead to something worse
Haw :- who learns to adapt in time when he sees changing can lead to something better !


Here are the simple but very important notes/principles mentioned in this book :-

(1) Having cheese makes you happy
(2) The more important your cheese is to you, the more you want to hold on to it
(3) If you do not change, you can become extinct
(4) What would you do if you weren't afraid ?
(5) Smell the cheese often so you know when it is getting old
(6) Movement in a new direction helps you find new cheese
(7) When you stop being afraid, you feel good !
(8) Imagining yourself enjoying your new cheese leads you to it
(9) The quicker you let go of old cheese, the sooner you find new cheese
(10)It is safer to search in the maze, than remain in a cheeseless situation
(11)Old beliefs do not lead you to new cheese
(12)When you see that you can find and enjoy new cheese, you change course
(13)Noticing small changes early helps you adapt to the bigger changes that are to come


Enjoy reading ! :-)

Tuesday, May 19, 2009

Astronomical Dating of the Ramayan and South America was known in Ramayan era - by Dr. P V Vartak

I recently read a book "Vastav Ramayan" (Real Ramayan) written by Dr. P.V.Vartak.
He has done scientific research and calculated dates of the important events during Ramayan era. It is a very interesting and scientific book that everyone should read.

Here is a link for Astronomical Dating of the Ramayan :-

Astronomical dating of Ramayan events

Also, his research shows that South America was known at the Ramayan era. Indians migrated to South America which is called "Patal Lok" in sanskrit. There are some places in South America which denote the Indian culture, like Surya Mandir (Sun Temple), Elephants, Lord Ganesha and snakes carved on ancient monuments, etc.

In Ramyan, when King Sugriv directs his men in all directions in search of Sita, he instructs people going to east direction to check out for a TRIDENT engraved on a mountain. He describes the Trident as "A long Golden flagstick with three limbs stuck on top. It always glitters in when seen from sky". (This trident is on west coast of peru - Lima and is visible clearly from the sky)

In Valmiki Ramayan - Kishkindha Kaand - The sanskrit shlok is as below: (Kishkindha-39/47-48)




The entire Valkimi Ramayan can be found at :-

Complete Valkimi Ramayan in Sanskrit

The description given is so clear that Sugriv or Sage Valmiki must have seen this trident from sky proving they might have aeroplanes to travel.



Around 100 miles from this trident, there is a place called Nazca or Nasca, where gigantic geometric shapes are drawn on land (Spread in miles across). These are visible from sky only. Looks like big airport at that time.

Pls visit these links so that you can get a picture.
Trident at Lima-Peru
Nazca lines

According to Dr. P. V. Vartak, the trident is a sign of east ( as we have 180 degrees today to decide from where west starts ). This was created by Lord Vishnu around 15000 - 17000 years ago. And the lines on the Nazca are the signs of Ancient Airport of King Bali, around 15000 years ago.

If you get a chance, please read this book - Vastav Ramayan! It is awesome !

Also the book 'PataalYatra' by Anil Patil is good to read. It is a fiction inspired by South America and Pataal invention by Dr. P V Vartak.

Michael Crichton's fictions

I have read few fictions of Michael Crichton and very impressed with his writing skills. He keeps one totally engrossed with the story.

Jurassic Park, The Lost World, The Terminal Man, Eaters of the Dead, Timeline, State of Fear, The Andromeda Strain are some of his fictions that I have read and liked all of these.

I have also seen some movies that are based on his novels, but truely speaking the thrill that I experienced while reading the novels was much greater than watching the movie :-)

Thursday, May 14, 2009

Shaping Models in ruby on rails

Whenever a new team member enters to any enhancement project, from technical perspective, he tries to understand the already developed code. Code comprehension may become difficult if there is no proper documentation. There can be many models with different relationships defined amongst themselves. Won't it be good to have some sort of diagrammatic representation of the Model relationships ? It will certainly be very helpful for the development and support teams to understand the application in technical perspective.

Let's develop small and simple ruby code to construct a diagrammatic representation
of the Model (Active Record) relationships (Model in M-V-C architecture) in any Ruby on Rails application. (We will follow KISS principle - Keep it simple and Succinct ! :-)

Active Record is an implementation of the object-relational mapping (ORM) pattern by the same name as described by Martin Fowler:

"An object that wraps a row in a database table or view, encapsulates
the database access, and adds domain logic on that data."



Active Record supports three types of relationship between tables:
(1) one-to-one
(2) one-to-many
(3) many-to-many.
You indicate these relationships by adding declarations to your models: has_one, has_many, belongs_to, and has_and_belongs_to_many.

There is a tool called 'Gvedit' (graphviz-2.20.2.exe) (http://www.graphviz.org/) which generates Directed and Undirected graphs. It accepts a dot file in specific format and it generates directed graphs free of cost ! :-) Why not use this tool ?

We can use the reflections for findling all associations of a Model.
http://api.rubyonrails.com/classes/ActiveRecord/Reflection/ClassMethods.html

Here is the utility which can be run from the rails application root and generates simple text file with the represention that the dot file requires for creating graphs. It looks for all the model classes under app/models directory.



It generates a simple text file as below :-

digraph model_relationship {
Asset -> DbFile [label=belongs_to]
Asset -> Thumbnail [label=has_many]
Category -> Child [label=has_many]
Category -> Content [label=has_and_belongs_to_many]
Category -> Parent [label=belongs_to]
Content -> Category [label=has_and_belongs_to_many]
Content -> Asset [label=belongs_to]
}


Save this as a .dot file. Open this file in Gvedit and run to generate the graph.

Here is a sample graph generated out of Gvedit :-



We can thus get a picture of all the model relationships in a typical ruby on rails application !

Tool Version Tracker rails application for sourceforge tools

There are many sourceforge open source tools and it is sometimes difficult to track the latest vesions of all tools and keep us updated. We should atleast try to track the latest versions of the open source tools that we daily use in our projects.

So why not develop a very simple rails application which will allow you to add, edit and destroy tool information, the sourceforge url, version information, etc. Let's develop tool version tracker app with CRUD operations and some logic to track the tool versions :-) The logic may not be great but definitely useful for core developers who are always looking for new things/tools/versions ! Find the updated versions of the sourceforge tools and send an email with the updated versions to all team members :-) We can either run this periodically through web application or we can do some modifications to run this as a scheduled cron job :-)

We will use hpricot for parsing html.
Let's take an example of checkstyle. If we go to this link :- http://sourceforge.net/project/showfiles.php?group_id=29721

We will find the version information as :-


So in our code we will just compare the release number by parsing the html with hpricot and find out any change in version of the tool.

Here is the code in html_parser.rb under lib :-



In the environment.rb file, add the following line :-

SOURCEFORGE_URL = "http://sourceforge.net/project/showfiles.php?group_id="

For each tool, we have a unique group id.

The migration for Tool model is as below :-



You can view all the tools on index as below :-


You can find the updated version of individual tool or all tools by clicking on the links. So after clicking on the Update versions of all tools, you will get :-



And an email is also sent with the latest information (Simple Rails ActionMailer):-




You can edit/add the tool information from your application as :-


So how do you find it ? It is simple and easy to develop through Rails and definitely useful for all the Automated Tool Lovers :-)
It certainly solves our purpose :-)

Thursday, April 23, 2009

Sinatra - web application framework in Ruby

In one of my ruby applications, there was a requirement to monitor application log file. We did it very quickly with sinatra web application framework. The requests made are checking whether application is running, viewing log file, etc.

http://www.sinatrarb.com/intro.html

Sinatra is a DSL for quickly creating web-applications in Ruby with minimal effort. In Sinatra, a route is an HTTP method paired with an URL matching pattern. Each route is associated with a block. Routes are matched in the order they are defined. The first route that matches the request is invoked.

Sinatra rides on Rack, a minimal standard interface for Ruby web frameworks. One of Rack’s most interesting capabilities for application developers is support for “middleware” — components that sit between the server and your application monitoring and/or manipulating the HTTP request/response to provide various types of common functionality.

Just do this and you will be on track :-)

gem install sinatra
ruby myapp.rb

In myapp.rb :-
get '/checklog' do
Some code here ...
[200, {"Content-Type" => "text/html"},
"Log is ok?:true or false]
end

Saturday, February 7, 2009

Verifying Compliance to Coding Standards with Checkstyle

CheckStyle is an open source tool that helps in verifying compliance to a coding standard. The rules of the coding standard can be configured in an XML file. This makes it ideal for projects that want to enforce a coding standard.

CheckStyle increases code comprehension and makes code review less taxing. It is most useful when integrated into a build process or development environment.

http://checkstyle.sourceforge.net/

Detect commonly occurring defects with PMD, Findbugs and Jlint

A compiler may have difficulty in finding some commonly occurring defects such as null assignment, empty catch block, catching the canonical Exception instead of a specific one, etc. Dr. Eric Allen lists many instances of these defects in his book ‘Java Bug Patterns’.

PMD can detect such defects in a given set of Java source file once they are described as ‘patterns’. PMD rules can be written in java.

FindBugs & JLint can detect common defects by reviewing the class files. JLint can detect inconsistencies and synchronization problems.

CPD – a variant of the PMD is used for detecting instances of code that has been copy-pasted. Duplication of code indicates non-existence of single point of control. A bug can propagate to other parts of the code if the base code contains bug in it. CPD thus can denote code that needs to be refactored.

http://pmd.sourceforge.net/
http://findbugs.sourceforge.net/
http://jlint.sourceforge.net/

These tools are very interesting and simple to use.


Friday, January 23, 2009

Articles on Trekking - Vasota-Nageshwar, Fansad-Korlai, Ankaai-Tankaai

Here are my few articles about trekking and nature ! I have written those in my Mother Language, i.e. Marathi ! :-)

http://trekshitiz.com/articles/Article_Index.htm

Ruby on Rails - Metric_fu integration with cruisecontrol.rb



You can integrate metric_fu with cruisecontrol ! It is very simple and straightforward !
http://metric-fu.rubyforge.org/

Metric_fu is a set of rake tasks to generate metrics reports. It uses Saikuro ( Cyclomatic complexity), Flog (Cyclomatic complexity) , Rcov (Unit test coverage), Churn ( Finds how many times your files have been changed), Subversion, Git, and Rails built-in stats (LOC, Methods, Test LOC, Code LOC, etc.) task to create a series of reports.

There was issue with stats report not rendering properly in the browser. Fixed that issue with modifying stats rake task inside metric_fu.
Modified file :- jscruggs-metric_fu-0.8.0\lib\tasks\stats.rake