Monthly Archives: January 2014

CodeChef Problem: Feedback

Lots of geeky customers visit our chef’s restaurant everyday. So, when asked to fill the feedback form, these customers represent the feedback using a binary string (i.e a string that contains only characters ‘0’ and ‘1’. Now since chef is not that great in deciphering binary strings, he has decided the following criteria to classify […]

How to Find the Real URL Behind a Redirect in Java

Say you have a URL that redirects to another (e.g., bit.ly). How do you find the real URL behind the redirect? You can do this in Java using the HttpURLConnection class. Like this: String url = "http://bit.ly/23414"; HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection(); con.setInstanceFollowRedirects(false); con.connect(); String realURL = con.getHeaderField(3).toString(); You basically create a connection, disable […]

How to Search and Find Files on Linux

As a Linux user you’ll inevitable need to search around for a specific file once in a while, be it a configuration file you need to edit or a version of a document you somehow lost. There are three basic ways to search for files using the command line: 1. locate The locate command is […]

vi/vim Basic Commands

As far as I know there are 10 types of programmers around: emacs programmers and vi programmers. Jokes aside I think both text editors are fine, but I prefer vi/vim. The problem is that getting started with it is not trivial, as once you open it you’ll be presented with a blank screen and a […]