May 04, 2006

A very short sad lovestory

someone left this story on IM. Here it goes.
A guy had cancer and had only few days to live. He liked a girl working in a cd shop very much..but he did not tell her about his love.. evryday he used to go to cd shop & buy a cd to talk to her..after a month, he died..when the girl went & asked about him..his mother told he died & took her to his room & the girl saw all the cds unopened & the girl cried bitterly..u know y?? she had kept letters inside the cd to LET HIM KNOW HOW MUCH SHE LOVED HIM.

December 11, 2005

The bit logics; this two digits 1 and 0 can cause chaos

Are you a typical programmer who appreciates a diferent way of doing something? then you will definitely like this blogpost. After several months of thinking in terms of objects, believe me, it will be so difficult for anyone to come down to a level of thinking in terms bits. Cant believe it? then try to solve the following three programming puzzles.

Q1. Quickly find if a given number is a power of two or not?
Q2. Write logic to count the number of ones in a 32 bit unsigned integer? and finally
Q3. I have an array of numbers out of which all the numbers are occuring even number of times except for one that occurs odd number of times. Write a logic to find this number that is appearing odd number of times in the array?

If you have solved them without using bit level operations, thats fine, now try to solve them using bit level logic.

The Answers.
Ans1. If a number is a power of two then only one bit is 'on' in the bit representation of the number. Example int 2 is represented in binary as 0010, integer 4 is 0100, integer 8 is 1000. All the time if a number is a power of two there is only one 1 bit in the bit representation of the number. Now what? Try to make use of this property to find if a number is a power of two. Here we go.
If the number is n and if we do a logical and with (n-1) then all the bits should cancel out. so if n &(n-1) == 0 then the number is a power of two.

Ans2. After understanding this logic I now really have a tough time to explain it. Think on this. If I do something like this, what will happen?
n = n&(n-1);
if the number is 11. and we do n&(n-1) ie (1011) & (1010) n becomes (1010). making the last one bit in the bit representation of n, disappear. Now n =10 ie (1010) and now if we do n&(n-1) again then the last one bit in n will again disappear. Thus the algorithm goes as follows

unsigned count_ones(unsigned num){

unsigned count = 0;

while (num)
{
num &= num - 1;
++count;
}

return count;
}
Spend some time on it you will understand.

Ans3. This is a tricky question too. You should be knowing what xor does?
1 ^ 1 is 0
1 ^ 0 is 1
0 ^ 1 is 1
0 ^ 0 is 0
whats with this? If you xor a number with itself we get zero right? and if we agian xor zero with the number we get back the number. That means if we xor a number the even number of times then the result is zero and if we xor the number odd number of times the result is the number itself. eg x = 7 ^ 7 ^ 7 implies x is 7.

Now take an array of some numbers 2,5,6,2,5,5,6 if we keep on xoring the numbers ie 2 ^ 5 ^ 6 ^ 2 ^ 5 ^ 5 ^ 6 in this series of xoring the numbers that are appearing even number of times will cancel out to zero and the only number that is appearing odd number of times will be the result of the operation of xoring the whole array. we got the number, we wanted.

Enjoyed it, now if you are of the opinion that such answers cannot be expected of a candidate in an interview, then Iam with you. I agree that it is very rare that such a logic will strike your mind in the interview. Most of the times one can answer the question only if he/she read about the logic somewhere.

November 07, 2005

My idea of a good corporate desktop screen saver

The other day I was looking at my PC and was not happy to see the same old screensaver and press alt+ctl+DEL to unlock screens. I started dreaming on what could be better than the current ones and checkout what came to my dreams?
Cool to have features.
1. On the screen saver visitors to your place should be able to type into the screen with section "when you were not at your desk".
2. Ability to leave a voice message will still be better.
3. With the advent of ubiquitous mobile technology and if you could have a way to connect your cell phone with your computer wirelessly it would be wonderful if your distance from your desktop can be displayed on the screen saver.

What more can we ask for? A live satellite video feed of my current location onto my desktop....Iam just kidding.

Does Software Expire?

The Question may sound meaningless but it can be a good discussion starter. And my starting point of view on the topic is Yes! Software expires, thats the reason why we create all new requirements and renovate software often. My extention to this point is even you continue to renovate, make enhancements and no matter what you do software still expires or gets out dated.

The example to this is observing the Internet Explorer browser. ie was designed longback probably with a best design. Over a long term it sure would have undergone so many changes and now if you compare it today with mozilla firefox(Iam not saying its inferior or superior) you can see that ie was not targetted at tabbed browsing at all and the solution implemented for this tabbed browsing in msn toolbar download is not quite appealing. This is a symptom that over a period of time software grows to a point that any more changes will not cover its outmodishness and hence it moves towars the direction of expiry unless you redesign the major part of the code and give the same name to it.

