Creating Tests – As long as they are automated

I have been often asked about testing, how something could be tested automatically, how something could be tested at all. Especially if there is/was no testing framework. My answer has been always the same:

It doesn’t matter. As long the tests are autmated.

Testing frameworks have been created over time. They have not been there from the beginning. Eventually, there is no test framework for your problem yet. However, this does not mean you can’t test.

An error was reported in my EIP-PlantUML side project. After some analysis, I figured out it was caused by a syntax issue within a string in a definition file. The problem here, you see the particular error only once the result has been rendered as an image. How to test this?

I simply wrote a Bash script checking the definitions instead. That’s all. It passes with the exit code 0 or 1 if the test fails. That way I will be able to integrate it in a test suite later one ,even if I don’t know how this will look right now.

The test script itself is rather simple using grep in a shell script.

#!/bin/bash
Red=$'\e[1;31m'
Green=$'\e[1;32m'
Clear=$'\e[0m'

count=$(grep 'r_label' -c ../EIP_Elements.puml)

if [ "$count" -eq "0" ] ; then
    echo "$Green PASSED:$Clear No issues detected."
    exit 0
else
    echo "$Red FAILED:$Clear Issues detected."
    grep 'r_label' -n ../EIP_Elements.puml
    exit 1
fi

Fixing Podlove Cron Jobs in WordPress Docker Containers

While we were publishing the first episode of our Podcast, I came across some issues with WordPress, though.

First of all: We are using the Podlove Publisher and therefore WordPress to host our Podcast.

Unfortunately, I encountered an issue with the required cron jobs. The Podlove WP Cron Diagnostics showed, that there was nothing set up.

PHP Constant
ALTERNATE_WP_CRON: not definde
DISABLE_WP_CRON: not defined

As a result, any attempt to connect to running cron jobs failed. After checking Google I found a helpful hint here. All you have to do is to add

define('ALTERNATE_WP_CRON', true);

in your wp-config.php.

And here the fun begins. I am using the official WordPress Docker container and Ansible to deploy it on my servers. So you need a way to add this line to a wp-config.php file on your server using an Ansible script… I think you get it. Some years ago, you would have simply logged into your server, changed the line in the file and eventually restart your webserver.

Now everything becomes more difficult. First of all I try such things manually. To do so (as well as to verify the changes on the server) I bash into the running WordPress container

docker exec -i -t {containerId} /bin/bash

just to realize there is neither vim or even vi on this container available. Also less did not work. At least I was able to read the file using more.

Again I looked for some hints and found a great hint on Stackoverflow:

You can make use of the WORDPRESS_CONFIG_EXTRA environment variable to define any other config values in the wp-config.php file.

With this environmental variable, you can literally add anything to your wp-config.php file in the prebuild WordPress image without fiddling with own containers and so on.

environment:      
  WORDPRESS_DB_HOST: db:1234
 WORDPRESS_DB_USER: wp
 WORDPRESS_DB_PASSWORD: topsecret
 WORDPRESS_CONFIG_EXTRA: |
   define('ALTERNATE_WP_CRON', true);
    define( 'DISABLE_WP_CRON', true );

Looking into your wp-config.php now should reveal the following line:

// WORDPRESS_CONFIG_EXTRA
 define('ALTERNATE_WP_CRON', true);
 define( 'DISABLE_WP_CRON', true );

Also running the diagnostics in the Podlove plugin now should come up with some better news:

Started the Podcast

A few weeks ago, I announced to start my personal educational project Hack-the-Planet.

I started the GitHub Project, the Twitch Stream and we already gathered a small community at Reddit and Discord.

Eventually, I wanted to start a podcast. However alone, it’s only half the fun. Said that I had a surprising phone call by an old friend who was willing to start the podcast with me. That’s not only a lot of fun but also a great honor to perform the Podcast with him.

Yesterday, we finally recorded episode 0 of the podcast and already published it. The Podcast is already available at Spotify and will be available soon at iTunes as well once the Apple site works again. More on this topic in episode 1. If you are using any other application I can also subscribe directly from our feed or head to the podcast site at https://podcast.hack-the-planet.tv.

We hope to publish an episode once a week. So stay tuned and feel free to subscribe to the podcast.

Visual Studio Code: Open in Browser

While I started using Visual Studio Code frequently for several Web development project, I got very annoyed by copying file paths and pasting them into my browser to view the file there.

The open-in-browser extension for Visual Studio Code is a small simple solution to exactly this problem. It lets you open a file directly in your default browser.

Open an html file, Windows and Linux keyboard shortcut is Ctrl+Alt+O, for MacOS is Cmd+Alt+O. If you want to preview html in your default browser directly, please type Ctrl+K D.

Visual Studio Code open-in-browser Extension
Visual Studio Code open-in-browser Extension

Links:
Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=coderfee.open-html-in-browser
GitHub: https://github.com/coderfe/vscode-open-in-browser

6-axis Mini Industrial Robot Arm

Unfortunately, I don’t have time at the moment to spend on this project. But I really want to keep this for myself in my blog: Mirobot, 6-axis Mini Industrial Robot Arm.

Inspired by the ABB IRB 6700 industrial robot arm which is utilized in advanced factories around the world, we created the Mirobot robot arm – a small, affordable, and user-friendly industrial robotic arm that is accessible to everyone. Whether you are a robot expert, creative enthusiast or beginner, you can get started in the exciting world of robotics with Mirobot.

It’s currently a Kickstarter project, already funded. The robot will probably be available at a retail price of less than 1.000 €. The Kickstarter early backer price is even about less than 400 $.

If you want to know what I plan to do with it: Skip to 3:15 in the video below. I want to run a GoPro through my my sons Lego… what else.

