Monday, August 21, 2006

trip to kasauli + chail

I have been a bit busy and the blogger was really missing me... anyways, had gone for a trip to kasauli & chail (both are near to Shimla).

Well, initially we were planning to go to jaipur, but we found that due to rains the santuaries would be closed. Moreover, there might be lots of heat in jaipur. And we were planning to go on our bikes. Me on my bullet. So, this got dropped. Next we decided to go to some nearby hillstation. After a lot of research, we decided to visit kasauli and chail. Both are near to each other.

Again the plan of going there on bikes was unsuccessful because one of our group members had a leg injury and it was difficult for him to drive for that long on his bike. It was supposed to be a 6-7 hours/300 kms drive.

Kasauli is around 300 kms from delhi and all we have to do is catch the NH1 to chandigarh and from there to panchkula and then to kasauli/shimla/chail. There is a single road to shimla, on taking a left you reach kasauli and on taking a right you reach chail.

Chail is around 60 kms from kasauli. You have to go down to a small river and then there is a very steep climb up a hill via a narrow road surrounded by greenery and trees. Lovely place to drive through.




We left at around 3 in the morning, gathered at a friends house and then moved on from there in his car. We were able to get on the highway by around 5:30 after filling air and petrol in the car. The highway was good and the drive was great. After a very long time i was able to see the sun rise and we also saw 2 rainbows one above the another on the way.




We reached kasauli around 12 in the afternoon. And we were shocked to see the rates of hotels. We were unable to find anything below 700 for a two bed and nothing below 800 for a 4 bed set. Anyways after lots of research we finalized to stay at R Maidens' some nice hotel with a 4 bed big and decent room. Then had something to eat and went to sleep. Roamed about a bit in the evening and relaxed at night.




Well, the next day we left at around 11 am for chail. Had parathas on the way and enjoyed the hills and the cool and clean air. I was able to see lots of people on bikes and really missed my bullet. At chail, the two things that we visited were - worlds highest cricket pitch and a temple. All the time we were in the clouds. The temple was very peaceful. And the drive wonderful. We came back in the evening and then relaxed.

Next day we went to manki point at kasauli. It was the best place we visited. It is situated inside a military layout, so you could not take any electronic items to that place, neither click photos of the place. We had to leave everything including the our cells, cameras and locking keypad of car inside the car. Had to climb for about 500 meters on a 75 degree slope. On top of th e place, there is a helipad and near that there is a temple. It is a very small place. After reaching the top we were inside the clouds. All we could see was clouds above and below us.

The monkeys over there are very aggressive. During our climb downhill, one of the monkeys took all prasad that we had. Anyways, the visit was good. And the place was worth all the effort.

Later that day, we did some shopping and then relaxed. Next day we left kasauli around 12 pm and were in delhi at around 6:30 pm. Back to the city, heat, pollution and our everyday busy lives.

Saturday, August 05, 2006

mysql partitioning

Table partitioning is a concept which allows data to be stored in multiple locations on one or more disks and access to the data is through SQL queries. The way data is stored and retrieved is invisible to the end user.

Mysql allows the user to select the rules based on which data would be spread over multiple partitions in a table. Mysql supports horizontab partitioning whereby the rows of a table are spread across multiple locations. Support for vertical partitioning is not there. So using mysql partitioning, you cannot assign different columns to different physical partitions of a table.

Benefits of partitioning a table :
1. Being able to store more data in one table than can be held on a single disk or filesystem partition. Though current operating systems allow extremely huge files on the disk.
2. Data that loses its usefulness can often be easily be removed from the table by dropping the partition containing only that data. And adding of new data can be facilitated by adding a new partition specially for that data.
3. Some queries can be greatly optimized in virtue of the fact that data satisfying a given WHERE clause can be stored only on one or more partitions, thereby excluding any remaining partitions from the search. Data can also be re-organized to move more frequently accessed data to one partition.
4. Queries involving aggregate functions such as SUM() and COUNT() can easily be parallelized.
5. Greater query throughput can be achieved by spreading data seeks over multiple disks.

