The lessons I learned by trial and error about my Laserjet 1020.
Monday, February 23, 2009
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 http://www.tbray.org/ongoing/When/200x/2007/09/20/Wide-Finder
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
end
end
keys_by_count = counts.keys.sort { |a, b| counts[b] <=> counts[a] }
keys_by_count[0 .. 9].each do |key|
puts "#{counts[key]}: #{key}"
end
Bray's original idea was to check if Erlang is good option for this problem on multi-core platforms.
Read more ...
Wednesday, February 4, 2009
Subscribe to:
Posts (Atom)