Moving

I am moving my blog to http://gautamk.heroku.com.


Adding Mongo DB driver to XAMPP

Like many developers I use XAMPP for PHP development. But adding PHP extensions in xampp to does not seem to have a direct procedure . So when I wanted mongodb drivers I was on my own to figure out how to get it working . Here is the knowledge I gained .

I am using Ubuntu oneiric ocelot machine so this procedure is similar for all *NIX machines  (Sorry windows users but the procedure must similar).

  1. First download and install Mongo db from mongodb.org/downloads
  2. Secondly download the PHP MongoDB driver source from github.com/mongodb/mongo-php-driver
  3. Now to compile the code
    1. You need phpize to compile the source code, so install php5-devpackage by running `sudo apt-get install php5-dev`
    2. Navigate into the mongo-php-driver directory and run `phpize` on the terminal
    3. Then run `./configure` to check for dependencies
    4. Run `make` to build the package
  4. Assuming XAMPP is installed at `/opt/lampp/` copy `mongo.so` and `mongo.la` from `modules` directory inside mongo-php-driver directory to `/opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/` directory
  5. Add the line `extension=mongo.so` to  `/opt/lampp/etc/php.ini`
  6. Start mongodb and xampp servers and run the program test program from php.net/manual/en/mongo.tutorial.php to check if it is working

 


Bit Twiddling @ JUG

Here is the link to the presentation that I did at Java User Group – Chennai on 7 Jan 2012

http://gautamk.github.com/Sieve-of-eratosthenes/bit_twiddling.html

This presentation was built using impress.js

I will expand this post to include a Bit Twiddling tutorial later today .


Careers @ stackoverflow

I got an email from Stack Overflow Careers 2.0 Inviting me to join careers.stackoverflow.com.

In recognition of your contributions to Stack Overflow, we’d like to invite you to create a professional profile on Stack Overflow Careers 2.0.

A Careers 2.0 profile is a great place to showcase your professional work as a programmer – Stack Exchange answers, open source projects, even the books you’ve read.

Click here to accept the invitation. It’s free!

Even if you’re not looking for a new career today, your Careers 2.0 profile will be your professional home on the web. It lets your colleagues, friends, and peers know who you are and what great work you’re doing. It’s a terrific way to build your professional reputation and take your career to the next level. And it’s fun!

You’ll always have complete control over what’s in your profile, who can see it, and whether or not employers can contact you.

But please act soon: this invitation expires in 14 days, so sign up now!

Even if you decide not to join Careers 2.0, we would like to thank you for all your contributions to Stack Overflow. It wouldn’t be the same without you.

Best wishes,

Joel, Jeff and The Stack Overflow Team

I have been trying for some months to get an account on that site because It is sort of exclusive , They seem to hand pick the people who get a profile on the . So once I get the privilege to invite people I will be sending a few to some deserving friends.

Take a look at the stats , There are only 49 people from chennai who have an account on that site, which includes me .

What is more surprising is that the IT hub of India Bangalore has only 5 people .

But there was a catch Since this site is yet to catch the fancy of many people in India there are (at the time of this blog post ) No job postings in India , but the job postings that are present are of really good quality and seem to be quite reliable .

Here is a link to my profile http://j.mp/gautamk .


C some Speed !!

Most programmers know that c programs are the next best thing to assembly language programs in terms of Speed , and here is yet another example .

When solving one of the problems at projecteuler.net.I Suddenly came upon the idea to compare the speed of execution of the same algorithm in different languages.

So here is the program in Three Programming languages , C , Java and Python

First in C

#include<stdio.h>
long long  LargestPrimeFactor(long long number) {
		long long n = number , i , Largestfactor = 1;
		for (i = 2; i <= (n / i); i++) {
			while (n % i == 0) {
				Largestfactor = i > Largestfactor? i : Largestfactor;
				n /= i;
			}
		}
		Largestfactor = n > Largestfactor ? n : Largestfactor;

		return Largestfactor;
	}
int main (){
	printf(" %d \n",LargestPrimeFactor(600851475143));
}

Then in Java

class ex3{
	public static long LargestPrimeFactor(long number) {
		long n = number, factor = 1 , i;
		for (i = 2; i <= n / i; i++) {
			while (n % i == 0) {
				factor = i>factor?i:factor;
				n /= i;
			}
		}
		factor = n>factor?n:factor;
		return factor;
	}
	public static void main(String [] args){
		System.out.println(LargestPrimeFactor(600851475143L));
	}
}

and now in Python

def LargestPrimeFactor(num):
        n=num
        factor = 1
        i=2
        while( i<= (n/i) ):
                while( n%i == 0 ):
                        if i>factor :
                                factor = i
                        n /= i
                i += 1
        if n > factor:
                factor = n
        return factor

print LargestPrimeFactor(600851475143)

I computed the times using the time utility in linux .

I expected the c program to win there was no doubt about that , and java was expected to come in second with python last .

$ time ./a.out
 6857

real	0m0.003s
user	0m0.004s
sys	0m0.000s

$ time java ex3
6857

real	0m0.114s
user	0m0.084s
sys	0m0.028s
$ time python ex3.py
6857

real	0m0.035s
user	0m0.028s
sys	0m0.004s

From the results its quite visible that c had won over python and python had won over java ,even though java was supposed to be faster than python.

The reason for python winning is that the cost of starting up the JVM is quite high, when compared with the cost of starting the python interpreter.

So lesson learnt If your program is short run it in python when given a choice , but still C is the king of Speed

