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[:]

brown reticulated python

Pipeline Poetry

A few months ago, I found myself hacking chunks out of a monolithic Python repo to break out a few generic reusable packages. Splitting out the libraries had a number of benefits beyond being able to reuse the code in other places: it gave a much clearer picture of the test coverage, provided a chance to ditch some vestigial code, as well as some impetus to pay off roll over some old technical debt. But one area that gave me a few headaches was getting the packages to play nicely with existing CI/CD pipelines.

Lightroom Crashing on Import

Argh! One of those maddening adventures down the digital rabbit hole later, and the solution turned out to be quite simple. Every time I clicked to import files into Lightroom 5.7 (because yes I’m that old) the program crashed without so much as a smell you later. After checking plug-ins, corrupted preferences files and databases, and avoiding various people suggesting I needed to re-install Windows, the solution turned out to be rather straightforward:

Do you have an Android device attached to your computer? If so, unmount it and try again.

Jeffreytranberry

That was all there was to it. Сharging an old tablet was enough to cause Lightroom to fall over itself when presumably being refused access to read the attached storage device.

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:

^\s*\*\s+

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

(?<unordered_list>^\s*\*\s+)

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");
    print(newContent);
    bulk.find( { _key: entry._key } ).updateOne( { 
        $set: { 'content': newContent } 
    });
    count++;
    if (count % 100 === 0) {
        // Execute per 100 operations and re-init
        bulk.execute();
        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]

Page 1 of 9

Powered by WordPress & Theme by Anders Norén