I once described my ideal coding environment to a colleague as "telneting directly into prod and damn the consequences!" I jest. But only a little. When I build for myself I treat best practices and coding styles as harmful. Chaotic evil but, hey, it's only myself I'm hurting. Anyway, my wife and I run a hobby site - OpenBenches.org - which was coded in a long alcopop fueled weekend. It's fair to say that it has exceeded our expectations in terms of people getting involved. But is…
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 →
This pissed me off and I couldn't figure out what I was doing wrong. So I'm blogging about my ignorance. Imagine you're using Symfony and Doctrine to access a database. You are using prepared statements to prevent any SQL injection problems. There are two main ways of doing this - and they disagree about how positional variables should be specified. Data Retrieval And Manipulation Here's a fairly trivial SQL statement with a couple of variables: $sql = "SELECT `userID` FROM `users` WHERE…
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 →
I've been thinking a lot about footnotes in Markdown. I've contributed a patch to make them slightly better in WordPress. Now I'm wondering how to make them more useful by enhancing their pop-up title text. To that end, I'm writing a patch for PHP Markdown which will display the first ~200 characters of a footnote in the pop-up title text. Hover over the superscript number and you'll get a preview of the footnote. Dealing with all sorts of weird HTML & Markdown edge-cases is tricky. So, if…
Continue reading →
WordPress's Jetpack plugin allows you to easily syndicate your blog to Twitter, LinkedIn, Tumblr, Email, and a few other services. But there's no native way to publish directly to your Mastodon feed. This is a guide to how I got my blog to publish every new post to Mastodon with a nicely formatted preview. This uses Jan's "Share on Mastodon" plugin which you'll need to install and configure. Once you've followed these instructions, you'll get a share which has a headline, excerpt, link,…
Continue reading →
I was asked to help create some pseudo-NFT style avatars for Cambridge Digital Humanities' Faust Shop project. Something with vaguely the same æsthetic as those daft "Crypto Punks". You can see it in action partway through this TikTok video. @cambridgeuniversity Visit the #Faust Shop and see what happens when you make a deal with your digital double. #Devil #EduTok #Cambridge #Performance #Philosophy ♬ original sound - Cambridge University Here are some examples of the types of av…
Continue reading →
Previously on Terence Eden's Blog: I turned an old eReader into an Information Screen. This time, I'm taking a different Nook, and turning it into a magic gallery. Here's what it looks like in action: Terence Eden is on Mastodon@edentUpcycled an old eReader into an art frame.Displays a new black & white piece of art from Flickr every few minutes.Full write-up this weekend, but pretty straightforward to do. pic.x.com/ttvrbhz3ee❤️ 137💬 14🔁 021:20 - Wed 22 September 2021 Video With the front l…
Continue reading →
One of the problems with OEmbeds of Tweets is that they're heavy. Lots of JavaScript, tracking cookies, and other detritus. See this excellent post by Matt Hobbs looking at how to make your website faster by removing Twitter embeds and replacing them with images. Here's my attempt to turn a Tweet into a semantic SVG! This doesn't attempt to faithfully recreate the exact look and feel of an authentic Tweet. But it is designed to be a small, fast, and semantic representation. Here's what it…
Continue reading →
This experiment has now ended. The code is available on https://gitlab.com/edent/very-slow-website One thing most websites try to do is try to serve you the page as fast as possible. So I've decided to do the opposite. I've made a (toy) web server which goes as slow as humanly possible. You can visit it at http://slowww.rf.gd - but you'll need to be patient. This delivers a page at about 175 bits per second. Yes, bits. Not bytes. It is deliberately set to be about as fast as an adult…
Continue reading →