PHP and SQLite FTS4: How to process the matchinfo function

Part I: Reading the binary output from the matchinfo() function

The MATCHINFO() function returns a binary string which represents a variable number of 32-bit unsigned integers in machine byte-order. It can be read into an array of integers using the PHP unpack() function and Format ‘L*’.

Continue reading “PHP and SQLite FTS4: How to process the matchinfo function”

SQLite FTS4: Standard vs Enhanced Query Syntax

The SQLite documentation talks about two ways to perform full text queries: standard or enhanced query syntax. Be aware: which one is available depends on how SQLite was compiled. You might, like me, run into troubles when developing locally using one syntax and then publishing remotely only to find out your query does not return anything. You can check which version is supported by your server by querying the PRAGMA compile_options, e.g. for PHP:

Continue reading “SQLite FTS4: Standard vs Enhanced Query Syntax”

Minify CSS with PhpStorm automatically

Installation guide for PhpStorm 2019.3.1 to minify CSS files automatically after editing using the command line interface for CSSO as a file watcher. You could also use yuicompressor instead, but version 2.4.8 chokes on CSS @keyframes rules.

Continue reading “Minify CSS with PhpStorm automatically”

BIOS update with Linux Mint

Updating your BIOS on Linux Mint 19 can be as easy as on Windows. If your computer is listed on the Linux Vendor Firmware Service, then all you have to do is:

~ $ sudo apt install fwupd
~ $ fwupdmgr get-updates
~ $ fwupdmgr update

The firmware-manager might even get included in the next version of Linux Mint 20.

Linux Mint 19.1: Lightning Calendar in English, but dates in the 24-hour time format

I like having the user interface of my Linux Mint 19.1 in English, but the regional settings such as numbers and currency in a different language such as Swiss German.

Screenshot of the Language Settings dialog in Linux Mint 19.1
Continue reading “Linux Mint 19.1: Lightning Calendar in English, but dates in the 24-hour time format”

VirtualBox 6: How to enable symlinks for shared folders

For security reasons, creating symbolic links in a shared folder is disabled in the guest OS (ticket 10085 and manual 5.3 Shared Folders). If you trust your Linux guest OS, you can enable symlinking from the host OS with the following command:

~ $ VBoxManage setextradata "VM_Name" VBoxInternal2/SharedFoldersEnableSymlinksCreate/Folder_Name 1

Replace VM_Name and Folder_Name with your own names. To get a list of names of your virtual machines, execute in the host console:

~ $ VBoxManage list vms

You can also list information about a specific machine with:

~ $ VBoxManage showvminfo "VM_Name"

Now you can start your Linux guest OS and create the symbolic link, in my case  I wanted to point my shared folder to the apache directory /var/www/html, e.g.

~ $ sudo ln -s /media/sf_Websites /var/www/html

The search for the Okinawa Rail

The Okinawa Rail is a flightless bird endemic to the Yambaru region in the north of Okinawa. The Japanese call it Yambaru Kuina, and though stylized versions of it are ubiquitous on packaging, advertising or road signs, most people have never actually seen it.

photo of street sign with a stylized Okinawa rail photo of a warning sign depicting an Okinawa rail
Okinawa rail on street signs.
Continue reading “The search for the Okinawa Rail”

How to install ExifTool with Composer

I’m working on a PHP project, that uses Phil Harveys excellent ExifTool to read Exif and XMP tags from photos. Since ExifTool is written in Perl, there is of course no composer.json to install this dependency directly with Composer. But you can create your own package information in your master composer.json as follows:

{
    ...
    "repositories": [
        ...        
        {
            "type": "package",
            "package": {
                "name": "philharvey/exiftool",
                "version": "10.75",
                "dist": {
                    "url": "https://sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-10.75.tar.gz",
                    "type": "tar"
                }
            }
        }
    ],
    "require": {
        ...
        "philharvey/exiftool": "10.*"
    }
}

This will automatically download ExifTool version 10.75 and extract it into the vendor folder /vendor/philharvey/exiftool/

Note, that the package type ‘tar’ should extract the file completely. If that is not the case, make sure you have the latest composer version 1.6.2 installed. Some Linux distributions (e.g. Linux Mint 18.3 and probably Ubuntu 16.4 too) are still on version 1.0.0-beta2, which does not support extracting ‘tar.gz’. Read my quick tutorial on how to upgrade composer on Linux Mint 18.3.

How to update Composer on Linux Mint 18.3

When you install Composer (the dependency manager for PHP) globally on Linux Mint 18.3 with the package manager…

$ sudo apt install composer
$ composer -V
Composer version @package_branch_alias_version@ (1.0.0-beta2) 2016-03-27 16:00:34

…you’ll get the totally outdated version 1.0.0-beta2. The problem is that this version does not support extracting compressed package files ‘tar.gz’. It also does not support updating itself with:

$ composer selfupdate

So, you need to download the latest composer version (currently 1.6.2) manually and then put it into the directory /usr/local/bin/composer (which overrides /usr/bin/composer)

$ sudo mv composer.phar /usr/local/bin/composer
$ chmod +x /usr/local/bin/composer

now login – logout to apply the changes, voila:

$ composer -V
Composer version 1.6.2 2018-01-05 15:28:41

Visited by a roe deer

Over the New Year, I’ve spent a couple of days in my vacation home in the canton Vaud. During one night, we got quite a bit of fresh snow and the next evening my wife discovered this roe deer in our orchard. He was probably looking for apples.

Roe deer (Capreolus capreolus)
A roe deer (Capreolus capreolus) looking for food under the snow cover. Nikon D500, Nikon 300mm f2.8, 1/1250, f4.0, ISO 1250

Continue reading “Visited by a roe deer”