Archive for December, 2007

Dead simple IP to Country in Rails

Saturday, December 1st, 2007

Step 1:

Follow these instructions to get MaxMind’s GeoLite IPCountry table into your Rails MySQL database.

Step 2:

In a Rails Controller:

  def get_country_from_ip
    ip = request.remote_ip
    result = ActiveRecord::Base.connection.execute("SELECT country_code FROM ip_country WHERE MBRCONTAINS(ip_poly, POINTFROMWKB(POINT(INET_ATON('#{ip}'), 0)))")
    result.fetch_row
  end

Step 3:

There’s no step 3. There’s no step 3! Ahahahaa!

Saturday, December 1st, 2007

My favourite comment from a “free” QuickLook plugin from some crappy shareware company I’ve never heard of:

Truth Is Spoken

Couldn’t have put it better myself!

But I have a quick solution to the advertising problem. Download the plugin, decompress and “Show Package Contents” in finder. In Contents > Resources > English.lproj you’ll find a simple HTML file which is the basis for the QuickLook view that actually appears on screen. Opening that file, you’ll see the advertising message in plain editable HTML.

I’m not suggesting you remove the advertising from this copyrighted code or anything. I’m just sayin’.

More Mail.app RSS freezes

Saturday, December 1st, 2007

108 MB Attachment

Thanks Mail.app, for completely freezing up while you download this large attachment to an RSS feed against my will. There is no option to turn off downloading of these attachments, and since the blog is mostly text there’s way to read it in iTunes or similar. There is no way for me to cancel this download without force-quitting Mail.app.

You can’t see the beachball in the picture, but I assure you – it’s there!

UPDATE: It was an amazing movie though, slightly quenching my fiery rage. I do want to download the attachments – just when I choose to, and in another thread.

Beginning of the end of ageing?

Saturday, December 1st, 2007

This WIRED article describes the initial success, on mice, of a treatment for skin cells which genetically reprograms the cells to, at least partially, “act younger”.

The article is couched in unconclusive weasel words – that this “may” lead to human remedies, that it “could” lend support to Aubrey De Grey’s theories on combating aging which I thought I’d talked about here before but now can’t find it. Anyway, that’s all bullshit – when the article pointlessly asks “Are Humans Next?” – of course they are. Humans are willing to go to almost any length and pay any price to look younger, and the anti-senescence market will be enormous. Hell, I bet that they’d have no difficulty at all signing up 500 desperate test subjects just based upon the mouse success.

Aubrey de Grey’s theories are compelling and this new experiment’s success indeed lends them credibility. Hopefully this spurs increased urgency of investment and research into the area.

View de Grey’s lectures on the subject here – I recommend the speech from TED Global here.

UPDATE: Check out this chart of a “Network Model of Biochemical and Physiological Interactions in Human Senescence” to crush any momentary optimism you may have experienced upon hearing the above news.

Causes of Aging Flowchart

Then again .. is it really all that much more complicated that what IIS does every time it serves a web request?

IIS Syscall Graph