I had used partitioning with MYIASM tables and found out that they were very useful. The complete logic of how rows were divided and stored and how they need to be accessed was invisible to me. What happened when i created some partitions for the table is that the same number of .MYI and .MYD files were created. Though the table definition remained in the single .frm file. A separate .PAR file was created for the table which i think was being used to define the logic of how database was being partitioned.

Moreover, an insert on the table locks all the partitions for a small time that is, the time needed by mysql to decide in which partition the record should be put.

The logic using which a table can be partitioned are listed as below:

RANGE partitioning -> Here table partitions are defined based on a range of data to be stored in each partition. For example -

CREATE TABLE abc (
name VARCHAR(100) NOT NULL,
email VARCHAR(40),
dob DATE NOT NULL
)
PARTITION BY RANGE( YEAR(dob) ) (
PARTITION p0 VALUES LESS THAN (1960),
PARTITION p1 VALUES LESS THAN (1970),
PARTITION p2 VALUES LESS THAN (1980),
PARTITION p3 VALUES LESS THAN (1990),
PARTITION p4 VALUES LESS THAN MAXVALUE
);

This would create 5 partitions in the table abc. Partition p0 will contain records whose dob is from 0 to 1959, partition p1 will contain records whose dob is from 1960 to 1969 and so on. In case a row is entered whose dob cannot be accomodated in any of the partitions, an error is thrown and the data is not inserted in the table.

LIST partitioning -> Here table partitions are defined based on a list of data for each partition. Rows which satisfy a criteria list is inserted in that partition.

CREATE TABLE abcs (
name VARCHAR(100),
dob DATE NOT NULL DEFAULT '1979-01-01'
age INT
)
PARTITION BY LIST(age) (
PARTITION p0 VALUES IN (3,5,6,9,17),
PARTITION p1 VALUES IN (1,2,10,11,19,20),
PARTITION p2 VALUES IN (4,12,13,14,18),
PARTITION p3 VALUES IN (7,8,15,16)
);

This would create 4 partitions in the table abcs. Partition p0 would contain records whose age would be 3,5,6,9 or 17. Again if you try to insert a record whose dob is not in any of the partition list created, an error is thrown and the record is not inserted.

LINEAR HASH partitioning -> Here table data is evenly divided between all partitions using some simple functions. for example

CREATE TABLE abc (
name VARCHAR(100),
dob DATE NOT NULL DEFAULT '1970-01-01',
age INT
)
PARTITION BY HASH( YEAR(dob) )
PARTITIONS 4;

Here 4 partitions are created and data is distributed using the following formula
Partition number = MOD(YEAR(dob),number_of_partitions);
So since my date of birth is 1980, my record will be in partition number 0.

LINEAR HASH partitioning -> This is almost similar to hash partitioning except for the fact that the algorithm used to divide data is different. The syntax is also almost same. We use PARTITION BY LINEAR HASH instead of PARTITION BY HASH.

The algorithm used is :

Given an expression expr, the partition in which the record is stored when linear hashing is used is partition number N from among num partitions, where N is derived according to the following algorithm:

  • Find the next power of 2 greater than num. We call this value V; it can be calculated as:
    V = POWER(2, CEILING(LOG(2, num)))

  • Set N = F(column_list) & (V - 1).

  • While N >= num
    {
    Set V = CEIL(V / 2)
    Set N = N & (V - 1)
    }



The advantage in partitioning by linear hash is that the adding, dropping, merging, and splitting of partitions is made much faster, which can be beneficial when dealing with tables containing extremely large amounts of data. The disadvantage is that data is less likely to be evenly distributed between partitions as compared with the distribution obtained using regular hash partitioning.

KEY partitioning ->
Partitioning by key is similar to partitioning by hash, except that where hash partitioning employs a user-defined expression, the hashing function for key partitioning is supplied by the MySQL server. The syntax used is PARTITION BY KEY instead of PARTITION BY HASH.

In most of the cases either a primary key or an unique key is used to create partitions.

Mysql also supports sub partitioning whereby a partition can be divided into further sub partitions of similar type.

