Monday, February 23, 2009

HP printer on Ubuntu 8.10

The lessons I learned by trial and error about my Laserjet 1020.
  1. foo2zjs works sometimes, but will have problem when CUPS is updated.
  2. HPLIP always works if you install the latest version, not the one in repository.

Friday, February 20, 2009

A page about the wide finder

I have published the page of wide finder, which was created for a group discussion on Erlang.

The problem of wide finder was coined by Tim Bray, and is summarized in

The task is to read an Apache logfile and figure out which pages have been fetched the most.

The reference Ruby code

# 11 lines

counts = {}
counts.default = 0
ARGF.each_line do |line|
if line =~ %r{GET /ongoing/When/\d\d\dx/(\d\d\d\d/\d\d/\d\d/[^ .]+) }
counts[$1] += 1
keys_by_count = counts.keys.sort { |a, b| counts[b] <=> counts[a] }
keys_by_count[0 .. 9].each do |key|
puts "#{counts[key]}: #{key}"

Bray's original idea was to check if Erlang is good option for this problem on multi-core platforms.
Read more ...