Ps: This Question on stackoveflow goes over some more details .


Rajapattai Movie Review : ராஜசோத்தை (rajasothai)

 

What would prompt a perfectly stable minded person like me to suddenly spend 3 hrs of time and 120 rupees at a local theater ? Well the answer could lie in the story, screenplay , acting , or effects in a movie . But sadly that was not the reason this time . The reason this time was that I was not really in a proper state of mind and had been pretty shaken up from being sick for the past week.

So lets analyse the bad choice I made.

Rajapattai is essentially a commercial pot boiler as you can easily guess from the trailer . I have nothing against that , but still I expect a bit of brain effort from the director and the writer .

The real story :

Your usual corrupt politician is after somebody else’s stuff , Hero comes and saves the day,

The END.

The actual story :

அனல் முருகன் (Anal Murugan ) works as a small time actor in movies and aims to become a Big Villain actor. He encounters Dhakshina moorthi in a temple and saves him from a bunch of goons and learns that the goons were sent by Dhakshina moorthi’s son who is after his father wealth . So being the kind-hearted person he is, Vikram (If you still haven’t guessed who Anal Murugan is.) takes him into his custody and protects him.

Dhakshina moorthi’s son wants to get into politics so He needs to give the land on which his father has built and orphanage to MAMA Party Leader AKKA (Who incidentally is revealed later in the film to have been a pimp in the beginning only to climb up the ladder and become a politician).

Then a whole bunch of stuff happens and some how the real villains in the movie get the land , and as expected AKKA betrays Dhakshina moorthi’s son who now joins vikram and tries to get his father’s land back.

To get the land back they must take out the Big Boss Wapa, and as usual vikram does the job and proves AKKA’s crimes and AKKA is killed . The children get their orphanage back.

In the mean time there is a Romance that brews between Vikram and Deeksha Seth, Nothing special here.

That about wraps it up.

The Acting :

Vikram has really put in the effort to look like the character he plays . This is a really amazing transformation after Deiva Thirumagal , and as usual he impresses with his acting skills even though his character suffers from a bad case of cliché syndrome.

The vetran telugu actor K.Vishwanath really impresses in the scenes where he give romance tips to vikram , but other than that he doesn’t have a lot of scope.

Deeksha Seth is passable as the female lead looks gorgeous and she tries to show bit emotion in the extremely limited scope that she has, as eye candy. Its commendable that she has not fallen into the glamour trap nor has she stood with a blank face all the time like many heroines who I do not want to mention.

Pradeep Rawat as wapa is not really that frightening a villain as he was in Ghajini .

The actress who plays AKKA needs to do some research on Sornakka (ச்வர்ணக்கா ) characters like for example the female villain from DHOOL (Another Vikram film)  , She goes around with the same expression on her face for the entire length of her screen time .

All the other actors do their parts justice .

Other Technicalities:

This a big let down by director Suseenthiran who directed movies like Vennila Kabadi Kuzhu and Naan Mahaan Alla ,  that is all there is to say in the direction department.

Music by Yuvan Shankar Raja is boring , nothing really catchy , I was counting the minutes to the end of each song in the theater .

Camera work by R. Madhi is ok , A few stunts are shot well .

Few other points :

The songs in the film were a big hindrance to the and the song in which vikram reportedly appears in 17 different costumes was a big letdown.

I couldn’t bear sitting through the final “Laddu Laddu Rendu Laddu” which features Reema Sen ( Who seems really out-of-place ) and Shriya Saran ( Who hasn’t changed her dance moves for a long time ) .

Overall :

If you must see this movie , either remove your sense of logic and music, or try getting a case of sudden short-term memory loss .

 


JRuby and Sinatra

Here is the presentation did at Java User Group chennai on 26th November 2011.


Scalaxia for Android

Scalaxia for android was just released by Jug-C Member Ragunath Jawahar who is also the Founder and  CTO of Mobs and Geeks

Scalaxia is a project by Java User Group Chennai , It aggregates tweets related to the Scala Language , It is built using the Scala language itself and it runs on Google App Engine

Here are a few screenshots

 

And here is a video of it in action

 

The App can be Downloaded from here


Short term memory loss !!

An arch Linux box that I was running on my laptop just ran out of memory

Serves me right for allocating only 128MB RAM for it.

I was not even running a GUI , there was only a ssh server and the network services running. I was installing a few JRuby gems via a ssh session when this suddenly happens.

This highlights a very valid point in today’s world of computing, I feel that today’s software aren’t really very efficiently built.

We are taking the amount of memory that is available, for granted and not writing very efficient software .


An Easter Egg in Google Search

An easter egg has been found in Google search . It was about time that google did something interesting with google search , which even after the recent redesign wasn’t very interesting, But still the minimal look is what we all love about google search .

What is an easter egg anyway , well Wikipedia defines it as

A virtual Easter egg is an intentional hidden message, in-joke or feature in a work such as a computer program, web page, video game, movie, book or crossword.

What it means is that easter egg is just a simple trivial feature that in placed by the creators of the software product to lighten things up .

So now back to google’s easter egg, Imagine Google doing a Barrel roll well you can literally ask google to do it by typing Do a barrel rollin the search box , the same effect can also be triggered by typing “z or r twice” .

Then try imagining google having a slight tilt , well neither could I , but you can still see it by searching for tilt or askew” .

These effects seem to be working in the recent versions of all  major browsers .

I have made a video of all the effects take a look