Tuesday, October 14, 2008
Mail Goggles - Stop sending mails you regret later!
Funny feature, read more and try it out!
http://gmailblog.blogspot.com/2008/10/new-in-labs-stop-sending-mail-you-later.html
Friday, October 10, 2008
Case studies on highly scalable architectures.
Nice link to go: http://highscalability.com
Tuesday, July 08, 2008
And the Answer is...
Thanks to Shan, and Yasar for spending their time at answering my question in the previous post!
Even I too don’t know the exact answer, but I am happy with your answers. So, you may be called ‘Mr.Smarts’ as going forward! J
I went and searched for the answer a lot on google, but no direct answer was found. Google is very smart in asking such interview question, which you probably can’t find from internet.
In Comp.Science, there are lots of classical problems. When you encounter such question, try to see if you can match it with some existing problem. Or, try to find out the base ‘Problem Class/Type’. Yes, you can map most of the problem to a Data Structure or Algorithm!
Consider the priorities and scenarios in this case.
(Before that, remember Sorting Thumb Rule #1: Bubble Sort is a wrong way to go! :) )
1. If memory is a constraint:
Since, Merge sorting takes only O(nlogn) time (at average case and as well as at worst case)!. The combined External sort mechanism can help you to assist ‘Divide and Conqueror’.
2. If speed is the constraint (and not memory):
Two choices: Quick Sort, Heap Sort, Merge Sort.
Quick Sort: Gives you O(nlogn) speed. But, this sorting approach is little dangerous. Because, if your input (1 million integers) is close to already-sorted form, then the Quick Sort will slow down to the speed of O(n^2) .
Also, Quick Sort is unstable sort! Quick sorting is based on recursion (recursion means stack.. stack means more memory). So, the repeated recursion calls can tend to hog more memory.
But, you stand a good choice to use parallelism. That’s quick sort creates lots of temporary partitions. So, you can distribute these portions across various processing units (say, across a cluster).
One important thing is, if you have N number of processors, each processor can process a partition, than you can complete the sorting by O(nlogn)/N = O(logn) !
That is an extreme performance as it is in Linear Time!
Heap Sort:
Takes very less memory – good point.
Runs at O(nlogn) time, even at worst case – Too good point! :)
Not sure about partitioning.
One should definitely consider HeapSort, when speed is a constraint.
PS: I have NOT taken or NOT got this answer from anywhere/anybody! The answer is purely based on my own thoughts, so it MAY NOT be 100% correct!
Monday, July 07, 2008
Tough Question, Excellent Answer!
Just happened to see this video in Youtube: Barack Obama (U.S Presidential Candidate) is being interviewed at some Google office (a funny interview).
Don’t know how many of you would start thinking and try to answer some thing immediately..!
(Youtube video link: http://www.youtube.com/watch?v=1nnj7r1wCD4 )
I could have clapped, if I were sitting at the audience side. Even a computer science graduate cannot suddenly answer this kind tough question. Anyway, though he didn’t tell in what way it can work, he told an other way in which it cannot work. May be that’s should be a personality identification for some high profile jobs like U.S President :-). All the good luck to Obama!
Let it be.
I am very curious to know how many computer science graduates can bring out the right answer (or any relevant correct answer) for the same question. I’ve some answer in my mind. Don’t know how far it’s correct.
If you are a computer science student, you could refer any books, internet, discuss with people and do etc. Post the answer within one day – I’ve a very nice title waiting for you – if your answer convinces me :)
Question is repeated:
“Whats the most efficient way to sort a million 32-bit integers?”
Monday, April 07, 2008
ATM Machines..! Who has written?
---
Enter the card no: xxxx
Enter the Amount: 400
Choose Type: Saving Account
Confirm: OK
Output: Error: Please enter amount only in multiples of hundred (100).
---
I repeat the same use cases multiple times but, the output is the same error message. Even, I cross checked many times whether 400 is entered correctly. I am totally confused myself, whether 400 is divisible by hundred or not! Then, I couldn’t understand why the error message was displayed. I ran to another ATM, and I was getting some other error message there. Error: You have exceeded the maximum limit. (I have not drawn any money using my card for the last two days). Are the machines gone drunk?
Whenever, the ATM machines are ‘out of service’, I am not upset. Because, there might be ‘N’ number of reasons. It is agreeable. But, when they display such misleading/incorrect error messages, I easily get tensed. I am searching for the guy, who has written that kind of software.
It is not that, only the functional deviations are bugs. Also, if a system does not handle a error situation, or does not display a proper error message, then that is also a bug. It is a serious bug, at customer perspective. Leave the customers aside. Just few questions to the guy, who has developed the ATM software:
- With this incorrect error message, how will you find out what has gone wrong/failed in the system?
- Without knowing the actual failure, how are you going to fix it?
- What do you think, either an end user (me), or the bank people can react to the incorrect error message?
Thursday, September 06, 2007
Framework ?

