Categories
In the news

Best joke of the Festival

I visited Edinburgh beginning August this year at the start of the Fringe festival, which is over by now. The number of performing artists is immense as you can see from the official website, and so is the number of visitors, and it is therefore hard to get a room down town, at this time of the year.

With hundreds of performances completed, the best jokes of the festival have been picked by some 2,000 comedy critics.

Winner with 52% of the votes is:

“I tried to steal spaghetti from the shop, but the female guard saw me and I couldn’t get pasta.”

By Masai Graham

You have to have an accent to get the punch, but yes it is funny…

Runner up with 37% of the votes is:

“Did you know, if you get pregnant in the Amazon, it’s next day delivery?”

By Mark Simmons

For more background see the articles in the Guardian and on Inews.co.uk. The latter website also lists the past winners.

Categories
In the news

Respect the no-smoking rules

In the ongoing conflict between Russia and Ukraine there have recently been a number of explosions at airfields and ammunition depots in Crimea and in the Donbast that were explained by the Kremlin as military staff being rather lax with the no-smoking rules.

On the other hand with so much happening at almost the same time, would it be possible that the Ukrainians have had a “lucky strike” in attacking these facilities?

The whole issue is still shrouded in mystery 🤔…

Lucky strikes anyone ?

Categories
Programming

Debugging QGIS Python Plugins

1. Introduction

Recently, I started working with QGIS, and found it a very powerful open source GIS platform, with the ability to create Python (or C++) based plugin extensions.

However, as in any programming language, you’ll create errors, and there will be bugs to be fixed. Working with a debugger, that allows you to step through your code to check your code is doing what it should do can be a real time saver.

Debugging your Python scripts starts with selecting an IDE such as PyCharm, Eclipse or Visual Studio Code. Given the wide popularity and the ongoing development of VS Code I chose the latter, but setting it up for debugging is not that straightforward.

First it is worth noting that there are two ways to install QGIS on Windows:

  1. As part of an OSGEO installation, that by default has its own folder at the root of the C-drive (C:\OSGeo4W)
  2. As a standalone installation under the C:\Program Files folder (which is a ‘protected’ folder, requiring admin write access)

In my case, the latest standalone version of QGIS has been installed under C:\Program Files\QGIS 3.26.0.

The steps I took are listed to make it all work, are listed here :

2. QGIS Plugin ‘debugvs’

In QGIS install the plugin debugvs, where ‘vs’ stands for Visual Studio.

debugvs selected in the Plugin Manager

3. Debugvs dependencies

The debugvs plugin needs the python module ptvsd to function. This module is not installed by default.

In principle you just pip install ptvsd using the python interpreter used by QGIS, but you need to pay attention here, in order to update information under the Program Files folder, you need to run it from the OSGeo4W Shell ("C:\Program Files\QGIS 3.26.0\OSGeo4W.bat") in elevated mode. You can do this by right clicking the OSGeo4W Shell from the QGIS 3.26.0 program group, and then select Run as administrator in the context menu.

Then type pip install ptvsd and installation should proceed, with files stored under the Program Files folder in the appropriate directory. Upon installation, you should get a confirmation that the installation went okay, and you might get a message asking you to update pip to the latest release.

According to the ptvsd documentation this package is deprecated, and one should use debugpy instead. That package is available here. I have not yet tested the difference. For now, ptvsd does the job.

4. Python extension for Visual Studio Code

After installing VS Code, you’ll need to install the Python extension, in order to develop Python code.

This will automatically install a Python interpreter as well. But that interpreter may not be 100% compatible with the one in QGIS. See next paragraph.

Python extension for VS Code

The Python extension will also install the Pylance and Jupyter extensions to give you the best experience when working with Python files and Jupyter notebooks.

Pylance is an optional dependency, meaning the Python extension will remain fully functional if it fails to be installed. You can also uninstall it at the expense of some features if you’re using a different language server.

5. Setting the interpreter

The Python interpreter can be set to C:\Program Files\QGIS 3.26.0\bin\python3.exe by selecting an interpreter in the right part of the status bar.

6. Prepare for debugging

