24 November 2007

Anti-Features?, or, Never attribute to malice what can be explained by math.

Apparently, if you buy a cheap camera, and you can't save an uncompressed picture, that's treacherous computing, that's an anti-feature.

It's not. The camera won't stop working if you correctly patch in a different chip set.

And assuming the worst, assuming that the chips are exactly the same in an expensive camera, it still doesn't matter. The native resolution is still small on the cheap camera--that's mostly what makes it cheap--so you'll be better off buying the high-resolution expensive camera.

Of course, if you really want a camera that you can program, you might like an XO that drives a Roomba.

06 June 2007

cheap illustrations.

I'm a cheap nerd, so I printed myself an enormous wall decoration last August 2006: it's Pi, in a textual fractal. (This is it to two levels, and the one in my room is to five.) 3'x5', $10 from Kinko's. Nice conversation piece.

I've been printing more things recently, I've been thinking about combining text and images, and an author of two books on classical themes bemoaned the expensiveness of art in an email today. (Illustrating an book on Aesop's Fables, specifically.)

Most art schools have job boards; the artists can be of varying qualities, but sketches in pen are quick to do, and hard to do badly. (Lots of approximate lines.) Twenty seconds a sketch, which is a not-too-fast speed, scan one as you're doing the next one, and you've got a hundred in an hour.

Has anyone used Flickr for (cc)by-sa images? I wonder if that's cheaper.

21 May 2007

Amazingly bad APIs?

There are some amazingly bad APIs in Java, so Paul Buchheit says. The best API is system(), or backticks.

The end result is basically an ImageMagick conversion (kudos to a useful incantation for the less than sign):

mogrify -geometry "220x133>" -antialias -quality 90 /tmp/c.jpg /tmp/c-thumb.jpg

You wouldn't write an encyclopedia in limericks (though it's been done before), so there's no need to use a general purpose programming language to manipulate images. Small Pieces Loosely Joined is pretty popular for Unix, CGI/REST, Erlang, Messenger RNA, etc.

02 May 2007

microsoft knows drm.

I've been hearing a lot about this string of hexadecimal numbers. It starts with 09, ends with c0, and I think it has f9 and 88 somewhere inside.

Let's ask Microsoft search what it is!

require('open-uri') && puts(open('http://search.msn.com/results.aspx?q=09+f9+88+c0') {|f| f.read}.downcase.gsub(/<[^>]+>/,'').tr('^0-9a-f','').scan(/09.+?c0/).inject(Hash.new(0)) {|h,nu| h[nu]+=1;h}.sort_by {|str,freq| freq}.last.first)

Whew!

For non-Rubyists:
require we can open urls like files, and put this string: open the msn search page for all pages that have 09, f9, 88, and c0, read it in one gulp into lowercase, regexp out all html tags, translate out any character that's not a hex digit, scan for all substrings that start with 09 and end with c0, make a histogram* of the array, sort by most popular, and take the most popular string.
(* Inject a hash table through the array of scanned substrings; the strings are the keys, the frequencies are the values; add one to the value every time you see any string, starting at zero.)

Remember folks, this is Microsoft's suggested answer to the 128-bit programming challenge
posed earlier today, so like love, and Cambridge weather, it's just temporary.

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."