Tag: coding
-

Elegant error handling in Rust
I’m slowly becoming more proficient working in the Rust language. I’ve now made my third tool, a command-line task manager called fini, and I’m starting to see the patterns that work well. One of them that I really like is how Rust provides convenient ways to handle errors. I think that other languages could really…
-

Using PHP property hooks wisely
PHP 8.4 included a new feature for class definitions called “property hooks“. These are a way to dynamically control the behavior of property reading and writing an object property. To put it another way, they let you turn property access into method calls. This is something that many other programming languages do, and it’s nice…
-

Grappling vine animation
When I designed my game, The Lost Card, one of the powers I had come up with was a sort of extending vine that acted like a grappling hook, able to pull the player toward specific rocks on the map. However, with my limited game development experience, this proved way too difficult. I was able…
-

The making of phpcs-changed
Automattic developers have always held the WordPress PHP coding guidelines as the basic advice for writing WordPress.com code. However, when I started in 2013 most of the code I actually encountered in the codebase did not follow those guidelines. When I transitioned to my current team around 2016, the codebase had no automated linting at all. Having seen…
-

Refunding linked subscriptions
Today I wanted to write about another work project that’s taken up a lot of my time: how to properly refund subscriptions that were paid for over multiple transactions. Refunding an upgraded subscription Let’s say you sign up for a subscription at a service’s Basic tier for $10, and then later upgrade that subscription to…
-

The Receipt Item Tag Trick
I’m not sure I should be proud of this solution, but I wanted to discuss a technique I invented to solve a tricky problem at work. Our billing receipt database records have a separate table called “receipt tags” which are just simple strings that can be associated with a receipt. These are useful for all…
-

Commas and periods make cents
A long time ago (relatively speaking), all prices displayed to users on my company’s website were rendered from their numeric data (like 10.25) into a formatted string in PHP (like £10.25) and then passed along to the client. As our frontend began to have more complex requirements for the way prices were displayed, this was…
-

Thirty days hath September
Here’s a riddle for you: what’s one month past January 31? Is it February 28, the end of the month? Or is it March 2, thirty days ahead? Or March 3, thirty-one days ahead? There’s no correct answer. So if you signed up for a monthly subscription on January 31, or on October 31, or…
-

Enemy State Machines in Lost Card
This summer I made a simple game called The Lost Card using TypeScript and the Phaser framework. I wanted to write a little about some of the things I learned during that process. This post is about enemy behavior. Once I had a character I could move around my world, I needed to have enemies…
-

Rust and Grepdef 3.0
As part of my summer vacation from work this year, I decided to learn Rust, a programming language that’s been gaining a lot of popularity recently. After using it for a few months I can see why. Rust is a systems-level language designed for things that need to be very efficient and fast. It’s designed…