Pragmatism in the real world

Displaying exif information in WordPress posts

After discovering that WordPress modifies img tags when rendering a page, it crossed my mind that I could display exif information underneath each image on my new photography blog. The basic process is applicable to any manipulation of the content that you would want to do before it is displayed. To do this, we add a new filter to the the_content hook: add_filter('the_content', function ($content) { // manipulate $content return $content; }); As with all… continue reading.

Images and WordPress

My new WordPress project has multiple photographs per post and as I wanted them to work in an efficient manner for multiple screen resolutions. The secret to this is the srcset and sizes attributes on the img tag. It turns out that WordPress will create multiple sized thumbnails when you upload an image. It will also add the srcset and sizes attributes into your img tags for you if your image tag has a class… continue reading.

Developing WordPress sites with Docker

I recently set up a new WordPress based website and local Docker-based development environment. This post documents what I did, so that I can do it again next time! As I'm not in the WordPress world, many things are strange to me and I'm indebted to Jenny Wong for pointing me in the right direction on numerous occasions and being very patient with my questions! Thanks Jenny! Project organisation There's always ancillary files and directories… continue reading.

Creating virtual environments with Pyenv

rst2pdf is a Python 2 application that we're making compatible with Python 3. When developing Python applications, I've found it useful to be able to switch python versions easily and also set up clean environments to work in. To do this, I currently use pyenv. This is how I set it up: Install Pyenv On my Mac, I install pyenv & its sister project pyenv-virtualenv with Homebrew: $ brew install readline xz $ brew install… continue reading.

Using a separate master password in 1Password for Mac

I really like the 1Password password manager and recently switched to using the subscription based account. This allows access to my passwords via the web so, as you can imagine, I have a very strong 35 character master password set. On my Mac, I use the 1Password app and that requires me to enter my master password reasonably frequently, so this very long password is not so desirable here. I'm comfortable that a 12 character… continue reading.

Running PHP applications on Azure App Engine

Azure App Service is a way to host your web application in a container without having to think about the server. It's the same PaaS concept as AWS Elastic Beanstalk and supports all the main web programming languages. It also supports Windows and Linux OS containers. I have a client that is moving an on-premises PHP application to App Service and so have been looking at what I needed to do to deploy it there.… continue reading.

Step debugging sphinx-build in PyCharm

I've been trying to solve an issue with the rst2pdf Sphinx extension which allows you to use rst2pdf to create a PDF of your Sphinx documentation rather than using Sphinx's default pdfTeX builder. In order to understand what was happening, I really wanted to inspect variable at certain stages of the process, which is easiest with a step debugger. As I already use PhpStorm for step debugging PHP, I fired up PyCharm and worked out… continue reading.

PHP Architect: Serverless PHP With Bref, Part 2

Part two of my article on using Serverless PHP using Bref has been published! In part one, I introduced Bref as we wrote a simple "Hello World" application. Part follows this up exploring a more complete serverless application, my Project365 website. This S3 hosted static website is build using a serverless PHP function that connects to the Flickr API to retrieve my my one-photo-per-day images and present them on a single page per year. In… continue reading.

Keyboard shortcut to Save as PDF on Mac

I regularly print to PDF on my Mac, This is done from the print dialog by selecting Save as PDF from the drop down in the bottom left of the dialog which is a bit of a pain to get using the mouse. I recently discovered that I could create a keyboard shortcut to make this much easier. In System Preferences -> Keyboard -> Shortcuts -> App Shortcuts you can create a keyboard shortcut to… continue reading.