« | » Main « | »

SSAO JS Snowman WTF?

Monday 28 December 2009

Román Cortés has a special place in my heart, since it was my animation of his Homer Simpson in CSS that got me my first and only Slashdotting. But Román hasn't rested on his laurels. His blog is full of edge-pushing browser experiments.

So far in December alone, he's done Las Meninas in 3D with CSS, a pure JavaScript text reflection, and his latest, a 3D snowman in JavaScript.

This last one, he explains, uses parallel sphere raycasting, with some simplified screen-space ambient occlusion, all built on the canvas element with direct pixel color control. Of course it does. The words describing it are practically longer than the mere 4k of JavaScript that implemented it!

I don't understand what all that is (yet!), but I know Román routinely does things other people don't realize are possible.

The Historical Thesaurus of the OED

Sunday 27 December 2009

The Oxford University Press is continuing to push the envelope on reference books, with the Historical Thesaurus of the Oxford English Dictionary. It's a 3952-page behemoth that not only includes every word in the OED, but traces meanings through history as well. It took 44 years to write, and weighs 14½ pounds.

It looks like pure lexicographical porn. There are some detractors, though, specifically about the classification scheme. The Amazon page has an annotated sample page, which shows that "express ill-humor" is categorized as "02.02.21.05.04.01", hardly a friendly scheme. I'm used to the Roget system, which is also numerical, but doesn't hew so slavishly to a strict hierarchy, so those same concepts can be found at 951.15, a number better fitted to my short-term memory capacity. I can imagine flipping back and forth quite a bit between index and content: "02.02.21.what?"

But this still looks to be a very impressive achievement, the first and maybe last of its kind. I'll have to find a physical copy some place to further examine (peruse, study, inspect, scrutinize, check up on).

BibliOdyssey

Saturday 26 December 2009

BibliOdyssey came to my attention because of tweets about their Victorian Infographics post, which is very nice, but they have lots more in a similar vein. I also liked History of Colour Systems, and especially Arabic Calligraphy:

Abstract Arabic calligraphy

The idea that this beautiful interweaving is also writing is fascinating to me. The post has a few other examples of abstractly beautiful Arabic writing, and links elsewhere.

That's what BibliOdyssey is like: a quick browse in a rich library, a brief introduction to exotic topics with pointers off to more information. There's no way to chase them all down, but I feel like in another life I could devote myself to their study...

Looking for a Python developer

Tuesday 15 December 2009

The Tabblo group is a small high-powered web development team. We build web sites and services to help explore and build new businesses within HP's printing group. Our current work supports HP's new line of web-connected printers. We're looking for a skilled software engineer to join our tight-knit group of developers.

We need someone who can jump into a project with both feet. If you don't know the technologies needed, you can learn them quickly with a minimum of fuss. Good overall engineering skills are a must, as well as a passion for delivering polished software even in demanding circumstances. We build and maintain outstanding software and experiences, and would like your help to continue to do so.

To apply for the job, visit HP's craptastic jobs board. Drop me a line if you apply, so I can make sure you don't get overlooked by the HR flacks reviewing resumes.

Prettying XML in Komodo

Wednesday 2 December 2009

I use ActiveState Komodo as my editor these days, and have for a while. It's got just the right feature set for me, including scriptability in Python.

I haven't dug into the scripting much, but one constant need finally drove me to learn more about it. At work, we often deal with chunks of data sent from servers in either XML or JSON formats, and that data is rarely indented for readability. So I often need to pretty up a file so that I can see what's going on.

Here's a Komodo Python script to prettify XML, either the current selection, or the entire document:

import xml.dom.minidom as md

def pretty_xml(x):
    """Make xml string `x` nicely formatted."""
    # Hat tip to http://code.activestate.com/recipes/576750/
    new_xml = md.parseString(x.strip()).toprettyxml(indent=' '*2)
    return '\n'.join([line for line in new_xml.split('\n') if line.strip()])

def filter_selection_or_document(fn):
    """Filter the current selection, or if none, the entire document.
    
    `fn` is a function taking text and returning text.
    
    """
    the_sel = komodo.editor.selText
    if not the_sel:
        komodo.editor.selectAll()
        the_sel = komodo.editor.selText
    
    komodo.editor.replaceSel(fn(the_sel))

filter_selection_or_document(pretty_xml)

Unfortunately, the Komodo scripting docs are not great: they are fairly terse, with not much introductory material to help you find your way around. And the Python bindings are step-children: you have to read about JavaScript, then translate to Python in your head.

But you can call into the extensive Python standard library to get done what you need done, so the power is there. I also made a JSON prettifier by using this filter function in the above code:

def pretty_json(j):
    """Make JSON prettier."""
    return json.dumps(json.loads(j), indent=2)

« | » Main « | »