Monthly Archive for June, 2010

Chelsea Song – Blue Is The Colour

Popularity: 2% [?]

Testing Code Using Serialized Objects

After having written few new methods to enhance a functionality, I needed to test the code. Now the app requires dataset, binning library and various groovy nodes for initialization.  Also it does a lot of pre-processing. So there were two options for me -

  • Hack the code to insert special test methods at a particular point.
  • Write a test class which does all the initializations and then runs the app

I did not want the run the whole app. All I wanted to test was if my methods were running fine on one iteration or not. I did not want to wait for 10 minutes to wait for the algorithm to complete and then look at the log files to see the impact.

What I did was serialization of all the objects required by my methods. It required me to hack the code and write a few lines serializing the various maps, data structures and stuffs. But with that done, all I now need to do is to deserialize these objects and get whatever I need to test my methods.

Simple! I can now write small, neat methods whose purpose is only to test the particular methods without running the whole algorithm.

Popularity: 2% [?]

FICO : Hips Don’t Lie

The video speaks for itself. It was a night when we had lots of fun with our juniors at FICO. I wish a few of them join the cultural team and we continue planning fun activities.

Popularity: 3% [?]

Chelsea Songs

A few Chelsea songs that I liked:

Carefree:

Carefree
Where-ever you may be
We are the famous CFC
And we don’t give a fuck
Who-ever you may be
Cause we are the famous CFC

Blue Is The Colour:

Blue is the colour, football is the game
We’re all together, and winning is our aim
So cheer us on through the sun and rain
’cause Chelsea, Chelsea is our name
Here at the Bridge whether rain or fine
We can shine all the time
Home or away, come and see us play
You’re welcome any day
Blue is the colour, football is the game
We’re all together, and winning is our aim
So cheer us on through the sun and rain
’cause Chelsea, Chelsea is our name

Come to the Shed and we’ll welcome you
Wear your blue and see us through
Sing loud and clear until the game is done
Sing Chelsea everyone.

Blue is the colour, football is the game
We’re all together, and winning is our aim
So cheer us on through the sun and rain
’cause Chelsea, Chelsea is our name
Here at the Bridge whether rain or fine
We can shine all the time
Home or away, come and see us play
You’re welcome any day
Blue is the colour, football is the game
We’re all together, and winning is our aim
So cheer us on through the sun and rain
’cause Chelsea, Chelsea is our name

Popularity: 3% [?]

Ted Talks : How Youtube Thinks About Copyright

Margaret Gould Stewart in this video explains the copyright violation of new videos that are uploaded to youtube. She says that when a video is uploaded, its heatmap is checked for a match with all the existing videos. Each point is tried for a match with each other point so that if the uploaded video is a clip of the original, or has audio/video slightly slowed or fast forwarded, even then the two would get matched.

Unless, the user of original video has mentioned strict no copy policy, in which case a new upload gets immediately rejected, when an uploaded video is found to match with an existing copyright video, the user owning the copyright is given an option to deal with the video .  The user might want to allow the upload if he sees a potential for advertisement/propagation.

She mentions an example wherein a video song released by Sony went off the charts in just a few weeks. Months later, a wedding video was uploaded featuring the same song. Now since Sony had the copyright to the song, they were given the option to either reject the upload or let it be. They allowed the upload, and put up advertisements and links to this upload from their page. Within weeks the video went ballistic and was watched by millions of people all across the world. The song was back in reckoning and it made to the 4th spot in the weekly charts!

Thinking about it, I do feel a bit of leniency can do good promotion of a video and should be the encouraged option.

Popularity: 7% [?]

Intelligent Tutor System

I spent a couple of days reading about the Intelligent Tutor Systems and gave a presentation to our team at FICO. The presentation was a brief overview on the cognitive aspect of building up a tutor.

Popularity: 7% [?]

A Few Monologues I Liked

Not at all an exhaustive list. Mentioning only 4 that come to my mind now.

Jack Nicholson, A Few Good Men (1992)

You can’t handle the truth! Son, we live in a world that has walls, and those walls have to be guarded by men with guns. Who’s gonna do it? You? You, lieutenant Weinberg? I have a greater responsibility than you can possibly fathom. You weep for Santiago, and you curse the Marines. You have that luxury. You have the luxury of not knowing what I know – that Santiago’s death, while tragic, probably saved lives. And my existence, while grotesque and incomprehensible to you, saves lives.

