birthdays
created 27 May 2009 in notes.
| blech | oh, today is the actual birthday? that explains all the cake! |
| blech | hyvää syntymäpäivää, as someone said on Facebook |
| blech | I hope they weren't just being rude in Finnish |
created 27 May 2009 in notes.
| blech | oh, today is the actual birthday? that explains all the cake! |
| blech | hyvää syntymäpäivää, as someone said on Facebook |
| blech | I hope they weren't just being rude in Finnish |
created 18 May 2009 in notes.
| The | i'm in a taxi on a laptop on irc with broadband. and frankly, i don't see why this is excessive in any way. |
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 }"
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>
created 23 April 2009 in notes.
| Mark | It's the '00s now right? |
| Tom | yep. |
| Tom | still. |
| Mark | Does that mean I can telecomute my flipping out? |
| Tom | No, that was early '00s. |
| Tom | now you just outsource it. |
| Mark | No, that was the mid '00s |
| Mark | Now you crowdsource it |
| Mark | you let your users flip out for you |
created 23 April 2009 in notes.
Automagic: Love Footage And Tools Demo | Rock, Paper, Shotgun. Love looks so pretty. And crazy, of course.created 23 April 2009 in notes.
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.