Tracking Facebook OpenGraph Referrals in Google Analytics

Facebook Insights aren’t always predictable, and don’t give you an accurate picture of how much of your traffic is coming from FB. You can track this with the following code snippet:

window.param = function(name) {
     return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(||[,""])[1].replace(/\+/g, '%20'))||null;
var ref = param("fb_ref"),
source = param("fb_source");
source && _gaq.push(['_trackEvent', "FB", source, ref]);

Run IE9 in VirtualBox for Free!

I’m a long time Linux user, and one of the pain points of doing any sort of browser development is cross browser testing. I came across this cool Github script that pulls Microsoft’s freely available Virtual PC images for different IE version and sets them up for VirtualBox, which can be used on OSX or Linux. You can find the script and instructions here:

Your Startup Sucks

Don’t take it personally, but most do. Why? Recent developments in Software that have really changed the game. Here are the driving factors:

  • Rise of cloud infrastructure. Amazon AWS, Google AppEngine, and Heroku(and clones) have removed the necessary technical understanding of setting up a Linux cluster and operating it. Anyone can do it. It’s more pricey than doing your own box, but you save on managing it all yourself. To start it’s typically free; this means you don’t need an upfront capital investment to start working on something. In the words of my friend Hemang, this is a framework that just got better and I agree.
  • More abstract software frameworks. The popular ones here are Ruby’s Rails, and Python’s Django. There are thousands of Ruby tutorials, which make it possible for anyone and everyone to whip up a project very quickly.
  • Flow of capital to technology. It is easier to raise money. Venture capitalists want to fund the next X, and there is a strong focus technology. Some hopefuls like Marc Andreessen hope this is just the beginning. The strategy here has become throw money at a promising space(such as deals, checkins, etc), and one of them will win and you will have a return on your investment.
  • Glamorization. Culturally startups are trendy, which means design over function. Users over revenue. Raising capital over product market fit.

These are all good things (besides the last one), but there are significant problems that arise. First off, there are too many choices. There are literal clones of every product out there. How many todo lists do you know? Everyone thinks they can make a better one. Choosing Software now is harder than buying home appliances, you have to do a ton of research before figuring out what is good. Also it saturates the market and makes it harder for higher quality applications to flourish.

Another problem is that quality is lower. When you are spending your own capital or raising it, you will try and figure out some proof points for your idea/experiment/startup. It’s not cheap to just hack it together and throw it out there, so you put more thought into the actual quality of what you are producing. This is pushed even further by the glamorization of technology. Technology wise higher abstractions from frameworks like Rails have boundaries, and so most of the products out there work within those boundaries and are limited by them. Companies like Quora,, sneakpeeq(I’m affiliated) are more immersive because of the real time aspect, which at this point is not possible out of the box with Django or Rails without some real technical knowledge.

The fast jQuery way of inserting the Facebook JS Library

$(“<script/>”, {async: “true”, src: document.location.protocol + ‘//’}).appendTo(“#fb-root”);

jQuery Google Image Plugin

Here is a quick and convenient Google Image plugin for jQuery. Just give it an IMG tag with an empty src or a default image. It will use the alt text of your image, and select the first image based on that term.

$.fn.googleImage = function() {
		return $(this).each(function() {
			var self = this;
			var url = "" + $(this).attr("alt");
			$.getJSON(url, function(data) {
				if(data.responseData.results.length > 0)
					$(self).attr("src", data.responseData.results[0].unescapedUrl);

Component-Object Model for jQuery: BrickJS

I’ve written and open-sourced a jQuery plugin that really changes the way that you write UI components in Javascript.

It’s still in beta, but I’ve written a few components with it at Flixster and it has been very concise and effective. It uses a lot of function introspection to pre-bind DOM elements and attach event handlers.

It allows for clean and elegant OOP design. It doesn’t provide any components, but gives you the tools to easily create your own. Check it out here:

GoogleTV Flixster App

Here is my latest work:

GoogleTV Flixster app

Hibernate QuickTip: MappedSuperclass

One of the hibernate tricks for cleaner entities is the @MappedSuperclass annotation. This allows you to specify a set of fields that all of your entities share. Write a class with this annotation at the class declaration level and then make the entities inherit from this class. Without it Hibernate will throw errors.