The next step in VS Code is to prepare for Python debugging, for which we need to prepare a launch.json file in the the .vscode directory. This can simply be done by hitting F5 to start debugging, when you’ll be asked to create this file. In our case, we want to attach the debugger to an existing QGIS process, and the launch.json file then looks like :

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "${workspaceFolder}"
                }
            ],
            "justMyCode": true
        }
    ]
}

See this link for more information.

7. Overall Workflow

The overall workflow now is as follows:

  1. In VS Code, set one or more breakpoints in your Python code, from where you want to step through your code
  2. From the QGIS Plugin toolbar, or the Plugins menu select:
    Enable Debug for Visual Studio .
    You should see a message like:
    DebugVS : Remote Debug for Visual Studio is running(“request”: “attach”, “Port”: 5678, “host”: “localhost”)
  3. In VS Code, enable debugging by pressing F5
  4. Start your Plugin from the Plugin toolbar, or menu
  5. Step through your code
  6. Solve your bug(s) …
  7. Reload your plugin reload
  8. Test updated functionality, and if required:
  9. Adjust your breakpoints, and go back to step 4.

8. Pylance fix

For some reason I got niggling warnings that I did not understand; Pylance was not able to find some essential QGIS packages, which resulted in the following warnings:

  1. Import “qgis.PyQt.QtCore” could not be resolved
  2. Import “qgis.PyQt.QtGui” could not be resolved
  3. Import “qgis.PyQt.QtWidgets” could not be resolved
  4. Import “qgis.core” could not be resolved

This was rather strange, as debugging & code execution worked fine. According to the Pylance Common Questions and Issues, unresolved imports are often related to lack of a suitable relative path. I did extensive search on the internet, where – among other things – you come across Pylance bug reports that have in the mean time been closed out, so not very helpful.

In the end, the following Note helped find me the solution:

To find the required folders, you need to open the QGIS Python Console (Ctrl+Alt+P) and run the following command to see a list of default directories : QStandardPaths.standardLocations(QStandardPaths.AppDataLocation) . In my case, this command returned the following:

['C:/Users/Bart/AppData/Roaming/QGIS/QGIS3', 'C:/ProgramData/QGIS/QGIS3', 'C:/Program Files/QGIS 3.26.0/bin', 'C:/Program Files/QGIS 3.26.0/bin/data', 'C:/Program Files/QGIS 3.26.0/bin/data/QGIS/QGIS3']

This path has been added in a settings.json file under the .vscode folder.

Also the path for the default Python interpreter can be added in the settings file. The Python interpreter used by QGIS can also be found from the Python Console using the following command : QgsApplication.prefixPath(). In my case this returned: 'C:/PROGRA~1/QGIS32~2.0/apps/qgis'.

This is the ‘old’ 8.3 character representation of a folder path. By replacing the forward slashes by backward slashes and typing this path in the explorer window, it evaluates to : C:\Program Files\QGIS 3.26.0\apps\qgis.

This leads to the following setting.json file

{
    "python.defaultInterpreterPath": "C:\Program Files\QGIS 3.26.0\apps\qgis",
    
    "python.autoComplete.extraPaths": [
        "C:\\Users\\Bart\\ppData\\Roaming\\QGIS\\QGIS3", 
        "C:\\ProgramData\\QGIS\\QGIS3", 
        "C:\\Program Files\\QGIS 3.26.0\\bin", 
        "C:\\Program Files\\QGIS 3.26.0\\bin\\data", 
        "C:\\Program Files\\QGIS 3.26.0\\bin\\data\\QGIS\\QGIS3"
    ],
​
    "python.analysis.extraPaths": [
        "C:\\Users\\Bart\\ppData\\Roaming\\QGIS\\QGIS3", 
        "C:\\ProgramData\\QGIS\\QGIS3", 
        "C:\\Program Files\\QGIS 3.26.0\\bin", 
        "C:\\Program Files\\QGIS 3.26.0\\bin\\data", 
        "C:\\Program Files\\QGIS 3.26.0\\bin\\data\\QGIS\\QGIS3"
    ]
}

