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.
-
Flutter on iOS: themeMode does not change to dark mode if `ThemeMode.system` is used
Written by
In my case, a simple app should automatically use the theme (light or dark) of the system to style the user interface. By default, this should work when using ThemeMode.system (see flutter documentation). But it didn’t. The themes have been defined as follows: In addition, the WidgetsBindingObserver callback didChangePlatformBrightness() was never called. It was defined…
-
fatal error: ‘Flutter/Flutter.h’ file not found
Written by
After switching the flutter channel to beta and back to stable, my app did not compile anymore. The compilation stopped with the following error: Multiple flutter clean and channel switches did not work in this case. The following commands fixed this behavior: See: https://github.com/flutter/flutter/issues/70895#issuecomment-744734693
-
Swift: how to create a Singleton pattern
Written by
What is a Singleton? A singleton pattern guarantees that only one instance of a class is initialized and available from different points of an app. Some examples are already available in Apple’s frameworks: How to define a Singleton Often a static constant is used to adopt the Singleton pattern. To do that the reference to…
-
PHPUnit: faster and better unit tests with pcov
Written by
When using PHPUnit there are different ways to create a code coverage report. By default, XDebug is used. But as mention on different sites, XDebug is very slow and the generation of a code coverage report might take several minutes for big projects. phpdbg To speed up things, phpdbg can be used. This significantly speeds…
-
PHP: realpath() for non-existing path
Written by
The php method realpath() can transform the string format of a path into a real path. Means, a path string like: will become: But this only works, if the path really exists. For non-existing paths, this function cannot be used. To get the same functionality, the following function can be used:
-
How to ignore PHP_CodeSniffer warning: Line exceeds 120 characters
Written by
When using CodeSniffer to check your code, a lot of warnings might appear when the lines are too long: Limiting the length of a line of code improves code readability. It also makes comparing code side-by-side easier and improves compatibility with various editors, IDEs, and diff viewers. Nevertheless, it may be helpful to ignore those…
-
CocoaPods: pod update/install stuck at “Pre-downloading …”
Written by
When CocoaPods stops the execution of install or update command, it’s helpful to clean the CocoaPod cache using the following commands: After this, the update (or install) should run smoothly:
-
PNG – deactivate interlace to avoid ‘libpng warning: Interlace handling should be turned on when using png_read_image’
Written by
I stumbled appon a warning message that was thrown by PHP when handling images with GD lib (e.g. imagecreatefrompng()). The message shown was: This message even exists, when deactivating ‘interlace’ with the help of: The point is that this message is not caused by any wrong php code, it is caused by the processed images…
-
Composer – PHP Fatal error: Allowed memory size of ## bytes exhausted
Written by
Composer may sometimes fail on some commands with this message: In this case, the PHP memory_limit should be increased. Note: Composer internally increases the memory_limit to 1.5G. To get the current memory_limit value, run: Try increasing the limit in your php.ini file (ex. /etc/php5/cli/php.ini for Debian-like systems): Composer also respects a memory limit defined by the COMPOSER_MEMORY_LIMIT environment variable: Or, you can increase the limit with a command-line argument:…
-
Background tasks in iOS
Written by
As already discussed in Background task in iOS action extension, it sometimes becomes necessary to perform time consuming tasks in the background. This is really important, if such a task would block the user interaction. Especially for action and share extensions, this might lead to some waiting time before a task completes and the extension…
-
Hello World in 74 natural languages
Written by
Hello World is the example of coding which is used to show that a code snippet is running in a specific programming language. But how do you say “Hello World” in different natural languages? Language Translation Afrikaans: Hello Wêreld! Albanian: Përshendetje Botë! Amharic: ሰላም ልዑል! Arabic: مرحبا بالعالم! Armenia: Բարեւ աշխարհ! Basque: Kaixo Mundua! Belarussian:…
-
CocoaPod Workflow – eine Zusammenfassung
Written by
Eine auswführliche Beschreibung, wie man von Grund auf einen CocoaPod erstellt, findet sich unter https://guides.cocoapods.org/making/making-a-cocoapod.html. Ist der CocoaPod erstellt, dann lassen sich Updates mit wenigen Befehlen einpflegen. Hier nun die wichtigsten Schritte: Zum Testen des Quelltextes: Vor dem Veröffentlichen zunächst die Versionsnummer anpassen. Dazu die .podspec bearbeiten: Hinweis: Wenn der Tag in spec.source als Variable…
-
Python: alle Anaconda Pakete über die Konsole aktualisieren
Written by
In der Python-Umgebung Anaconda können Pakete manuell aktualisiert werden. Sind das ein paar mehr, dann ist es von Vorteil das Terminal mit folgendem Befehl zu nutzen: conda update –all
-
Python: Spyder aktualisieren
Written by
Nutzt man Spyder unabhängig von einer wissenschaftlichen Umgebung (z.B. Anaconda, WinPython or Python(x,y), …) dann lässt sich Spyder mit folgendem Terminal-Befehl aktualisieren: pip install –upgrade spyder Der Befehl aktualisiert auch alles Spyder-Abhängigkeiten.
-
Customizing Bootstrap 4 without changing the core files
Written by
A simple instruction to customize the Bootstrap 4.0 using SASS and Autoprefixer. But why? You can either… When you choose number 2, then it’s necessary to use SASS for compiling the style sheet and Autoprefixer for CSS vendor prefixing. And this is how to get a customized version of Bootstrap: First make sure, you’ve installed Node.js and…
-
Visual Studio / C#: “Für die angegebene Kultur oder die neutrale Kultur konnten keine Ressourcen gefunden werden.”
Written by
Dieser Fehler tritt normalerweise auf, wenn versucht wird, auf Ressourcen zuzugreifen, die nicht gefunden werden können. Ressourcen können in C#-Anwendungen verwendet werden, um lokalisierte Texte, Bilder oder andere Dateien zu speichern, die in verschiedenen Sprachen oder Regionen angezeigt werden sollen. Um den Fehler “Für die angegebene Kultur oder die neutrale Kultur konnten keine Ressourcen gefunden…
-
BASH: Nach jedem xten Zeichen ein Zeichen in einen String einfügen
Written by
Mit sed “s/.\{x\}/& /g” kann man in eine Zeichenkette alle x Zeichen ein Leerzeichen automatisiert einfügen. Aber auch andere Zeichen sind möglich. So kann man bspw. alle zwei Zeichen einen Doppelpunkt in einen String einfügen: #~> echo “AA11CC22EE” | sed “s/.\{2\}/&:/g” AA:11:CC:22:EE: Sollte das letzte Zeichen stören, kann man dies wie folgt entfernen: #~> a…
-
Could NOT find mhd (missing: MHD_INCLUDE_DIR MHD_LIBRARY) / MHD lib : MHD_LIBRARY-NOTFOUND
Written by
When cmake complains about a missing MHD library, install the microhttpd library development files. On RHEL/CentOS: yum install libmicrohttpd-devel Or download the up-to-date release from https://www.gnu.org/software/libmicrohttpd/ and compile and install it with: tar -xzf libmicrohttpd-latest.tar.gz cd libmicrohttpd-* ./configure && make install