I think i am creating a very long blog for mysql partitioning. However there are a list of syntaxes available on the mysql site to alter, analyze, optimize, rebuild, checking and repairing partitions. Please check http://dev.mysql.com/doc/refman/5.1/en/partitioning.html. It will give a more detailed idea of whatever ranting i have done over here...

I will be signing off from here now. Next blog may or may not contain more info about partitions...

Anyways will keep blogggging...

Saturday, July 29, 2006

Maybe....

How do you handle emotions? What do you do when you feel depressed? You may feel as if there is no goal in your life. You feel lost. You dont know what to do. And to top it up, you are not absolutely sure about the reason for all these emotions/feelings. You try to find a reason.

Maybe your friend did something wrong. No, but he/she was right in her own way. What he/she did is in no way wrong for him/her. But then, why are you upset about what he/she did? Maybe there are issues at your college or work place. Your professor never takes you seriously. No matter what you write, he would not give you good marks. Whereas, his favourite student gets all the good marks and all the praise. Or maybe, your boss had a problem at his place and decided to bring it all out on you. Or maybe you are not getting the responsibilities you deserve. Or maybe you are underpaid and on searching you are not getting a job that you would like. Or maybe, your collegues just dont get along with you. Or maybe you had a fight with your collegue over some small issue in the project. Or maybe your girlfriend/boyfriend or wife/husband cares for someone more than he/she cares for you. Maybe you are right. Maybe you are wrong. You are not sure.

What do you do in such a situation? You feel lonely. You feel lost. You may want to end up your life. How? Take loads of sleeping pills. Or maybe hang yourself from the cealing. Or maybe just jump off the tallest building in your city. But then again, there is no reason for doing so. There is no reason to kill yourself. Why should you kill yourself when you have not achieved what you were meant to achieve in life. But then again what are you supposed to achieve? You are not sure of anything. Well or maybe you are afraid of death. Buy why?? After all some day you are going to die. Is there a reason to live? Why are you alive? What is the purpose of your life?

Maybe you would sit in a corner and cry. And you try to hide yourself from the world. Maybe your friend comes to console you. And maybe you cry on his/her shoulder or maybe you just shoo him away. You expect someone to take care of you. But when someone comes and asks you what is wrong, you dont know how to explain. Maybe you can trust the person or maybe you cant. Maybe the person will understand you or maybe not. You are not sure. You are alone. You are lonely. You struggle with yourself trying to decide what to do. What is right and what is wrong.

And then maybe the next day, you wake up and you feel lucky. Or maybe, you get a call from someone you really care about. Or something unexpectedly good happens. Or maybe the grief simply fades with time. Your mind hides the grief in one of its secret places. And you decide never to look in that place. You cope up with yourself. You feel good. You continue to live...

You laugh, you cry. You get angry. You get depressed. You get excited. That, i think is life...

Sunday, July 23, 2006

why?? why??


  • Why are people jealous of each other?

  • Why do people have an ego?

  • Why do people have an attitude?

  • Why can't people consider each other as equal?

  • Why are there caste restrictions?

  • Why is a girl child not considered as equal to a boy child?

  • Why is there more than 50% reservation for SC/ST/OBC people?

  • Why do we give and take dowery?

  • Why are most of the cops corrupt?

  • Why is there crime in society?

  • Why can't we simple admire beauty without tampering with it?

  • Why are we possessive of the ones we love?

  • Why do terrorists kill innocent people?

  • Why do we fight with a rickshaw wala for Rs 2/- while we spend 150/- on a movie without a word of protest?

  • Why are people emotional?

  • Why do some relations break?

  • Why is love painful?

  • Why do girls mostly answer "I used to think of you only as a friend" OR "I never had such thoughts about you" when you propose her?

  • Why are there issues with property?

  • Why cant we simply take what is ours and let others have what is theirs?

  • Why do we have to tip the waiter always?

  • Why cant we do what we love to do?

  • Why do people steal what is not theirs?

  • Why do people kill?

  • Why do people rape?

  • Why are homo sapiens self destructive?

  • Why is it difficult to let go of someone you love?

  • Why do we fall in love?

  • Why is there a censor board in a democratic country?

  • Why is there still illetracy in India?

  • Why do i like India but still hate it?

  • Why do we fight with someone we love?

  • Why is it that most of the times boys have to propose and be rejected?

  • Why cant girls propose?

  • Why are there love triangles?

  • Why are we afraid of the truth?

  • Why can't I simply be what i am no matter whatever the situation is?

  • Why is sholay still considered to be the best bollywood movie?

  • Why are some people fat and others thin?

  • Why are most of the girls cute?

  • Why is it difficult to live alone?

  • Why do we need to marry?

  • Why are people not ok with gay and lesbian relations?

  • Why cant everybody be in peace and happy?

  • Why is it difficult to live?

  • Why are we afraid of death?