Things seem to work okay now. For instance my code contains:

crs = QgsProject.instance().crs()
units = crs.mapUnits()

By right-clicking on units and selecting go to type definition, the correct Python Interface Definition file (_core.pyi) is opened and it shows:

   class DistanceUnit(int):
        DistanceMeters = ... # type: QgsUnitTypes.DistanceUnit
        DistanceKilometers = ... # type: QgsUnitTypes.DistanceUnit
        DistanceFeet = ... # type: QgsUnitTypes.DistanceUnit
        DistanceNauticalMiles = ... # type: QgsUnitTypes.DistanceUnit
        DistanceYards = ... # type: QgsUnitTypes.DistanceUnit
        DistanceMiles = ... # type: QgsUnitTypes.DistanceUnit
        DistanceDegrees = ... # type: QgsUnitTypes.DistanceUnit
        DistanceCentimeters = ... # type: QgsUnitTypes.DistanceUnit
        DistanceMillimeters = ... # type: QgsUnitTypes.DistanceUnit
        DistanceUnknownUnit = ... # type: QgsUnitTypes.DistanceUnit

As the units variable returned ‘0’ it confirms that the units being used are meters. So it seems that Pylance can now complete code (Intellisense) and find parameter type definitions.

For this all to work, no environment file (.env) is required.

Categories
In the news

Art gone bananas

It has been more than two years ago that some ‘artist’ taped a banana to a wall and presented this as a real work of art.

According to galerieperrotin Maurizio Cattelan’s new sculpture ‘Comedian’ at Art Basel Miami marks the artist’s first major debut at an art fair in over 15 years!

Comprised of a real banana affixed to the wall with a piece of duct tape, this new work is no different than Cattelan’s hyper-realistic sculptures lampooning popular culture and offer a wry commentary on society, power, and authority. In the same vein as Cattelan’s America (2016), this piece offers insight into how we assign worth and what kind of objects we value. The idea of this work came to the artist’s mind a year ago. Back then, Cattelan was thinking of a sculpture that was shaped like a banana. Every time he traveled, he brought a banana with him and hung it in his hotel room to find inspiration. He made several models: first in resin, then in bronze and in painted bronze for finally coming back to the initial idea of a real banana. Discover it in 📍 Perrotin Booth D24, Art Basel Miami Beach, 📆 December 5 – 8, 2019

All according to galerieperrotin

This is all rather weird to begin with, but the madness does not stop there. This piece of art has been sold three times for $120,000.- (or more) according to Huffpost. Estimated costs:

  1. Banana 🍌 : $1.00
  2. Duct tape 🩹: $ 0.20

Total costs $ 1.20. Price / cost ratio 100,000❗
And that times three, of course.
But now, the story takes a twist…

An artist claims Maurizio Cattelan copied his banana artwork. And now Maurizio is being sewed for plagiarism by Joe Morford, an artist from Glendale, California.

“I did this in 2000. But some dude steals my junk and pimps it for 120K+ in 2019,” Morford wrote in a public Facebook post in 2019 with an image of the artwork. “Plagiarism much?”

Joe Morford

Morford is seeking damages over $390,000 — the total amount of Cattelan’s sales for three editions of the artworks — as well as court costs and travel expenses.

Categories
WordPress

Kurt Vonnegut quote

Looking for a tool to fix broken links in WordPress, I bumped into the following quote:

Kurt Vonnegut quote

If I look at doing maintenance on this website, and even the effort of keeping it ‘alive’, or when I look at the chaos in my study room, I can only agree wholeheartedly with this observation 🤔.

Categories
Synology NAS WordPress

Synology WordPress update to 5.8.3-1060

When I got a message that a new Synology package was out that would update WordPress to version 5.8.3-1060, I decided to update for security reasons. One thing that caught my eye was the following ‘important note’:

Starting from this version, WordPress no longer supports retaining or restoring package-related data after an uninstallation.

Important Note

I did not pay too much attention to this, as I wasn’t planning to uninstall my website. However…

After updating WordPress to 5.8.3-1060, my website was completely broken. I could not even login to the wp-admin page, so I was completely locked out of the WordPress console.

