Compact `switch` alternative

Some situations in PHP require a set of variables to have values depending on some condition. To achieve such variable-assignment, a switch statement is the traditional GOTO, but PHP’s array syntax combined with the list() language construct. 

C Control Embedded

Filtering and Control Library

Check out this header-only C++11 library of control and filter tools. Currently it features PID control, bi-quads (or second-order-sections), state-space systems and a PRBS (pseudo-random-binary-signal) system identification function.  The code-documentation and tests provide reference and example to use the library. Creating a second order floating-point state-space is easy:


Quick-fix: MATLAB FMU import error

MATLAB 2017b introduced support for the Functional Mock-up Standard by providing FMU-import blocks in Simulink. This open standard enables mixing of simulation models created with different tools, like prototype controllers before coding them. This is an extremely powerful feature that I will write more about in soon. This memo, however, is about an error that occurred to me […]


Fixing: Vagrant LXC error, mount.nfs: mount to NFS server ‘’ failed: timed out, giving up

Vagrant-LXC is a plugin that provides integration of Vagrant with LXC containers, a modern virtualisation technology native to Linux. To share files between the host and the container, NFS can be used. The Vagrant NFS plugin ensures that a NFS server runs at the host that exports predefined locations of the host’s filesystem. Sometimes, an […]

MySQL Servers

Configuring MySQL with .my.cnf file

Connecting to a MySQL server often involves providing hostnames, usernames and passwords. Use a .my.cnf configuration file to provide defaults that simplify working with a MySQL server.  Providing a default password reduces security. Take effort to make sure that the password cannot be read by other users on the system. If the server runs locally, use credentials that […]

Geen categorie PHP

Random values from PHP array one-liner

PHP provides the array_rand( $arr, $num )  function which returns an integer or array containing the keys of the array. To obtain an array of values the following one-liner can be used: array_intersect_key( $arr, array_flip( array_rand( $arr, $num ) ) ); This picks $num random keys from $arr (array_rand), flips keys with values (array_flip), intersects the […]