OTB#59: Il conformista

The Conformist. Bernardo Bertolucci. 1970. ☐

I am not a fan of Bertolucci, so I was happy to see that there’s only one movie by him on the “Best Of” list. And this is movie of his I haven’t seen before, so that’s even better. Perhaps this one will be great!

There’s a whole bunch of impressively well-composed huge shots in here, which shouldn’t surprise me (I mean, The Last Emperor).

[time passes]

I have to admit to not concentrating 100% on this movie (the mayor here just requested that everybody stay at home for the unforeseeable future due to Corona), so I’m probably missing something. But I found this movie more than a bit confusing. I normally love movies that I don’t know where are going, or even what they’re all about… and I have no clue where this is going, and what it’s about (beyond Fascism). But there are scenes in here where I’m genuinely going “er… who… what… er…”

That may be totally my fault! Totally! I should put the laptop away and pay more attention. It’s just a bit… hard… today.

OK, I had to pause the movie for a while: The gummint had a press conference where they announced that all schools and pubs and stuff are closed immediately. And health personnel are now forbidden to leave Norway (out April). I didn’t even know that it was possible to forbid that…

“The most severe measures taken in Norwegian peace-time” I think they said. They’ve even shut down hairdressers!

Eep.

And I’m just sitting here watching movies. Doing my part to keeping us safe.

Anyway!

Back to the movie. The cinematography is great, but I have no idea whether this is a good movie or not. I should re-watch it on a less Corona day? I probably won’t, though.

This blog post is part of the Officially The Best series.

The Mysteries of WordPress

I moved to a self-hosted WordPress last week, and importing the images failed, so I had to do that manually. (That is, with rsync.)

Everything seemed to work fine, but then I noticed that loading the images of some of the older pages seemed to take a long time. Like, downloading megabytes and megabytes of data.

Time to do some debuggin’.

I’ve been a WordPress.com user for almost a decade, and I have avoided actually looking at the WordPress mechanisms as much as I can. But I did know that WordPress rescales images when you add them to the media library:

So uploading that dsc00863.jpg file results in all those different files being made, and since that hadn’t happened during my migration, I tried the Media Sync plugin, which is apparently designed just for my use case. I let it loose on one of the directories, and all the scaled images were dutifully made, but… loading the page was just as slow.

*sigh*

I guess there’s really no avoiding it: I have to read some WordPress code, which I have never done, ever, in my life. And my initial reaction to reading looking at the code can best be described as:

AAAAARGH!!!! IT”S THE MOST HORRIBLE THING EVER IN THE HISTORY OF EVER!

It’s old-old-style PHP, which is an unholy mix of bad HTML and intermixed PHP, with 200-column-wide lines. I had imagined that WordPress was … you know, clever, or something. I mean, it’s what the internet is built on, and then it’s just… this?

Anyway, I started putting some debugging statements here and there, and after a surprisingly short time, I had narrowed down what adds srcset (with the scaled images) to the img elements:

And I started to appreciate the WordPress code: Sure, it’s old-fashioned and really rubs me the wrong way with its whitespace choices, but it’s really readable. I mean, everything is just there: There’s no mysterious framework or redirection or abstract factories.

The code above looks at the HTML of an img tag, and if the class (!) of the img contains the string “wp-image-“, then that’s how it identifies the image in the database, and uses that to look up the metadata (sizes and stuff) to make the srcset attribute.

You may quibble and say that stashing that data in the class of the img is a hacky choice, but I just admire how the Automattic programmers didn’t do a standup where that went:

“well, what if we, in the future, change ‘wp-image-‘ to be something else? And then the regexp here will have to be updated in addition to the code that generates the data, so we need to encapsulate this in a factory factory that makes an object that can output both the regexp and the function to generate the string, otherwise we’re repeating ourselves; and then we need a configuration language to allow changing this on a per-site basis, and then we need a configuration language generator factory in case some people want to store the ‘wp-image-‘ conf in XML and some in YAML, and then”

No. They put this in the code:

preg_match( '/wp-image-([0-9]+)/i', $image, $class_id )

Which means that somebody like me, who’s never seen any WordPress code before, immediately knows what had to be changed: The HTML of the blog posts has to be changed when doing the media import, so that everything’s in sync. Using the Media Sync plugin is somewhat meaningless for my use case: It adds the images to the library, but doesn’t update the HTML that refers to the media.

So, what to do… I could write a WordPress plugin to do this the right way… but I don’t want to do that, because, well, I know nothing about WordPress internals, so I’d like to mess that up as little as possible.

But! I’ve got an Emacs library for editing WordPress articles. I could just extend that slightly to download the images, reupload them, and then alter the HTML? Hey? Simple!

And that bit was indeed trivial, but then I thought… “it would be nice if the URLs of the images didn’t change”. I mean, just for giggles.

This is basically what the image HTML in a WordPress source looks like. The images are in “wp-content/uploads/” and then a year/month thing. When uploading, your image lands in the current month’s directory. How difficult would it be to convince WordPress to make it save it to the original date via the API?

I grepped a bit, and landed on mw_newMediaObject() in class-wp-xmlrpc-server.php, and changed the above to:

And that’s it! Now the images go to whatever directory I specified in the API call, so I can control this from Emacs.

