Keep Walking!

Deleting a given node from a linked list

Delete a node from a linked list - Java implementation
Read the full post here.

It's Magic

The upcoming Content-Aware fill in Photoshop CS5 is nothing short of CS5. Wanna delete trees from your photos, extend the sky or desert, delete some lens flares, go ahead and play the king/queen. Don’t believe me, just watch the video.

Read the full post here.

Queue using Stacks!

Recently, a casual conversation in the office brought me to an observation, most of the candidates we had interviewed had flunked the question, How do you implement a Queue using two Stack's? Hence, I take today’s opportunity to discuss the implementation for the problem stated above.

Read the full post here.

Evenstar | Update 8

Finally I could find some time to work on Evenstar again, two weeks after we discovered some bugs. I just happened to fix the bug related to user permission where-in a user with permission was not able to view the post that was restricted to certain users. The bug was specifically related to some OpenID function which I messed up.

The fix is in and you could get the latest code at

The latest code base is now deployed on PoetInside and is running good. I just tested adding an Open ID account of mine from Blogger, and it works perfect!

Keep exploring folks! Cheers!

Read the full post here.

Eclipse debugger works intermittently

Yesterday, I had some tough time figuring why my Eclipse Debugger (for Java) was working intermittently. Initially I thought it was due to the recent Eclipse updates I might have installed, and hence, I reverted back to Ganymede from Galileo. It still didn’t work. The next guess was workspace corruption so I deleted and rebuild the entire workspace, but to no avail. After a lot of futile efforts and after wasting 3 hours on the same, here is what I got.

Read the full post here.

Magical Generics Trick

Recently, I had to look back at some of the pieces I coded a few years back and found a generics trick I had forgotten. Thought of sharing with everyone.

Most of the time when we are working with Dependency Injection, Caching, Helper methods etc, we are not aware of the type of object a method may return. Perfect examples to the same could be the use of HibernateTemplate, EHCache, ApplicationContext.getBean, and alike. What we do at such hour is simply, define the return type of the method as Object and then cast back to the required original such as,

Read the full post here.

Evenstar | Update 7

This one is going to be a short. A friend of mine did spend some time on PoetInside, which now runs on Evenstar and informed me of three cool bugs which I missed unit-testing.

Read the full post here.

Evenstar | Update 6

50 days since I started on this journey, I am glad to say that today I can take some rest. Today, Evenstar reaches its first milestone. Yes, Evenstar is now in running session. And to showcase the same, I moved one of my favorite blogs to be powered by Evenstar. But, the final destination is far away. One day of rest, and then I embark further to make Evenstar, a place where dreams come true.

Read the full post here.

Evenstar | Update 5

What use writing a blogging system if I can’t use it for my own thoughts, right? And with all the more so into blogging, I can’t expect to start something new. I will thus have to migrate all my blogs to Evenstar, sooner or later. How to do that blazingly fast? Can’t even think of posting each and every post manually - that would be suicidal.

Read the full post here.

C++ Interview Question Bank

For some reason I happened to be searching for a good question bank on C++ questions that may aid one in brushing up concepts just before the call of an interview. My search did lead to some very useful stuff (though a bit stale and old) which I happen to share in now.

The following questions are part of this bank. All credit goes to Marshall Cline from Paradigm Shift, Inc. Somehow the contact information mentioned in the document doesn't work, but when do the concepts change, right?

Download the question bank from here.
Q1: What is C++? What is OOP?
Q2: What are some advantages of C++?
Q3: Who uses C++?
Q4: Does C++ run on machine `X' running operating system `Y'?
Q5: What C++ compilers are available?
Q6: Is there a translator that turns C++ code into C code?
Q7: Are there any C++ standardization efforts underway?
Q8: Where can I ftp a copy of the latest ANSI-C++ draft standard?
Q9: Is C++ backward compatible with ANSI-C?
Q10: What books are available for C++?
Q11: How long does it take to learn C++?

