Posts

Showing posts from November, 2007

Difference between StringBuffer and StringBuilder

There is a subtle yet important difference between the StringBuffer and StringBuilder. StringBuffer is synchronized when it has to access/modify its contents, where as StringBuilder is not. A StringBuilder object is not safe to be shared across multiple threads. It is much efficient to make use of StringBuilder when the StringBuilder object is not shared between multiple threads. StringBuilder was introduced in JDK 1.5.

Starting X sessions in Cygwin

Question: "I want to have my Linux desktop in my Windows machine. I have installed Cygwin. How to do this?" Follow these steps: Start your Cygwin command shell. Give "xinit -- -clipboard" in the command line. You will see a bare X window show with a command prompt in it. You will also see something like "Cygwin/X - 0:0" on the left-top of the window. This tells you the display in which the X server is listening for incoming connections. Give "xhost +" in the command prompt. This is to let the server accept all the incoming connections. Remember: if you are concerned about the security, refer to the man page of xhost on how to give a list of hosts instead of wild card "+". Start an ssh connection to your Linux box. Once logged in, set the display variable. As per this example it would be "export DISPLAY=x.x.x.x:0.0" where x.x.x.x is the IP address of your Windows box. Start your Gnome session by giving "gnome-session"...

Glossary from Altova

I was searching for one good place where I can get a decent list of acronyms that I come across often, without a need to search for them every time in the net. The Altova glossary page looks like a good place (despite their nepotism toward their brainchild XML Spy!).

Finding DLL dependencies in Windows

For quite sometime now I was searching for a tool that will help me in finding out the dependent DLLs for a given EXE/DLL (like ldd in Solaris/Linux). I came across an amazing utility today called Dependency Walker . Its really neat and cool in finding out the broken dependencies.

Nuke those Google ads that come in your way

Google ads are good, at times. But I don't remember when was the last time I clicked on one and visited the target page. If I need something, I mostly use Google search, not the ads. Most of the time I feel that those ads come in my way when I am reading something really serious. Its waste of bandwidth and time to load these ads when I am not in a mood to clicking on them. Here is a cool solution for the Firefox. All that you have to do is to download the Adblock plug-in and install it. Then restart your Firefox. Go to Tools -> Adblock -> Preferences. Enter the Google syndication URL (http://pagead2.googlesyndication.com/pagead/show_ads.js). Save and you are done. Have a Google ads free surfing :-)

Puzzle of repeating numbers

My friend Siva asked me this puzzle. There is a set of N numbers. All numbers in this set repeat even number of times, except two numbers that repeat odd number of times. Develop an algorithm that will find these two numbers in O(N) space & time complexity. I couldn't find the solution, but the solution Siva gave and another variant of that solution that his friend gave were simply amazing. Not to spoil the fun, I am not giving any of those solutions here :-)