A Mind @ Play

random thoughts to oil the mind

Category: Technology Page 1 of 9

Commenting memoQ Light Resources

Editing memoQ’s light resources can be a painful experience, with somewhat clunky interfaces, intimidating lists, small default window sizes, and the inability to add comments to rules written with regular expressions. Anyone who’s tried to pin down an error in a list of dozens of autotranslatable rules will know the maddening experience of trying to wade through to reams of similar-looking rules to find the culprit, especially as any edited rules are automatically re-added to the bottom of the list, so any initial effort at structuring rules according to their purpose gradually falls apart over time.

As Kevin Lossner recently pointed out, one clever strategy is to export copies of the rulesets and, adding comments to these XML files, essentially manage these rules outside of memoQ. This makes the rules themselves easier to navigate, and indeed edit, with changes being implemented with a simple reimport of the file.

However, there can be a couple of disadvantages to this solution, depending your workflow. Firstly, the comments only work in one direction, as they’re lost on import. If you make any alterations to resources from within memoQ, exporting the updated ruleset would mean having to combine the files or otherwise restore all the comments. Secondly, memoQ prevents you from overwriting resources on import, so while you can always add a new version and delete the previous one, it can prove to be a royal pain if you also need to update a large number of templates and/or ongoing projects which are using the resource.

Fortunately there is one more cheeky option available to us to make our rules easier to read, however, and that is to abuse named capturing groups and use them as comments. For example, take a rule from a cascading filter for tagging the asterisks in a Markdown list:


We can simply give this group a name and make it easy to identify:


Once all rules have been commented, we immediately have a much cleaner overview of the ruleset, especially useful when you need to go back in and tweak or add something later.

Example cascading filter for Markdown

Note that one potential side-effect of this strategy is that mixing named and numbered capturing groups may upset the numbering, so particularly for autotranslatable rules it may be easiest simply to use named capturing groups consistently throughout.

[Photo by Daiga Ellaby on Unsplash]

Migrating phpBB to NodeBB

I recently set about migrating an aging phpBB forum to NodeBB and ran into enough problems that I considered cancelling the whole project.

The phpBB exporter script has been updated various times, and I managed to find a fork which appears to work with phpBB 3.2. Unfortunately, it refused to install itself correctly and appeared to land in the wrong directory, so I had to manually clone the Github project into the expected subdirectory.

And bingo! The import worked, and after disabling/deleting unnecessary plugins and updating NodeBB to the latest branch, the majority of things were working as expected. A few things remain to be fixed, in particular navigating mongodb’s structure to perform a few custom replacements where the import script had trouble deciphering bbcode.

Fortunately StackOverflow provided a good start:

var bulk = db.getCollection('objects').initializeUnorderedBulkOp();
var count = 0;
db.getCollection('objects').find({$and: [{_key:{$regex: /^post:\d+$/}}, {content: {$regex: /<size size="150">(.*?)<\/size>/}}]}).forEach(function(entry){
    var newContent = entry.content.replace(/^<size size="150">(.*?)<\/size>/gm, "## $1");
    bulk.find( { _key: entry._key } ).updateOne( { 
        $set: { 'content': newContent } 
    if (count % 100 === 0) {
        // Execute per 100 operations and re-init
        bulk = db.getCollection('objects').initializeUnorderedBulkOp();
        count = 0;

// Clean up queue
if (count > 0)  bulk.execute();

Using this I was able to find and replace those tags which had been missed and replace them with valid markdown.

[Photo by Kobu Agency on Unsplash]

memoQ and XSLT: Fun with Namespaces

Using memoQ to translate standard XLIFF (XML Localisation Interchange File Format) files can be made that bit more user friendly when you take advantage of the built-in feature to use XSLT transformations. Since I can’t get my head around namespaces, my simple transformation ended up strewn with unreadable references to local-name() nodes. As ever, there is an easier way.

Take a standard XLIFF file along the lines of:

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns="urn:oasis:names:tc:xliff:document:1.2">
   <file source-language="en" datatype="plaintext" original="Project">
         <trans-unit id="string">
            <source>This is the source content.</source>

We can identify the nodes in the source using standard XPath syntax having defined the namespaces in the header:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
   exclude-result-prefixes="xsl xlf xsi"
<xsl:output method="html" omit-xml-declaration="yes" />
<xsl:template match="/">
<xsl:text disable-output-escaping='yes'><!DOCTYPE html></xsl:text>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
   <link rel="stylesheet" type="text/css" href="yourStyles.css" />
   <title>XML Preview</title>
   <h1><xsl:value-of select="xlf:xliff/xlf:file/@original"/></h1>
   <xsl:for-each select="xlf:xliff/xlf:file/xlf:body/xlf:trans-unit">
      <div class="id"><xsl:value-of select="@id"/></div>
      <div class="content"><xsl:value-of select="xlf:source"/></div><br>   </xsl:for-each>

This produces a basic, ugly but ultimately workable HTML file which memoQ can display in its preview pane:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
      <link rel="stylesheet" type="text/css" href="yourStyles.css"/>
      <title>XML Preview</title>
      <div class="id">string</div>
      <div class="content">This is the source content.</div>

Obviously you can add references to any other information available in your XLIFF files, and then serve and style up the resulting HTML in any desired shape or form, but this basic scaffolding might help someone out there avoid the namespace minefield I ran into!

[Image courtesy of @emilep]


CPU Throttling

Over the past few weeks I’ve had a niggling suspicion that my machine was running slowly. Things felt a little sluggish, sites were less responsive, switching between applications took longer than usual. My machine was showing signs of ageing, despite its relative youth.

Then I tried launching Heroes of the Storm, a game I hadn’t played for a few weeks and which had been updated in the meantime. After getting through the menus and starting a game, the performance gradually plummeted, with the frames per second dropping from around 20 at launch to just 1 when there were a few moving characters on screen at once.

Since other games such as Counter-Strike: Global Offensive didn’t exhibit the same unplayable jerkiness, instead reacting rather more like the rest of my system in being generally lethargic, I assumed something in one of the patches had ruined my settings. After rooting around on the forums I found a variety of potential solutions, including running the 32-bit client, verifying the installation, reinstalling the game, reinstalling drivers, changing resolutions, running the game in windowed mode, forcing Nvidia’s hand in the control panel, and many more.

In reality, however, the problem had nothing to do with the game itself, but something had instead gone horribly wrong with my power management settings. Although I hadn’t touched them myself, somehow my CPU was stuck in first gear, being throttled down to 5% instead of dynamically altering to cope with the demands of the system at any particular time.

The solution on Windows 10, in case anyone should have the same problems, was simple:

  1. Navigate to the power options in the Control Panel (or for a shortcut, hit WIN + R and type powercfg.cpl).
  2. Verify that you’re using the default Balanced power plan.
  3. Click Change plan settings then Change advanced power settings.
  4. Scroll down the list to Processor power management and check the entry for Maximum processor state.
  5. Normally this should be set to 100%. If it isn’t, either do so manually, or if you haven’t otherwise changed anything about your power management settings, click Restore plan defaults.


This entry is also available in English.

Eines Morgens sitze ich am Frühstückstisch, eine warme Tasse in den Händen, ein köstlicher Kaffeegeruch in der Luft. Durch das Fenster scheint die Sonne auf einen neuen Tag, während das Vogelzwitschern dem sonst unbeschriebenen Tagesblatt eine Melodie verleiht. Plötzlich ertönt und vibriert es auf dem Fenstersims: Vater ruft an.

„Der Akku im Autoschlüssel ist leer.“ Anscheinend steht er vor seinem Wagen auf dem Parkplatz und drückt verzweifelt auf die Fernbedienung. „Rufst du mal den Autodienst an? Ich komme nicht rein.“

„Benutz doch den Schlüssel.“

„Wie, den Schlüssel?“

„Schlüssel rein, drehen, Tür öffnen.“

„Und das geht?“

Mir ist dieses kurze Gespräch, das sich schon vor vielen Monaten ereignete, wieder in den Sinn gekommen, als ich einen ähnlichen aber wenig heiteren Bericht aus Neuseeland gelesen habe. Dort hat sich ein älteres Ehepaar in seinem Wagen ohne Schlüssel eingesperrt. In dem Glauben, es säße jetzt in der Klemme, versuchte das Paar durch Hupen die Aufmerksamkeit der Nachbarn zu erregen, sowie das Fenster mit einem Wagenheber einzuschlagen. Doch der Versuch, die Tür durch bekannte Methoden zu öffnen, blieb außen vor.

Schließlich wurden die beiden nach 12 Stunden in dem Fahrzeug von den Nachbarn gerettet, wobei die Frau bereits ohnmächtig und der Mann in Atemnot geraten war. Wahrscheinlich ein wenig dramatisch eingekleidet, sei den Rettungsdiensten zufolge dieses kleine Missgeschick beinahe mit Todesfolgen verbunden.

Wie können manch unserer elementarsten Werkzeuge so schnell in Vergessenheit geraten, wenn sie ersetzt werden? Warum werden wichtige Ideen und Methoden, die unser tägliches Leben so prägen, so einfach verdrängt? Obschon leicht amüsant oder tödlich, stehen sich diese zwei Geschichten im Hinblick auf ihre Auswirkungen an zwei entgegengesetzten Polen gegenüber. Doch auch wenn die meisten von uns über die scheinbare Ahnungsloskigkeit und Dummheit der Anderen nur den Kopf schütteln oder hämmisch lachen können, befinden wir uns wohl leicht in dieser und anderen ähnlichen Situationen, seit wir uns zunehmend auf die Geräte der modernen Technik verlassen, um einfach durch den Alltag zu kommen. Seit die mechanische Welt durch die digitale ersetzt wird, weiß überhaupt irgendeiner noch, wie man die Dinger repariert, wenn die Maschine versagt?

Im Leben vergleichen wir viele Aspekte mit dem Fahrradfahrenlernen: Das vergisst man ja nie. Zumindest nur so lang das Fahrrad nicht angeschlossen ist. In dem Fall muss man bloß hoffen, man weiß noch, wie das geht.

Page 1 of 9

Powered by WordPress & Theme by Anders Norén