Category: Uncategorized

  • I don’t know why ‘spaces’ won against ‘tabs’

    I spent five years in a codebase with tabs instead of spaces. In my editor, I had indents set to 2 spaces. GitHub annoyingly defaults to 8 and requires customization in order to fix that. Because of the prevalence of spaces, we often had to maintain forks of tooling to support tabs because ‘spaces has […]

  • Wait, a 304 reply can change headers?

    Wait, a 304 reply can change headers?

    This evening I was optimizing some caching things for a web app I’ve been working on when I discovered something obvious when you think about it. Now, this is specific to Chrome-ish browsers and Firefox; I have no idea what will happen in Safari. Imagine the following PHP code: This code sets a random integer […]

  • Algorithms in PHP: Deques (circular buffers & linked lists)

    In the previous post, I talked about priority queues. But in my explanation of an alternative implementation, I neglected to mention a few things: The alternative implementation isn’t for production; there are edge cases and unhandled errors. The alternative implementation is meant for a short queue, not an infinite one, such as the one you […]

  • Algorithms in PHP: Priority Queues (and Heaps)

    This is the beginning of a series on implementing various algorithms in idiomatic PHP and their reference implementation (usually based on C++). Today we’re going to be talking about Priority Queues. A priority queue is where each value has an associated “priority” that determines which order things come out of the queue. The best real-life […]

  • Stateless-Passwordless Authentication using Cryptography

    Say you want to ensure a user has access to a given email address (or phone number) on the device that they are trying to access your service. This is handy in a number of circumstances, but more importantly, can you authenticate the user without using a database? It turns out the answer is yes, […]

  • Um, since when is PHP faster than C++?

    Last week I was working on porting an encryption scheme to PHP from C++, mostly to embed it in a website and make changes to it specific to my use case; and for fun. Needless to say, I was surprised to see my PHP version was faster than the C++ version. TL;DR: it isn’t faster, […]

  • Finally Getting ipv6 in WSL2

    I really like using Windows to get around the web and write software, but I prefer Linux and bash for a CLI. Thus I tend to use WSL2 to do lots of things around the house. One thing missing for a long time is IPv6. Finally, today, I managed to get IPv6 working. Requirements If […]

  • A More In-Depth Reasoning behind PHP as a good language

    Yesterday, I wrote a post over lunch that people just absolutely hated. It was great, in sort of weird way, to see that many people didn’t see what I saw when I posted it. I think it was a somewhat-not-gentle reminder that I see the world differently. The post was shared on Reddit and I […]

  • Yes, PHP is faster than C#

    So, I got an interesting spam comment on my post today: “It gets even crazier when you actually benchmark the two languages only to discover in some real-world cases, PHP outperforms C#.” I triple dare you to show code examples so we can explain why you’re wrong. Quadruple dare Jesus christ, how did you think […]

  • My Favorite Language has Changed to PHP

    For the last 15 years or so, my favorite language has been C#, despite using mostly PHP in my workplace since 2012. Over the years, I’ve written a lot of side-projects in C#, and it’s been great, for the most part. Until I learned Assembly… last year. When I learned Assembly, I think I broke […]