Category: Programming

  • String Length Differs Between Programming Languages

    Measuring string length seems easy, but it’s such a nuanced trap. Here’s a string. Can you guess its length? “My 👨‍👩‍👦‍👦‍ is fun” It’s a trick question. There isn’t a single answer. In PHP, it’s 38. strlen($string) counts bytes in memory. In JavaScript, it’s 22. string.length counts UTF-16 code units. In Swift, it’s 11. string.count

    Read article →

  • Unicode Facts You Should Know

    Before Dennis Snell started talking to me about Unicode, I thought displaying text on a screen was the most boring thing. I had no clue. It’s fascinating! And I’m sharing my favorite bits below. Aha, if you wonder what are codepoints, code units etc. you may want to start with the short introduction to Unicode

    Read article →

  • Short introduction to Unicode and UTF-8

    I’m fascinated with Unicode. This blog post is one I wish I had 20 years ago when I was starting to learn about text encoding. Around 2005, I struggled to use Polish words on my website. I would type in koło in Windows notepad, but in Firefox I would see ko³o. Why? Notepad used the

    Read article →

  • mysqli_real_escape_string() can be dangerous

    We’ve had prepared statements for years, but the WordPress ecosystem still relies on mysqli_real_escape_string() and it’s scary. Can you find the security issue in this, deceivingly simple, code snippet? It’s related to text encoding. Adding backslashes to $_POST[‘new_content’] string can corrupt the data at best, and open up a SQL injection vulnerability at worst. Here’s

    Read article →

  • Running PHP code after closing the HTTP connection

    Dennis Snell and I want to sync two WordPress sites and we’ve been looking for a way to run a continuous content indexing in WordPress. One idea was to reuse the PHP process that renders the site and do a little bit of indexing after every page render. We’d need to flush all the buffers, ship the

    Read article →

  • Code Contributions I’m proud of

    Creating WordPress Playground helped me grow as an engineer, leader, and product person. This post, focusing on the engineering side, highlights the technical contributions I’m particularly proud of.

    Read article →

  • WordPress as a git repo

    During my Christmas break, I’ve turned WordPress into a markdown editor, a git client, and a git server. It’s all dependency-free PHP code. It works in Playground, on any cheap hosting, and it could be merged into WordPress core. Why would I do that? I want Notion that’s free, offline first, and where I own

    Read article →

  • Generating 1MB of PHP code with AI, a story of MySQL query parser

    I’ve used Google Gemini to generate a MySQL query parser in PHP and I’ll tell you exactly how. It took two nights, ~$520, and yielded a 1MB MySQLParser.php file that worked out of the box, but not without bugs. This post is just a summary. If you want the full story. check out the original

    Read article →

  • Learn how to build PHP to WebAssembly in 10 minutes

    This may be my last WordPress-related post until I’m back from my Sabbatical on September 26th. Enjoy! WebAssembly is easier than you think. It is difficult to get started with, but then it’s not. I’ve spent the last 10 months learning that, and now I will save you that time by sharing how to build

    Read article →

  • WordPress Playground was prototyped in a week

    People are often surprised that the first prototype of WordPress Playground came together in just a week. It is so very tempting to wear my serious face and add something like oh, you know, that’s just experience and a few tricks from robust chaos theory. Some experience was involved, sure, but mostly tricks and chaos.

    Read article →

Exit mobile version