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.