Samuel L Jackson, Pulp Fiction (1994)

The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he who, in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother’s keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon you.

Mel Gibson, Braveheart (1995)

You have come to fight as free men, and free men you are. What will you do with that freedom? Will you fight? Aye, fight and you may die, run and you’ll live. At least a while. And dying in your beds many years from now, would you be willing to trade all the days from this day to that for one chance. Just one chance to come back here and tell our enemies that they may take our lives, but they’ll never take our freedom!

Robert Duvall, Apocalypse Now (1979)

You smell that? Do you smell that? Napalm, son. Nothing else in the world smells like that. I love the smell of napalm in the morning. You know, one time we had a hill bombed, for twelve hours. When it was all over I walked up. We didn’t find one of ‘em, not one stinkin’ dink body. The smell, you know that gasoline smell, the whole hill. Smelled like… victory. Someday this war’s gonna end…

Popularity: 3% [?]

2010 WC Finals : Germany vs Australia – Beautiful

It was a wonderful game yesterday. I was amazed at the fluency with which the young German midfielders passed the ball around. At every chance they spurt forwards creating a goal scoring opportunity. 4-0 is a scoreline any team would be excited with, but I think the Germans could have won by a bigger margin.

With the likes of Ballack and Frings missing, I was skeptical of this young and relatively unknown group of players. To add to that, Podolski and Klose were coming after a difficult season with their respective clubs. But the two have a knack of lifting their game when they put on the white jersey of the national team. And they did that again tonight. You could see the brilliance of Podolski feeding crosses for Klose from the left wing. Klose though failed to grab them, and you could see his agony and the frustration.

The movements of Ozil and Khedira were troubling the Australians already.  Muller made it worse with his forward runs. It was simply amazing to watch them take control and dictate the pace of the game. And then Podolski scored!!! A powerful shot into the nets, even the palm of the Australian goalkeeper could not keep it away. But when Klose headed the ball home I had tears in my eyes. He sliced himself between the keeper and a defender to win the ball and head it right into the nets. This might be his last world cup finals, and I really want that guy to net another 5 goals this summer.

What excited me the most was the youthful energy of this team. They were ready to press ahead. As a fan commented:

Germany has evolved ever since Klinasmann took the helm. The days of slow build up play followed by a cross/header attempt are over. Although the Germans dont have 1 world class striker they have proven several players can slice through defences like a shark in water and put the ball in the back of the net. Now lovely through balls and tic-tac-toe passes are the heart of the german offence. However the Defence and Keepers have yet to prove themselves for this German side as I belive they are the weaklink.

The real test of this young side will be in the knockout stages when they run into the likes of Spain and England. It is then that the youth vs. experience will be tested, and we shall know if the 20-somethings of this starting 11 have it in them to cope up with the pressure. I have faith in the youthful energy of this reinvigorated German team, and even if they fail to reach the final, I am sure they will provide an entertaining and spectacular game of football.

Popularity: 7% [?]

FICO : Icebreaking Session – Lessons Learnt

Well, being a part of a group who had to think up something for the ice-breaking, I have learnt a new lesson today.

People on their first day are just too nervous to really play a game even if you ask them to.

My idea was pretty simple. I believe that creating systematic chaos is the best way to make people gel together. So we had come up with this idea of having a simple ball game. The instructions were to move around the room and throw the ball at a person who you want to play the game of truth-or-dare with.

