Archive for December, 2006

Patches for WP-Cache

Sunday, December 31st, 2006

UPDATE 4:45: Ricardo Galli, the author of WP-Cache, has accepted my patches and released WP-Cache 2.0.20 incorporating them (along with one other fix).


I use the WP-Cache plug-in here on the blog in case that anything I post here should get dugg/linked-listed/reddited/etc. Over on Jeff Johnson's blog, Scott Stevenson says:

… Vienna … seems to get confused on these:

  • feed://boredzo.org/blog/feed/atom/

This prompted me to run my Atom feed through the Feed Validator. It mentioned that I was using the “copy” named entity reference and that that was undefined; that was easy enough to fix. It also mentioned that my feed was being sent as text/html.

Wait, what?

Sure enough, curl -D /dev/stdout -o /dev/null revealed that my feed was being sent as text/html; charset=utf-8. I looked in wp-atom.php (I use Jeff Johnson's Atom 1.0 version, in case you're wondering), and saw that it was indeed promising application/atom+xml. Funky.

I did something or other to wp-atom.php, then reloaded the Feed Validator. Imagine my surprise to discover that — in addition to still saying text/html — it still had the “copy”-entity-reference error!

Then I remembered that I use WP-Cache, so it was retrieving a cached copy of the feed. So I went to the WP-Cache Manager and dropped the cache. OK, curl says application/atom+xml now, so I went back to the Feed Validator.

Still text/html!

I tried curl again. Sure enough, it was back to text/html. WTF?

I also noticed this other symptom: When I loaded it freshly after dropping the cache, it had a bunch of headers like “Cache-Control” and “Expires”. I didn't know those were there. When I loaded it again (from the cache), those headers — among others — were missing.

The verdict was clear at this point: WP-Cache was eating my headers.

Further investigation confirmed the diagnosis, and several hours of even further investigation revealed the nature of the bugs (plural) that resulted in it:

  1. WP-Cache wanted to retrieve the headers from the response in order to cache them, but the function that it was using to do that (apache_response_headers) didn't exist, so it (correctly) skipped over all of that code. I added code to make it use headers_list when apache_response_headers isn't available.
  2. Even after I did that, WP-Cache didn't actually store its shiny new headers anywhere because it had not yet created the description object to put them into.

I have filed two tickets, each with a patch. I'm running with both patches now, and I provide the links to them so that you may run with them too. (The second patch fixes both of the problems above; the first patch is for an unrelated bug that I fixed while I was there.)

Keynote Bingo sneak preview

Friday, December 29th, 2006

Here's a sneak preview of the MWSF 2007 Keynote Bingo card, which I'm still working on.

The bingo card with none of the strings shown yet. New font: Bitstream Vera Sans, in place of Optima.

Changes:

  • The new font for headings, instructions, and the “Made in the USA” tag is Bitstream Vera Sans, replacing Optima from the previous Bingo.
  • I replaced the word “FREE” in the center with a star on an 80%-white background.

  • You'll be able to enter any seed value of your choice. This is so that John Siracusa can distribute cards 1–n (for a value of n of his choosing), if he wants to. It'll also make it easier for winners, if any, to tell others what cards they won on.
  • There'll be an app that will let you enter the seed value, so that you can reproduce somebody else's previously-generated card. You'll also use this app to generate a card randomly (using the current time as the seed). In either case, the seed value is printed on the card.
  • You'll no longer be required to have the disk image mounted when you open the card in Preview. The app will take care of being in the right directory when it converts the EPS files to a PDF.
  • If I have time, I may do a Windows version: EPS only, no app. Obviously, this means that Windows users wouldn't be able to use a seed value of their choosing; it would be hard-coded to use the current time. Consider it a downside of not being on a Mac. (Or, feel free to write your own app using the same EPS files. It'll be the same BSD license.)

I'm open to suggestions for new and different header graphics, and my call for strings still stands — I'll be doing the strings last, so you still have time to think of predictions (serious or humorous) and either post them in comments on the call-for-strings post or email them to me directly.

Keynote Bingo: Call for strings!

Sunday, December 24th, 2006

I'm working on the new Keynote Bingo for MWSF 2007. It'll be a little different this time, with an actual app that lets you enter a specific seed number for the PRNG.

Other than the “iPod phone” and the “Illuminous” UI replacement for Aqua, what do you think may be announced in the MWSF 2007 keynote? Some degree of fancy/humor is welcome, but I do want to keep it mostly grounded in order that, maybe, we should hear a “Bingo!” on the live stream. ☺

(I do request that if anybody yells “Bingo!”, that it should be the last “Bingo!” for that keynote. Once is amusing; twice is pushing it; any more than that is simply disruptive. Let Mr. Jobs give his keynote address in peace.)

Feel free to post your suggestions in the comments, or if you'd rather suggest something anonymously, by email. I will list your name in the credits in the Keynote Bingo app unless you tell me otherwise.

Questions on a test

Wednesday, December 20th, 2006

