The cake is a lie

Archive for October, 2008

Google’s Lucky is fickle, too

One of Google’s most used underacknowledged features is the I’m Feeling Lucky query. On the surface, it seems silly and beside the point, but many people have grown to depend on it. What is it good for? Link resolving. You could go to Youtube.com and type “Rickroll” into the search box, or you could type “rickroll video” into your Firefox address bar (effectively doing an I’m Feeling Lucky search) and jump straight to where you want to go.

I no longer type “wikipedia.org” when I can type “wikipedia“. Why type “mail.google.com” when I can just type “gmail“? To me, Google has become a kind of DNS — resolving keywords into a complete URL. At that point, it’s hardly even search — it’s just a convenient side effect.

Providing a transparent link resolving service seems like a great selfless gesture by our unevil Google overlords. Rescuing the lazy with transparency and anonymity… Well, not quite. It turns out that the I’m Feeling Lucky feature only really works if you run it from the Google homepage, and approximately half-works from anywhere else.

Getting technical…

Anyone can turn a normal Google query into an I’m Feeling Lucky query, just append btnI=1 to the end of the URL (contrary to popular belief, btnI can take on any value, even empty string).

Let’s examine the problem. Consider this query:
workerpool site:shazow.net

Try opening that link, and then to compare, try the same query from google.com by hitting I’m Feeling Lucky.

Notice how clicking the link brings you to the Google results page, but the same query from the Google homepage does what it’s supposed to — takes you to the first result. It’s starting to become evident what’s going on here, but let’s beat this dead horse into the ground by hand crafting some HTTP requests, for great justice.

$ nc google.com 80
GET /search?q=workerpool+site%3Ashazow.net&btnI=1 HTTP/1.1
User-Agent: Mozilla/5.0 (Oh hai, I can haz redirect?)
 
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Date: Thu, 09 Oct 2008 01:07:47 GMT
Expires: -1
Content-Type: text/html; charset=UTF-8
...
 
$ nc google.com 80
GET /search?q=workerpool+site%3Ashazow.net&btnI=1 HTTP/1.1
User-Agent: Mozilla/5.0 (Oh hai, I can haz redirect?)
Referer: http://www.google.com/webhp?hl=en
 
HTTP/1.1 302 Found
Location: http://shazow.net/blog/2008/04/02/gentoo-rockband-code-and-music/
...

I used netcat to send a raw socket request (the first two lines) to google.com on port 80, and then Google responded (lines 4 and onwards). There are two requests, one is a vanilla request and the second includes a fake Referer header claiming that I was coming from the Google homepage, which yielded the 302 redirect we want.

Sometimes external I’m Feeling Lucky links work, other times they don’t. It appears that Google has some secret threshold to decide when to get in the way of your destination like an angry ceiling cat catapulting itself onto your face. It seems to happen when there’s a small number of results, or the magic search juice score of the top score is relatively low.

Sadface, but what can we do?

Google may not be completely selfless, but they’re still pretty good compared to some jerkwads. Thankfully, Google provides a no-strings-attached search API to their wonderful magic search juice. It’s not very well advertised (or clearly documented), but once you hunt it down, it’s simpler than sketching a wrinkly gourd. Observe: Same fail query as above in JSON.

Writing your own I’m Feeling Lucky redirector is a piece of cake. I took the liberty of making one on the Google App Engine with a few bonus features:
http://302found.appspot.com/ (source code @ github)

6 comments

Pass-through multi-car elevators

I had a dream last week about elevators that go through each other. After a bit of research, I found a few multi-car elevator shaft schematics and patents but they all seem to use a cyclic method of elevators cycling from one shaft and into another, instead of passing through each other.

Here’s my idea:

At least two shafts are required. One shaft is dedicated for people going up, the other is dedicated for people going down. Each shaft will contain many elevator cars, proportional to the number of floors. For an average residential building, 3 cars per shaft should be sufficient. Huge office buildings can have 5-10 cars per shaft.

Considering a single shaft (for people going up), it will work as follows:

People enter an “active” elevator car, the car goes up. Once the last person leaves the car, the elevator car transforms into “inactive” mode: The doors close and the floor collapses outwards to be on the same plane as each side wall. Then, each wall extends outwards one level, effectively allowing “active” elevators below it to pass through it. Once an elevator is in the “inactive” mode, it will make its way down to the bottom floor and wait until the last active elevator departed the bottom floor, at which point the walls will contract, the floor hatch will close, and the door will open waiting for new passengers.

Pass-through multi-car elevator schematic

Considerations

  • Advantage: Elevator shafts are expensive. Consider a large office building with six to ten elevator shafts, imagine how much money would be saved if there were only two shafts with the same (or better) efficiency.
  • Rush hour: This scheme is great for repetitive bursts of people. There should always be a steady stream of elevators, unlike current elevator systems where the shafts tend to accidentally get in sync and you end up waiting while all 4 elevators make their way down from the 40th floor.
  • Danger: Collapsing floor instantly screams danger, yes. But with some thorough planning, it should be alright. The elevators cars can use sensitive weight sensors to insure that nothing remains in the elevator when the floor opens. If something refuses to leave the elevator, then the car will proceed to a special extra floor at the top (or bottom) of the building where further effort can be taken without interrupting the rest of the cars.
  • Movement mechanism: The classic pulley setup wouldn’t work here. The columns on each corner of the shaft will need some kind of rails which each car can use to traverse and power itself.

In all practicality, it wont happen. But it’s still a cool idea. Who wants to write a simulator?

3 comments