Kickstrter project: https://www.kickstarter.com/projects/mirobot/mirobot-6-axis-mini-industrial-robot-arm

Unsolicited SMS Advertising

For some days, SMS seems to be in some kind of renaissance. Frequently, I receive unsolicited SMS advertising. Not necessary to add, this is quite annoying.

While I am personally not necessarily happy with all the regulation and rules we have in Germany, I really do like the telecommunication regulations. In the early years of the internet, I successfully dealt with dialers and other malware using the possibility, the Federal Network Agency offers.

Here you see one of the SPAM SMS I receive. No sender number, links which you don’t know where they lead to. And most important, no consent to send me such SMS.

Unwanted SMS
Unsolicited SMS

Luckily, the Federal Network Agency provides a form where you can fill a complaint against such unsolicited SMS or calls.

Eventually, if you get such SMS or calls, you might want to fill out the complaint form, helping to prevent this in the future.

Update: 2019-07-27

Today, I received feedback regarding my complaints from the Federal Network Agency. Unfortunately, nothing can be done as the sender is based in Malta and they do not provide any callback number.

Aus Ihrer Sachverhaltsschilderung ist kein von der Bundesnetzagentur zu verfolgender Verstoß zum Rufnummernmissbrauch oder zu unerlaubter Telefonwerbung erkennbar. Unter den konkreten Umständen besteht daher für die Bundesnetzagentur keine Möglichkeit einzuschreiten. Der Firmensitz des Anbieters befindet sich im Ausland (Malta) und es wird keine Rufnummer  beworben.

This is in fact very unfortunate, as it is obviously SPAM (similar SMS with different sender names), they want to make you to click on the links provided.

Link: https://www.bundesnetzagentur.de/DE/Sachgebiete/Telekommunikation/Verbraucher/RumitelBeschwerde/beschwerde-node.html

NGINX WordPress Rewrites

After moving my blog to its new domain try-catch-finally.net there was one major issue open: Search engines. Google, Bing, DucDuckGo and whatever have their indices. Eventually, I want to make sure when you hit one of the search results, you will end up with the proper site.

Using NGINX allows you to do this with a few files. Using the location section let you match against path segments and applying a rewrite rule.

The trick is done by the two parameters $1 and $1. While the $1 is the content in the first paratheses, $2 is the rest of the path segment from your request which is in the second paratheses. Once I got this pattern, It was easy to write the below rule.

server {   
  ...   
  location location ~ /(2004|2005|2006|2007|2008|2009|2010|2011|2012|2013|2014|2018|2019|feed|comments|tag|author|category)/(.*) {
    return 301 https://www.hack-the-planet.net/$1/$2;     
  }   
  ... 
}

In addition to just forwarding your request, the client will receive the HTTP status code 301, that way there is a good chance search engines get the information about the change for this particular URL.

Organizing My Availability

Meanwhile, I spent quite some time answering emails and requested my availability. There is a family calendar, a work calendar, a lecture calendar and maybe I miss one or two.

I usually have to look through all of them. And of course, I usually miss one or two of them. Therefore, I started to use the Doodle MeetMe feature to consolidate the availabilities of various calendars at one place.

Doodle MeetMe

Especially the feature to share the availability times was quite appealing to me. Most users just know Doodle for creating polls about events and meetings. Therefore, I decided to give it a try for some time. To see how this works out.

Link: https://doodle.com/aheil

Log into dockerized MySQL

From time to time there is the need to log into a containerized MySQL instance. And of course, when this time comes, I have completely forgotten how this works. Consequently, I should write it down. Here you go:

Bash into the running container

docker exec -t -i <container_id> /bin/bash

Usually, you should end up with something like the following:

root@localhost:~# docker exec -t -i 365a8a95c335 /bin/bash
root@365a8a95c335:/#

Log into MySQL

mysql -u “<useranme>” -p

Once again, it should look similar to the following:

root@365a8a95c335:/# mysql -u "wpuser" -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g. 
Your MySQL connection id is 146
Server version: 5.7.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement

mysql>

Now you should be able to do whatever you want to do with MySQL.

try-catch-finally.net

Back from vacation, I had to think about how to go on with things. Things are going to change. Winter is coming. While running this blog for years, I finally decided to move the blog to another domain. I am looking for a “better” brand. aheil was my alias at Microsoft as well as in many other systems. It is my alias in many other systems, my XBOX Live ID and so on.

While this migration will cause a major disruption in the force, many search engines will have issues as well. But still, there are some good reasons for me to do so:

  • It’s a DE top-level domain. Would you guess English content here? Yes, me neither.
  • If you are not a German native speaker you probably can’s say this without causing some major dislocations of your tongue. No, I am serious. How do you pronounce it [éháyl], [áhájl] or [áhíɪ́l]? I think you get the idea.
  • I am looking for a better separation of my interests. The blog is a pure personal kind of diary about tech, development, coding and geek stuff. At the same time, I am using the alias aheil for my consulting work for years as a trademark. I want a better separation in the future.
  • The current domain name has nothing to do with coding, tech or even geek stuff. How could it at all, if you can’t even say it!?

I used to own the domain try-catch-finally.net for years, I canceled it some years ago, it was parked and offered for quite an amount of money bit released recently. So I picked it up again. That’s the name the blog is going to be branded as try-catch-finally.net in the future. And just to make it clear, you call it [traɪ kæʧ ˈfaɪnəli dɑt nɛt].

The domain is up, forwarding is active and if you read this, migration is in progress or already done. If eventually add some forwarding rules for blog articles, so sold links still work. But for now, I will go and think about a nice logo using my limited to non-existing graphical skills.