As work on the Negative Turing Test WordPress plug-in progresses — currently, the Options panel should work, though I haven't had the opportunity to test it yet — I find myself wondering what would be a good challenge to which commenters must respond.

Here's my current front-runner:

The eighth word in this sentence is wrong. Change it to be right.

Any other suggestions?

John Hodgman’s new book, free on iTunes

Tuesday, December 19th, 2006

The Areas of My Expertise by John Hodgman (aka a PC, aka The Daily Show's resident expert), read by the author. All six hours, 58 minutes of it. Free.

Plugging the comment spam inlet

Saturday, December 16th, 2006

I'm going to be working on the comment spam problem today. Attempt #1 is adding a Turing test to the comment form; you might not be able to comment while I'm debugging it. I'll update this post when it's all working.

UPDATE 2006-12-16: I've decided to host the project for attempt #1 at Google Code. It's called Negative Turing Test. You'll be able to get the fruits of my labor when it's done, and you can watch me work on it in the Subversion repo. (And yes, that means that I'm not debugging yet. You can still comment for now. ;)

One month of spam

Thursday, December 14th, 2006

“Comments in moderation: 2,920”

As measured from 2006-11-14T12:33 to 2006-12-14T12:44. I now have the fun of deleting them all.

UPDATE 2006-12-15: As of the end of -12-14, it was 3,268.

And in case you're wondering, not one spam made it to visibility, and not one legitimate comment was blocked. This is because I use the Comment Authorization plug-in for WordPress. Despite its disclaimers, it works just fine for me on WP 2.0.4. (And in case you're wondering what happens if somebody doesn't supply an email address: I get to approve it myself. It's rare, though.)

UPDATE 2006-12-16: OK, not quite. I just got done scrolling through the moderation queue to double-check that there were no legitimate comments in it (in preparation to delete them all), and I did find exactly two real comments being held there. One had no real email address associated with it; I don't yet know why the other one (the first comment on this post, in fact) wasn't approved. It may simply be that Mike had not yet received the self-authorization email in the time that the 370 comment spams after it came in. I wasn't looking at timestamps. ☺

Now I get to look into ways of stopping the spammers from even getting into the queue. I'm thinking of a JavaScript that dynamically changes the action of the form, or a reverse-CAPTCHA that makes you delete some text.

Any other suggestions before I start hacking?

Screencast codec showdown

Friday, December 8th, 2006

So I'm looking at making some screencasts in iShowU. I noticed that, thanks to QuickTime, it supports rather a lot of codecs:

iShowU's codecs pop-up menu, showing 29 different codecs of various suitability.

Dizzying, isn't it?

So I asked the Goog about some of the codecs, and also more generically about screencast codecs. H.264 is a popular choice, but I found no comparison to other codecs nor any discussion of what any of the codecs is particularly good at.

I also had a small amount of previous experience with the difference between codecs. I've watched two of rentzsch's screencasts: “Introduction to Core Data” and “Embedded Cocoa Frameworks”. The former is 1024×768 using H.264; the latter is 800×600 using Sorenson 3. “Introduction to Core Data” looked flawless; “Embedded Cocoa Frameworks”, OTOH, had noticeable artifacts. I wondered at first what the difference was, and after I found out, whether there wasn't a better codec with which to implement screencasts.

Part of the problem is that there really isn't a codec that's been well-optimized for screencasting. Video codecs have historically been optimized for, well, video — that is, video shot with a camera. Screen images usually don't change much except to follow mouse movements; a compressor specifically optimized for recording the screen should make a big difference in screencast file sizes. Are you listening, Apple? (Or Ambrosia?)

Anyway. In order to find the perfect (so far) screencast codec, I recorded a brief screencast using iShowU in demo mode using the None (no-compression) codec, and used QTAmateur by Michael Ash to export it to all the other codecs.

The results? Well, you'll just have to read the screencast codec showdown for yourself. ☺

Compiling EPS files to PDF files using Xcode

Wednesday, December 6th, 2006

You may remember Daniel Jalkut's blog post about resolution independence, with its demonstration of the superiority in quality of vector graphics over raster graphics (using an EPS file that I created for him ☺).

The problem with using an EPS file, as I pointed out to him when I emailed him the file originally, is that EPS files are very slow on OS X. The current (Tiger) implementation of NSEPSImageRep uses Quartz's CGPSConverter to convert the EPS data to PDF data, then instantiates an NSPDFImageRep (kept in a private ivar) that it has do all the real work.

That PostScript-to-PDF conversion is the bottleneck. You don't want that multiple-second delay (yes, really) at runtime. Better to take it before runtime. At the time, I suggested that he use pstopdf to convert to a PDF file, then put the PDF file into his Xcode project to be copied into the app bundle.

But what if you decide later to change the PostScript file? You need to remember to run pstopdf again. EPS files are just PostScript source code, so why not treat them like any other source code file? Or, a better question: How?

The answer is quite simple: Add a custom rule to your target in Xcode that runs pstopdf over EPS files. Then, you add the EPS file — not the PDF file — to the project, and Xcode will exhibit normal build-only-when-necessary behavior on the EPS file and copy the generated PDF file for you. And of course, you can have as many EPS files as you want — they're source code files just like any others.

Screenshot of Xcode's Target Info window, showing the custom rule. The rule matches the glob pattern “*.eps” and runs the shell script “pstopdf ${INPUT_FILE_NAME} -o ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.pdf”. It has one output file, which is “${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.pdf”. In the background is an Xcode project window showing a couple of EPS files in the “Other Sources” group.

Whaaat?

Wednesday, December 6th, 2006

The Independent, “A guide to email etiquette”:

When John Debrett founded his eponymous toffs' "Bible" in 1769, he didn't have to contend with such modern delights as the e-mail, text message and video-conference. Yet if the legendary expert in Georgian manners had been born 250 years later, you get the feeling that he'd have used digital technology in the nicest possible fashion.

No, he'd be using holographic technology. 1769 + 250 = 2019.

With this in mind, the publisher of Debrett's Peerage and Baronetage has dragged itself kicking and screaming into the 21st century…

Would someone please explain how it is possible to drag oneself kicking and screaming?

(That part is what the title refers to. It was originally the entirety of this post, before I realized that the entire article was worth fisking too. ☺)

For longstanding Debrett's readers, who might normally use the book for advice on addressing the wife of a son of a baron, it is likely to be quite an eye-opener.

How can it be an eye-opener if for it to open your eyes, you must read it, and you cannot read anything without your eyes opened?

Next to a chapter on how to address a King or Queen ("Your Royal Highness" for the first time and subsequently "Sir" or "Ma'am" as appropriate) lies a beginners' guide to text-messaging: "A quick and efficient method of communication, usually sent from one mobile phone to another."

This is one poorly-organized book.

The advice offered by Debrett's covers everything from the mundane to the potentially explosive.

Do not bring this book onto an airplane.

Compact archives view

Monday, December 4th, 2006

This blog post about a corrupted Address Book came up on rentzsch's del.icio.us. While I was there, I noticed this awesome archives view at the bottom:

One row for every year, with every column being a number in the range [01–12].

I might adapt that for use on my own blog. I'm thinking maybe in my sidebar, with three-rows-of-four per year.

Way to go, Walt Dickinson.

Wanted for abuse of operators

Saturday, December 2nd, 2006

From the stock app delegate in Apple's Core Data application template:

[managedObjectContext release], managedObjectContext = nil;
[persistentStoreCoordinator release], persistentStoreCoordinator = nil;
[managedObjectModel release], managedObjectModel = nil;

And in case you were wondering how Apple could possibly ship code that doesn't even compile in the app templates…

… that's legal code.

Yes, there is a comma operator, and that's what's at work there. There is a warning (-release returns void, whereas assignment of nil returns id, so the types are mismatched, which GCC doesn't like), but the code is legal.

Legal doesn't always mean correct, however. The comma operator is supposed to be used for things like this:

printf("%s\n", (-‍-argc, *++argv));

Though in modern usage it is out of favor, replaced on sight with less obfuscative code:

printf("%s\n", *++argv);
-‍-argc;

printf("%s\n", argv[idx++]);

It is not for performing a void function call followed by an assignment. A void expression should never appear in a comma expression. The code would be greatly improved by replacing the comma with a semicolon, dividing each statement into the two statements that it should be.

Instant replay in iTunes

Friday, December 1st, 2006

While flipping through Michael McCracken's blog, I found his blog post about his instant replay in QuickTime Player script, and decided that that would be a good thing to have in iTunes (especially when I want to quote some George Carlin to somebody).

So here it is. It's in source-code-only format; you should probably compile it using Script Editor before using it. It uses iTunes' own rewind function, which will jump back four seconds; play with the “delay 0.1” line if you want to jump back farther. I bound it to ctrl-⌘-⇠ using Quicksilver's Triggers feature.

SketchFighter 4000 Alpha

Friday, December 1st, 2006

First, despite the name, this apparently is a regular release. The Get Info string says it's version 1.0.0 — no alpha there. The name of the game is “SketchFighter 4000 Alpha”, in a misplaced attempt at increasing the whole sci-fi-ness of it.

Second:

Save points must die.

Seriously. Every game that has save points can be massively improved by replacing them with a “Save game” command in the menu.

Third, the save games are next to useless. They save your last location, but not the deaths of all the enemies and objects you've blown up. So when you restore, SURPRISE! All your enemies have come back from the dead, and they're understandably pissed.

And fourth, a note to all game developers: Please ship your games set by default to windowed mode, not full-screen. Nobody has a CRT anymore, and nobody has an LCD with a native resolution of 800×600 anymore. More to the point, maybe I don't want to start right into your game right away; I'd like to go through the Options first, and as long as I'm doing that, there's no reason for me to not to have my email and IM windows visible.