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.
-
Steuerbescheinigungen von Ecoligo, Bettervest und anderen secupay basierten Crowdfunding Plattformen in CSV Tabelle konvertieren
Ecoligo und Bettervest sind zwei innovative Plattformen, die sich darauf spezialisiert haben, nachhaltige Investitionsmöglichkeiten zu bieten. Ecoligo ermöglicht es Privatpersonen, in Solarprojekte in aufstrebenden Märkten zu investieren, um den Ausbau erneuerbarer Energien voranzutreiben und gleichzeitig attraktive Renditen zu erzielen. Bettervest konzentriert sich auf Crowdinvesting in Energieeffizienzprojekte und erneuerbare Energien, bei denen Menschen von Einsparungen und…
-
Fatal error: Call to undefined function bindtextdomain()
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…
-
HTML: how to vertically center an object with CSS?
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…
-
Dart: Zufallszahl in einem Bereich erstellen
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…
-
WordPress: how to remove the ‘link rel=shortlink’ tag from your site
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…
-
How to delete a single element from an array in PHP
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…
-
PHP fatal error: Uncaught TypeError: ftp_nlist(): Argument #1 ($ftp) must be of type FTP\Connection, null given
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…
-
JavaScript: how to check if a string variable is an integer value
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…
-
How to decode the exception backtrace of an ESP32
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…
-
FutureBuilder: handle multiple futures in a single widget
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…
-
mysqldump: how to use a specific port
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…
-
JavaScript: the differences between escape(), encodeURI(), and encodeURIComponent()
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,…
-
ESP32: how to read and write the partition table of an ESP device?
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…
-
PHP: when to use ‘self’ and when to use ‘$this’?
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…
-
PHP: How to check if a string contains a specific word?
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…
-
Dart: What is the difference between the “const” and “final” keywords?
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…
-
Flutter: How to Create a Color from a Hexadecimal Color String
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…
-
Pecl: fixing “fatal error: ‘pcre2.h’ file not found”
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…
-
jQuery methods in plain JavaScript
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.…