Zero Rupee Bill
February 8th, 2010
Our very own Blue Planet Run Foundation
July 27th, 2009
Only In India
July 15th, 2009
Update : Jul 15, 2009
Install a rpm in home directory as non-root
July 10th, 2009
Do you ever need to install a rpm package however don't have permission to do it as root. You can install the rpm in your personal home folder as long as all the pre-requisites are met.
Here is how.
Step 1. Intialize your own private rpm db
rpm --initdb --root /home/username/local --dbpath /home/username/local/lib/rpm |
Step 2. See what files are in the rpm and where they will be installed by default. Relocate the path to your rpm root directory.
rpm -qlp package.rpm |
This will list all the files in the rpm. If they all start with /usr, we can just use /home/username/local as the new path as shown below.
Step 3. See if all dependent rpm met?
rpm -ivh package.rpm |
This will fail as you don't have permission to install. However if doesn't complain about dependent files then you are good. Other install the dependent rpms first.
Step 4. Install the rpm
1 2 |
rpm --root /home/username/local --dbpath /home/username/local/lib/rpm \ --relocate /usr=/home/username/local --nodeps -ivh package.rpm |
You have to add the flag --nodeps as the dependent rpms are in the system rpm database but not in your own.
disable body onload with a simple GreaseMonkey Script
June 23rd, 2009
I needed to disable a site from executing body onload event. Onload code actually opened the print dialog box and closed the window when the print dialog is closed. However I needed to see how the page looks like in the browser without actually printing.
Greasemonkey came to rescue. I just created a very simple script and added
document.body.setAttribute('onload',''); |
Hope this helps somebody out there.
References: Google Group Discussion
Copy, Split Large Directory on to Multiple Disks | Mac OS X
January 27th, 2009
If you need to backup or copy a huge directory to multiple disks then this might be useful to you. I am on Mac OS X Leopard.
1 2 3 4 5 6 7 |
# Create a image of the folder. hdiutil create -o Image.dmg -format UDRO -srcfolder SourceFolder # Segment the image into multiple segments. hdiutil segment -o Image.Segment.dmg -segmentSize 4.7g Image.dmg |
The above command would split the Image.dmg into multiple segments of Size 4.7GB. The first one would be named Image.Segment.dmg and the rest would be Image.Segment.001.dmg and so on. Burn them to individual disks as you like. To mount the images, mount(double click) the first segment. Mac would do the rest.
New Law in India where Police can't arrest
January 18th, 2009
I just heard this. There is a new law going around in India where Police can't arrest a person if the offense carries a penalty of upto 7 yr jail term. I would be honest to say that I don't know much about this law or don't know what is the motivation behind this. But this sounds really bad on first read.
In India, attempt to commit culpable homicide, robbery, attempt to suicide, kidnapping, voluntarily causing grievous hurt, cheating, outraging a woman's modesty and death caused by negligence ( source times of India) are all offenses for which this law would apply and the police can't arrest.
I think Police in India are a clueless and corrupt bunch. But cutting the criminals a slack no matter what is the reason is insane. Just look at Oakland. When crime occurs our Mayor Ron Dellum blames everybody except the criminals. What else would justify random violence during a protest of police brutality ( which I think sucks and the officer should be hold accountable). That also during second time around when everybody was expecting it and were prepared to deal with it.
Wow... Please somebody educate me!!!!!!!!!
This is funny | Great Moments in Presidential Speeches
January 17th, 2009
validate before_destroy
January 12th, 2009
Recently I had to look at various options to do proper validation before destroying a model. Rails doesn't have a validate_before_destroy callback but it does have before_destroy.
We could implement a simple validation before destroy two ways:
Option 1: Implement the callback before_destroy in the model class itself.
Implement the method before_destroy in the model code itself.
1 2 3 4 5 6 7 8 |
class Organization < ActiveRecord::Base def before_destroy # Do your thing # Return true or false self.expired? end end |
From the rails documentation
Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last.
So with that said, any associations that are defined in the model would be destroyed before model.destroy call is aborted and there no way of going back.
Option 2: Register the callback before_destroy at the top of the method
In your model code declare at the top
1 2 3 4 5 6 7 8 9 10 |
class Organization < ActiveRecord::Base before_destroy :okToDelete protected def okToDelete # Do your thing # Return true or false self.expired? end end |
In this case, if you define the callback at the very top of the model class (before any other association declaration), then rails makes sure to call this callback first and aborts the destroy call.
You can also pass a block to the callback to keep it simple.
1 2 3 4 5 6 7 8 |
class Organization < ActiveRecord::Base before_destroy do |r| # Do your thing # Return true or false r.expired? end end |
or even less
1 2 3 4 |
class Organization < ActiveRecord::Base before_destroy {|r| r.expired?} end |
Apple Genius Bar | Real Genius | Works
October 4th, 2008
Palin | What Fareed Zakaria Had to Say?
September 29th, 2008
Quadtrillion dollar!! I can't even spell it.
September 4th, 2008
Recall Petition of Oakland Mayor Ron Dellum.
August 26th, 2008
Only in India
August 26th, 2008
Avoid trueroots if you planning to call India
June 11th, 2008
I wanted vent here. VSNL or trueroots or TATA or whatever the f**k they call themselves recently launched their service in US to call india. They are a bunch of copy cats for sure of airtel call home offering which doubled the calling card amount during their launch promotion.
However, after I signed up & paid, when I try to call India, the 800 number said my account is blocked. Then I called customer service and I was told that my account has been terminated. The reason, my email address doesn't match my first initial & last name. This must be the stupidest reason I have ever heard. These guys need an excuse to cancel the account ( donnow why ) & found the most lame reason to do this.
Avoid them at any cost.


