Saturday, October 31, 2009

Find files containing a word/phrase

If you are using cygwin on Windows or using Linux/Unix, here is a simple way to find the files containing a particular word or phrase:

find . -name '*.java' -exec grep -l 'phrase to search' {} \;

Note that this will do a recursive search inside the sub-directories as well. To search only in the current folder, the grep command is sufficient.

Use rsync to backup files

Since I have moved to Ubuntu, I am able to use rsync to backup files from my laptop to my external HDD very simply. In fact I do the same at work using cygwin on WinXP Pro!

I use the following command to verify which files will be copied to the external HDD:
rsync -cnrv --exclude-from=~/sync/exclude_patterns.txt /<source_folder>/ /<dest_folder>/

And once I am ok with the list, I run the command without the "-n" option as:
rsync -crv --exclude-from=~/sync/exclude_patterns.txt /<source_folder>/ /<dest_folder>/

Explanation of Options:
  • -c: Use checksum, ot modification date & time to compare files
  • -n: Dry Run - perform a trial run without any changes
  • -r: Recurse into sub-directories
  • -v: Verbose - give detailed output
  • --exclude-from: Use the file patterns given in the file to exclude files from source
  • trailing / in paths: Do not create the current folder - copy it's contents

There are many other options - checkout the man page for other great features of rsync.

Tuesday, October 20, 2009

Filter rows in a file based on composite key in another file

Here is a quick, simple and easy way to filter the records in a file based on a composite key present in another file!

There are many ways to do it, this method uses ask, grep & sort to do the job

  1. Files are pipe ("|") separated
  2. File containing the key is called "accounts"
  3. Columns 2 & 4 join to form the key to be used for filtering
  4. File containing the records to be filtered is called "acdata"
  5. This file contains the "key" column apart from other data
  6. Filtered records need to be stored in the file "filtdata"

awk 'BEGIN { FS="|";} {k1=$2; k2=$4; k=k1 k2; print "grep " k  " acdata" ;}' accounts | sort -u | bash > filtdata

Sort with unique option turned on needs to be used to ensure that we get only one row from the key file in case there are more than one rows with the same composite key.

Wednesday, October 14, 2009

Albania wants Mother's remains

In a very strange turn of events, Albania wants India to hand over the remains of Mother Teresa stating that she was born in Skopje which was then a part of Albania. However, it is important to note that she was born to immigrant parents in Skopje which is now the capital of the Republic of Macedonia. So there is a bitter dispute going on between Albania and Macedonia as well regarding the citizenship of Mother Teresa.

Mother Teresa once said: "By blood, I am Albanian. By citizenship, an Indian. By faith, I am a Catholic nun. As to my calling, I belong to the world.". So this three-sided tussle over her remains does not make much sense - she should just be left alone in peace in the land which she took as her own.

It seems that this is being done by Albania as it is on the hunt for other national icons as it struggles (since 1992) to heal the scars of four decades of communism. Albania wants to reclaim her remains before the 100th anniversary of her birth in August next year so that it can promote tourism as people will throng to visit her grave. The fact that Vatican is in the process of canonizing her, adds to the lucrativeness.

Here is a short timeline of important events in her lifetime:
  • August 26, 1910: Born Agnes Gonxha Bojaxhiu, in Skopje
  • 1928: Moved to the Loreto Abbey in Rathfarnham, Ireland, to learn English
  • 1929: Arrived in India as a novitiate in Darjeeling
  • May 24, 1931: Took religious vows as a Nun
  • May 14, 1937: Took her solemn vows while serving as a Teacher at Loreto Convent School, Calcutta
  • 1948: Left Sisters to teach slum children and care for the homeless
  • 1950: Started Missionaries of Charity in Calcutta
  • 1951: Given Indian Citizenship
  • 1952: Opens the first Home for the Dying in space made available by the City of Calcutta
  • 1962: Awarded the Padma Shri - an award given by the Government of India generally to Indian citizens to recognize their distinguished contribution in various spheres of activity
  • 1962: Awarded the Philippines-based Ramon Magsaysay Award for International Understanding, given for work in South or East Asia
  • 1971: Paul VI awarded her the first Pope John XXIII Peace Prize, commending her for her work with the poor, display of Christian charity and efforts for peace
  • 1979: Awarded the Jawaharlal Nehru Award for International Understanding
  • 1979: Awarded the Nobel Peace Prize
  • 1980: India's highest civilian honour, the Bharat Ratna for her humanitarian work
  • November 16, 1996: Proclaimed directly by Act of Congress an Honorary Citizen of the United States.
  • September 5, 1997: Died of heart attack
  • 2002: Beatified by Pope John Paul II given the title "Blessed Teresa of Calcutta"

Cash for Clunkers to impact Inflation