No!!, this is not something i am writing under desperation or depression. I am as happy as a lark. Have been thinking about writing this for a long time... It is something i think is right but... whatever.......

Maybe this is how the world is, and, if everything would be right, there would be no challenges worth facing in life. These are the questions which i think should define life (a struggle) as it is. There are still lots of whys still left out.

And finally, why do i like my bullet so much...

Saturday, July 22, 2006

firefox 2.0 is out

Can be downloaded from http://developer.mozilla.org OR from http://www.mozilla.org/projects/bonecho/all-beta.html

Major features in firefox 2.0 from the end user view point are

User experience

  • Inline spell checking for text areas lets you compose with confidence in web forms.

  • Microsummaries provide a way to create bookmarks that display information pulled from the site they refer to, updated automatically. Great for stock tickers, auction monitoring, and so forth.

  • Extension Manager user interface has been enhanced.

  • Search engine manager lets you rearrange and remove search engines shown in the search bar.

  • Tabbed browsing enhancements include adding close buttons to each tab, adjustments to how Firefox decides which tab to bring you to when you close the current tab, and simplified preferences for tabs.

  • Autodetection of search engines allows search engines that offer plugins for the Firefox search bar to offer to install their plugins for you.

  • Search suggestions allow search engines to offer suggested search terms based on what you've typed so far in the search bar.



Security and privacy

  • Anti-phishing feature to warn users when the web site you're looking at appears to be a forgery.

Wednesday, July 19, 2006

Freedom Of Blogging

Censorship, or limiting access to certain specific data is a big drawback for democracy. It limits freedom of speech, thought, expression, the basic fundas of democracy.

We say india is a democratic country. Why? There is censorship in almost all movies, in addition to rating given by the censor board.

Well forget that. But why is my blog not opening up since yesterday. I had to do some blogging but since my blog was not opening up, i thought, it might be down. But that is not the case...

Take a look at the traceroute below (for techies):

C:\Documents and Settings\Admin>tracert jayant7k.blogspot.com

Tracing route to blogspot.blogger.com [66.102.15.101]
over a maximum of 30 hops:

1 314 ms 298 ms 300 ms 97.239.1.15
2 298 ms 320 ms 299 ms 97.239.2.1
3 297 ms 320 ms 499 ms 202.138.101.57
4 517 ms 540 ms 519 ms 220.224.184.178
5 517 ms 540 ms 519 ms 62.216.145.221
6 557 ms 539 ms 559 ms eqixva-google-gige.google.com [206.223.115.21]
7 638 ms 639 ms 640 ms 216.239.47.120
8 539 ms 539 ms 540 ms 72.14.238.235
9 718 ms 740 ms 719 ms 66.249.94.233
10 717 ms 720 ms 719 ms 66.249.95.246
11 717 ms 719 ms 719 ms 216.239.46.44
12 637 ms 619 ms 619 ms 72.14.236.9
13 617 ms 639 ms 620 ms 72.14.233.121
14 639 ms 619 ms 659 ms 216.239.49.78
15 * * * Request timed out.
16 * * * Request timed out.
17 * * * Request timed out.
18 * * * Request timed out.
19 * * * Request timed out.
20 * * * Request timed out.
21 * * * Request timed out.
22 * * * Request timed out.
23 * * * Request timed out.
24 * * * Request timed out.
25 * * * Request timed out.
26 * * * Request timed out.
27 * * * Request timed out.
28 * * * Request timed out.
29 * * * Request timed out.
30 * * * Request timed out.

