Wednesday, November 07, 2007

Piracy

In ancient ages, piracy referred to robbery at sea. Pirates used to mark down ships and boats and capture people and rob them.

In recent times, piracy refers to unauthorized reproduction and distribution of materials covered by copyright law.

So if you buy an mp3 cd with the latest songs for 50 rupees, you are supporting piracy.

But there is no stopping piracy. Looking it from the consumer point of view, an original DVD would cost around 800-1000 rs while a priated DVD would cost around 100 rs. The difference is huge. Why should a consumer - an end user pay 800/- for something that he can get for 100/- only. Because the end user is interested in the media or software and is not concerned with the source.

And then you keep on seeing those ads which try to make you go against pirated stuff.

But would you?

Recently i got an Xbox 360, and when i went out looking for games for xbox 360, i was shocked to see games priced around 2000. I was shocked. Paying 2000 for a game is too much. Earlier i used to get game cds for 100 rs (ofcourse pirated). But after some research, i came to know that games are locked using region codes. So games made for US cannot be played in a Xbox sold in india. That is something that only microsoft could think of. I have always worked with open-source stuff. Have always got the source and compiled it as i liked it and used it. And microsoft ofcourse would not support open-source.

Every businessman works to make money. And so does microsoft.

some more research led me believe that if i get my console modified, i could play region free games and also play pirated games which i can obtain for 100-200 rs. I would have gone ahead and modified the console, but then i thought, why spend so much time and money after modifying the console. I am not going to be a hard-core gamer. I would be using xbox for occassional gaming only. So i would be getting new games once in 3 months.

Maybe i would be able to find friends and share/exchange games.

Modifying software is ok - it should not cause any issue - since it is a low cost stuff and can be easily replaced. But modifying hardware is a costly issue. If anything goes wrong you could lose your hardware. And there is no easy replacement.

Maybe after an year of use, i find that i have become a very avid gamer, then i would get my xbox modded and play tons of games.

Wednesday, October 31, 2007

Friday, October 19, 2007

Disk space on windows Vista

Recently i got a new lappy with windows vista. And within 2 weeks my disk usage went up from 25 GB to 34 GB. Though all i had installed was a few small softwares.

Ever imagine where the disk space goes when you are using windows vista?

What i did was i logged into linux and did a du -Sh and found that there was a hidden folder "System Volume Information" which was around 10 GBs and the folder was invisible in windows explorer. And then there was this hyberfile.sys and pagefile.sys taking up 2 GB each.

So windows is chewing up 14 GB of disk space for its processing in addition to the installation size of 6 GB.

System Volume Information is used by windows to store restore points for the system. The larger the volume, the more restore points it can store and the more restore points it can offer in case of a crash.

In my earlier lappy, i had windows xp and i had reduced the size of restore volume to 500 MB using some slider available somewhere. Though i never had to use the restore option in my 2 years of usage. I had a crash and had to reinstall windows again.

But in windows vista, i was unable to find such slider. And so i googled for "System Volume Information Disk usage windows vista" and found some cool links explaining the complete funda.

One of the most interesting links was this which explains in detail the use of restore points.

Well to make a long story short open up the command prompt (right click and do "run as administrator").

