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.
-
Enable debugging output in PHPUnit
When running PHPunit there are only dots and letters for each test by default: To enable debug output and get some more details about the tests running, simply add the logging section to phpunit.xml.dist: This will create a debug output and helps to track the tests: In my case, this helped when my code reached…
-
Xcode: how to disable an extension during app build
Sometimes the development version of an app includes multiple code e.g. an extension that should not be released yet. In this case, it’s possible to exclude the extension when building an app. This keeps all your code, but does not include the extension during the build phase. To achieve this, simply open the Build Phases…
-
Flutter on iOS: themeMode does not change to dark mode if `ThemeMode.system` is used
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
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
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
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
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
PHP_CodeSniffer is a set of PHP scripts to detect violations of a defined coding standard, and to automatically correct such coding standard violations. When using CodeSniffer to check your code, a lot of warnings might appear for such violations. Accodring to PSR-2 coding style guide, a warning is raised when the lines are too long:…
-
CocoaPods: pod update/install stuck at “Pre-downloading …”
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. 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’
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
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
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
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
Eine ausfü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
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:
-
Python: Spyder aktualisieren
Spyder ist eine freie und open-source wissenschaftliche Umgebung, die in Python für Python geschrieben und von und für Wissenschaftler, Ingenieure und Datenanalysten entwickelt wurde. Nutzt man Spyder unabhängig von einer anderen wissenschaftlichen Entwicklungsumgebung (z.B. Anaconda, WinPython or Python(x,y), …) dann lässt sich Spyder mit folgendem Terminal-Befehl aktualisieren: Der Befehl aktualisiert auch alles Spyder-Abhängigkeiten.
-
Customizing Bootstrap 4 without changing the core files
This post provides a simple instruction on how to customize the Bootstrap 4.0 stylesheet 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…