Luckily, I had made backups diligently, using UpdraftPlus, so I tried to uninstall WordPress, and restore the website by re-installing WordPress, then installing the UpdraftPlus plugin, to restore the latest backup. Alas, that did not work either.

Synology DS220+

As my website was hosted on a (slow) DS213j NAS, this was also a very lengthy process. For that reason, I decided to instead host my website on a newer (and faster) DS220+.

Therefore I installed MariaDB 10, PHP7.4 and Apache HTTP Server 2.4 and Web Station, which are all required to run WordPress. I then installed the WordPress package, and immediately ran into problems.

The reason being, that I had forgotten that router ports 80 and 443 were still being forwarded to my ‘old’ NAS. That wasn’t so much of a problem when setting up the website, but it resulted in the Let’s Encrypt SSL certificate giving error messages, as the certificate was basically being pulled from the wrong NAS.

Therefore I forwarded ports 80 and 443 to the newer NAS, and removed the virtual host from the old NAS.

Now I surely was ready to install WordPress again. But would it all work this time? Should I use the Synology v5.8 package again, or should I try to install v6.0, directly from WordPress.org?

A very good instruction video to install WordPress V6.0 without using the Synology package is shown here. So I tried this and it brought up a new website, but I wasn’t able to use UpdraftPlus to recover my website content. Maybe there was a version conflict here ???

As I got fed up with tinkering with WordPress on a NAS, I looked into the possibility of hosting it using a virtual server on my PC.

Several solutions are offered for this purpose, discussed in-depth at this link. To name a few solutions: xampp, wamp, mamp, lamp, ampps & laragon. All these packages offer as a minimum local server access to Apache, MySQL and PHP. Take the Windows version, and you get the acronym WAMP.

After trying a few packages that did not install very well on my machine, I settled on WAMP. You need to make sure that all needed Visual Studio redistributable packages are installed upfront, but a very handy utility (check_vcredist.exe) is available for that purpose.

Then I downloaded a previous WordPress package (v5.7.2) from WordPress.org, that should be compatible with my backups, and copied this under the D:\wamp64\www folder.

So… I installed WordPress under WAMP, and then copied all UpdraftPlus backup files under the wp_content folder. The only thing left was to handle the database itself.

I created a new database using phpMyAdmin, and imported the content of my site’s database backup. The next step was to have two entries (siteurl and home) in the wp_options table point to the right address, and to replace the name of the database in the wp-config.php file.

/** The name of the database for WordPress */
define( 'DB_NAME', 'ds213j' );

By now, the main page of my website was accessible again. But all the posts and the pictures were all having the wrong (global) links, so these needed to be fixed.

I used the Better Find and Replace plugin for this purpose. The nice thing is that it allows you to do a dry run. So you see how many entries and which tables are being affected.


Now my site was fully up and running again – all be it locally! A moment of euphoria. At the same time, the WordPress console now offered the option to upgrade to V6.0, which I did, after first making a backup.

With my local website now running V6.0 of WordPress, I installed V6.0 also on my NAS, again using the guidance from Will on SpaceRex.

The next steps were copying all plugins and media under the wp_contents folder, import the local database and then to have wp_config.php point to the new database.

I then discovered that I could not (un)inststall any plugins as WordPress was asking for ftp credentials;

“To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.”

WordPress asking for FTP credentials

If you Google for this issue you’ll find various solutions. I was able to solve it by adding one line at the end of the wp-config.php file.

define('FS_METHOD', 'direct');

The last step was using Better Find and Replace to have all other links pointing to the proper (global) url.

Now I’m running the latest version of WordPress on my DS220+, with the recommended versions of PHP and Apache, but what a journey – sigh 😔 …

Categories
In the news

R.I.P. Internet Explorer

the rise and demise of Inernet Explorer

As reported by Reuters and other news agencies, for Jung Ki-young, a South Korean software engineer, Microsoft’s decision to retire its Internet Explorer web browser marked the end of a quarter-century love-hate relationship with the web browser.