Software people should often hear this term ‘Framework’. What is it all about? The picture you see looks like an exploded building. But, you see the steel skeleton standing alone right? That’s Framework. That is some thing that supports the building architecture and gives a structural support.
I am thinking of writing a framework for my pet project. Especially for database persistence and queries. It might simplify coding complexity and speedup writing of code. Because, frameworks can provide basic structural support for projects. Also, it can help to eliminate boilerplate code found here and there in projects. When I imagined, how the coding style could change if I develop a framework, it turned me excited.
Few lines about Framework:
1. Usually, at the beginning of projects, Architects do some basic works -- one of them is building a Framework.
2. A Framework will offer basic structural support and services. For example, accessing a database is a common scenario in any project. We end up writing database access calls every where in project; every where we need to handle transaction, synchronization and etc. This plate of code can be moved into Framework and can be accessed from any part of the projects. Like wise, a Framework can have basic and structural functionalities for a project. Change/upgradation in code/functionalities can be done in one place, that’s in the Framework level, and dont need to change every part of the project.
A cool example,
Suppose, if you want to insert some values into database, you write painful code like this,
-------------------------------------------
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con = DriverManager.getConnection(connectionURLThin, userID, userPassword);
PreparedStatement preparedStatement = con.prepareStatement("insert into emp(?,?,?,?)");
preparedStatement.setInt(1, 100);
preparedStatement.setString(2, "mani");
preparedStatement.setDate(3, new Date());
preparedStatement.setDouble(4, new Double(46000.50));
preparedStatement.executeUpdate();
con.commit();
preparedStatement.close();
con.close();
-------------------------------------------
Ssshh! Take a break and come back :-) Just think what will happen if one need to repeat this code everywhere? That’s something called 'boilerplate'.
Rather, this can be abstracted/wrapped into a Framework, like
-------------------------------------------
MyDatabaseFramework.persistValues(100, "mani", new Date(),
new Double(46000.5)); // this single line code will insert, commit & save your head.
-------------------------------------------
That’s what Framework is, and that’s something, I am planning to write. Now Framework can be abbreviated into single word, "COOL" -- isn't?
Tuesday, September 04, 2007
Books in wish list.
I wish to read the following books whenever get time,
1. Refactoring: Improving the Design of Existing Code
2. Design Patterns: Elements Of Reusable Object Oriented Software
3. Patterns of Enterprise Application Architecture
(I've just mentioned that thats my wish list -- no written/oral guarantee that I'll read those books!! God needs to consider extending a day's time beyond 24 hours.)



Monday, September 03, 2007
Art of designing it.
I might start coding slowly. I am expecting a developer gang to join for the code development. Let's see again how it goes. I dont have plan or schedule for release, because this is absolutely my personal project, based on personal interest, and a base for personal learning :-)
(Click on the image to enlarge it)
Wednesday, July 04, 2007
Pet project

I was running in irritation since last few weeks. I gotta code hell a lot of things in java. Officially & Personally. Life was stuffed with full of NullPointerException and clueless traps in programs.
Also, using all my free times, I've developed a pet project, for personal use. It is a stock analyzer -- loads stock data daily from internet and helps to do complex cross queries over the stored data. Carefully developed it, keeping in mind that, any mindless barbarian should be able to understand the source code. I often used to read best practices/design/principles in coding & developing softwares. But, I never got time (or) chance to apply all those magics. So, I took this pet project as a chance for everything. I had almost lost my mind in thinking better, better, the better design round the clock - there were might nights, when I was thinking why PrintWriter is not appendable in java 1.4 !. Every single variable is designed carefully.
She helped a lot on this. She coded parser & data loader parts. I didn’t know how much time she caught headache. Thanks a lot for her, her work & interest. [She = Jeya]
The first drop of the project is here: http://sab-archer.sourceforge.net I've licensed it under CPL2.0. ('free download & modify the source, as you wish!'). I dont have energy to spend time on it any more. I am looking forward some interested people to join it. Let' see how far it happens.
Friday, June 02, 2006
How do I register a project & upload at sf.net?
Hey, Successfully done! I have uploaded my sample project at http://j2ee-examples.sourceforge.net ....
Yeah, Here is the snap shot of my putty. Thanks to Hari, who helped me to get out of the mess!

And this is scp uploading screen-shot

As I promised, this is the FAQ I present from my experience:
------------------------------------
How do I register a project at sf.net?
First register for a user account. Then, go to ‘My Projects’ column and follow the new project link. It will guide throughout registering a project. After the registration, you have to wait for approval more than 2 weeks. Approval will not be emailed, you have to go and check.
I followed the instructions and successfully uploaded the project using CVS into sf.net. (I mean projectname.cvs.sourceforge.net). But, it is not available for download for other users. What went wrong?
Same sweet first! I was also such an ignorant last week. CVS is for you and for managing your versions. Sf.net doesn’t allow the CVS folder’s or files for download. For uploading projects (which can be downloadable), you can use ‘scp’ or ‘sftp’ (about which we are going to discuss later).
So, how do I upload?
In case of windows, first download putt.exe and scp.exe (use Google). Then, launch the scp like from the command prompt like,
scp -r . username@shell.sourceforge.net:/home/groups/P/PR/PROJECTNAME/htdocs
The command says, “Hey scp, recursively (-r) copy all the files present in current directory (.) to shell.sourceforge.net server, under the directory /home/groups/P/PR/PROJECTNAME/htdocs”
Note: you have to replace the ‘P’ (in the destination directory path) by the first letter of your project name and ‘PR’ by the first two letters of your project name.
htdocs directory is where the htmls files are kept. (like your web root directory). The allocated quota is 5 MB. In the same hierarchy you have cgi-bin directory where you can put your php or cgi scripts.
Then, how do I login and see every thing?
Use either putty or ssh on windows. The host name is shell.sourceforge.net, the port is 22. You have your login and password right? Then, what else! Enjoy.
I can just tell you where you should not try to login. Projectname.cvs.sourceforge.net – This is not for ssh-ing. Only for CVS repository access.
Last time, when I logged in to sf.net, it was successful. Same thing I try now… but the putty is closed saying “connection problem”... but the network is fine …sf.net is ‘Ping’ able from my host …. What went wrong?
(OR)
My ssh gives some strage errors like
‘ssh_exchange_identification: Connection closed by remote host’
Do you want to see more ?
$ ssh -v username@shell.sourceforge.net
OpenSSH_3.5p1, SSH protocols 1.5/2.0, OpenSSL 0x0090701f
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Rhosts Authentication disabled, originating port will not be trusted. debug1: ssh_connect: needpriv 0 debug1: Connecting to channel-e.sourceforge.net [66.35.250.209] port 22.
debug1: Connection established. debug1: identity file /home/csea/.ssh/identity type -1
debug1: identity file /home/mani/.ssh/id_rsa type -1
debug1: identity file /home/mani/.ssh/id_dsa type -1 ssh_exchange_identification: Connection closed by remote host
debug1: Calling cleanup 0x80674d0(0x0)
Now, tell me what went wrong?
Don’t worry. You are not the culprit. Sf.net might have blocked the access. I also got the same error message.
I tried logging after 1 or 2 days. Then, it worked fine. I guess, the access list would have released the lock. Not sure…
All the best!
Thursday, May 18, 2006
sf.net approved my project and ??
Links given below may give details:
1. https://sourceforge.net/projects/channel-e
2. https://sourceforge.net/projects/online-exam
Wait, wait... I have not uploaded any files/docs. I am giving final touch up on the source code and docs. With in few days (yes, during this week end) I will host project source/docs.
PS:
I have registered for one more project (J2EE-Examples), which is a simple book store application.
In this project, I will make my effort to follow all the authorised and recommended best practices and design for every J2EE modules.
Also, this project will be a good example for developing Struts based applications.
This project will cover JSP/JSTL, custom taglibs, Struts, EJB (Stateless/Stateful session bean, Entity Beans (CMP, CMR), Message Driven Bean), Java mail API, Junit.
Tools: Jboss/Ant/Mysql.
Probably, at end of this week end, I may be ready with the front end Struts - UI .