What's been on my mind

Use Twig's default filter in place of the ternary operator

Submitted by Charles on Tue, 03/09/2021 - 16:29

Instead of using the ternary operator to set a value or a default if that value doesn't exist, Twig's "default" filter provides a more compact and readable way of doing so. For example:

{% set alignment = alignment ? 'pagination--' ~ alignment : 'pagination--center' %}


{% set alignment = 'pagination--' ~ alignment|default('center') %}

Selectively disabling Bootstrap tooltips for form field elements

Submitted by Charles on Sun, 04/05/2020 - 13:45

On a Drupal 8, Bootstrap based site that I’m currently working on we have a couple of forms that have a boolean ‘Acknowledgement’ field that is displayed at the bottom.

Because we’ve enabled “Smart form descriptions (via Tooltips)” in the theme settings, the form field descriptions are not visible, but in this case we wanted to display it below the field, instead of as a tooltip.

Cape Town 1.6°C above normal in 2018

Submitted by Charles on Thu, 02/07/2019 - 10:30

The New York Times has a tool on their site which allows you to check how much warmer a city was in 2018, compared to an average calculated using data from 1981 to 2010. The data, provided by AccuWeather, comes from a database of more than 3800 cities worldwide which shows that about 83% of cities experienced average temperatures higher than normal last year.

Copying multiple words in PhpStorm

Submitted by Charles on Wed, 01/23/2019 - 12:43

To copy multiple, non-adjacent words in PhpStorm, option click at the start of each word, then hold option and shift and hit the right-arrow key and each word will become highlighted. Ctrl + c to copy and then move to where you want to place the copied words and paste (Ctrl + v). You can also add extra text before or after the copied words, and the extra text will occur in the same place on each line from which the words were copied.


"Plastic Nightmare": a presentation in Kommetjie by Surfer and Scientist Dr. Tony Butt

Submitted by Charles on Mon, 08/20/2018 - 15:00

Surfer and oceanographer Dr. Tony Butt, who has been a regular at the big wave spots around the Kommetjie area over the years and who has given talks about the science of waves and geomorphology, spoke again this evening at the Kommetjie Surf Shop, but this time it wasn’t about surfing or the formation of waves, rather he presented his research and thoughts on this “Plastic Nightmare” we are living in and are all contributors to.