Then run vssadmin list shadowstorage, it will give a list of available shadow storage points ("System Volume Information"s' in the system - there is one on each drive). How much space is allocated and how much is used.

C:\Windows\system32>vssadmin list shadowstorage

vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool

(C) Copyright 2001-2005 Microsoft Corp.

For volume: (C:)\\?\Volume{3ce0cbe2-57c2-11db-a712-806e6f6e6963}\ Shadow Copy Storage volume: (C:)\\?\Volume{3ce0cbe2-57c2-11db-a712-806e6f6e6963}\

Used Shadow Copy Storage space: 9.335 GB

Allocated Shadow Copy Storage space: 9.539 GB

Maximum Shadow Copy Storage space: 10.395 GB


Now list down all the shadow storage points using vssadmin list shadows. And check out the number of restore points. Remember, your storage space should be large enough to have atleast 1 storage point. But i generally dont care for windows, cause, even if it crashes, all you could do is reinstall. I doubt "restore" would work...

And finally reduce the shadow storage size

C:\Windows\system32>vssadmin resize shadowstorage /on=C: /For=C: /MaxSize=3GB

Rerun the vssadmin list shadowstorage command and check the amount of disk space used now

C:\Windows\system32>vssadmin list shadowstorage

vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool

(C) Copyright 2001-2005 Microsoft Corp.

For volume: (C:)\\?\Volume{3ce0cbe2-57c2-11db-a712-806e6f6e6963}\ Shadow Copy Storage volume: (C:)\\?\Volume{3ce0cbe2-57c2-11db-a712-806e6f6e6963}\

Used Shadow Copy Storage space: 1.347 GB

Allocated Shadow Copy Storage space: 1.389 GB

Maximum Shadow Copy Storage space: 3 GB


Bingo and now you have around 7 GB freed up.

Thursday, October 18, 2007

Fasting, the gen-next way

In India, there are numerous occasions when people who worship gods, tend to observe fast. Fast, it seems to them would make the Gods happy and give them their blessings.

Though i truly fail to understand as to why would God be happy, if human beings stay on empty stomach - or eat this or that.

There are customs according to which people who prefer to eat non-vegetarian food, observe a "fast" and eat only vegetarian food on tuesdays and thursdays. I have never been able to figure out why? And why only tuesdays and thrusdays and why not mondays and wednesdays?

And then there is this huge festival called karwa-chauth where married women "fast" for their hubbies. They are not supposed to drink water or eat anything. But some women in my office say that though water is not allowed, you can have cold-drinks and tea/coffee. Strange... Well, if you look at it in this manner, even beer should be allowed... Just kidding...

And the latest trend in fasting is to "fast" for 9 days straight. The navratras. Shop keepers have special "navratra thalis". In fact, this fast seems to me more like a gen-next trend than to do anything with the Gods. All girls and most of the boys "Fast". There are rules about what you can eat and what you cannot eat. So though salt is not supposed to be allowed, but there is special "salt" available which can be had. And then since you are not allowed to eat normal rotis and rice, but there is a distinct variety of flour (not wheat flour) which could be used to make puris and whatever. And ofcourse there is another variety of rice - which you can have. And you can have potatos and lots of "special" papads, and "special" laddoos(sweets). And today itself i came to know that you can also have some green veggies like bottle-gourd and "arbi" (dont know the proper name).

Hence, i fail to understand the purpose of the fast, when eventually you tend to eat everything.

And i fail to understand why under-nourish yourself on the pretension of "fasting".

The fast that i remember is that of a college friend who decided that on every saturday - he would have food only once in the whole day - the main purpose being to lose weight. And he did good. Within 6 months, he had shaped his body pretty well.

Finally, to those people who are actually fasting, i would ask them to have mercy on their close ones who take tension since you would be going without food. The same tension that you would have, if they go without food for a day.

Monday, October 15, 2007

Why not rails?

SUMMARY: I spent two years trying to make Rails do something it wasn’t meant to do, then realized my old abandoned language (PHP, in my case) would do just fine if approached with my new Rails-gained wisdom.

INTRO / BACKGROUND:

Back in January 2005, I announced on the O’Reilly blog that I was going to completely scrap over 100,000 lines of messy PHP code in my existing CD Baby (cdbaby.com) website, and rewrite the entire thing in Rails, from scratch.

I hired one of the best Rails programmers in the world (Jeremy Kemper aka bitsweat), and we set off on this huge task with intensity. The first few months showed good progress, and Jeremy could not have been more amazing, twisting the deep inner guts of Rails to make it do things it was never intended to do.

But at every step, it seemed our needs clashed with Rails’ preferences. (Like trying to turn a train into a boat. It’s do-able with a lot of glue. But it’s damn hard. And certainly makes you ask why you’re really doing this.)

Two years (!) later, after various setbacks, we were less than halfway done.* (To be fair to Jeremy’s mad skillz: many setbacks were because of tech emergencies that pulled our attention to other internal projects that were not the rewrite itself.) The entire music distribution world had changed, and we were still working on the same goddamn rewrite. I said fuckit, and we abandoned the Rails rewrite. Jeremy took a job with 37 Signals, and that was that.

I didn’t abandon the rewrite IDEA, though. I just asked myself one important question:

“Is there anything Rails can do, that PHP CAN’T do?”

The answer is no.

I threw away 2 years of Rails code, and opened a new empty Subversion respository.

Then in a mere TWO MONTHS, by myself, not even telling anyone I was doing this, using nothing but vi, and no frameworks, I rewrote CD Baby from scratch in PHP. Done! Launched! And it works amazingly well.

It’s the most beautiful PHP I’ve ever written, all wonderfully MVC and DRY, and and I owe it all to Rails.

Inspired by Rails:

*- all logic is coming from the models, one per database table, like Martin Fowler’s Active Record pattern.

*- no requires or includes needed, thanks to __autoload.

*- real MVC separation: controllers have no HTML or business-logic, and only use REST-approved HTTP. (GET is only get. Any destructive actions require POST.)

*- all HTML coming from a cute and powerful templating system I whipped up in 80 lines, all multi-lingual and caching and everything

*- … and much more. In only 12,000 lines of code, including HTML templates. (Down from 90,000, before.)

Though I’m not saying other people should do what I’ve done, I thought I should share my reasons and lessons-learned, here:

SEVEN REASONS I SWITCHED BACK TO PHP AFTER 2 YEARS ON RAILS:

#1 - “IS THERE ANYTHING RAILS/RUBY CAN DO THAT PHP CAN’T DO? … (thinking)… NO.”
For 2 years, I thought Rails is genius, PHP is shit. Rails is powerful, PHP is crap.
I was nearly killing my company in the name of blindly insisting Rails was the answer to all questions, timeframes be damned.
But when I took a real emotionless non-prejudiced look at it, I realized the language didn’t matter that much.
Ruby is prettier. Rails has nice shortcuts. But no big shortcuts I can’t code-up myself in a day if needed.
Looked at from a real practical point of view, I could do anything in PHP, and there were many business reasons to do so.

#2 - OUR ENTIRE COMPANY’S STUFF WAS IN PHP: DON’T UNDERESTIMATE INTEGRATION
By the old plan (ditching all PHP and doing it all in Rails), there was going to be this One Big Day, where our entire Intranet, Storefront, Members’ Login Area, and dozens of cron shell scripts were ALL going to have to change. 85 employees re-trained. All customers and clients calling up furious that One Big Day, with questions about the new system.
Instead, I was able to slowly gut the ugly PHP and replace it with beautiful PHP. Launch in stages. No big re-training.

#3 - DON’T WANT WHAT I DON’T NEED
I admire the hell out of the Rails core gang that actually understand every line inside Rails itself. But I don’t. And I’m sure I will never use 90% of it.
With my little self-made system, every line is only what’s absolutely necessary. That makes me extremely happy and comfortable.

#4 - IT’S SMALL AND FAST
One little 2U LAMP server is serving up a ton of cdbaby.com traffic damn fast with hardly any load.

#5 - IT’S BUILT TO MY TASTES
I don’t need to adapt my ways to Rails. I tell PHP exactly what I want to do, the way I want to do it, and it doesn’t complain.
I was having to hack-up Rails with all kinds of plugins and mods to get it to be the multi-lingual integration to our existing 95-table database.
My new code was made just for me. The most efficient possible code to work with our exact needs.

#6 - I LOVE SQL
Speaking of tastes: tiny but important thing : I love SQL. I dream in queries. I think in tables.
I was always fighting against Rails and its migrations hiding my beloved SQL from me.

#7 - PROGRAMMING LANGUAGES ARE LIKE GIRLFRIENDS: THE NEW ONE IS BETTER BECAUSE *YOU* ARE BETTER
Rails was an amazing teacher. I loved it’s “do exactly as I say” paint-by-numbers framework that taught me some great guidelines.
I love Ruby for making me really understand OOP. God, Ruby is so beautiful. I love you, Ruby.
But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because he’s a better programmer now! You look back at your old ugly PHP code, compared to your new beautiful Ruby code, and think, “God that PHP is ugly!” But don’t forget you wrote that PHP years ago and are unfairly discriminating against it now.
It’s not the language (entirely). It’s you, dude. You’re better now. Give yourself some credit.

Ok. All that being said, I’m looking forward to using Rails some day when I start a brand new project from scratch, with Rails in mind from the beginning.

But I hope that this reaches someone somewhere thinking, “God our old code is ugly. If we only threw it all away and did it all over in Rails, it’d be so much easier!”

Copied from the original post http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html

Wednesday, October 10, 2007

driving in noida - Part 2

In case you have missed my previous post, you can take a look at it here.

Recently, it seems that the number of vehicles in noida has doubled. Specially the number of rickshaws and cycles. And if I am driving my car, i am doomed.

The choice is always between either kill someone or get killed. So if i drive a car, i am safe but other people may get hurt by it and i might land in trouble. On the other hand, if i ride my bike, i am not safe at all. And Other cars and specially busses might run over me and that might be the end of me.

The problem is that there is complete chaos on the roads. The traffic police try their best to control the traffic at red lights, but they don't seem to do a good job. And the road between two traffic lights is a mess. In noida, the red lights seem to come every 1 km. So after every 1 km, you have to relax for 2 minutes. And that adds to the frustration of people.

The cycles and rickshaws are the best. They move in clusters and in the center of the road, preventing the fast moving traffic to go ahead. Also all cycles and rickshaws do not have to look behind while turning. Neither do they understand signals (left/right turn indicators, or red lights). And they could squeeze in between the narrowest gaps between cars and rickshaws. Not caring if they scrape a car or a bike in the process. Ofcourse, they dont have anything to lose.

And then there are busses and tampos, which would stop in the middle of the road to load and unload passengers, not caring about the queue of vehicles piling and honking after them.

And the most unique feature of the roads in noida is the abundance of stray cattle and bullock carts. A friend of mine was once held behind 2 bullock carts racing with each other. He and ofcourse people behind him had to move at the pace of the bullock carts for about 30 minutes until the bullock carts reached their destination and one of them was declared winner. And there are cases where cows and buffaloes cross roads in a queue and hold up traffic.

The point i think is that no one cares. All want to move ahead, not caring if they are the cause of a traffic jam. There was a case once when i was at a red light held in a traffic jam - where buses and cars and rickshaws have just moved in the center of the road and other people were unable to move. I was just sitting and waiting for the jam to clear up, letting people ahead of me move more into the jam, when suddenly this maruti comes from the left and plunges in between the jam and my car. And when i honk at him, he shows his big eyes to me - as if i have committed the most terrible crime till date. Ofcourse, i had to wait till the car ahead of his car moved and he moved.

What do people get out of such abrupt action? More mess and more jams.

And then i remember this case in delhi, where a lady was hit by some other vehicle and she parked her vehicle in the center of the road blocking up the traffic and the cops surveying at leisure and getting all the details of the mishap from her while people waited in queue behind her.

And a similar incident in noida, just near my house where a maruti banged into a truck. No one was hurt. And from where i passed by, i could see that neither the car nor the truck was much damaged. But still the two vehicles were in the middle of the road and there was a big traffic jam behind it while the cops tried to find the cause and process of the accident at their leisure.

I think, i have been ranting too much. But the situation has gone from bad to worse. Maybe the situation was as bad earlier, but i did not face the peak traffic those days, cause i used to go early and come back late. But now, going on time and coming back on time matters. So...

I still love my bike and the way she could move in and out of such traffic.

Tuesday, September 25, 2007

How stock markets work!!!

It was autumn, and the Red Indians on the remote reservation asked their New
Chief if the winter was going to be cold or mild. Since he was a Red Indian
chief in a modern society, he couldn't tell what the weather was going to
be. Nevertheless, to be on the safe side, he replied to his Tribe that the
winter was indeed going to be cold and that the members of the village
should collect wood to be prepared. But also being a practical leader, after
several days he got an idea. He went to the phone booth, called the National
Weather Service and asked 'Is the coming winter going to be cold?' 'It looks
like this winter is Going to be quite cold indeed,' the meteorologist at the
weather service Responded.

So the Chief went back to his people and told them to collect even more
Wood. A week later, he called the National Weather Service again. 'Is it
going to be a very cold winter?' 'Yes,' the man at National Weather Service
again replied, 'it's definitely going to be a very cold winter.'

The Chief again went back to his people and ordered them to collect every
scrap of wood they could find. Two weeks later, he called the National
Weather Service again. 'Are you absolutely sure that the winter is going to
be very cold?' 'Absolutely,' The Man replied. 'It's going to be one of the
coldest winters ever.'

'How can you be so sure?' the Chief asked. The weatherman replied, 'The Red
Indians are collecting wood like Crazy.'

This is how stock markets work!!!

Monday, September 10, 2007

myisamchk - checking and repairing myisam tables in mysql

First of all, how and why does a mysql table go corrupt?

Tables generally go corrupt when mysql server crashes and the tables are not closed properly. They remain in an inconsistent state when mysql is again restarted. What generally happens when a table gets corrupted is that the index file (.MYI) and the data file(.MYD) do not synchronize properly. So there might be some records in the data file for which index entries are not proper.

I have also seen cases where the table goes corrupt just like that. Which might be due to
a) the disk being bad
b) some bug in mysql leading to inconsistent reads and writes.

