Category: Coding & Scripting

This category contains all posts about coding and scripting. It combines topics like programming and scripting languages, best practices for coding styles and documentation, and others.

  • Fatal error: Call to undefined function bindtextdomain()

    Fatal error: Call to undefined function bindtextdomain()

    By

    in

    This error might be caused by a missing GetText extension. GetText is a widely-used internationalization and localization (i18n/l10n) system that provides tools for translating software messages into different languages. To solve the error, you have to enable the extension in your php.ini. For this, open your php.ini and uncomment (or add) the following line: If…

    Read more

  • HTML: how to vertically center an object with CSS?

    HTML: how to vertically center an object with CSS?

    By

    in

    There are several ways to vertically center an object with CSS: align-content Property Since Google I/O 2024, a new CSS solution to vertically align an object was shown by the Chrome Development Team. Inside a block element it’s now possible to use the align-content property. The alignment works without additional html blocks or CSS definitions and…

    Read more

  • Dart: Zufallszahl in einem Bereich erstellen

    Dart: Zufallszahl in einem Bereich erstellen

    By

    in

    Analog zum Artikel über Java Zufallszahlen bietet auch Dart Möglichkeiten, um eine Zufallszahl zu erstellen. Hierzu kann beispielsweise die Klasse Random aus dem Paket dart:math verwendet werden. In der Dokumentation heißt es: Generiert eine nicht-negative Zufallszahl gleichmäßig verteilt im Bereich von 0 (einschließlich) bis max (ausschließlich). https://api.dart.dev/stable/3.3.3/dart-math/Random/nextInt.html In nachfolgendem Beispiel wird eine Zufallszahl zwischen einem Minimum und…

    Read more

  • WordPress: how to remove the ‘link rel=shortlink’ tag from your site

    WordPress: how to remove the ‘link rel=shortlink’ tag from your site

    By

    in ,

    By default, WordPress adds <link rel=”shortlink”> meta tag to the <head> of a website and uses the short url like https://mixable.blog/?p=4803 for this. When you already use nice slugs as permalink structure, such a tag is not necessary, because you already have unique urls. To remove the shortlink tag, you can use an additional plugin…

    Read more

  • How to delete a single element from an array in PHP

    How to delete a single element from an array in PHP

    By

    in

    PHP already provides a large number of methods to manipulate arrays. The official PHP documentation shows a full list of array functions. Those can be used to create, sort and edit any of your arrays. Let’s assume you want to remove an item from an array. PHP provides multiple solutions out of the box. Let’s…

    Read more

  • PHP fatal error: Uncaught TypeError: ftp_nlist(): Argument #1 ($ftp) must be of type FTP\Connection, null given

    PHP fatal error: Uncaught TypeError: ftp_nlist(): Argument #1 ($ftp) must be of type FTP\Connection, null given

    By

    in ,

    After moving a WordPress installation to another server, the following error showed up: The new server had a different linux distribution and a newer PHP version. In my case, the environment changed from PHP 7.4 to PHP 8.2. I already added some missing PHP extensions and updated the configuration to match the old one, but…

    Read more

  • JavaScript: how to check if a string variable is an integer value

    JavaScript: how to check if a string variable is an integer value

    By

    in

    In JavaScript, one way to check if a variable is of type integer, Number.isInteger() can be used: Nevertheless, this solution has the disadvantage, that a string with integer value like ’22’ will result in false. But there are different solutions for this: Use parseInt You can use the parseInt function to parse a string and…

    Read more

  • How to decode the exception backtrace of an ESP32

    How to decode the exception backtrace of an ESP32

    By

    in

    When the execution of code on an ESP32 throws an exception, the output might look like this: The Espressif tools contain a binary called xtensa-esp32-elf-addr2line which will decode the backtrace addresses and return details about the source files, lines and function names, etc. To run the tool, call: In the command above, simply…

    Read more

  • FutureBuilder: handle multiple futures in a single widget

    FutureBuilder: handle multiple futures in a single widget

    By

    in

    By default, FutureBuilder provides a single future parameter that handles a single Future. For multiple Futures, we can combine them into a single Future using Future.wait. Here’s a step-by-step guide on how to do this: Create a list of Future objects Create a list of Future objects that represent the asynchronous operations you want to…

    Read more

  • mysqldump: how to use a specific port

    mysqldump: how to use a specific port

    By

    in

    The mysqldump client utility performs logical backups, producing a set of SQL statements that can be executed to reproduce the original database object definitions and table data. By default, the mysqldump command uses the port 3306 to connect to the database. To use a different port, you can provide the –port (or -P) option followed by the port number…

    Read more

  • JavaScript: the differences between escape(), encodeURI(), and encodeURIComponent()

    JavaScript: the differences between escape(), encodeURI(), and encodeURIComponent()

    By

    in

    In JavaScript, escape(), encodeURI(), and encodeURIComponent() are three functions used to encode strings for different purposes. Each function serves a distinct purpose, and it’s essential to understand their differences: escape() The escape() function is used to encode a string so that it can be safely included in a URL query string. It encodes special characters,…

    Read more

  • ESP32: Stack canary watchpoint triggered (loopTask)

    ESP32: Stack canary watchpoint triggered (loopTask)

    By

    in ,

    Recently, I stumble upon the following error on an ESP32: The reason for this was an infinite loop that was caused by two methods that where called from each other. So the execution of the first method never ended. The code looked something like this (extremly simplified): Foto von Vishnu Mohanan auf Unsplash

    Read more

  • ESP32: how to read and write the partition table of an ESP device?

    ESP32: how to read and write the partition table of an ESP device?

    By

    in

    To communicate with an ESP32 the ESP-IDF (Espressif IoT Development Framework) can be used. This framework provides a collection of useful scripts to communicate with your ESP device. The framework is supported on Windows, Linux and macOS. You can download the ESP-IDF repository and extract the contents into a folder. Note that you need to…

    Read more

  • PHP: when to use ‘self’ and when to use ‘$this’?

    PHP: when to use ‘self’ and when to use ‘$this’?

    By

    in

    In PHP, the term $this is utilized to point to the current instance of the class whereas the term self is used to indicate the class itself. Its recommended to use $this when referring to instance level properties or methods within the class, like accessing a property of the object or invoking a method of…

    Read more

  • PHP: How to check if a string contains a specific word?

    PHP: How to check if a string contains a specific word?

    By

    in

    When working with strings in PHP, you can already use many useful functions to manipulate the string contents. However, sometimes you only want to check for the string contents before performing an action. In PHP you can determine if a string includes a word by utilizing functions like strpos(), preg_match() or str_contains(). Using strpos() The…

    Read more

  • Dart: What is the difference between the “const” and “final” keywords?

    Dart: What is the difference between the “const” and “final” keywords?

    By

    in

    In Dart, both const and final are used to declare variables that can’t be reassigned after they’re initialized. However, there are some differences between them: In general, use const when you have a value that will never change and you want to ensure that only one instance of it exists, and use final when you…

    Read more

  • Flutter: How to Create a Color from a Hexadecimal Color String

    Flutter: How to Create a Color from a Hexadecimal Color String

    By

    in

    In Flutter, you can use included the Color class to create a color from a hexadecimal color string value. The Color class accepts a 32 bit integer value with the first 8 bits denoting the alpha channel (transparency) and the subsequent 24 bits representing the red, green and blue channels. To create a color object…

    Read more

  • Pecl: fixing “fatal error: ‘pcre2.h’ file not found”

    Pecl: fixing “fatal error: ‘pcre2.h’ file not found”

    By

    in

    When using pecl to install a PHP extension, I always got a “fatal error: ‘pcre2.h’ file not found” after PHP has been updated. The update was done using brew upgrade php. In my case, this happens when I try to install pcov using: The output was: To fix the issue, make sure you have pcre2…

    Read more

  • jQuery methods in plain JavaScript

    jQuery methods in plain JavaScript

    By

    in ,

    Life is already very complex, so let’s simplify your projects by removing all the jQuery code. Plain JavaScript provides the same functionalities and it does not require any additional frameworks. And it’s supported by most of the modern browsers out of the box. This is a list of replacements for your daily used jQuery methods.…

    Read more

  • Flutter: How to remove the debug banner during development

    Flutter: How to remove the debug banner during development

    By

    in ,

    By default, Flutter shows a debug banner on the top right corner of an app, that indicates that the app was build in debug mode. This banner… … is intended to deter people from complaining that your app is slow when it’s in debug mode. In debug mode, Flutter enables a large number of expensive…

    Read more