wp make-wxr

As part of my day job, I’ve lately been looking at trying to improve the performance of WXR imports into WordPress.com. This has meant, so far, lots of testing and profiling of code, and it’s meant my wanting to be able to generate export files that meet particular criteria.

For example, one useful test is to repeatedly import a file that contains 1,000 posts so that you wind up with a benchmark for how long it takes on average to pull in that many posts (so that you can try to make that number consistently lower). Not everybody has a test site with exactly 1,000 posts in it, and it’s sure no fun to manually generate that test data.

For another example, say you’re trying to understand what impact taxonomies have on import sluggishness. The WXR file lists tags and categories near the top of the file and imports them all at the beginning of the process. Then it associates terms with posts as it imports the posts later. In order to understand how the taxonomy import performs, it’d be useful to have a WXR file with exactly 500 tags for that initial import, with a few randomly assigned to the posts.

And say you wanted to learn how comments get bogged down. It’d be handy to be able to easily import a single post that had a great many comments, or to import many posts with either few or many comments each.

Enter make-wxr, a wp-cli command I wrote to help me generate just these sorts of WXR files on demand. Now, by typing a simple command into my terminal, I can instantly have a reasonably customized WXR file for testing various trouble spots in the WordPress importer.

After some initial skepticism, I only recently started using wp-cli as part of a big data migration, and now I’m a pretty big fan of the tool. My little command here is just a brand new baby, conceived and born within the last couple of hours. I already have some ideas for improvements (though probably not much time to implement them, since the itch I was scratching by writing this is now scratched). If you’re a developer who works with debugging WordPress with data of varying sizes and characteristics, maybe the new command will be useful. (If you’re a theme developer, you should use the standard WXR file, since it covers lots of test cases like long titles, menus, etc.)

Lisbon

I’ve just returned from meeting up with some coworkers in Lisbon, Portugal. It’s the prettiest city I’ve been to. I loved how the terra cotta roofs contrasted with the colors of the buildings, the greenery, and the sky.

It’s a pretty easy city to get around in. Taxis are surprisingly cheap and the drivers actually give you change, though they often seem not to know where your desired location is until they have an epiphany partway there. You tell or show them the address and they more often than not give you a long puzzled look. Occasionally they’ll consult a book that helps them out. Then they tear ass toward your destination, whipping around the streets, tailgating trolleys, and narrowly avoiding pedestrians. In spite of apparent confusion and the distinct impression that the drivers are just wandering to find the place sometimes, the fares still wind up being cheap. The ride is also generally somewhat Mr. Toad’s Wild Ride-ish.

We went to the aquarium, which was pretty nice but which I didn’t bother to take many photos of thanks to lighting and the sort of universality of aquariums. We also went to the Castle of São Jorge, which was really neat. After wrapping up at the castle, several of us wandered the old city for a few hours. Near the end of the trip, I stopped by the Estrela Basilica just a couple of blocks from our house, but I took no pictures of the interior because it was quiet and being an obnoxious American tourist there felt inappropriate. It was beautiful inside but also seemed somehow more used, more dingy, than some similar buildings I’ve visited.

We ate at several pretty good restaurants that were mostly reasonably priced. Cod is the thing to get if you’re into fish, though I heard from a native that they import most of their cod from Norway. Wine is absurdly cheap and pretty good. We bought plenty of bottles of utterly decent wine for two to three Euro each (less than four bucks).

Jerusalem

I visited Jerusalem on a recent trip with coworkers. Although I’m not religious, it was still a neat experience. Lots of history. My photos follow.

The Dead Sea

Some coworkers and I went to the Dead Sea while on a team meetup in Israel. My lower body’s too dense to float under normal circumstances (my legs just sink… like… stones), but I was assured I’d float here. And I did! It was such a funny sensation to wade out, squat, and feel my body rotate backwards as my legs sprang involuntarily up to the surface of the water.

The floor of the sea is covered with really goopy, dark greenish mud, and people actually rub the mud on their skin for (I presume) restorative purposes. I opted not to and didn’t think to get a photo. I did sink into the muck nearly up to my knee at one point.

As I was walking (more like stumbling) out of the water, I found a rock that had a bunch of salt crystals growing like gems on its surface. I also neglected to get a picture of this.