I had imagined a room full of people enthusiastic about joining their first job. But it turned out to be otherwise. When we asked a guy to sing, all he could muster his courage and blurt out was that he was too nervous to do anything right then. Also, those fools were rooted to their places. They weren’t moving at all! :( … My ideas of systematic chaos just did not lift up.

Thinking retrospectively about the whole thing, I guess it was asking too much.

The other activity that we made them do was more fun. It involved the bollywood theme, so people enjoyed it.

Popularity: 6% [?]

Project Euler : Pascal Triangle To Find nCr

Problem 53 required one to find all the generated numbers of nCr, 1 <= n <= 100, which are greater than a million. And the solution was all too simple – Pascal Triangle.

Each row of the Pascal Triangle is a series of nCr. So all that was needed to be done was to generate a triangle to a depth of 100, and find all the large numbers.

One small modification that I could have done is – not all numbers needed to be calculated. Once a number greater than a million is found, all successive number in that series till the halfway mark will be greater than million. Remembering just the smallest number greater than a million should have sufficed.

public class Problem_53 {
	public static int solve() {
		int count = 0;

		Map<Settings, Object> settings = new HashMap<Settings, Object>();
		settings.put(Settings.ONLY_RIGHT_HALF_GENERATION, true);

		PascalTriangle pascalTriangle = new PascalTriangle(settings);
		for (int i = 1; i <= 100; i++) {
			int sum = 0;
			for (double num : pascalTriangle.constructNextLevel()) {
				if (num < 1000000)
					break;
				sum++;
			}
			count += sum > 0 ? (i % 2 == 0 ? 2 * sum - 1 : 2 * sum) : 0;
		}

		return count;
	}

	public static void main(String[] args) {
		System.out.println(Problem_53.solve());
	}
}

The Pascal Triangle Generator

public class PascalTriangle {
	private List<List<Double>> m_triangle;
	private int m_currentLevel;
	private boolean m_onlyRightHalfGeneration;

	public PascalTriangle(Map<Settings, Object> settings) {
		m_currentLevel = 0;
		initTree();
		m_onlyRightHalfGeneration = isOnlyRightHandGenerationEnabled(settings);
	}

	/**
	 * Create a new tree and initialize the Level 0
	 */
	private void initTree() {
		m_triangle = new ArrayList<List<Double>>();
		List<Double> levelZero = new ArrayList<Double>();
		levelZero.add(new Double(1));
		m_triangle.add(levelZero);
	}

	/**
	 * Check if the property ONLY_RIGHT_HALF_GENERATION is enabled by the user
	 *
	 * @param settings The settings provided by the user
	 * @return true if the ONLY_RIGHT_HALF_GENERATION is set to true
	 */
	private boolean isOnlyRightHandGenerationEnabled(Map<Settings, Object> settings) {
		return !settings.containsKey(Settings.ONLY_RIGHT_HALF_GENERATION) ? false : (Boolean) settings
		        .get(Settings.ONLY_RIGHT_HALF_GENERATION);
	}

	/**
	 * Construct the next level of the Pascal Triangle.
	 *
	 * @return the new level added to the Pascal Triangle
	 */
	public List<Double> constructNextLevel() {
		return m_onlyRightHalfGeneration ? constructRightHaflTreeNextLevel() : constructLeftHaflTreeNextLevel();
	}

	/**
	 * Construct the left half of the tree
	 */
	private List<Double> constructLeftHaflTreeNextLevel() {
		List<Double> nextLevel = new ArrayList<Double>();
		Double prevNum = new Double(0);
		for (Double num : m_triangle.get(m_currentLevel)) {
			nextLevel.add(prevNum + num);
			prevNum = num;
		}
		if (m_currentLevel % 2 != 0)
			nextLevel.add(2 * prevNum);

		m_triangle.add(nextLevel);
		m_currentLevel++;

		return nextLevel;
	}

	/**
	 * Construct the right half of the tree
	 */
	private List<Double> constructRightHaflTreeNextLevel() {
		List<Double> prevLevel = m_triangle.get(m_currentLevel);
		List<Double> nextLevel = new ArrayList<Double>();

		Double prevNum = prevLevel.get(0);
		if (m_currentLevel % 2 != 0)
			nextLevel.add(2 * prevNum);

		for (int i = 1; i < prevLevel.size(); i++) {
			Double num = prevLevel.get(i);
			nextLevel.add(prevNum + num);
			prevNum = num;
		}
		nextLevel.add(new Double(1));

		m_triangle.add(nextLevel);
		m_currentLevel++;

		return nextLevel;
	}

	/**
	 * Settings for the Pascal Triangle Generator
	 *
	 * @author AnuvratSingh
	 */
	public enum Settings {
		ONLY_RIGHT_HALF_GENERATION
	}
}

Popularity: 9% [?]