To commemorate its demise, he spent a month and 430,000 won ($330) designing and ordering a headstone with Explorer’s logo and an English epitaph.

“He was a good tool to download other browsers.”

Epitaph

What else is there to be said 🤔 ❓

Categories
In the news

Safety First ?

No Safety – Smoking First

Somehow, maybe I was bored, I came across this rather remarkable picture on boredpanda.com. Makes you wonder 🤔.

Categories
In the news

Mayday mayday

Moskva flagship listing to port

There has been a lot of discussion whether the fire onboard the Moskva was caused by an accident, or whether the vessel was hit by two Neptune anti-ship missiles.

Moskva radio communication on a Telegram posting

If the alarming audio recording posted on Telegram is anything to go by, it is clear that the vessel was hit by two rockets below the waterline, and the subsequent explosions caused a serious amount of damage and panic onboard.

Categories
In the news

No pun intended

The following article on the Guardian caught my eye:

https://www.theguardian.com/world/2022/apr/12/brazil-armed-forces-viagra-jair-bolsonaro

The title of the article reads:

Bolsonaro faces stiff questioning over Brazilian army’s Viagra purchase

Can’t help but wondering how this questioning was carried out…

Categories
Games

“Bonken”

Bonken” is the name of a card game I learned to play whilst studying in Delft. If you Google for “Bonken” you’ll find it is around on Wikipedia and gamerules.com. You can find it back on a few Dutch websites as well, such as kaartspeluitleg.nl and wikibooks.org. Apparently it has become very popular at the Bossche Bedrijfs Tafeltennis Federatie.

The word bonken has various meanings that don’t always have a positive connotation.

For us it has just been a great game to play at the end of an evening of socializing and fun. But it seems we’ve been playing it with slightly different rules than those published on several sites listed above. In ‘our version‘ twelve out of thirteen available games were played, so each player has three chances to select a game. Obviously the choice reduces as the game progresses, as each game can only be played once.

#GameTricksWeightScore
1No King of Hearts1-100-100
2No Queens4-45-180
3No Gents8-25-200
4No Tricks (Duck)13-10-130
5No 7th / 13th2-50-100
6No Last Trick1-100-100
7Domino1-100-100
8No Hearts13-10-130
9Spades1320260
10Hearts1320260
11Diamonds1320260
12Clubs1320260
13No Trumps1320260
Total0

Please note that out of the last five (no-) trump games only four are being played. Each player needs to play (no-) trump once in the game, therefore one of these five games ends up unused.

As you are allowed to double your opponents, score keeping can become quite daunting, in particular when the evening progresses and the beers keep coming around. Evidence of this is shown in the next two score sheets that somehow avoided being binned.

So I thought it must be easier than that, and earlier I developed a little program for my PDA which is history now. Therefore, I now created an Excel spreadsheet instead, that you can pickup from the download area. I hope you find it fun to use and easy to tweak.

Categories
In the news

Icons and halos

Greek Wooden Icon of St. Bartholomew
Greek Wooden Icon of St. Bartholomew

In the past an icon was a painting, usually on wood, of Jesus Christ, or of a person considered holy by Christians, especially in Russia and Greece. These icons often had a halo also known as a nimbus, aureole, glory, or gloriole. It is a crown of light rays, circle or disk of light that surrounds a person in art. It has been used in the iconography of many religions to indicate holy or sacred figures.

Later the meaning of ‘icon’ evolved into a famous person (or thing) considered as representing a set of beliefs or a way of life. Like David Beckham becoming one of the UK’s best-loved sporting icons.

Buddha Icon with Aura
Buddha Icon with an Aura

Nowadays we think of it as a symbol reflecting a particular file type on a PC. And within an application it’s a small picture or symbol that you point to and click on (= press) with a mouse to give the computer an instruction. Believe it or not, there are nowadays even icons for your PC with an aura, indicating concentration, enlightenment, and meditation.

American Bald Eagle
American Bald Eagle

In this context it was funny to see some pictures from politicians lately taken recently, from such a point of view that they were iconified so to say. What to think about the following pictures from Joe Biden where the American Bald Eagle symbol on a blue background took the roll of an aura.

