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: expand TextField height to match parent widget

    Flutter: expand TextField height to match parent widget

    By

    in

    In Flutter, the TextField widget shows a single line by default. To expand the height of TextField to match the parents widgets height, the following code can be used: The important thing is, that both minLines and maxLines need to be set to null. To set the height of the Container to match it’s parent…

    Read more

  • Enable debugging output in PHPUnit

    By

    in

    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…

    Read more

  • Xcode: how to disable an extension during app build

    Xcode: how to disable an extension during app build

    By

    in ,

    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…

    Read more

  • Create certificate for localhost domains on macOS

    Create certificate for localhost domains on macOS

    By

    in ,

    The following steps describes how to create a certificate for localhost domains for a local webserver on macOS. Step 1: create a self-signed root certificate First, let’s create a self-signed root certificate: The parameter -days 390 sets the number of days, this certificate is valid. Starting on September 1st (2020), SSL/TLS certificates cannot be issued…

    Read more

  • Flutter on iOS: themeMode does not change to dark mode if `ThemeMode.system` is used

    Flutter on iOS: themeMode does not change to dark mode if `ThemeMode.system` is used

    By

    in

    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…

    Read more

  • fatal error: ‘Flutter/Flutter.h’ file not found

    fatal error: ‘Flutter/Flutter.h’ file not found

    By

    in

    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

    Read more

  • Swift: how to create a Singleton pattern

    Swift: how to create a Singleton pattern

    By

    in

    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…

    Read more

  • PHPUnit: faster and better unit tests with pcov

    By

    in

    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…

    Read more

  • PHP: realpath() for non-existing path

    By

    in

    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:

    Read more

  • How to ignore PHP_CodeSniffer warning: Line exceeds 120 characters

    How to ignore PHP_CodeSniffer warning: Line exceeds 120 characters

    By

    in

    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:…

    Read more

  • CocoaPods: pod update/install stuck at “Pre-downloading …”

    By

    in

    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:

    Read more

  • PNG – deactivate interlace to avoid ‘libpng warning: Interlace handling should be turned on when using png_read_image’

    PNG – deactivate interlace to avoid ‘libpng warning: Interlace handling should be turned on when using png_read_image’

    By

    in

    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…

    Read more

  • Composer – PHP Fatal error: Allowed memory size of ## bytes exhausted

    Composer – PHP Fatal error: Allowed memory size of ## bytes exhausted

    By

    in

    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:…

    Read more

  • Background tasks in iOS

    Background tasks in iOS

    By

    in ,

    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…

    Read more

  • Hello World in 74 natural languages

    Hello World in 74 natural languages

    By

    in ,

    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:…

    Read more

  • CocoaPod Workflow – eine Zusammenfassung

    By

    in

    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…

    Read more

  • How to set C, C++ or Fortran compiler for CMake

    By

    in ,

    To use a different compiler (e.g. Intel Compiler, CLANG or PGI) or a different version then CMake uses by default, one can either set environment variables or modify the CMakeLists.txt file. CMake evaluates the environment variables CC for the C compiler, CXX for the C++ compiler and FC for the Fortran compiler: For a more…

    Read more

  • Python: alle Anaconda Pakete über die Konsole aktualisieren

    By

    in

    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:

    Read more

  • Python: Spyder aktualisieren

    By

    in

    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.

    Read more

  • Customizing Bootstrap 4 without changing the core files

    Customizing Bootstrap 4 without changing the core files

    By

    in

    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…

    Read more