WordPress doesn’t like overwriting files, of course, so if asked to write 2017/06/foo.jpg, and that already exists, it writes to 2017/06/foo-1.jpg instead. Would it be difficult to convince WordPress otherwise?

No! A trivial substitution in wp_upload_bits() in functions.php was all that it took.

With those in place, and running an Emacs on the same server that WordPress was running (for lower latency), Emacs reuploaded (and edited) all the 2K posts and 30-40K images in a matter of hours. And all the old posts now have nice srcsets, which means that loading an old message doesn’t take 50MB, but instead, like… less than that…

It’s environmentally sound!

(Note: I’m not recommending anybody doing these alterations “for real”, because there’s probably all kinds of security implications. I just did them, ran the reupload script, and then backed them out again toot sweet.)

Anyway, my point is that I really appreciate the simplicity and clarity of the WordPress code. It’s unusual to sit down with a project you’ve never seen before, and it turns out to be this trivial to whack it into doing your nefarious bidding.

OTB#59: Blue Velvet

Blue Velvet. David Lynch. 1986. ⚅

I think I may only have seen this movie once before, which is odd, because I love David Lynch. On the other hand, I remember not being … thrilled? by this movie when I saw it. Which was probably on VHS in 1987 when I was 19.

What I remember from this movie is… uhm… Dennis Hopper huffing… something? And… Kyle MacLachlan… being in it? And… “Heineken? Fuck that shit! Pabst Blue Ribbon!”

I think that’s it, so I’m watching this from a pretty blank slate.

Oh! De Laurentiis produced it? I guess that makes sense, after the … success … of Dune…

Oh, Laura Dern is in this one! She’s the best American actor of her generation, so it was fun to see her finally win an Oscar this year (for the otherwise unremarkable Netflix movie she was in).

The cinematography on this movie is so weird. It’s 2.35:1, which is wider than most things, and Lynch is using a lens that’s slightly fish-eyed in many scenes (meaning that things go pear-shaped out at the edges). But even more strange is the way the edges of many of the shots fade into blackness… it’s almost as he’s hinting that behind the pedestrian suburban reality there’s… something… darker…

Is that too on the nose? Perhaps it is, but Lynch has never been subtle.

ANYWAY! This was the movie that, I guess, was Lynch’s breakthrough? He’d done the brilliant Eraserhead (but that was too experimental), and then The Elephant Man (which I haven’t re-watched since the 80s, but was a commercial success), and then Dune (which was… Dune), and then this: A movie that has “themes” that can easily be summarised as “Lynchian” (the horror beneath ordinary life)…

Watching it now, I like it a whole lot better then when I was a teenager, but I’m also… going… “is this Lynch’s least best movie?” That is, I think I like everything else he’s done better than this? And this is pretty good?

I guess my objection to this movie is that it seems to flail around a lot. Hopper’s performance is meme-inducing, and the movie seems to give itself over to that, but…

The documentary extras on the blu-ray are really good.

Today’s leftover cocktail Vieux Carré Cocktail uses a lot of leftover stuff.

I normally don’t like all-booze cocktails, but this is pretty good. I think the bitters are what make it.

This blog post is part of the Officially The Best series.

OTB#59: The Good, the Bad and the Ugly

The Good, The Bad and the Ugly. Sergio Leone. 1966. ⚄

Has anybody remarked on the similarity between the first trumpet thing (mow mow moooow) in the theme song and the Sad Trombone thing?

No?

Anyway, this is the first Leone movie in this blog series, and it’s a movie I’ve seen a couple times before. But probably on VHS in the 80s. And then possibly at the Cinematheque in the 90s?

Oh right! This is the movie that Big Audio Dynamite sampled for their Medicine Show:

It’s very hard not to be charmed by this movie. It’s got a boyish mischievousness that’s off the scales. And it looks fabulous, of course, using the wide widescreen to great advantage. The sweaty closeups are iconic. But…

It does go on for longer than you’d expect. It’s a pretty simple story, but Leone goes for Epic Movie, and it’s not a bad sleight-of-hand.

One thing this movie has going for it is a sense of timelessness. I mean, if you watch American western movies from this period, there’s always something that screams 60s: A way of doing makeup; the hair styles; the jargon. And, sure, this couldn’t have been made any other time, but it’s less obvious.

It’s an oddly apolitical take on the US civil war. It’s got the “war is stupid” thing going on, but nothing about what was at stake.

The 2K restoration job here is pretty spiffy.

I’m watching the documentaries included on the blu-ray… and it turns out that they’ve done the restoration based on the Italian cut. Which was longer than the US cut, which means that Clint had never done those lines. So they got him in (in 2002) (and Eli, too) to do those lines now.

That’s way beyond the call of duty for a restoration, and it’s seamless here.

But the restoration guy has also put in offcuts that had also been cut from the Italian version, and one of the scenes (in the cave) I can totally see why they took out. So… this isn’t perfect.

I’ve been lax in doing cocktails for this blog series, because… I didn’t want any cocktails. But time to get back on the horse again with this Singapore Sling (Dale DeGroff’s recipe).

Oops. I didn’t have pineapple, so I substituted … orange.

It’s fine.

This blog post is part of the Officially The Best series.