26 April 2007

fark is grabbing copyrights?

Some would think so. But if you read really closely, you're not submitting anything meaningful, you're submitting a web link. And if they want the copyright of that web link, then, ok, TinyURL it. They'll have the copyright to a TinyURL uid. And the copyright to any images on the page stay where they were.

Pretty simple.

08 April 2007

kata 6.

prag dave's anagrams resonated with me, because i'm working on hashing text down.

so follow along in irb, if you have /usr/share/dict/words:

class Symbol
def to_proc(*args) lambda {|*a| a.first.send self, *(args+a[1..-1])} end
alias [] to_proc
end # for faux currying

w = File.readlines('/usr/share/dict/words').map {|w| w.strip.downcase}.uniq ;:done
h = Hash.new([])
w.each {|word| nu = word.split('').sort.join; h[nu]+=[word]} ;:done
anas = h.values.find_all {|v| v.size > 1} ;:done
puts anas.map(&:join[',']) # all anagram n-tuples
puts "---"
puts anas.sort_by(&:size)[-30..-1].map(&:join[',']) # the top by set size
puts "---"
puts anas.sort_by {|a| a.first.size}[-30..-1].map(&:join[',']) # the top by word size

in fairness, the symbol-currying is in "sym2proc.r", so it's really just 10 lines of code, but that's the general idea.
(lots of the library functions look haskelly, but ruby just felt better for string processing)

08 March 2007

eval is amazing.

In terms of things, eval is much bigger than JSON callbacks, even bigger than Lisp itself. It's big like the ribosome --- eval is how things come alive.

For example, I'm rendering urls and associated metadata in the browser from a ruby cgi script. Instead of some big XML specification, I'm just passing an array of strings from server to client. It's big_array.inspect in Ruby, and eval(inspectedBigArray) in Javascript. No monadic parsers, no macro magic; inspect and eval, code I don't even have to write myself. (And if the inspected big array is too big, the browser can start lysis; so it goes.)

G J Sussman: Programming is a good medium for expressing poorly-understood and sloppily-formulated ideas: exactly the opposite of people who'd want to plague me with type theory.

23 February 2007

origins

Some people call it disclaimers, some call it biscuiting, some youthful naïveté. When I was 16, my poetry teacher had told us that the only unwritten preface we were allowed to give to any piece was "It's slightly new, but it smacks of genius."