How to list all currently running docker containers?

To list all currently running docker containers run

docker ps

If no containers are running, this will give you this output:

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

In case some containers are running, there will be additional lines listing the container like

CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                    NAMES
1bd0a1461b38        bitnami/mariadb:latest   "/ /run…"   6 minutes ago       Up 6 minutes        3306/tcp                 mydb


How to fix WebPack error describe:


You are trying to build your webpack project, but you see an error message like this:


TypeError: Cannot read property 'properties' of undefined
    at module.exports (/home/uli/project/node_modules/webpack-cli/bin/config-yargs.js:89:48)
    at /home/uli/project/node_modules/webpack-cli/bin/webpack.js:60:27
    at Object.<anonymous> (/home/uli/project/node_modules/webpack-cli/bin/webpack.js:515:3)
    at Module._compile (internal/modules/cjs/loader.js:723:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Module.require (internal/modules/cjs/loader.js:659:17)
    at require (internal/modules/cjs/helpers.js:22:18)


This is a known bug in webpack 4.20.0 – you can circumvent this issue by using webpack 4.19.0.

Look for a line like

"webpack": "^4.7.0",

in your package.json. The caret (^) allows npm to use any 4.x.x version – including the broken 4.20.0.

Replace the aforementioned line by

"webpack": "4.19.0",

to use only webpack 4.19.0.

After that, run npm install and retry building your application.

How to fix Arduino SigFox.h: No such file or directory


You are trying to run the Arduino SigFox first configuration tutorial but when trying to upload the sketch, you get this error message:

SigFox.h: No such file or directory


While you have installed the board libraries and compiler for the SigFox boards, you have not installed the SigFox library itself.

Press Ctrl+Shift+I to open the library manager (you can also open it from the Tools menu).

Look for Arduino SigFox for MKRFox1200 by Arduino and click the Install button

Since the SigFox sketches also require the Arduino low power libraries (i.e. you would get the error message ArduinoLowPower.h: No such file or directory), also click the Install button for the Arduino Low Power by Arduino library.

After that, enter RTCZero in the search bar at the top of the library manager and click the Install button for the RTCZero by Arduino library.

After that, retry uploading the sketch.

Fixing MomentJS interpreting dates as local time


You live in a non-UTC timezone. Dates parsed using MomentJS like


are interpreted as local time as opposed to UTC (as would be appropiate based on the Z in the ISO8601 timestamp) and therefore trying to format them yields an offset timestamp:

// "2016-12-31T23:00:00.000Z" <-- Offset by 1 hour (MEZ - UTC)

This causes you trouble as often the original date is not preserved: In the example above, the correct date would be 2017-01-01 but it is 2016-12-31 instead.

Solution 1: Force moment to parse the date as UTC

// "2017-01-01T00:00:00.000Z" <-- Correct

Solution 2: Manually subtract the timezone offset

let m = moment("2017-01-01");
// Subtract the difference between timezone and UTC
m = m.subtract(m.toDate().getTimezoneOffset(), 'minutes');
// m.toDate().toISOString() === "2017-01-01T01:00:00.000Z" - CORRECT

Use this if Solution 1 does not work or you can’t modify the parsing code: This solution works even if the date has already been parsed.

DO NOT use

new Date().getTimezoneOffset() // NEVER USE THIS! MIGHT USE THE WRONG OFFSET!

because it uses the timezone offset of the current date instead of the date parsed by MomentJS. Obviously this is wrong in countries with summertime, since dates may have different offsets depending on the date. Moreover, in rare cases the client’s computer timezone may have changed due to travel etc in the meantime and might therefore might not represent the correct offset to use.

Running a function for each file in Octave

Often if you have a directory of data files, you want to run a processing or parsing function for every file in that directory.

This snippet allows you to select files using a glob pattern (e.g. data/*.txt)


% Run func(filepath, fileId) for each file and fclose() it afterwards
% Usage example: runForEachFile(@parseTXT, "data/*.txt")
function runForEachFile(func, pattern)
  files = glob(pattern);
  for i = 1:numel(files)
    file = files{i};
    % Open file...
    fid = fopen(file);
    % Run function
    func(file, fid);
    % Cleanup

Usage example:

% Define utility handler function to only display the filename
function dispFirst(x, y) disp(x) endfunction

% Essentially displays a list of filenames,
% with the opened files being ignored by dispFirst.
% Opens only one file at a time!
runForEachFile(@dispFirst, "data/*.txt")

String startsWith function in Octave

This function is the equivalent of Python’s startsWith function and works for strings:


% Check if a string starts with a given prefix
% Returns 1 if s starts with prefix, 0 else
function retval = startsWith(s, prefix)
  n = length(prefix);
  if n == 0 # Empty prefix
    retval = 1; # Every string starts with empty prefix
  retval = strncmp(s, prefix, n);


>> startsWith("myString", "my")
ans = 1
>> startsWith("myString", "abc123")
ans = 0
>> startsWith("myString", "My")
ans = 0
>> startsWith("myString", "")
ans = 0


Octave: How to create a function file from a function?

You have an Octave function and you want to move it into a separate file.

First, you need to know that a function file can only contain ONE function and that function needs to be named just like the file.

Therefore, if your function is called myfunc, you absolutely need to move it to a file called myfunc.m, or else Octave won’t find it.

Creating the file is pretty simple: Just paste the function into the file. You must ensure that the first statement in the file is function ... (else, it will be treated as a script file, not a function file) (any number of comments and empty lines is OK though)

Example: myfunc.m:

function retval = myfunc(n)
  retval = n + 5

After you have saved that file, you can immediately use myfunc() in Octave:

>> myfunc(3)
retval =  8
ans =  8

Octave will automatically use the updated version in case you make changes to myfunc.m

How to concatenate strings in Octave

In order to concatenate strings, in GNU Octave, use this snippet:

% Concatenate and assign to a variable named "concatenated"
concatenated = strcat("test", "123");
% OPTIONAL: Show the value of the "concatenated" variable in the terminal
disp(concatenated); % Displays "test123" (without quotes) in the terminal

Similarly, you can concatenate three or more strings:

strcat("test", "123", "456"); # test123456

You don’t have to use literal strings, you can also use variables instead:

mystr = "xyz";
strcat("test", mystr, "456"); # testxyz456

Alternatively you can use this short syntax (no commata between the strings!):

concatenated = ["test" "123"]

% Show the value

Octave: How to print a string or number to the terminal

In order to print a string to the terminal in GNU Octave use

disp("Hello world");

This prints:

>> disp("Hello world");
Hello world

If you want to display a number/variable in addition to the string, use this snippet:

mynumber = 5;
disp("Hello world, mynumber="), disp(mynumber);

This prints:

>> mynumber = 5;
>> disp("Hello world, mynumber="), disp(mynumber);
Hello world, mynumber=

Alternatively, you can use printf, which I recommend for all but the most simple cases:

>> printf ("Hello world, mynumber=%d\n", mynumber);
Hello world, mynumber=5

Don’t forget to add \n to the end of the printf format string to end the line, and use the correct format specifier (e.g. %d in this case for integers – see the printf docs for details).

Copying io.BytesIO content to a file in Python


In Python, you have an io.BytesIO instance containing some data. You want to copy that data to a file (or another file-like object).


Use this function:

def copy_filelike_to_filelike(src, dst, bufsize=16384):
    while True:
        buf =
        if not buf:

Usage example:

import io

myBytesIO = io.BytesIO(b"test123")

with open("myfile.txt", "wb") as outfile:
    copy_filelike_to_filelike(myBytesIO, outfile)
# myfile.txt now contains "test123" (no trailing newline)


Fixing ‘netplan apply’ Failed to start NetworkManager.service: Unit NetworkManager.service not found.


You’ve configured a wifi or similar (non-ethernet) network in netplan. Your netplan configuration (e.g. in /etc/netplan/50-cloud-init.yaml) looks similar to this:

            addresses: []
            dhcp4: true
            renderer: NetworkManager
            match: {}
            dhcp4: true
                    password: "mywifipassword"
    version: 2


But when you run

sudo netplan apply

you see an error message like this:

Failed to start NetworkManager.service: Unit NetworkManager.service not found.
Traceback (most recent call last):
  File "/usr/sbin/netplan", line 23, in <module>
  File "/usr/share/netplan/netplan/cli/", line 50, in main
  File "/usr/share/netplan/netplan/cli/", line 130, in run_command
  File "/usr/share/netplan/netplan/cli/commands/", line 41, in run
  File "/usr/share/netplan/netplan/cli/", line 130, in run_command
  File "/usr/share/netplan/netplan/cli/commands/", line 101, in command_apply
    utils.systemctl_network_manager('start', sync=sync)
  File "/usr/share/netplan/netplan/cli/", line 68, in systemctl_network_manager
  File "/usr/lib/python3.6/", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['systemctl', 'start', '--no-block', 'NetworkManager.service']' returned non-zero exit status 5.


The renderer: NetworkManager line tells netplan to use NetworkManager to connect to this network.

The error message tells you that NetworkManager is not installed on your system.

On Ubuntu and Debian, use

sudo apt install network-manager

to install it. On other distributions, try to install network-manager or a similarly named package using your distribution’s package manager.

After than, run

sudo netplan apply


How to fix apt-key gpg: keyserver receive failed: No dirmngr


You want to add a repository signing key using apt-key using a command like

sudo apt-key adv --keyserver hkp:// --recv-key E0FF663E

but you get an error message like this:

Executing: /tmp/apt-key-gpghome.qn3065We9J/ --keyserver hkp:// --recv-key E0EE663E
gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory
gpg: connecting dirmngr at '/tmp/apt-key-gpghome.qn3065We9J/S.dirmngr' failed: No such file or directory
gpg: keyserver receive failed: No dirmngr


sudo apt install dirmngr

then retry the apt-key command

Launching Debian containers using LXC on Ubuntu


You know you can launch an Ubuntu LXC container using

lxc launch ubuntu:18.04 myvm

Now you want to launch a Debian VM using

lxc launch debian:jessie myvm

but you only get this error message:

Error: The remote "debian" doesn't exist


The debian images are (by default) available from the images remote, not the debian remote, so you need to use this:

lxc launch images:debian/jessie myvm


Use PHP mail function instead of SMTP in Framadate


You want to use framadate as a Doodle alternative, but you don’t have access to SMTP on your server


This solution was tested with Framadate 1.0. It might not work with other versions. The best approach is to just try it out.

First, configure the mailer in app/inc/config.php just as you would with SMTP. Most importantly set

'use_smtp' => true

The settings in

'smtp_options' => [
    // [...]

do not matter, so you can leave them at their defaults.

Next, edit app/classes/Framadate/Services/MailService.php:

and find this line:


Comment it out:


This tells PHPMailer, the underlying library, not to use SMTP but to use the PHP mail() function.

Now ensure that you have uploaded all the changed files to the server and test your modifications.

Fixing Angular Error: Unexpected value ‘undefined’ declared by the module


For a module of yours, you get an error message like this on load:

Error: Unexpected value 'undefined' declared by the module 'MyModule'
    at syntaxError (compiler.js:1021)
    at compiler.js:10623
    at Array.forEach (<anonymous>)
    at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (compiler.js:10621)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._loadModules (compiler.js:23876)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:23857)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.compileModuleAsync (compiler.js:23817)
    at CompilerImpl.push../node_modules/@angular/platform-browser-dynamic/fesm5/platform-browser-dynamic.js.CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:143)
    at core.js:4999


First, try to restart ng serve. In some cases this will outright fix the issue.

The error message is caused by some element of your @NgModule declarations: [ /* ... */ ] to be undefined.

For example, if you have a @NgModule declaration like this:

  imports: [
  declarations: [,
  providers: []

the issue is in the stray comma in the declarations line: When compiled, it results in [undefined, MyDetailComponent, MySearchComponent]. Removing the stray comma fixes the issue.

If you don’t have stray commata in your declarations, comment out every element in your declarations array and see which causes the error message to disappear.

Fixing NodeJS Intl.DateTimeFormat not formatting properly for locales


NodeJS starting from version v9.x supports the ES6 Intl.DateTimeFormat

When you use it with the ‘en-US’ locale, it works properly and prints "August 13, 2018":

const df = new Intl.DateTimeFormat('en-US', {day: 'numeric', month: 'long', year: 'numeric', timeZone: 'UTC'});
console.log(df.format(new Date("2018-08-13T04:00:00.000Z")));

However, using it with a different locale fails:

const df = new Intl.DateTimeFormat('de', {day: 'numeric', month: 'long', year: 'numeric', timeZone: 'UTC'});
console.log(df.format(new Date("2018-08-13T04:00:00.000Z")));

While you would expect this to print "13. August 2018" , it will print "2018 M08 13"


By default, NodeJS is only built with small-icu support, thereby only installing the en-US locale in order to reduce the installation filesize.

Solution 1 (preferred):

You can use the intl polyfill module to completely replace NodeJS’s implementation of intl:

npm i --save intl
// Replace Intl by polyfill
Intl = require("intl")

const df = new Intl.DateTimeFormat('de', {day: 'numeric', month: 'long', year: 'numeric', timeZone: 'UTC'});
console.log(df.format(new Date("2018-08-13T04:00:00.000Z")));

This will print 13. August 2018 as expected.

Solution 2 (alternate):

You can use the full-icu package to continue using the NodeJS ICU implementation (i.e. no polyfill), but just install the ICU data.

While this reduces the total installation filesize, installation is slow and the exact method depends on the NodeJS version and requires more work than just using the intl polyfill.

In order to install, use

npm i --save full-icu

This will take some time to compile the data and then will print instructions like this:

 √ icudt62l.dat (link)
Node will use this ICU datafile if the environment variable NODE_ICU_DATA is set to “node_modules/full-icu”
or with node --icu-data-dir=node_modules/full-icu YOURAPP.js
 For package.json:
{"scripts":{"start":"node --icu-data-dir=node_modules/full-icu YOURAPP.js"}}

By the way, if you have full data, running this in node:
> new Intl.DateTimeFormat('es',{month:'long'}).format(new Date(9E8));
... will show “enero”. If it shows “January” you don't have full data.
News: Please see

In order to actually use full-icu, you need to use the --icu-data-dir=node_modules/full-icu argument every time you run node. In order to run node interactively, use

node --icu-data-dir=node_modules/full-icu

If you use scripts in your application (e.g. the start script, i.e. what gets executed if you run npm start), you need to adjust the configuration in package.json:

Instead of

// [...]
"scripts": {
    "start": "node index.js"
// [...]


// [...]
"scripts": {
    "start": "node --icu-data-dir=node_modules/full-icu index.js"
// [...]

Depending on your application, you might need to use a different script name than index.js – common names include server.js and start.js

How to fix Angular6 “_getAriaLabel is not a function” with production build


You are building an Angular6 application and in development mode everything works fine. However, if you build in production mode:

ng build --prod --aot

you see an error like this in the client:

main.4d1baabffbba5677af03.js:1 ERROR TypeError: i.ɵnov(...)._getAriaLabel is not a function
    at Object.updateRenderer (main.4d1baabffbba5677af03.js:1)
    at Object.updateRenderer (main.4d1baabffbba5677af03.js:1)


The issue appears to be caused by incorrectly updated NodeJS modules. You can fix it by simply deleting your node_modules folder:

rm -rf node_modules

Furthermore, it’s recommended to update @angular/cli as the bug does not seem to be present in newer versions of @angular/cli:

sudo npm i -g @angular/cli

Source & discussion on GitHub

How to fix phpMyAdmin error #1231 – Variable ‘lc_messages’ can’t be set to the value of


After logging in to your phpMyAdmin instance, you get an error message like this:

#1231 - Variable 'lc_messages' can't be set to the value of 'de_DE'


This error message is caused by a bad language code – in the example listed above, MySQL does not understand the de_DE language code.

The easiest fix for this is to set phpMyAdmin to a fixed language. In order to do this, add this line to your config in on the server.

$cfg['Lang'] = 'en';

You can add this almost anywhere in the file, but I recommend adding it after the $cfg['blowfish_secret'] line.

In case the error message does not disappear after doing this, ensure there is no other $cfg['Lang'] line in

How to translate using your custom AutoML model in Python

If you’ve successfully trained your first custom AutoML neuronal translation model, the next step is to integrate it into your application.

Here’s a python3 utility class that easily allows you to translate using your custom model:

class GNTMAutoMLTranslationDriver(object):
    Custom AutoML model translator.

    Usage example (be sure to use your own model here!):

    >>> translator = GNTMAutoMLTranslationDriver('myproject-101472', 'TRL455090968000816104449')
    >>> translator.translate("This is a translation test")
    def __init__(self, project_id, model_id):
        self.client = automl_v1beta1.PredictionServiceClient()
        self._name = 'projects/{}/locations/us-central1/models/{}'.format(project_id, model_id)
    def translate(self, engl):
        payload = {'text_snippet': {'content': engl}}
        params = {}
        request = self.client.predict(self._name, payload, params)
        return request.payload[0].translation.translated_content.content

See the class documentation for a usage example. Most of the code is also present in the official AutoML example, but I had to figure out some parts for myself, e.g. how to extract the string from the protobuf (request.payload[0].translation.translated_content.content).

Also note that AutoML is currently in Beta and therefore the API might change without prior notice.

How to disable SSL certification verification in LFTP


You want to use lftp to access a FTPS server, but you get an error message like this:

mirror: Fatal error: Certificate verification: certificate common name doesn't match requested host name ‘’ (C8:98:BC:01:1E:FF:08:CB:62:08:6B:F1:E8:4C:1F:13:0A:3B:D8:06)


You can use the following command in lftp to disable certificate verification:

set ssl:verify-certificate false

Inside the lftp command line, you can run the command and then retry the command that caused the error message. As lftp has a memory of which commands you used before, just press the Arrow up key multiple times until you see the original command.


lftp> mirror . MyBackup
mirror: Fatal error: Certificate verification: certificate common name doesn't match requested host name ‘’ (C8:98:BC:01:1E:FF:08:CB:62:08:6B:F1:E8:4C:1F:13:0A:3B:D8:06)
lftp> set ssl:verify-certificate false
lftp> mirror . MyBackup

In case your server doesn’t actually support FTPS, you might need to use the set ftp:ssl-allow no command to disable FTPS entirely.