Another noteworthy example to this discussion is the introduction of object oriented programming in perl. Its really hard to do object oriented programming in perl compared to the way we do in c++ or java. Thats the reason why the perl6 team is going with a new design from the scratch with one of the aims to support object orientedness.

September 03, 2005

A list of top security tools appraised

Just stumbled here, turned out to be a very good compilation of network security tools. http://www.insecure.org/tools.html

August 12, 2005

Security Focus.

I was wondering how one can fight system crashes and security attacks because of getting online using windows? It was then I got this crazy idea. Microsoft has a product called virtual pc using which you can have any number of pc based operating systems on your machine. And now find a way to connect to internet only using one of the OSes installed inside the virtual pc. This implies you will not be able to access the internet on the main windows OS. This makes your data and system on the main OS safe and secure. Virtually its the same as if you are accessing the net from a secure sandbox. The whole concept should work well or atleast give a tough time to hackers. Who knows you never know something works until somebody finds a way to break this virtual barrier too.

August 07, 2005

A Bit skeptic about WiFi

Can this be true? here. I dont really understand much of whats said in there until I try that on my own. But the users are warned to be privacy and security savvy. A good to know thing.

July 13, 2005

An incomplete List of all areas u can do IT business

An incomplete List of all areas one can do IT business, Suggestions welcome

1. Write security software Norton,symantic
2. Write Content management softwares EMC
3. ERP Applications Oracle, SAP
4. Operating systems Microsift,IBM
5. Software development tools microsoft, Oracle, eclipse
6. Database, Oracle
7. Write Desktop applications
8. Write web service applications
9. Office automation
10. Write hardware interfaces to software like device drivers etc
11. Write messaging and communication software.
12. Content search software business
13. Advertising software.
14. Unicode and font developers
15. Content presentation software.
16. Graphics software
17. Gaming software
18. Software for audio and video processing
19. Provide services to implementaion of open source products
etc

An overdose of GRE.......very funny

GRE STUDENT : Scintillate, scintillate, asteroid minim.

NORMAL PERSON : Twinkle, twinkle, little star

---------------------------------------------------------------------------------------------

GRE STUDENT : Individuals who make their abodes in vitreous edifices would be advised to refrain from catapulting perilous projectiles.

NORMAL PERSON : People who live in glass houses should not throw stones.

---------------------------------------------------------------------------------------------

GRE STUDENT: All articles that coruscate with resplendence are not truly auriferous.

NORMAL PERSON : All that glitters is not gold.

---------------------------------------------------------------------------------------------

GRE STUDENT : Sorting on the part of mendicants must be interdicted.

NORMAL PERSON : Beggars are not choosers

---------------------------------------------------------------------------------------------

GRE STUDENT : Male cadavers are incapable of rendering any testimony.

NORMAL PERSON : Dead men tell no tales

---------------------------------------------------------------------------------------------

GRE STUDENT : Neophyte's serendipity.

NORMAL PERSON : Beginner's luck

---------------------------------------------------------------------------------------------

GRE STUDENT : A revolving litchi conglomerate accumulates no congeries of small, green, biophytic plant.

NORMAL PERSON : A rolling stone gathers no moss

---------------------------------------------------------------------------------------------

GRE STUDENT: Members of an avian species of identical plumage tend to congregate.

NORMAL PERSON : Birds of a feather flock together

---------------------------------------------------------------------------------------------

GRE STUDENT : Pulchritude possesses solely cutaneous profundity.

NORMAL PERSON : Beauty is only skin deep

---------------------------------------------------------------------------------------------

GRE STUDENT : Freedom from incrustations of grime is contiguous to rectitude.

NORMAL PERSON : Cleanliness is godliness

---------------------------------------------------------------------------------------------

GRE STUDENT : It is fruitless to become lachrymose of precipitately departed lactile fluid.

NORMAL PERSON : There's no use crying over spilt milk

---------------------------------------------------------------------------------------------

GRE STUDENT : It is fruitless to attempt to indoctrinate a superannuated canine with innovative maneuvers.

NORMAL PERSON : You can't try to teach an old dog new tricks

---------------------------------------------------------------------------------------------

GRE STUDENT : Surveillance should precede saltation.

NORMAL PERSON : Look before you leap

---------------------------------------------------------------------------------------------

GRE STUDENT : The person presenting the ultimate cachinnation possesses thereby the optimal cachinnation.

NORMAL PERSON : He who laughs last, laughs best

---------------------------------------------------------------------------------------------

GRE STUDENT : Exclusive dedication to necessitous chores without interludes of hedonistic diversion renders Jack a hebetudinous fellow.

NORMAL PERSON : All work and no play makes Jack a dull boy.

---------------------------------------------------------------------------------------------

GRE STUDENT : Where there are visible vapours having their provenance in ignited carbonaceous materials, there is conflagration.

NORMAL PERSON : Where there's smoke, there's fire!