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.

CSS3+jQuery rotate and wiggle

Simple and concise way to leverage CSS3 (don’t work in IE7 <) effects. Using this currently to call out the primary call to action on a page.

$.fn.rotate = function(/* String */ deg) {
		return $(this).each(function() {
			$.each(["webkit", "moz", "ms", "o"], $.proxy(function(i,prefix) {
				$(this).css("-" + prefix +"-transform", "rotate(" + deg + "deg)");
	$.wiggle = function(el, times, dir) {
		if(times === 0) {
		window.setTimeout(function() {
			el.rotate((dir? "-" : "") + "2"),
			$.wiggle(el, --times, !dir);
		}, 170);

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);

Facebook and Human Behavior

I’ve had a long fascination with the Lucifer Principle by Phillip Zimbardo (see video). A lot of his anecdotes are from the Stanford Prison Experiment, and other like it. The crux of the argument being that humans have immense capacities for doing good and doing evil, but the side they choose is a function of their environment. One of the most poignant points are that anonymity, and therefore the loss of accountability are necessary conditions for misbehavior.

I think the web has its own share of evil. If you look at the past few years the web has been a cat and mouse game between spammers and spam fighters. Phishing is and continues to be a large problem. Comment/conversation streams all over the web are filled with hateful spewing, flaming, and trolling. If we connect it back to what Zimbardo observed in the physical world, it makes sense: the internet provides a veil of anonymity therefore resulting in bad behavior.

Now if we take a look at Facebook the landscape looks very different and the reason continues to make sense and be consistent with the aforementioned. Facebook provides transparency, and the loss of anonymity. The environment online is changing and so is the behavior. Companies are less likely to spam for the fear of being banned. Fake identities are hard to foster. Facebook has changed the rules without even knowing it, but in a good way.

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

Gmail Should Be Social

I have a couple of various ideas on how Gmail could be improved. I took a small step in that direction with a Chrome plugin I wrote:

This of course is just the beginning, you can imagine using LinkedIn, Twitter, and Facebook APIs and bringing that content into your email in a meaningful way. These can naturally be integrated with a Rapleaf. If this extension gains any traction then I’ll write one for Firefox and expand the pool of networks.  One of the great things about the extension is that it’s serverless. This is important since it means no cost to me and no worrying about scalability. Plus it was a great way to learn the intricacies of Facebook Graph API.