PART03 -- Basics of the paradigm
Q12: What is a class?
Q13: What is an object?
Q14: What is a reference?
Q15: What happens if you assign to a reference?
Q16: How can you reseat a reference to make it refer to a different object?
Q17: When should I use references, and when should I use pointers?
Q18: What are inline fns? What are their advantages? How are they declared?

PART04 -- Constructors and destructors
Q19: What is a constructor? Why would I ever use one?
Q20: What are destructors really for? Why would I ever use them?

PART05 -- Operator overloading
Q21: What is operator overloading?
Q22: What operators can/cannot be overloaded?
Q23: Can I create a `**' operator for `to-the-power-of' operations?

PART06 -- Friends
Q24: What is a `friend'?
Q25: Do `friends' violate encapsulation?
Q26: What are some advantages/disadvantages of using friends?
Q27: What does it mean that `friendship is neither inherited nor transitive'?
Q28: When would I use a member function as opposed to a friend function?

PART07 -- Input/output via and
Q29: How can I provide printing for a `class X'?
Q30: Why should I use instead of the traditional ?
Q31: Printf/scanf weren't broken; why `fix' them with ugly shift operators?

PART08 -- Freestore management
Q32: Does `delete ptr' delete the ptr or the pointed-to-data?
Q33: Can I free() ptrs alloc'd with `new' or `delete' ptrs alloc'd w/ malloc()?
Q34: Why should I use `new' instead of trustworthy old malloc()?
Q35: Why doesn't C++ have a `realloc()' along with `new' and `delete'?
Q36: How do I allocate / unallocate an array of things?
Q37: What if I forget the `[]' when `delete'ing array allocated via `new X[n]'?
Q38: What's the best way to create a `#define macro' for `NULL' in C++?

PART09 -- Debugging and error handling
Q39: How can I handle a constructor that fails?
Q40: How can I compile-out my debugging print statements?

PART10 -- Const correctness
Q41: What is `const correctness'?
Q42: Is `const correctness' a good goal?
Q43: Is `const correctness' tedious?
Q44: Should I try to get things const correct `sooner' or `later'?
Q45: What is a `const member function'?
Q46: What is an `inspector'? What is a `mutator'?
Q47: What is `casting away const in an inspector' and why is it legal?
Q48: But doesn't `cast away const' mean lost optimization opportunities?

PART11 -- Inheritance
Q49: What is inheritance?
Q50: Ok, ok, but what is inheritance?
Q51: How do you express inheritance in C++?
Q52: What is `incremental programming'?
Q53: Should I pointer-cast from a derived class to its base class?
Q54: Derived* --> Base* works ok; why doesn't Derived** --> Base** work?
Q55: Does array-of-Derived is-NOT-a-kind-of array-of-Base mean arrays are bad?
Inheritance -- virtual functions
Q56: What is a `virtual member function'?
Q57: What is dynamic dispatch? Static dispatch?
Q58: Can I override a non-virtual fn?
Q59: Why do I get the warning "Derived::foo(int) hides Base::foo(double)" ?
Inheritance -- conformance
Q60: Can I `revoke' or `hide' public member fns inherited from my base class?
Q61: Is a `Circle' a kind-of an `Ellipse'?
Q62: Are there other options to the `Circle is/isnot kind-of Ellipse' dilemma?
Inheritance -- access rules
Q63: Why can't I access `private' things in a base class from a derived class?
Q64: What's the difference between `public:', `private:', and `protected:'?
Q65: How can I protect subclasses from breaking when I change internal parts?
Inheritance -- constructors and destructors
Q66: Why does base ctor get *base*'s virtual fn instead of the derived version?
Q67: Does a derived class dtor need to explicitly call the base destructor?
Inheritance -- private and protected inheritance
Q68: How do you express `private inheritance'?
Q69: How are `private derivation' and `containment' similar? dissimilar?
Q70: Should I pointer-cast from a `privately' derived class to its base class?
Q71: Should I pointer-cast from a `protected' derived class to its base class?
Q72: What are the access rules with `private' and `protected' inheritance?
Q73: Do most C++ programmers use containment or private inheritance?

