jerakeen.org

notes by Tom Insam

notes☴

code☷

links☲

photos☵

birthdays

created 27 May 2009 in notes.

blechoh, today is the actual birthday? that explains all the cake!
blechhyvää syntymäpäivää, as someone said on Facebook
blechI hope they weren't just being rude in Finnish

the future

created 18 May 2009 in notes.

Thei'm in a taxi on a laptop on irc with broadband. and frankly, i don't see why this is excessive in any way.

We Made This: Wired

We Made This: Wired

created 05 May 2009 in notes.

We Made This: Wired

Decoding Geohashes in pure Ruby

created 28 April 2009 in notes.

Wrote this for work, threw it away again in favour of using an actual gem that someone else will maintain, but I thought I’d put it here anyway, because it might be useful. Also, the gem is written in C and therefore hard to deploy sometimes.

#!/usr/bin/env ruby
# pure-ruby geohash decoding function

# default is the example from http://en.wikipedia.org/wiki/Geohash
geohash = ARGV[0] || "ezs42" 

# convert geohash into a bit sequence
map = "0123456789bcdefghjkmnpqrstuvwxyz" # silly custom base32 mapping
bits = geohash.split("").map{|c|
    i = map.index(c) or raise("bad geohash (#{c} not permitted)")
    sprintf("%05s", i.to_s(2)).gsub(" ","0").split("")
}.flatten

# even bits are longitude, odd bits are latitude.
# probably a better way of doing this part, feels non-ruby-like..
lat_bits = []
lng_bits = []
bits.each_with_index{|b,i|
    if i % 2 == 1
        lat_bits << b
    else
        lng_bits << b
    end
}

# subdivide the world according to the bit sequences
def decode(bits, range)
    range = [ range.to_f * -1, range.to_f ]
    for b in bits
        if b == "1"
            range[0] = (range[0] + range[1])/2
        else
            range[1] = (range[0] + range[1])/2
        end
    end
    return range
end

lat_range = decode( lat_bits, 90 )
lng_range = decode( lng_bits, 180 )
puts "lat is range #{ lat_range.inspect }"
puts "lng is range #{ lng_range.inspect }"

Delicious bookmarks counter in JavaScript

created 27 April 2009 in notes.

This is a script I use on a few sites to automatically count the number of delicious links to various urls. There are a few of these that I’ve found, but I quite like writing JavaScript like this. Also, mine will combine as many urls as possible into a single request to the delicious API, because it’s faster that way.

<!-- jquery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<!-- this is md5 implemented in javascript -->
<script src="http://pajhome.org.uk/crypt/md5/md5.js" type="text/javascript"></script>

<script type="text/javascript">
$(function() {

  // This function gets called per link, this depends on the template.
  // In my case, I'm walking up to the surrounding 'post' object, then
  // down to a pre-prepared p tag I want to populate with link data.
  // You will want to change this if you use this code.
  //
  // Markup is approximately:
  //
  //   <div class="post">
  //     <a href="..." class="delicious">..</a>
  //     <p class="deliciousinfo"></p>
  //   </div>
  function markup_delicious_link( element, data ) {
    var html = "<a href='http://delicious.com/url/" + data.hash + "'>";
    html += data.total_posts + " delicious link(s)";
    html += "</a>";
    element.parents(".post").find(".deliciousinfo").html(html);
  }

  // Find all links with class 'delicious'
  var hashes = [];
  var elements = {}
  $('a.delicious').each(function(index, link) {
    if ($(link).attr("href")) { // sanity check
      var hash = hex_md5( $(link).attr("href") );
      elements[ hash ] = $(link);
      hashes.push( "hash=" + hash );
    }
  });

  // Make calls to the delicious feed API to get details
  while (hashes.length) {
    // delicious permit a maximum of 15 hashes per request
    var subsection = hashes.splice(0, 15);
    var url = "http://badges.del.icio.us/feeds/json/url/data?";
    url += subsection.join("&") + "&callback=?";
    $.getJSON( url, function(data) {
      for (var i=0; i<data.length; i++) {
        var $link = elements[ data[i].hash ];
        markup_delicious_link( $link, data[i] );
      }
    });
  }

});
</script>

Conversation

created 23 April 2009 in notes.

MarkIt's the '00s now right?
Tomyep.
Tomstill.
MarkDoes that mean I can telecomute my flipping out?
TomNo, that was early '00s.
Tomnow you just outsource it.
MarkNo, that was the mid '00s
MarkNow you crowdsource it
Markyou let your users flip out for you

Automagic: Love Footage And Tools Demo

Automagic: Love Footage And Tools Demo

created 23 April 2009 in notes.

Automagic: Love Footage And Tools Demo | Rock, Paper, Shotgun. Love looks so pretty. And crazy, of course.

Steampunk, eh?

Steampunk, eh?

created 23 April 2009 in notes.

Steampunk, eh?

Los Colorados - Hot & Cold

created 23 April 2009 in notes.

Things my colo does

created 22 April 2009 in notes.

Been looking into getting rid of my colo. It costs a non-trivial amount of money, and philosophically I rather feel I should be able to exist in the cloud by now.

  • It hosts my SVN repository and clones of some of my git repositories.
  • It serves jerakeen.org
  • I run irssi in a screen session as an IRC client. This will be hard to replace.
  • I run some perl-based IRC bots from it.
  • I back up my mail to it using offlineimap
  • Some friends have accounts and host simple web content / mail / irssi sessions on it. If you run a colo, don’t give friends accounts ever, for any reason. This one right here is probably the biggest barrier to me getting rid of it. But don’t take it personally if that’s you..

Things it doesn’t do that I’m thankful for

  • Host my mail. Tuffmail rock. But everyone I know already knows this.
« older entries