Ryan Angilly's Blog

Feb 24

Preparing…

Preparing…

Feb 22

Easier debugging when refactoring Rails controllers

When refactoring a big controller with lots of before filters, it’s common (for me anyway) to get into a situation where tests start failing due to before filters redirecting. Today I made it a lot easier to debug these failing tests by adding this to my ApplicationController:

   def redirect_to_with_logging(*args)
     logger.debug "Redirect: #{args.inspect} from #{caller[0]}"
     redirect_to_without_logging *args
   end
   alias_method_chain :redirect_to, :logging

This will log where the new redirect is coming from, and make it a lot easier to figure out what is breaking your tests. Enjoy.

Feb 11

To be great, you must understand the competition

I was listening to Morning Edition on the way to work a couple days ago, and something caught my ear. One of the reporters was talking about the recent problems that Toyota has been having. The president of Toyota, Akio Toyota, was seemingly absent from the response until he was cornered at the WEF. What he said wasn’t that big of a deal. But something the reporter harped on struck a chord with me.

Apparently, after giving a curt response, he hopped in an Audi and drove away. The reporter and people interviewed for this story made a big deal of this. OMFG, the president of Toyota isn’t driving a Toyota?!?!?! First of all, the WEF is in Davos, and I doubt the president of Toyota has is cars flown in when he visits foreign countries. But even if he owned the car, who cares?

It reminded me that to build a great product, you need to understand your competitors. And I can tell you that if I were the president of a car company, I would make sure to drive competitors products all the time. Luckily, I dont have to drop $30k to test out our competitors. I set aside 30 minutes a week to use our competitors products, just so I know ‘what is market’ with respect to other online invitation and party planning sites.

So just keep that in mind: if you are in a market where you can use your competitors products, take advantage. Use them. Learn from their successes and mistakes, and build something better.

Feb 08

Happy groundhog day

Happy groundhog day

Feb 07

damnit ruby.

damnit ruby.

Feb 06

wicked cool paper on erlang vs. C++ scaling

Jan 30

I love Vermont.

I love Vermont.

Jan 26

How Google tracks clicks for backpropagation

I was wondering a few nights ago: How does Google track clicks for their backpropagation algorithms? So I cracked open Firebug, did a search and watched the Console tab while I clicked a link. I was expecting to see a nice little XMLHttpRequest go across the screen… and didn’t.

Upon further inspection, I found that the links in search results all had inline onclick handlers:

A call to clk() in the console tab just returned true, so off to the source for clk() I went.

Cmd+U… Cmd+F… ‘clk’…:

  window.clk=function(d,e,f,j,k,l,m){}

Those sons of bitches. Back to Firebug, and the Net tab. At this point, I noticed a whole bunch of requests that had responded with 204s. The request for these 204’d documents had image/png and image/jpg in the accepts header, and it hits me: they’re pixel tagging. Very clever. But I still want to find clk(), so I see in the Net tab where there was a 19k JS file requested, open it up, do a search, and with a little bit of manual de-minifying:

function(d,e,f,j,k,l,m) {
  if(document.images){
    var a=encodeURIComponent||escape,b=new Image,
        g=window.google.cri++;
    window.google.crm[g]=b;
    b.onerror=b.onload=b.onabort=function() {
      delete window.google.crm[g];
    };

    var c,h,i;

    if(google.v6) {
      c=google.v6.src;
      h=google.v6.complete||google.v6s?2:1;
      i=(new Date).getTime()-google.v6t;i
      delete google.v6;
    }

    b.src=["/url?sa=T","&source="+google.sn,
      e?"&oi="+a(e):"",f?"&cad="+a(f):"","&ct=",
      a(j||"res"),"&cd=",a(k),"&ved=",a(m),
      d?"&url="+a(d.replace(/#.*/,"")).replace(/\+/g,"%2B"):"",
      "&ei=",google.kEI,c?"&v6u="+a(c)+"&v6s="+h+
      "&v6t="+i:"",l].join("")
  }
  return true
};

Jackpot.

When you think about it, this makes WAY more sense than an XHR. It’s cross browser, probably a hell of a lost faster (even though I haven’t taken the time to benchmark it), and just so… Google. This may be old hat to some, but I never though of using pixel tagging dynamically in this way. Something tells me we’ll be using this technique in Engineering Alley at Punchbowl HQ in the next few weeks.

Jan 23

What’s up @jaypeakresort

What’s up @jaypeakresort

Jan 20

peter norvig: models and theories