And one of the ways to repair corrupted mysql (MYISAM) tables is to use the myisamchk utility.

Generally i would do the following (sweet and simple)

mysql> CHECK TABLE ABC;
mysql> REPAIR TABLE ABC;

But there are cases when these queries fail to recover the table. I had a case where "REPAIR TABLE" used to give me "OK" but "Check table" used to give me "table marked as crashed". To recover from such cases the only method to use is the myisamchk utility.

./bin/myisamchk [options] ./data/<database_name>/<table_name>.MYI

A myisamchk --help would list down all the options.

Note: No other program should be accessing the table when myisamchk is repairing a table. I prefer to turn off the mysql on the machine where table is corrupted unless it is repaired.

The best option for full recovery is --safe-recover. Which can be used to repair tables which cannot be repaired by any other option. If the table cannot be repaired using this option then you might have to give up on the table.

But --safe-recover takes up a lot of time.

The way to speed up myisamchk is to increase the buffers that it uses to read, write and process.

--read_buffer_size and --write_buffer_size is used to read and write data from the table and to the temporary file.

--sort_buffer_size is used when the keys are repaired by sorting keys, which is the normal case when you use --recover

--key_buffer_size is used when you are checking the table with --extend-check or when the keys are repaired by inserting keys row by row into the table, that is using --safe-recover option. Repairing using the key buffer is slower and also takes much less disk space as compared to sorting.

