Selected movie recommendations

I watched a lot of films in 2007-2009. Here are some of my favorites from that time. I tend to like films that fully exploit the visual capacity afforded to film, or those that show me things beyond my imagination.

Taiwan
Millennium Mambo (2001). It’s an allegory, so you may want some background information before or after watching.
Crouching Tiger, Hidden Dragon (2000)

Korea
The Housemaid / Hanyo (1960)
3-Iron / Bin-jip (2004), and Kim Ki-duk’s other films if you get hooked.

Japan
Ran (1985). Criteron’s DVD commentary recommended.
Ghost in the Shell (1995). This made more sense after I watched Stand Alone Complex.
All About Lily Chou-Chou (2001). A second viewing may be required, due to the film’s structure.
The Great Happiness Space: Tale of an Osaka Love Thief (2006). It’s an unusually honest documentary about a completely alien world.
Battle Royale (2000)

U.S.
Lost in Translation (2003)
Network (1976)
Days of Heaven (1978)
The Triumph of the Nerds: The Rise of Accidental Empires (1996)

France
Le samouraï (1967)

Australia
Picnic at Hanging Rock (1975)

Other
The Holy Mountain (1973). Jodorowsky’s DVD commentary is practically required.

Want to discuss or have recommendations? Email me or leave a comment.

JavaScript’s sort: wonders never cease

>>> [1, 2, 10, 20].sort()
[1, 10, 2, 20]

>>> [3, "3", 3, "3", "3", "3", 3, 3, 3].sort()
["3", "3", "3", 3, 3, 3, "3", 3, 3]

The above was tested in Chrome 5. Sort varies by browser. Bedtime reading: ECMA-262 15.4.4.11 Array.prototype.sort(comparefn)

Don’t use from __future__ import division

tl;dr: For maintenance reasons, just float() one of the values instead.

Don’t use from __future__ import division. Consider these two cases:

1) You’re moving a block of code from a file without “future division” to a file with “future division”. You forget to change all of the /s to //s, and are screwed (because you have incomplete test coverage). Or maybe you’re moving a block of code the other way, and similarly forget to change things.

2) You have a module with from __future__ import division, but all division operations were removed in an earlier commit. Can you now remove the from __future__ import? Maybe not, and you might keep them forever, just in case there are outstanding patches to the module. But not everyone will follow that logic.

Summary: subtle global behavior mutation is bad, even if scoped to a single file.

(Consider ignoring all of this if you’re developing for both Python 2 and Python 3.)

Found an answer, left the conversation

I have had this experience several times in my life; I come across clear enough evidence that settles for me an issue I had seen long disputed. At that point my choice is to either go back and try to persuade disputants, or to continue on to explore the new issues that this settlement raises. As Eliezer implicitly advises, after a short detour to tell a few disputants, I have usually chosen this second route. This is one explanation for the existence of settled but still disputed issues; people who learn the answer leave the conversation.

Robin_Hanson2 (is it Robin Hanson? I don’t know.)

Python < 2.5 and unicode/str comparisons

Comparing strings to unicode objects should have never been possible, but it does “work”, and you’ve probably seen this behavior in Python 2.5 – 2.7:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
>>> u"\xff" == "\xff"
__main__:1: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
False

To do the comparison, Python calls unicode() on the str object behind the scenes, and if it cannot decode it, it emits a warning and returns False.

If you’re still maintaining software that must run on Python 2.4 (or worse), you might run into this old behavior:

Python 2.4.6 (#1, Aug 2 2010, 18:27:11)
>>> u"\xff" == "\xff"
Traceback (most recent call last):
  File "", line 1, in ?
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)

Also, if you’re writing tests that involve this, keep in mind that Python 2.4 does not have a UnicodeWarning.

(After I wrote this, I found that it was documented in What’s New in Python 2.5.)

Blizzard annoyances

If you use Blizzard Downloader, you might see:

“There was a problem authenticating your download. Please go to http://www.blizzard.com/account to start a new download”

One of the reasons you might see this is this (see others): when you download the downloader, Blizzard embeds your IP address into the executable, and only lets you start the download from the same IP. This is terrible software design, and completely unnecessary to stop bandwidth leeches: just embed a unique key into the executable, and ignore the IP address.

A language quirk

Let’s say you’re writing some documentation, and need to point people to a comment on a web page. Keep in mind that more comments may be added at any time. If you need to point people to the second (or third, or fourth, etc) comment, you have an easy time; you just say:

“See the second comment on <X>”

But if you need to point to the first comment, and at this time there is only one comment, you need to sound like a pedant:

“See the first (and possibly only) comment on <X>”

In English, “the second object” does not imply that more objects exist, but “the first object” does imply that more than one exists. Why would you have written “first” if there’s only one? If you wrote just “see the first comment”, and the reader saw only one comment on the page, they might wonder if a comment has been deleted, or if they’re even in the right place. If you wrote “see the only comment”, and soon another comment appeared, you would cause similar confusion.

I don’t expect this to catch on, but with a new word we can express doubts about the existence of more than one object:

“See the firsteth comment on <X>”.

If anyone out there is designing a human language, please make it easier to express things about changing environments.

Clock jumps and browsers

If you’re trying to build reliable web applications, you might have wondered what happens to existing timeouts and intervals after the system clock jumps. Not that clock jumps happen very often, but it’s nice to think of setTimeout(func, 0) (or similar) as a reliable abstraction. Unfortunately, it isn’t. See Clock jump test page for the results of my testing, or to do your own tests.

In some browsers on some OSes, if the clock jumps backwards, an existing timer might not fire for a long time. If the clock jumps forwards, an existing timer might fire too early, possibly causing misbehavior if you were relying on a correct time duration.

A summary of the test page: IE and Opera on any OS use the monotonic clock to schedule timeouts. Firefox on Windows uses the monotonic clock, but a setInterval timer is broken after a backwards clock jump. Every other OS/browser combination schedules by the system time, or behaves strangely when the time jumps.

Here’s the bug for Chromium, but a lot more bugs need to be filed.

Subscribe to a Google Group with your non-gmail email

You can subscribe to any Google Group with your non-gmail email. If you try to subscribe through the web interface, you’re typically forced to use a gmail account. The solution is quite simple, but few people know about it.

For a Google Groups group, send an email to groupname+subscribe@googlegroups.com.

For a Google Apps group, send an email to groupname+subscribe@domain, for example, chromium-dev+subscribe@chromium.org.

You’ll receive a reply if you’ve successfully subscribed. Note: when I did this, my first email to a +subscribe@ address was delayed by ~10 minutes.

Reference: How do I subscribe to a group?

Monoclock: Access the monotonic clock from Python

Python’s time.time() jumps around if the system time changes. The monotonic clock doesn’t, and climbs steadily upwards. Unfortunately, Python doesn’t give you easy access to the monotonic clock. A 50-line Python module may help you out, at least if you have a POSIX-like OS that has librt (I tested only Linux).

git clone http://ludios.net/git/Monoclock.git

Let me know if it works, or doesn’t. Please contribute, especially if you’ve implemented Windows or OS X support.