Luckily, I had no major flesh wounds on our visit, but I’m told the water really stings even minor cuts. I did have one little spot on my neck that burned just a tad, and although you’re discouraged from drinking the water or even getting it on your face, I ventured to lick my finger and found that the water burned my tongue.

Once we had our little swim (more of a bob), we showered off a little (an outside shower, no soap, just a rinse), but my skin felt horrible all the way home, as if I had gone for a week at the beach with no shower.

It was a really neat experience, definitely worth it if you’re in the neighborhood. It took us around two hours to drive back to our villa in Herzliya (near Tel Aviv), which is on the other side of the country from the Dead Sea. While in the sea, we could see Jordan across the way. I suppose we might have swum over for a visit, but the caretakers of the beach we went to had cordoned off an area for swimming, and I don’t imagine we could have gone  under the thing to swim outside it (seriously).

Jaffa

This week on a trip to Israel for my job, I went with my coworkers to the port of Jaffa. You may recognize the name as the city from which Jonah is supposed to have left on his fateful voyage. It’s also the city in which Andromeda was chained to a rock in sacrifice to a sea monster only to be rescued by Perseus. It was a neat place to visit.

Colorized Svn Diffs in Sparrow

For a year now, I’ve had mail forwarded from my work email to my personal so that I could check mail in only once place. With some vacation on the way and not wanting to have thousands of messages keeping me from efficiently checking personal mail via my phone while computerless for a week, I decided to split the accounts back up. But I don’t want to have to check two accounts for mail on a daily basis, so I wanted to use a mail client. I had been using Sparrow to check mail on my phone and liked it quite a bit. This morning, I downloaded the app for my computer and also gave Thunderbird (which I used for years) another quick spin.

Well, I’ve become such a junkie for the Gmail way of doing things that using Thunderbird’s just not tenable. It feels like I’m using a TRS-80 or something, and the lack of threading by default (maybe you can get an extension to handle it) made me cringe. Sparrow provides a much nicer user experience and handles the threading beautifully, but it doesn’t do anything smart for colorizing svn diffs, which I’ve written about before as a problem with the default Gmail experience.

I decided to see if I could fix this, and it turns out that you can. Just go into /Applications/Sparrow.app/Contents/Resources/conversation.css on your Mac and add these lines to the bottom of the file:

ins { background-color: #cfc; text-decoration: none; }
del { background-color: #fcc; text-decoration: none; }

Then restart Sparrow. You’ll have lovely green and pinkish diff lines rather than impossible-to-read underlined text. Of course, I don’t imagine this’ll survive any software updates (or at least any that touch the css file — I’m not sure whether Sparrow does partial/differential updates or not), so chances are that this’d need to be reapplied after any update, hence my storing the fix here for my future reference.

UPDATE: I tried this fix with the free version of Sparrow. Since I like the software so much, I decided to help fund it by paying the $9.99 to support it. A nice side-benefit of paying is that the ads that appear in the free version to support it go away. Unfortunately, so does the ability to hack the CSS. When I modify the CSS in the paid version, it crashes on startup. I guess there’s some kind of checksumming going on or something. So for now, I’m back to using the free version with the svn diff colorization and an ad. I’m happy still to have supported development on the project but do wish I could use the premium version with my custom CSS.

Custom Feed Links in WordPress

At a WordPress meetup tonight, the question arose of how to override default feed links for a WordPress site. For example, what if you’re using FeedBurner and want to just change the links in your source to the relevant FeedBurner links without hacking your theme? I don’t know if it’s the best way, but it looks like this is pretty easily done with a plugin that, in its simplest form, looks like this:

<?php
function feedme_remove_feed_links() {
        remove_theme_support( 'automatic-feed-links' );
}
add_action ( 'after_setup_theme', 'feedme_remove_feed_links', 11 );

function feedme_add_feed_links() {
?>
<!-- CUSTOM FEEDS HERE -->
<?php
}
add_action( 'wp_head', 'feedme_add_feed_links' );

Of course, you would need to make the feedme_add_feed_links() function do something a bit more useful, and in an ideal world, you’d provide an admin screen that allows people to specify their links.

One important detail that may not jump out at you is that when adding the “after_setup_theme” action, you need to give it a priority higher than 10. Else it just goes into a stack with all other of its sibling actions with the default priority and may be (in fact seems to be) overridden by one of them.