Terence Eden. He has a beard and is smiling.

Terence Eden’s Blog

Theme Switcher:

Minimum Viable Tweet to Semantic SVG

· 3 comments · 350 words · Viewed ~314 times


The Twitter logo.

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…

Introducing Slowww - the slow web server

· 21 comments · 300 words · Viewed ~83,203 times


A digital watch.

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 …

Adding Semantic Reviews / Rich Snippets to your WordPress Site

· 850 words


Screenshot of JSON code in a web page.

This is a real "scratch my own itch" post. I want to add Schema.org semantic metadata to the book reviews I write on my blog. This will enable "rich snippets" in search engines. There are loads of WordPress plugins which do this. But where's the fun in that?! So here's how I quickly built it into my open source blog theme. Screen options First, let's add some screen options to the WordPress…

Remove the first few lines from a string in PHP

· 1 comment · 250 words · Viewed ~851 times


Binary code displayed on a screen.

Problem: I have a multiline string - not a file - and I want to remove the first few lines from it and keep the rest. I found this surprisingly unintuitive. So these are notes in case I want to do it again. Feel free to suggest a better way! Example Given this input: $str = "Once upon\nA Time\nLived a big\nDragon\nCalled Cuthbert."; I want the output to be: "Dragon\nCalled Cuthbert." …

Quick and Dirty Self-Hosted Alexa Skills (2019)

· 3 comments · 700 words · Viewed ~2,185 times


I hate creating Alexa skills. What should be a 3-click process inevitably ends up requiring trips to multiple websites, to set up weird parameters, and reading outdated tutorials for obsolete libraries. So this is how to create a self-hosted Skill, using PHP. It runs on your own server and doesn't require any interaction. The Skill At a basic level, all your website has to do is spit out a…

Import Images From A Migrated WordPress

· 2 comments · 550 words · Viewed ~531 times


The Logo for WordPress.

Here's how to solve a common WordPress problem. I want to re-import all my blog's images into the media library. I've moved my blog to a new host - but kept the same domain name. I started with a new WordPress install, the uploads folder still has all my images, but WordPress can't see them. None of the plugins I found worked with huge amounts of images spread across multiple directories. One …

Counting Invisible Strings

· 300 words


The PHP logo.

When is a string not a string? When it's a series of control characters! Not a particularly funny riddle, but one I've been wrestling with recently. Imagine we want to write a program which displays a Twitter user's name. Not their @ handle, but their "real" name. For example, instead of @POTUS, display "President Obama". Easy, right? Not quite. What happens when a user is named "️"? N…

A UTF-8 Aware substr_replace (for use in App.net)

· 200 words · Viewed ~1,240 times


The PHP logo.

So, I stayed up bashing my head against a brick wall all last night! PHP's string functions aren't (yet) UTF-8 aware. This is a replacement for subtr_replace which should work on UTF-8 Strings: function utf8_substr_replace($original, $replacement, $position, $length) { $startString = mb_substr($original, 0, $position, "UTF-8"); $endString = mb_substr($original, $position + $length,…

Introducing a NEW QR Generator

· 4 comments · 450 words · Viewed ~1,096 times


A QR code.

When people ask me which QR generator to use, I usually suggest Google Charts. However, recently I've become dissatisfied with its limitations, so I've decided to write and release my own QR encoder. I'm still looking for a catchy name for it (suggestions welcomed) - so for now it's called "QR Generator PHP". It's available on GitHub or you can use it directly. So, how does it compare to…

Calibre PHP Patches

· 1,000 words


Two quick patches which should be in the next version of Calibre PHP. Adding File Size This shows the sizes of the eBook files. Screenshot shows a demonstration using the free "Hacking The BBC" eBook. (more…) …

Installing Calibre PHP

· 300 words · Viewed ~2,118 times


(These are mostly notes to myself!) I love Calibre, it's the perfect eBook management tool. It comes with a built in WWW server so you can easily access your library on the go. The only problem is that this really only works if you have a single machine dedicated to Calibre. For various reasons, I don't have a single machine. I have a desktop, laptop, and server. The Calibre Library is just…

Displaying Twitter Photos via Entities

· 3 comments · 200 words · Viewed ~1,909 times


Twitter has announced that it will soon open up a native photo sharing service. Rather than using an external service like Embed.ly to retrieve thumbnails, all the data is embedded within Twitter Entities. So, if you request a status using "include_entities=true", you will be able to grab the image and display the thumbnail using the following code. function twitter_get_media($status) { …