random thoughts to oil the mind

Category: Technology Page 1 of 9

[:en]On matters relating to computer hardware, software, and other technical goodies.[:de]Beiträge über Hardware, Software und Ähnliches[:]

Windows 10 Home/Pro

I recently gave my machine a long overdue brain transplant, but stupidly didn’t consider what would happen to my Windows 10 licence after making a major change to the hardware. Of course, upon booting back up I was greeted with the friendly warning that my OS installation had not yet been activated.

While it is possible to reactivate Windows after a hardware change, this relies on you having linked the licence to your Microsoft account, which I hadn’t done beforehand. Various attempts to troubleshoot the problem just had me going around in circles navigating the same help pages from different angles (“have you tried turning it off and on again?”) And as tempting as it sounded to spend another evening elbow-deep in transistors restoring the status quo ante, there’d be no guarantee that my copy would be activated again with the original hardware in place (anyone know if this is the case?)

So the only option was to buy a new licence. I was a bit loath to fork over the full price for a license from Microsoft, given that I’d only lost my original one through stupidity. But there are plenty of third parties selling licenses for throwaway prices, which are presumably legitimate for at least some value of legitimate. Off I go and basket up a Microsoft Windows 10 Pro licence for a reasonable price, wait with baited breath for a licence code, plug in the numbers and… it failed.

It was then that I noticed I had Windows 10 Home installed but had actually bought a licence for Windows 10 Pro. Fine, it should be possible to upgrade Home to Pro using my licence without having to install fresh, right?

Apparently not. After a few attempts at entering my key while trying to install Windows 10 Pro, I searched around and found various websites supplying generic keys for installing whichever version of Windows you prefer. Unfortunately, entering one of these keys would initially tell me my copy would be upgraded, before complaining that my version of Windows wasn’t activated, but would I like to troubleshoot my problem again?

Fortunately, there was a simple low-tech way out of this particular Catch-22. The solution was to cut the internet connection after entering the generic code for upgrading to Windows 10 Pro. The upgrader moaned a bit, but otherwise did its thing. Once the system was rebooted, I could then enter the licence key I’d purchased and boom. Back to having a fully licensed copy with no more annoying watermarks. Troubleshooters be damned.

[Photo by Tadas Sar on Unsplash]

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.

Page 1 of 9

Powered by WordPress & Theme by Anders Norén

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.