A photo of Brian Douglas

Hi, I'm Brian. Welcome to my blog. Here I write about the things I have learned whilst creating stuff on the web.

I hope that you will find something noteworthy here, that will pique your interest, and that you will visit again soon.

"when you don't create things, you become defined by your tastes rather than ability. your tastes only narrow & exclude people. so create."

— _why the lucky stiff
  • Bit shifting to increase performance

    I've been watching @Vercidium's awesome content on YouTube. His videos are all about performance optimization in regards to game development, and I learned a nifty performance optimization for my JS code as a result.

  • Generate OG images for blog posts

    When sharing an article on social media you will see a preview. The preview uses the html og:image meta tag. In this article I will demonstrate how I generate a unique og:image for each of my blog posts.

  • One assertion per test please

    Please! when you are writing tests try to limit each test case to one expect. Let's refactor the monstrosity below to understand why fewer expects and more tests are better.

  • Slugs with an ID fallback in Laravel

    Slugs make a URL look legit. No one wants to click on a link that reads like https://mysite.com/blog/1. I'd definitely get hacked if I clicked that. But what if it read https://mysite.com/blog/1/some-awesome-content. Now that looks trustworthy. I'm definitely gonna see some awesome content if I click that link.