
Let's say you want to automatically delete specific sorts of comments from your WordPress blog. For example, immediately trashing any comment that has a specific phrase "Elephant Juice" in it. You can do this by going to Settings -> Discussion → Disallowed Comment Keys. Or you can add something to your theme's functions.php file. Here's the code snippet: add_action( 'comment_post', 'check_comment_content', 10, 2 ); function check_comment_content( $comment_id, $comment_approved ) { $…
Continue reading →
I've recently started using Mosh. It's a clever bit of software that keeps your SSH sessions running, even if your client goes offline or changes IP address. But I find the syntax used to launch it a bit verbose and easy to forget. A typical command is something like: mosh --ssh="ssh -p 1234" myname@example.com Within the FAQ is a fleeting mention of how to configure Mosh. It says: Q: How do I use a different SSH port (not 22)? As of Mosh 1.2, you can pass arguments to ssh like so: …
Continue reading →
tl;dr - edit the file ~/.bash.rc add the line export MOZ_ENABLE_WAYLAND=1 then reboot. Once done, type into the Firefox address bar about:support and check that "Window Protocol" is set to "wayland". You can configure how swipes work by visiting about:config and filtering for "swipe": I'll say this for Linux - why have two different ways to accomplish something when you can have twenty? It seems there are dozens of different places where you can set environment variables - I've seen…
Continue reading →
This is ridiculously niche. If this is of help to anyone other than to me... please shout! The IntenseDebate comment system is slowly dying. It hasn't received any updates from Automattic for years. Recently it stopped being able to let users submit new comments. So I've switched to Commentics which is a self-hosted PHP / MySQL comment system. It's lightweight, pretty good at respecting users' privacy, and very customisable. But it doesn't let you easily import comments. Here's how I fixed…
Continue reading →
I blog. A lot. Too much really. One of the things I like to do is see what I was rambling on about this time last year. And the year before that. And so on. So, here's my On This Day page and here's how I built it. WARNING Extremely quick and dirty code ahead! This allows you to add a shortcode like [ edent_on_this_day ] to a page and have it auto generate a list of posts you published on this day in previous years. You may need to exclude that page from your cache. Add these functions to…
Continue reading →
I am enjoying playing with the eInk Watchy. It is a cute package and is everything I want in a Smart-Watch; geeky, long battery life, and not obnoxious. But - fuck me! - the documentation is atrocious! Well, that's a lie. There is no documentation. It has the "Chat to us on Discord" anti-pattern that infects so many otherwise great projects. So I'm left to figure out how to make the Watchy's haptics work. The example watchfaces have a file called settings.h which contains .vibrateOClock =…
Continue reading →
I recently read Darek Kay's excellent post about styling RSS feeds and wanted to do something similar. So, here's my simple guide to styling your WordPress blog's RSS / Atom theme. The end result is that if someone clicks on a link to your feed, they see something nicely formatted, like this: Prerequisites This involves editing your WordPress blog's theme. If you don't know what you're doing, you can mess up your blog. Make sure you take some backups before experimenting on your live…
Continue reading →
I am using Auth0's Symfony library to allow users to log in with their social network providers. It works really well. Using this firewall configuration, a user who visits /private is successfully taken through the login flow and I can then use $this->getUser() to see their details. security: password_hashers: Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto' providers: users_in_memory: { memory: null } auth0_provider: …
Continue reading →
I couldn't work out how to use Route Aliasing within my controller. I couldn't find anything in the documentation about it. But, thanks to a StackOverflow comment it is possible. Suppose you want users to be able to access a page using /users/123 and /people/123 - with both routes displaying the same data? Normally you'd write something like #[Route('/user/{id}', name: 'show_user')] - as it happens, that first parameter can be an array! Which means you can write: <?php namespace…
Continue reading →
I'm just getting started with Symfony, so I'm blogging some of the weird things I'm finding. Symfony has a concept of Cache Contracts. You can call an expensive / slow / intensive operation and immediately cache the result for a specific time period. Next time you call the operation, the results are served from the cache until the expiry time has been hit. Nifty! But I couldn't get it to work. Take this sample code. It should return the current date and time and cache the result for 5…
Continue reading →
I'm just getting started with Symfony, so I'm blogging some of the weird things I'm finding. I want to use Doctrine dbal to search a database for a partial match. For example searching for "smith" should find "blacksmith" and "smithy". I have a prepared statement like this: $queryBuilder = $conn->createQueryBuilder(); $queryBuilder ->select("whatever") ->from("table") ->where("name LIKE '%?%'") ->setParameter(0, $query); …
Continue reading →
Metawork is so much more fun than real work. Sharpening your pencils. Colour coordinating your filing system. Creating Gantt charts of what you intend to do. Marvellous! In that spirit, here's how I used the venerable pandoc to convert my MSc dissertation from .md into a variety of more readable formats. Prep I've no idea what you already have installed on your system but, at a minimum, you need to install the latest version of pandoc and you'll need a modern version of the weasyprint…
Continue reading →