To speed up table repairing use large values for key buffer and sort buffer. Both values can be made very large cause only one of them is used at a time.

Eg: myisamchk --key_buffer_size=512M --sort_buffer_size=512M --read_buffer_size=8M --write_buffer_size=8M ./path/to/database/table.MYI

Wednesday, September 05, 2007

legends cannot be remade

Yup thats true. You cannot remake legends. The originals are still the best. Why am i saying this? Well, recently i had a chance to watch the recently remade bollywood legend "sholay" - "Ram Gopal Verma ki AAG".

There has been remixes of all types of classic old songs. And remix videos with all "beautiful" gals dancing here and there. And yes upto some extent i tend to like them. But i cant hear them for ever. I can hear those remixes for some time. But the original songs are still the best and can be heard again and again.

There was the remake of the bollywood and amitabh bacchan classic - "DON" starring shah rukh khan. And it was not that good. The remake had one good quality that in the new version of "DON" - bad wins over good as opposed to the original version where good wins over bad. So though the movie was not that good the climax saved the movie and it did make some news. People liked it.

But then, what is wrong with "AAG"? Let me put it this way - it is a terrible mix of old and new. The movie is simply a very bad version for sholay. You cannot replace "Gabbar Singh" with "Babban" or "Thakur" with "mohanlal" or "Veeru" with "Heero" or "Jai" with "Raj" or "Basanti" with "Ghungroo" or "Dhanno" with "Laila". The original characters and their names were the best suited. Babban and mohanlal does not ring at all. Nor could you modernize the dialogues

Orignial - "Kitne Admi the?"
Remake - "Kitne ... Kitne"

It just does not ring. The final fight sequence is also very sick. And the mix of original sound track with modern sound track during the final fight sequence makes things terrible. You cannot remove thakur's fingers instead of his hand. And of course the thakur has to kill gabbar with his special shoes (with nails) rather than kill him with an axe or whatever...

Earlier bollywood movies used to be remakes of origial hollywood movies. Like the recently hit "Partner" was a remake of "Hitch". Though i enjoyed the orignial hollywood movie a lot more than the remake. But it still did make sense for those audience who do not watch or do not understand the hollywood movie/culture/language. But remake of a hindi original does not make sense at all.

It seems that the bollywood directors and producers and script writters have run out of new and fresh ideas and have also run out of more hollywood movies to remake. Though there a lot of hollywood moives which could be remade still... Or maybe, they are just tired of remaking hollywood movies.

Hope that "Victoria No 203" remake is better... Will watch it soon.