A 16-line hack to make the JS DOM API a tad more humane.
...absolutely amazing. I’ve yet to find a smaller and yet more astounding example of how you can encapsulate functionality within JavaScript and create brand new APIs on the fly.
Web pages are written in HTMLWP but as they have become more and more complex, they now tend to be written, clientside, through JavascriptWP, which can manipulate and insert HTML. Google Images, for instance, uses Javascript to write the HTML that displays your image results.
Yes, it’s roundabout, but it’s due to the nature of the languages: Javascript does stuff, HTML displays stuff. When you want the browser to do things (instead of merely displaying dumbly what it receives) and when these things themselves involve a lot of displaying, you end up writing HTML through Javascript.
It’s a little like writing French through English (André went to Marie and said: ”Bonjour! Ça va, ma chérie?”) and just as frustrating, particularly because you sometimes have to narrate whole scenes in French (pidgin tends to be painfully verbose) and your English self is left completely in the dark—so you end up naming things in both French and English and it gets as ugly as you can imagine.
HyperScript is a bizarre and quixotic attempt to write French in English; that is, HTML in Javascript. Basically, you do what went on in the Norman conquest of EnglandWP: you anglicize as many French words as you can; that is, you turn into Javascript as many HTML words as you can.
The lark itself takes gratefully (and rather surpisingly) only 16 paltry lines of Javascript code (highlighting thanks to Mark “Tarquin” Wilton-Jones.):
functioneach(a, f) { for(vari=0, l=a.length; i<l; i++) f(a[i]) }; each('a big blockquote br b center code div em form h1 h2 h3 h4 h5 h6 hr img iframe input i li ol option pre p script select small span strong style sub sup table tbody td textarea tr ul u'.split(''), function(label){ window[label]=function(){ vartag=document.createElement(label); each(arguments, function(arg){ if(arg.nodeType) tag.appendChild(arg); elseif(typeofarg=='string' ||typeofarg=='number') tag.innerHTML+=arg; elsefor(varattrinarg){ if(attr=='style') for(varstyinarg[attr]) tag[attr][sty]=arg[attr][sty]; elsetag[attr]=arg[attr];
};
}); returntag;
};
});
and you can play with it right here, right now:
Test Area:
The translation between HTML and Hyperscript is straightforward, where you would have written
“If it succeeds, milk it; if not, try something different. And if the fans are into file sharing (which they are), keep the lawyers leashed and find a way to make piracy work for you.”
Seven years ago musicians derived two-thirds of their income, via record labels, from pre-recorded music, with the other one-third coming from concert tours, merchandise and endorsements, according to the Music Managers Forum, a trade group in London.But today those proportions have been reversed—cutting the labels off from the industry’s biggest and fastest-growing sources of revenue. Concert-ticket sales in North America alone increased from $1.7 billion in 2000 to over $3.1 billion last year, according to Pollstar, a trade magazine.
Frustrated record companies have responded by trying to get their artists to spend more time promoting records and less time touring and endorsing products, says Jeanne Meyer of EMI, another big record label. “Sometimes you’ve got a tug of war going on,” she says. Yet the more labels spend on marketing pre-recorded music, the more they raise their artists’ profiles and boost their other, more lucrative, sources of income. Pre-recorded music, no longer the main cash cow, increasingly serves merely as a marketing tool for T-shirts and concert tickets.The best seats for The Police’s world tour this summer cost over $900; the group’s entire catalogue on CD costs less than $100.
The shift away from recorded music is due in part to the recognition that touring and merchandise are more lucrative. But it may also be a consequence of internet piracy, as free downloads give music fans more money to spend on other things. Jwana Godinho, the director of Música no Coração, a concert promoter in Lisbon, thinks many music lovers have a “mental budget” that they are prepared to spend on music, and have switched their spending from CDs to tickets and merchandise.
The logical conclusion is for artists to give away their music as a promotional tool. Some are doing just that. This week Prince announced that his new album, “Planet Earth”, will be given away in Britain for free with the Mail on Sunday, a national newspaper, on July 15th. (For years Prince has made far more money from live performances than from album sales; he was the industry’s top earner in 2004.) Outraged British music retailers were quick to condemn the idea. As far as the record industry is concerned, it is madness. But for the music industry, it could well be the shape of things to come.
I’ve always hated, with a passion, moral-indignation ads against piracy—not only because they’re manipulative but because they’re stupid. And the best defense for piracy may be how hard it is to make an argument against it that doesn’t stink of moral indignation—if maudlin pleas are the best you can do, you’re probably rotten. (On a related sidenote, I found it mighty interesting when The Economistcircuitously referred to Kazaa as “a file-sharing program that was widely used to download music without paying for it”—as much as ads want to make us believe pirating is stealing, there are crucial differences, which is why such circumlocutions are essential.)
To solve intellectual property’s malaise I’ve long sought for grand economic solutions (new innovative schemes or perhaps even a new concept of property rights) rather than grand political ones (which are just, ugh, imposed moral rules). While there has been plenty of both, I’m starting to see these days that maybe the solution will be simply to move on. Piracy is just another (admittedly extreme) form of commodificationWP. You don’t fight commodification by outlawing it, you take the next thing that hasn’t been commodified yet, you offer value however you can, you move on.
The first principle is that you must not fool yourself—and you are the easiest person to fool.
—Richard Feynman, Cargo Cult Science
Watched Al Gore’s An Inconvenient TruthWP a couple of days ago. Besides being astonished by the quality of the presentation that is the core of the documentary, he did manage to intrigue me, if not convince me, about global warming—I’m definitely reading Skeptical EnvironmentalistAM, E soon.
At any rate, what surprised me most was Gore’s evident hubris and mocking towards skeptics. I thought of a question for him then,
what reasons are there to disbelief your believes and your conclusions?
And it hit me that it was too good a question not to ask ourselves.
That’s the game I’m proposing today. It’s like when they asked you in high school to take the other side of a debate only this time it’s not about arguments, it’s about reasons—the difference here being that a reason is a fact you yourself are forced to accept while an argument is a verbal tool you use to to try to convince others. This is not about others, posing or fighting, this is about you and truth.
You know there have to be reasons for both sides, don’t you? Anything of more than trivial complexity is inherently ambiguous. If you can’t find them it’s probably because your knowledge of the subject is, well, trivial and superficial.
So take one of your most entrenched beliefs—say, in my case, that government is evil or that there is no god—and find a reason—a reason you can do nothing but accept—for disbelieving it. It is not about you abandoning that belief, it’s about letting doubt back inside your cramped head.
Personally, I’m losing so far. It’s incredibly easy to come up with plausible, convincing arguments that would be good weapons and yet you personally know are ultimately flawed and phony. But to come with true reasons—well, it’s much, much harder than I thought…
Speaking of locality, if you haven’t seen Google’s new Streetside View (like, say, in San Francisco) you’re missing a future shock gasp. (via O’Reilly Radar)
Breathtaking immersion. Eerily reminiscent of Rainbows EndWP, AM.
Also not to be missed are Immersive Media’s—one of the companies behind this new feature—richer demos: pannable videos!
Finally, after complaining for more than a year about its terrible interface design, the first sketch of a new interface for RAE’s Spanish Dictionary is now live. Expect service to be bumpy and patchy since the algorithms are still green but things will get better soon—daily!
The main improvements over DRAE so far are:
Definitions load in the same page, stacked newest on top, which means you effortlessly keep a history of lookups. Very handy.
You don’t have to type a word’s accents (or its ñ’s) for PLBRS to grok what you mean—99% of the time (the other, harmless 1% is made of words like LÚcido and luCIdo, where there is ambiguity). This effectively solves the original complaint and brings tears of joy to my eyes.
Various simple format improvements that make things more attractive, more compact, and easier to grok.
That silly tilde (~) used in phrases to stand for the entry word is now actually replaced with the word. In general, DRAE is full of abbreviations that may have made sense for the print version but are a confusing, pointless legacy in digital expanses. They’ll go away in the next couple of days.
Been getting a lot of ideas from Ninjawords—a very cool, very fast English dictionary. Check it out.
and I found it a very fitting answer and possible second slogan to the whole project. The best way I’ve found to describe what I want to do with Uruban is by adapting that phrase,
Uruban is about making the local web not suck.
It will be a wiki, a local encyclopedia, a local yellow pages, a local guide (not just a tourist guide). The place to find the menu of your neighborhood taco stand or the nearest Tejuino selling carts, movie listings of all theaters or places to get a hooker, cafes open late at night or drugstores that print your photos in an hour. It will be the city digitized and digested, given a common, comprehensive, and always updated interface. Above all, it will be local, hyperlocal.
So that’s the dream. For now I had to get myself to start and so I just transcribed a list of all churches in the metro area and their Sunday mass hours (I needed them when my grandfather was staying here and it disappointed me to no end they weren’t online anywhere). Expect bits and scraps of content added in the next couple of days and a full featured wiki (I’ll probably use MediaWiki) in a week or so.
Hope you like these two and please do tell me your first impressions-what works, what doesn’t? are these things at all helpful to you?
Better Definition Structure. Definitions are now grouped visually under grammatical category (like, say, all the definitions of the word as a noun, and then all those of it as an adverb). They’re already grouped sequentially in the original dictionary but it’s all very redundant and clumsy (every definition has the grammatical category indicated at the beginning). This is a big improvement. Try it out by searching for “correr” in both plbrs and DRAE.
Expanded Abbreviations. Most abbreviations are now automatically expanded, which works wonderfully in most cases though there are still several fringe cases like “usado o usada o usadas o usados”, which will be corrected tomorrow.
Improved the simple design. Added a “definir” button, a neat magnifying glass icon, made topbar type smaller, and chose slightly better color combinations. Moved slogan below and added a small explanatory sentence. Added Improv’dDaily and NotReality icons.
Improved status reporting. Now besides the loading image a message appears saying that your query is being searched. If multiple queries are being currently searched all of them appear in the message.
Improved Not Found message. The query you were looking for now appears on the message (duh!)—thanks chemito! Message trimmed. Added fallback link to a Google search for your query.
When people come to understand how big the universe is and how short a human life is, their hearts cry out. Sometimes it’s a shout of joy: I think that’s what it was for Jason; I think that’s what I didn’t understand about him. He had the gift of awe. But for most of us it’s a cry of terror. The terror of extinction, the terror of meaninglessness. Our hearts cry out. Maybe to God, or maybe just to break the silence.
Herbal Essences has always been one of the prettiest shampoos out there but their new color me happy line is something else. Not only is the industrial (blobjectyWP) and graphic (modern art noveau) design stunning, their personified, casual copy is like nothing I’ve seen before. Fascinating.
The others cast themselves down upon the fragrant grass, but Frodo stood awhile still lost in wonder. It seemed to him that he had stepped through a high window that looked on a vanished world. A light was upon it for which his language had no name. All that he saw was shapely, but the shapes seemed at once clear cut, as if they had been first conceived and drawn at the uncovering of his eyes, and ancient as if they had endured for ever. He saw no colour but those he knew, gold and white and blue and green, but they were fresh and poignant, as if he had at that moment first perceived them and made for them names new and wonderful.
J.R.R. Tolkien, The Fellowship of the Ring eemadge #51
Have I mentioned how much I love wet, crisp, brisk mornings?
Flickr AutoPagination has got to be the coolest Greasemonkey script I’ve seen yet, and, to judge by its code, a really intricate labor of love. It works flawlessly and does exactly what you’d guess: it makes every Flickr page (where it would make sense) “infinitely scrollable”. A cool, handy, and surprisingly stable script.