Virtual Multiblog and .htaccess


I had problems with permalinks and Virtual Multiblog (yet another linky), basically that for every wordpress instance I added I would have to add another set of permalink-related Apache Rewrite rules to prevent individual entries 404-ing. This was fragile and prone to failure. Fortunately, there is a Proper Way To Do It:

RewriteEngine On
RewriteCond %{REQUESTURI} (/blog|/news)?/
RewriteCond %{REQUEST
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . %1/index.php [L]


From the readme. Lovely.

ScribeFire’s Arrow Keys Don’t Work

This post is composed within ScribeFire, the blogging extension thing for Frirefox (et al). And I can’t edit posts easily because using the arrow keys causes a blank javascript:; to fire. Bloody useless. Searching for solutions gets a lot of complaints (eg this chap), but not much at the root of the matter.

A workaround is to edit in plain mode. Solution to be posted if I find one.

Update: Turns out trying to post a video to a tumblr blog froze up ScribeFire real good. This doesn’t help with the original problem, it’s just more fuel for the (Scribe)Fire.

Update 2: Arrow keys work in rich text editor when I install ScribeFire as an addon for my Portable Firefox install (for Windows, arrow key troubles are under Linux). There are certainly a few issues raised on the posting for the last release, dated November 2011 (!)

[Solved] Could not create java implementation loader / No JRE Found

After installing LibreOffice Portable (from here), I tried to install the Google Docs Sync extension, ooo2gd. However, installation failed with the error message “Could not create java implementation loader”. There are many posts about this, most of which suggest either

  1. disabling, then re-enabling “Use a Java runtime environment” on the Tools > Options > LibreOffice > Java menu page
  2. Deleting a user profile

That didn’t work in my case because that menu page had no JRE listed, in spite of me installing the latest JRE from (at time of writing JRE 7). What sorted it was installing the last version, which is confusingly also called the latest, recommended version (Version 6 Update 27 at time of writing). I got it from here: After installing it appeared in the JRE list on the Java options page in LibreOffice and oo2gd installed correctly.

Solved: No Files In MPD (eg mpc ls)

I was doing my initial “is it working?” tests after reinstalling mpc, and mpc ls was not giving me any output. ncmpc was also showing no files. What I didn’t appreciate was that the music database is no populated by default- you have to issue an “update” command manually (or semi-manually by running a client that issues the command for you).

mpc update

and your directories should be searched!

TF2 Connection Problems Persist

Team Fortress 2 has recently gone free to play, which I am guessing has resulted in a big spike in players (it is currently the most played game on Steam, with a peak of nearly 100 000 players today – no doubt it was busier at the weekend). As a result, my old post on fixing the “lost connection to server” issue has been very popular in the last few days.

I find it surprising this problem has persisted for over three years without apparent resolution. The fix that worked for me on my old BeBox was to forward to following ports to my PC:

TCP 27030 – 27039
UDP 1200
UDP 27000 – 27015

If this doesn’t fix the problem, there may be complicating factors. I’ve seen suggestions that the TCP timeout on a router may be set too low. I have a feeling that this may be what is causing connection problems a friend of mine is having, but since it does not affect me I haven’t investigated further. Wireshark would probably be useful if you wanted to probe further.

You can also take a look at my old post if you want more information.

Sort a List By Length and Alphabetically Using jQuery

A fairly common problem in jQuery is to sort a set of elements eg a list of <li>, and most examples I came across seemed to offer pretty decent solutions – provided you want to sort alphabetically. If you want to do this in a number of ways, then tinysort is a great way of doing it.

I wanted to sort a list of links by length for aesthetic purposes, eg

sort by length | sort alphabetically

It turns out there isn’t an iron-cast way of doing this. If you go by length of the text of each <li>, you potentially run into problems with variable-width text, where links with more letters appear shorter than links with fewer but wider letters. I then tried the width of the <li> elements, but being block elements (in my case) they all had the same width. The solution that eventually worked for me was to compare the widths of the <a> child element of each <li>. This took a little bit of experimentation with the selectors and iterator functions as I’m not that familiar with either jQuery or javascript. I based my code off code for sorting a list by Dan Sargeant of one more take, so thanks Dan!

I packaged my code up into a function (well two, as I used the alphabetical sort too) which takes one argument – the selector object representing the parent <ul> or <ol> that is to be sorted. Please adapt the code to your own needs, as it may well not work as is! (ie works for me, YMMV, etc)

function sortbylength($elements) {
        var listitems = $elements.children('li').get();
        listitems.sort(function(a, b) {
                var compA = $(a).children('a').width();
                var compB = $(b).children('a').width();
                return (compA < compB) ? -1 : (compA > compB) ? 1 : 0;
        $.each(listitems, function(idx, itm) { $elements.append(itm); });

function sortbyalpha($elements) {
        var listitems = $elements.children('li').get();
        listitems.sort(function(a, b) {
                var compA = $(a).text().toUpperCase();
                var compB = $(b).text().toUpperCase();
                return (compA < compB) ? -1 : (compA > compB) ? 1 : 0;
        $.each(listitems, function(idx, itm) { $elements.append(itm); });

Show Progress Bar During dd Copy

There are a number of ways of showing the progress of a dd copy. The easiest is sending the USER1 signal to the dd process, like:

dd if=FILE1 of=FILE2
pkill -USER1 dd

But that only gives a current status – eg 12345678 bytes transferred (11.77MB) … [8.56MB/s]. Not that helpful if you want an ongoing update. You can make it periodic by using the watch command:

watch -n 10 pkill -USR1 dd

Still not perfect. If you want a progress bar, ETA and so forth, you’re best off using pv, a utility that measures the speed of a file through a pipe. If you don’t know what that means, I’d recommend reading up on the UNIX philosophy and pipes, but basically it means you can tell what dd is doing. Use it like so:

pv FILE1 | dd of=FILE2

For my use, backing up a 500GB hard drive that I use with a NAS (an NSLU2 I’ve probably mentioned before), I used the following command:

sudo pv /dev/sde3 |dd of=~/tera/nslu2.img

/dev/de3 is the data partition on the drive
~/tera/nslu2.img is the image file I want written to a terabyte-sized hard drive, mounted at ~/tera/.

As a post-script, the reason I’m backing this drive up is my nslu2 is failing weirdly. It was running without a hitch for years, then it without apparent warning dismounted the drive in slot1 and reverted to running from flash. I only figured that out as I had to log in with an old password. Trying to start it up results in it beeping once every minute or so, with the ready status lamp flashing orange. It seems to go through a loop. I thought it was a temporary glitch, as when I plugged the drive into my desktop to check the thing was intact the partitions showed up, then when I plugged it back into the nslu2 and turned it on it worked fine.

That was 3 nights ago. This evening it’s done the same thing, except repeating the steps didn’t sort it out. Running the drive through some brief SMART diagnostics and a partition check shows up no problems, so I’m inclined to believe the problem lies in the nslu2. I’ll post again if I can sort it, but at this stage I think a re-flashing is in order. Only problem is I can’t remember what firmware I flashed onto the nslu2 in the first place. D’oh!

Solo Runs In Alien Swarm (Optionally With Bots)

Alien Swarm is still a fun game, and after a quick session this evening I felt like giving a solo run a try. Problem is, if you go to “Play online” and try to start by yourself the game complains that “This mission requires at least two players playing”. Fortunately, the developers were kind enough to include an option to ignore this requirement. Open up the console (first you need to enable it under Options -> Keyboard/mouse), and enter:
asw_ignore_need_two_player_requirement 1

You may also want to enter the following to prevent people joining.


For the optional bots part, you can add bots by using the following:
cl_selectm [character] [slot]

Quoting from wiki4games:

[character] is the character as a number from 0 to 7:
0: Sarge
1: Wildcat
2: Faith
3: Crash
4: Jaeger
5: Wolfe
6: Bastille
7: Vegas
[slot] is the slot number (from 0 to 3, or -1 to automatically pick the first available lot)
To remove a bot, use cl_dselectm [character] where [character] is a number from 0 to 7 as above.

Polish Demotivational Posters

I have some images up on this blog, images that are sometimes linked to. I occasionally check out who is checking out what, and found out that one of the mosaics I generated a few years ago is being used in what appears to be a demotivational poster.

You can see it at

Google translate translates the Polish to English:

Jesteśmy tym wszystkim
Co pozornie w niczym nas do siebie nie przypomina

We are all
What is apparently the way we do not like each other

Which isn’t much help in making sense of the thing. Funny though. Also, Google Translate is pretty awesome: real-time translation, spelling corrections, and a doodad to hear what it sounds like.

(image included below in case the original disappears)



Unzip Multiple Archives (Optionally With Password Protection) Using PowerShell on Windows

Short version: You need 7-zip to go with it if you want to do the password protection bit

Most of the shell posts here are to do with Linux, and particularly bash, but today I’d like to share a useful Powershell nugget. By the way, to get a powershell, open up a command prompt (Win + R -> cmd [enter]) and type powershell. Just like that.

Now, I wanted to unzip a big folder of zip archives, protected with a simple password. Well, turns out that is relatively easy to do with PowerShell and 7-zip, both of which I had. BWAIN*dump got me started, and I changed it to work with password protection and added a couple refinements. The code:

$shell=new-object -com shell.application




$ZipFiles = get-childitem *2010*.zip | where {$_.length -gt 22} | sort-object -property LastWriteTime -descending

$ZipFiles.count | out-default

foreach ($ZipFile in $ZipFiles)

C:\7z.exe e -y -oC:\directory -psomepass $ZipFile.Name


  • The first four lines are basic setup, saying “we’re going to work in the current directory”
  • $ZipFiles = get-childitem *2010*.zip – get all zip files that have “2010” in the name. This was for my own purposes, you could instead use *.zip for all zip files.
  • | where {$_.length -gt 22} – a pipe to select all files with a size of 22 bytes or more, as I didn’t want any empty files to be included
  • | sort-object -property LastWriteTime -descending – a pipe to sort by date modified, descending. Handy if you are only doing a subset of files, eg to test.
  • foreach ($ZipFile in $ZipFiles) – loop through the files
  • C:\7z.exe e -y -oC:\directory -psomepass $ZipFile.Name – the important bit, using 7-zip to extract the password-ed files. THis does assume they have all the same password, incidentally. If you have 7-zip in the same directory as the files (as I did), you can write:
    \7z e -y -oC:\directory -psomepass $ZipFile.Name, but you need to escape the 7 of “7z” for some reason. Note there are no spaces between -o and the output directory, nor -p and the password. -y just means answer “yes” to all questions, making it non-interactive. This will overwrite stuff that has the same name, I’m happy with that but you might not be.

Anyway, that code should extract files from zip archives with a password to a specified directory. Modify it to your purposes as I did!