PART12 -- Abstraction
Q74: What's the big deal of separating interface from implementation?
Q75: How do I separate interface from implementation in C++ (like Modula-2)?
Q76: What is an ABC (`abstract base class')?
Q77: What is a `pure virtual' member function?
Q78: How can I provide printing for an entire hierarchy rooted at `class X'?
Q79: What is a `virtual destructor'?
Q80: What is a `virtual constructor'?

PART13 -- Style guidelines
Q81: What are some good C++ coding standards?
Q82: Are coding standards necessary? sufficient?
Q83: Should our organization determine coding standards from our C experience?
Q84: Should I declare locals in the middle of a fn or at the top?
Q85: What source-file-name convention is best? `foo.C'? `'? `foo.cpp'?
Q86: What header-file-name convention is best? `foo.H'? `foo.hh'? `foo.hpp'?
Q87: Are there any lint-like guidelines for C++?

PART14 -- C++/Smalltalk differences and keys to learning C++
Q88: Why does C++'s FAQ have a section on Smalltalk? Is this Smalltalk-bashing?
Q89: What's the difference between C++ and Smalltalk?
Q90: What is `static typing', and how is it similar/dissimilar to Smalltalk?
Q91: Which is a better fit for C++: `static typing' or `dynamic typing'?
Q92: How can you tell if you have a dynamically typed C++ class library?
Q93: Will `standard C++' include any dynamic typing primitives?
Q94: How do you use inheritance in C++, and is that different from Smalltalk?
Q95: What are the practical consequences of diffs in Smalltalk/C++ inheritance?
Q96: Do you need to learn a `pure' OOPL before you learn C++?
Q97: What is the NIHCL? Where can I get it?

PART15 -- Reference and value semantics
Q98: What is value and/or reference semantics, and which is best in C++?
Q99: What is `virtual data', and how-can / why-would I use it in C++?
Q100: What's the difference between virtual data and dynamic data?
Q101: Should class subobjects be ptrs to freestore allocated objs, or contained?
Q102: What are relative costs of the 3 performance hits of allocated subobjects?
Q103: What is an `inline virtual member fn'? Are they ever actually `inlined'?
Q104: Sounds like I should never use reference semantics, right?
Q105: Does the poor performance of ref semantics mean I should pass-by-value?

PART16 -- Linkage-to/relationship-with C
Q106: How can I call a C function `f()' from C++ code?
Q107: How can I create a C++ function `f()' that is callable by my C code?
Q108: Why's the linker giving errors for C/C++ fns being called from C++/C fns?
Q109: How can I pass an object of a C++ class to/from a C function?
Q110: Can my C function access data in an object of a C++ class?
Q111: Why do I feel like I'm `further from the machine' in C++ as opposed to C?

PART17 -- Pointers to member functions
Q112: What is the type of `ptr-to-member-fn'? Is it diffn't from `ptr-to-fn'?
Q113: How can I ensure `X's objects are only created with new, not on the stack?
Q114: How do I pass a ptr to member fn to a signal handler,X event callback,etc?
Q115: Why am I having trouble taking the address of a C++ function?
Q116: How do I declare an array of pointers to member functions?

PART18 -- Container classes and templates
Q117: How can I insert/access/change elements from a linked list/hashtable/etc?
Q118: What's the idea behind `templates'?
Q119: What's the syntax / semantics for a `function template'?
Q120: What's the syntax / semantics for a `class template'?
Q121: What is a `parameterized type'?
Q122: What is `genericity'?
Q123: How can I fake templates if I don't have a compiler that supports them?

PART19 -- Nuances of particular implementations
Q124: Why don't variable arg lists work for C++ on a Sun SPARCstation?
Q125: GNU C++ (g++) produces big executables for tiny programs; Why?
Q126: Is there a yacc-able C++ grammar?
Q127: What is C++ 1.2? 2.0? 2.1? 3.0?
Q128: How does the lang accepted by cfront 3.0 differ from that accepted by 2.1?
Q129: Why are exceptions going to be implemented after templates? Why not both?
Q130: What was C++ 1.xx, and how is it different from the current C++ language?

PART20 -- Miscellaneous technical and environmental issues
Miscellaneous technical issues:
Q131: Why are classes with static data members getting linker errors?
Q132: What's the difference between the keywords struct and class?
Q133: Why can't I overload a function by its return type?
Q134: What is `persistence'? What is a `persistent object'?
Miscellaneous environmental issues:
Q135: Is there a TeX or LaTeX macro that fixes the spacing on `C++'?
Q136: Where can I access C++2LaTeX, a LaTeX pretty printer for C++ source?
Q137: Where can I access `tgrind', a pretty printer for C++/C/etc source?
Q138: Is there a C++-mode for GNU emacs? If so, where can I get it?
Q139: What is `InterViews'?
Q140: Where can I get OS-specific questions answered (ex:BC++,DOS,Windows,etc)?
Q141: Why does my DOS C++ program says `Sorry: floating point code not linked'?

Hope this helps.

Read the full post here.

Evenstar | Update 4

The number of spams I have been receiving on my blog is increasing day and night. It may be easily attributed to the steady decline in the legitimate comments. A few of the spam messages are in Chinese/Japanese, where a sequence of dots is displayed in the comment message. Upon using Google Translate one is informed that the message is nothing but cheap publicity of a worse cheap site. Blogger does not have a built-in spam protection for comments, and thus, it made me more inclined to have one in Evenstar.

Thus, I went ahead and integrated the first comment-spam protection in Evenstar, via Akismet. This would only be the first integration end-point for I intend to provide end-points to other services such as Mollom soon. This should allow the Evenstar administrator’s choice over which service/pricing model to use.

Another feature that comes to mind is an auto-translated view of the comment. Thus if you receive a message in, say, Chinese on your blog, when previewing comment before approval, one should also have a quick way to translate and see what it means in English. With Google Translate having an API for programmatic translation, this seems feasible. Thus, this becomes the next idea a plan to have in Evenstar.

Drop in your comments for any other feature you would like to see in.

As always, welcome to Evenstar, where dreams come true!

Read the full post here.

Omniture SiteCatalyst v/s Google Analytics

Recently I had a chance to work with Omniture’s SiteCatalyst. At first, it looked like another analytics tool, much lesser in capability to Google Analytics. But with time as I explored more and more of the features and its power to drill down and generate reports, I could not stop myself from compiling yet another comparison of the two tools.

Read the full post here.

Animator v/s Animated

Just click on the picture below, click on play, then leave the mouse alone , sit back and enjoy a piece of creative brilliance.

Read the full post here.

Mobile Comparison: iPhone, Xperia X10, Storm 2, Droid, Nexus One

Recently there have been various (next gen) mobile handsets announced. I was thinking of changing my phone and took some time out to compare them out. Herein I compare Apple iPhone 3GS, Sony Ericsson Xperia X10, Blackberry Storm 2, Motorola Droid, Google Nexus ONE. The results are interesting.

Read the full post here.

Evenstar | Update 3

Finally, my dream has started taking its shape. As promised in my earlier post, here comes the first preview of Evenstar. Catch evenstar live at The blog system in general is fully functional with some of the features pending wiring, and a few nice touches remaining, including building a beautiful but fast enough theme.

Read the full post here.

Evenstar | Update 2

It has been over two weeks since the last update on Evenstar. Before everyone thinks that this was just another idea that went down the drain, lemme assure you that its gonna be different this time. Over the last couple of days I have been working hard to finish up the first milestone build with all the features promised in the last post. What I have completed till today is the branding for evenstar, along with the major features. I still have to wire some security code here and there, along with some nice little tweaks to the look and feel itself. Till I tie all this stuff up, you may take a look at the full size version of branding here.

Read the full post here.