Trace complete.


After 14 hops, suddenly the request for data times out.

Well take a look at this... http://www.withinandwithout.com/?p=854. The GREAT indian government has decided to do censorship on internet also. Blocking freedom of blogging. This is very bad. The government says that terrorists are using blogs to communicate. Well agreed. But then there is google earth.

If you dont have any idea about what it is, you can do a search on google and download and take a look at it. Using google earth, you can zoom in on any place around the world be it "the white house" or "The parliament". You will be having the map of that place in front of you, no matter where you are.

If you have good internet connectivity on moon, maybe you can plan a terrorist mission from there using google earth. What will the government do then, decide to ban "google earth". Say that from now onwards, there would be no maps made for delhi.

It was just an example, of what technology can provide. Using it depends on who uses it. Just like an atom bomb. It can be used both for construction and destruction. Dynamites and explosives can be used for breaking rocks and making roads or for killing innocent people. With advanced technology, nothing would be impossible.

What i would say is that instead of blocking access to data, the government should focus on strengthening its own infrastructure. Look at the amount of corruption that is there in india. The cost of a traffic cop in DELHI/NCR is only around 100/- for whatever was done or not done. The feeling of doing something good for the nation has to be there, not only in the traffic cops but in the ministers and all IAS/IPS officers.

People in india want to become MPS, IAS, IPS because there is lots of under table money in these lines.

Sometimes, i just try to imagine how can this country run? But it is still running. Though a single earthquake, single famine or a single terrorist attack can bring it to a standstill any day.

Well, for example, we had a heavy downpour in delhi today, and believe me, more than half of delhi was immobile due to it. Why cant the government do something about it?

Well, anyways lets hope this does not go on for long and we can access our precious blogs soon.

To bypass the block, you can use www.pkblogs.com. And read whatever blogs that were blocked. The news is that blogspot, Typepad and geocities have been affected due to the ban. You can post blogs but cannot view your blog.

And almost all ISPs have dirtied their hands in this game. Have a look at http://censorship.wikia.com/wiki/List_of_ISPs_that_seem_to_have_blocked_blogger

Keep blogging........
Let the world know where we stand......

Tuesday, July 18, 2006

Honda Vallyrle Rune

Take a look... Costs something around 25K dollars...
6 Cylinder and styleeeee...






And this is a Triumph Rocket III - 3 cylinder :

Saturday, July 08, 2006

document scoring/calculating relevance in lucene

How is scoring of a document calculated in lucene? Well, first of all what is soring and what does it do. Scoring is a factor which decides the order by which documents are returned after a search is done using lucene. Something like "order by relevance". If we provide an order by/sort by clause in the search query, then ordering is done on this. Else, ordering is done on the score of the document. All documents returned from the search have a score no associated with it. The document with the highest score comes on top and that with the lease score comes at the bottom.

Scoring is implemented in the similarity class of lucene (org.apache.lucene.search.Similarity).

Lets see how the score of a document is calculated.

The score of a query q for document d is defines as follows (t refers to a term):





score(q,d)=
Σ (tf(t in d) * idf(t)^2 * getBoost(t in q) * getBoost(t.field in d) * lengthNorm(t.field in d) ) * coord(q,d) * queryNorm(sumOfSqaredWeights)
t in q


where


sumOfSqaredWeights =
Σ ( idf(t) * getBoost(t in q) )^2
t in q


Now, lets decode it...

tf = term/phrase(t) frequency in a document(d). Terms and phrases repeated in a document indicate the topic of the document, so implementations of this method usually return larger values when freq is large, and smaller values when freq is small.

idf = term document frequency(no of documents which contain the term). Terms that occur in fewer documents are better indicators of topic, so implementations of this method usually return larger values for rare terms, and smaller values for common terms.

getBoost (t in q) = Gets the boost for this clause in the query. Documents matching this clause will (in addition to the normal weightings) have their score multiplied by b. The boost b=1.0 by default.

