Simply Jonathan

Archive for March 2007

F8d 

Permanent location of 'F8d'

Wonderful web comic. It really is rather good.

Scripting and Talking

Dare Obsanjo‘s article, Brendan Eich on Mozilla and the Future of AJAX, has some interesting points, but this note won’t be commenting on those (although I may do so later on).

However, in the entry, the following snippet is found:

open_source + open_standards != user_driven_innovations;

Now, while I don’t have any trouble understanding Dare’s point, there’s just one little thing that annoys me with this approach: It doesn’t really make sense, from a programming perspective.

First of all, declaring the sum of two variables isn’t possible in any language I’ve ever heard of (think about it — what would be the value of each variable?). But more importantly, you can’t negatively declare a variable, meaning, you can’t define what it’s not. != is used in comparison only.

I see this rather often on IRC and such. The thinking seems to be that you can define what a value is, thus you can also define what it’s not. But that doesn’t make sense. It’s a smart ass way of intermingling programming with your writing, but makes you seem like you’re really not (smart, that is).

By all means, do define what things are not. Just don’t put in some hot shot mathematical formula, trying to look cool. You don’t.

(But again, this doesn’t have anything to do with the article itself — that’s a whole different story. Again, maybe more later.)

Football

I saw a documentary some weeks ago, about David Beckham going to LA Galaxy, and what it would take for him to succeed. There was also an interview with a guy — I don’t recall his name, but I think he was a journalist — who was confident that Becks would fail, mainly due to all the problems Americans seem to have with soccer:

  • There aren’t a lot of goals. Americans like lots of goals.
  • Soccer is played with the feet. Americans like to use their hands.

I think there was one more, but I don’t remember it, and what I want to do is focus on his second point: Americans like to use their hands. And then it struck me, only in America can a game where the only foot-to-ball contact is the field goals (and the rare use of the foot to kick the ball forward), be called football.

Information Architects Japan » iA Notebook » 10 Newspaper Myths Deconstructed 

Desktop Tower Defense 

Permanent location of 'Desktop Tower Defense'

Wow. Addictive.

Monkeypatching Beautiful Soup

Since html2css is built upon Beautiful Soup, it is relatively easy to monkeypatch it. (Especially since there is a shortcut in the code, that lets Soup objects be used directly, achieving greater speed.)

Monkeypatching BS to use html2css is as easy as this:

>>> from beautifulsoup import BeautifulSoup
>>> from html2css import html2css
>>> setattr(BeautifulSoup, 'toCss', lambda soup: html2css(soup).display())
>>> soup = BeautifulSoup('<html id="foo"><body></body></html>')
>>> print soup.toCss()
html {}

body {}

html#foo {}

 html#foo body {}

There you go. (This also illustrates an advantage of Python’s explicit self declaration, in that toCss actually takes an argument (soup), which is then used as a self-declaration, meaning that toCss can be called without arguments — otherwise, it would have been soup.toCss(soup), which really isn’t optimal.)

Karl Marx – Wikiquote 

Permanent location of 'Karl Marx – Wikiquote'

Marx quotes. Great stuff.

Karl Marx Quote

“Catch a man a fish, and you can sell it to him. Teach a man to fish, and you ruin a wonderful business opportunity.”

Lalit Dot Lab 

Permanent location of 'Lalit Dot Lab'

Brilliant. Potentially very dangerous, but indeed genious.

Extending Classes in Python

I tested today, and found that you can actually extend a class, on itself. Not just by using setattr(), but also by creating a new class:

>>> class bar:
...  def monkey(self):
...   print 'neat'
...
>>> class bar(bar):
...  def horse(self):
...   print 'sweet'
...
>>> bar().monkey()
neat
>>> bar().horse()
sweet

Again, this might be in the manual, I just didn’t know of it until some ten minutes ago.

This is Simply Jonathan, a blog written by Jonathan Holst. It's mostly about technical topics (and mainly the Web at that), but an occasional post on clothing, sports, and general personal life topics can be found.

Jonathan Holst is a programmer, language enthusiast, sports fan, and appreciator of good design, living in Copenhagen, Denmark, Europe. He is also someone pretentious enough to call himself the 'author' of a blog. And talk about himself in the third person.