Not just Biden got iconified recently. What to think about Mutti Merkel below 😉 ❓

Merkel iconified
Merkel iconified

Categories
In the news

Incompetent Government

Or is it just my dyslexia, kicking in again ?

An article in the Guardian described Seafood lorries travelling to Westminster for a protest against Brexit red tape. They parked metres from Downing Street on Monday, but they stopped short of carrying out their threat last week to dump fresh fish close to No 10. Some pictures of lorries were included, of which one in particular caught my eye:

Immediately, I thought, but why would the fishing industry say that it is selfish ? Obviously, this wasn’t what the text of the lorry was all about. Reading it again, it was the following text that was on the lorry:

Obviously, this makes much more sense, and I then remembered a similar situation where my dyslexia kicked in. This was several years ago, when visiting the boat club during the weekend, where a big sign advertised:

Welcome to an evening of time wasting

Obviously that wasn’t what the sign said. It mentioned:

Welcome to an evening of wine tasting

Once I decided there was not much difference between the two, I carried on to the bar at the beach to have a beer with some friends.

Categories
Synology NAS WordPress

WordPress on a Synology NAS

213jNAS
My Synology NAS

When I started to think about building a website, I wasn’t particularly clear about it’s purpose, or how much effort to put in. It was however clear I should use it to be able to host large software downloads as well as a large collection of photo’s. Having worked with ‘raw’ html before using FrontPage to publish web pages, I knew I had to do better nowadays, so I looked at available Content Management System (CMS) platforms. With WordPress having the largest market share and many themes and plugins, I choose it over Joomla, though the latter was praised for its good built-in security. For both WordPress and Joomla, there are ‘native’ packages in the Synology Package Center, so installation should be simple…

My NAS was already accessible from the outside world using a Quick Connect ID. This is very handy to access you music, photo’s and video’s. The quick connect ID is also used when you follow the default WordPress activation process on your Synology NAS. That means that your website becomes accessible under “http://www.quick-connect-id.synology.me/wordpress”, where “quick-connect-id” refers to your “own Synology ID” for that particular NAS. Now this is all fine, but at some stage you may actually buy a “proper domain name” and then you need to move all the web pages to the new domain. This is where you run into problems – big problems – as shown by the following picture

WordPress URL in General Settings
WordPress URL in General Settings

The problem here is that the WordPress Address (URL) is greyed out. So you cannot enter “my-real-domain-name” in that field. I’ve tried all sorts of migration plugins to help fix this problem, but all pages apart from the home page resulted in a 404-page-not-found error. Even worse, when updating my home page I got JSON error messages, so something had gone really wrong.

There are several guides on the internet on how to properly setup WordPress on a Synology NAS, with varying levels of expertise, and they are not all up-to-date. Also, some posts assume you have a static IP-address whilst others assume you have a dynamic IP-address. It is important to get this right, when you want to point internet users to your website.

The one post that saved my day was this post by Wundertech.

It is essential that you create a DNS record (if you run a local DNS-server) or a host record (within your ‘hosts’ file) on your local system before opening WordPress upon installation. Otherwise, it won’t work.

The same Wundertech post also contains a very helpful YouTube video to guide you along. Highly recommended !

Categories
Computers

Troubleshooting Bluetooth

My Intel NUCD54250WYK

In 2014 I bought an Intel NUC D5420 with 16GB of memory, an SSD of 256MB for program storage and a hard disk of 1TB for data storage. It was a very nifty little PC at the time, that served me well as a second PC, that I mainly used for image editing.

At regular intervals I updated the drivers and the BIOS, to ensure compatibility with the latest version of Windows 10.

Early 2019, after a Windows upgrade, I was no longer able to connect to my Microsoft Bluetooth mouse and keyboard.

It took me hours and hours to find out why, but in the end it was related to an issue with the Intel 7260 Wifi/Bluetooth Card.

The remedy was ultimately, to remove the card and to cover pins 20 and 51 with Scotch tape, to isolate them from the connector.

Can you imagine that you need Scotch tape and a scalpel to fix a software upgrade? Weird!