getBoost (t.field in d) = Gets the boost for the field in the document if the term is in the field. Again boost for the field b is 1.0 by default.

lengthNorm(t.field in d) = normalization value for a field given the total number of terms contained in a field. These values, together with field boosts, are stored in an index and multipled into scores for hits on each field by the search code. Matches in longer fields are less precise, so implementations of this method usually return smaller values when numTokens is large, and larger values when numTokens is small. These values are computed under IndexWriter.addDocument(Document d) and stored. Thus they have limited precision, and documents must be re-indexed if this method is altered.

coord = Score factor based on the fraction of all query terms that a document contains. This value is multiplied into scores. The presence of a large portion of the query terms indicates a better match with the query, so implementations of this method usually return larger values when the ratio between these parameters is large and smaller values when the ratio between them is small.

queryNorm = Computes the normalization value for a query given the sum of the squared weights of each of the query terms. This value is then multipled into the weight of each query term. This does not affect ranking, but rather just attempts to make scores from different queries comparable.

So affectively the score of a document returned, in search done, using a query is calculated keeping in mind the frequency of the term/phrase in the document, frequency of documents containing the term, boosting factor of a clause in the query, boosting factor of a field, total number of terms in a field, fraction of all query terms contained in a document and some normalization factor based in the idf and boost of term in query.

If you are searching a single field using a query, the results should be very relevant, provided the text entered is meaningful and gramatically correct. With the logic here, even if you are searching multiple fields, the order of relevance of results should be good. But relevance can be increased by assigning boost factor to fields either during the query formation process or during the indexing process. Fields could be boosted according to their order of importance resulting in very relevant results.

Boosting during the query formation process provides the flexibility to change the boost factor dynamically but slows down the search and scoring due to dynamic computation of score. Whereas if fields are boosted during the indexing process, then though the search will be much faster, you would loose the flexibility of altering the boost factor dynamically.

Anything i have missed, please let me know and i will add it...

Friday, July 07, 2006

blogrolling

Finally got some way of connecting other blogs to my site. Editing the template every time i want to add some blog to my site is a very tedious job...

blogrolling is cool.

The "i am online" link from yahoo is a bit buggy though. Shows me online even at times when i am NOT. Seems that yahoo is having problems with its database/messaging systems.

Clustermaps is also cool. Lots of people who visit me are from india, europe and North America. Good to know where i am getting fame. Will have to plan my celebrity trip accordingly ;-).

cbox.ws though gives no control on spam. People just write down anything in it. It should have a image verification process...

Anyways, i think i have got an almost perfect site.

Still missing something which gives referral details. Like from which site, people got links to my site. Will need to plan my advertising strategy accordingly ;-).

Searcing for more stuff ....

Wednesday, July 05, 2006

simply babbling...

Long time again and no blogs...And i have my excuses ready...

Well firstly there was nothing good enough to write...bad excuse!!, i could have written about my bike ride from noida to greater noida. Although i have gone through the ride again and again, but this time it was different. Me and my collegue, ankit raced through the 20-25 km express way connecting greater noida with noida/delhi. I think, i could have done an average of 100 kmph on my thunderbird. The bike has done only 6000 kms and people say it will open up after around 15000 kms. After that it may touch 120 kmph.

Had Shipra and IP (friends) for the drive. See the pics below...












Had loads of fun. Though there was nothing to do in Greater Noida. No malls, no food joints. All we could find was a Dominos pizza where we had some pizza and then we drove back. Great drive, something which inspired me to think for a delhi-jaipur drive sometime later.

Next, had a wedding in the family (my sis). Getting married on 5th of july 2006. So came down to baroda on 30th - my b'day and was a bit busy with the wishes. just enjoying myself.

And lastly, do remember that indian weddings are lengthy procedures which include shopping (specially for the wedding), lots of customs and traditions and finally the wedding followed by the vidai. Oh!!! a complete week would go by and still you would miss someone by the end of it. Dont know why people follow such traditions.

In the meantime, i tried downloading some games for linux. The best one yet is Quake-III Arena. Downloaded cube and tuxracer, but could not get them running....

Lets c what comes next...