The Cash for Clunkers program has been hailed as the savior for the Auto Industry. However, what will be it's impact on Inflation, Economy & the Auto Industry?

John Crudele of NY Post explores this impact in his article and points out that this incentive/subsidy amount will actually be accounted by the US Bureau of Labor Statistics in the CPI as if the prices of cars fell by that amount. This will create an artificially low Inflation rate. This deflation is actually being paid for by the people as it is coming out of tax payers money!
Read this full article here.

The Goldman Conspiracy?!

John Crudele of NY Post points out to facts and events pointing towards a "Goldman Conspiracy"!.

Could this be just a journalist's rant!
Or a thriller plot good enough to be made into the next movie or a book to beat Dan Brown at his own game!
Or it could even be very true!

Read these articles and then decide for yourself!

Read this full article here.

And another of his article here.

  • The views presented in the articles on NYTimes are of the original publisher/author
  • This post aims to show the various differing views, people have of a set of events!
  • This post also brings to light, that in retrospect, how events can be interpreted in totally different ways to fit the author's views/biases?!

Obama fails to win Nobel for Economics

U.S. President Barack Obama wins the Nobel Peace Prize but loses out on the Economics Nobel.

So writes Tom Bemis in this article on Market Watch.

Obama wins the Nobel Peace Prize within a very short tenure in office and that is the target of this sarcastic but bending towards truth article.

Tom Bemis mentions that Obama loses out on the Economics Nobel to "two obscure academics -- Elinor Ostrom and Oliver Williamson -- one noted for her work on managing collective resources, and the other for his work on transaction costs."

And this in spite of his good work in stabilizing the U.S. & world economies, the Stimulus package, Cash for Clunkers program, cap-and-trade bill, and many more real life implementations of Economics theories in such a short duration.

The strange part about all this is that the deadline for nominations for Nobel Peace prize is February 1st according to the Nobel Prize website. Since Obama took the oath on January 20th, it was only 12 days since he was in office when he must have been nominated for this prize - that's a pretty good achievement I would say!

Here's another article on Fox News which looks at the work done by Obama in the 12 days culminating to his nomination.

Tuesday, October 13, 2009

Deals for Tuesday, October 13, 2009

Here are some good Deals for Tuesday, October 13, 2009.
Note: These have been mined from D2B, SD, FW, etc, so all the credit for finding these deals goes to the OPs!

  • WinXDVD Platinum version download at WinXDVD for Free!
  • World of Goo at 2DBoy - the creators of this game, for Name Your Price

I tried the game World of Goo and it is absolutely awesome - very simple and engrossing - you should try it out!

New Widgets added - Tag Cloud & Related Posts

I found out and added two new widgets to this blog: Tag Cloud & Related Posts - thanks to the creators for providing these.

Here are the details of the widgets that I have added.

Tag Cloud:
I searched for and found quite a few free Blogger Tag Cloud widgets but liked this one provided by phydeaux3. It is very simple, flexible, highly configurable and suits my needs perfectly!

Related Posts:
I was looking around for cool widgets for this blog and found one which shows related posts below each post. This was awesome and quite simple to implement. You can check it out here. Check out the blog for a lot of good widgets, but some like the Search does not have proper install instructions.

Thursday, October 1, 2009

UML Tutorial Links

Learning & applying UML can sometimes be exasperating to the uninitiated. Here are a few links to useful tutorials on UML that I have used in the past.

Practical UML: A Hands-On Introduction for Developers
This is a very simple and straightforward introduction to UML and is very useful for understanding the basic concepts even though it is based on the older 1.x specification.

Wikipedia entry for UML
Wikipedia entry for UML is a bit scarce if you want to learn UML, but is very good as usual for reference and to jog your memory.

Articles on IBM Developer Works
The following articles on IBM Developer Works site are also very good at detailing the intricacies of UML:
UML basics: An introduction to the Unified Modeling Language
UML basics: The class diagram
UML basics: The component diagram
UML basics: The sequence diagram

Introduction to the Diagrams of UML 2.0
This clear introduction of the diagrams of UML 2.0 by Scott Ambler of Agile Modeling gives a very good idea of how the diagrams are organized and also provides links to details of each type of diagram.

Debugging in *nix

Debugging as it is, is a very tedious and painful job. And it becomes even more intimidating when it needs to be done on Linux/Unix. Read on for a good introduction to techniques for debugging on *nix.

This article by Guido Socher focuses on Linux and is titled Why does this not work!? How to find and fix faults in Linux applications.
This articles touches on properly setting up and using logging, using strace to trace the execution path of the program and using gdb & core files.

This article by Frank Schoep focuses on Linux and is titled GDB GNU Debugger Intro.
This article gives a very good introduction on using gdb and understanding core files.


Related Posts Plugin for WordPress, Blogger...