Category: Coding & Scripting

  • 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

    Written 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

    Written by

    in

    After switching the flutter channel to beta and back to stable, my app did not compile anymore. The compilation stopped with the 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

    Written 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

    Written 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

    Written 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

    Written by

    in

    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…

    Read more

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

    Written by

    in

    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’

    Written 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

    Written 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

    Written 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

    Written 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

    Written by

    in

    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…

    Read more

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

    Written 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: CC=/path/to/icc cmake ..…

    Read more

  • Python: alle Anaconda Pakete über die Konsole aktualisieren

    Written 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: conda update –all

    Read more

  • Python: Spyder aktualisieren

    Written by

    in

    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.

    Read more

  • Customizing Bootstrap 4 without changing the core files

    Customizing Bootstrap 4 without changing the core files

    Written by

    in

    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…

    Read more

  • Visual Studio / C#: “Für die angegebene Kultur oder die neutrale Kultur konnten keine Ressourcen gefunden werden.”

    Written by

    in

    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…

    Read more

  • BASH Shell: Einen Wert zu einer hexadezimalen Zahl hinzuaddieren

    Written by

    in ,

    Die einfachste Möglichkeit einen Wert zu einer hexadezimalen Zahl wie bspw. einen Teil einer MAC-Adresse auf der Konsole hizuzufügen ist die printf Funktion:

    Read more

  • BASH: Nach jedem xten Zeichen ein Zeichen in einen String einfügen

    Written by

    in

    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…

    Read more

  • Could NOT find mhd (missing: MHD_INCLUDE_DIR MHD_LIBRARY) / MHD lib : MHD_LIBRARY-NOTFOUND

    Written by

    in

    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

    Read more