Mike Coutermarsh
  • Home
  • About
  • Twitter
  • GitHub
Sign in Subscribe

Trick for fixing Rails `find_by` N+1's

Recently I had some code that was doing 100's of find_by queries. Due to the way it was setup, a simple fix using includes wasn't possible. I was able to know which records would be called via find_by though, meaning I should be able to preload all the
Feb 26, 2023 2 min read

New Rails health check endpoint

Rails just recently added a default /up route that will return a 200 when the application is running. I've had to implement this in pretty much every Rails app I've ever worked on. This is a nice addition! If you're not familiar. This is useful for load balancers which need
Jan 13, 2023 1 min read

Solving N+1’s with Rails `exists?` queries

I recently solved a Rails performance issue with exists? queries in our Rails API. Shared all the details on PlanetScale's blog. Check it out here: Solving N+1's with Rails exists queries.
Jan 10, 2023

Searching complex Rails routes

Mastering the routes command will save you a lot of time. Here are a pro tips on how to use it. rails routes Prefix Verb URI Pattern Controller#Action new_user_session GET /sign-in(.:format) users/sessions#new {:subdomain=>"auth"} user_session POST /sign-in(.:format)
Jan 7, 2023 1 min read

Local Dev for a Ghost Theme

I recently customized the default Ghost Casper theme for this blog. It took me a while to figure out a good local development flow. Here is what I ended up with. 1. Install Ghost locally First, you need to be running a Ghost instance locally. Instructions for doing this are
Jan 6, 2023 1 min read

Rails + MySQL: Querying JSON

Here's how to use ActiveRecord to query a JSON column in MySQL. In this example we have a json column user_settings. We want to find which records have theme set with a value. Model.where("JSON_EXTRACT(user_settings, '$.theme') IS NOT NULL").count JSON_EXTRACT is the
Jan 2, 2023
PlanetScale

Building a multi-region Rails application with PlanetScale

View this post on PlanetScale.
Dec 8, 2022
PlanetScale

Introducing FastPage: Faster offset pagination for Rails apps

View this post on PlanetScale.
Aug 16, 2022
PlanetScale

Ruby on Rails: 3 tips for deleting data at scale

View this post on PlanetScale.
Aug 1, 2022
PlanetScale

Deploy requests now alert on potential unwanted changes

View this post on PlanetScale.
Jul 6, 2022
PlanetScale

Identifying slow Rails queries with sqlcommenter

View this post on PlanetScale.
Jun 29, 2022

The anxiety of tech debt

No perfect code or system exists. Ask any engineer and they’ll have a list of improvements for most any file they’ve ever touched. This list of negatives can weigh on people. “We need to fix it eventually” or bad things will happen. Like any source of anxiety, the
Mar 19, 2022 1 min read
PlanetScale

How we made PlanetScale's background jobs self-healing

View this post on PlanetScale.
Feb 17, 2022

Using GitHub Package Registry with Netlify

This took me too long to figure out. I hope it helps you. Here’s the best way I’ve found to get GitHub Packages working with a Netlify build. 1. Add this file to your repo. I put it at .npmrc-netlify in the root of the project. This keeps
Feb 1, 2022

You should be using a clipboard manager

If you don’t have one already, install one and start using it. * Set a LONG history (mine is 3 months). * Now every code snippet you ever copy is in an easily searchable database so you can pull it back up whenever you need it. I personally use Paste and
Jan 27, 2022
PlanetScale

Using entropy for user-friendly strong passwords

View this post on PlanetScale.
Jan 24, 2022

I still use vim

You probably saw this video and are wondering: “After all this time, do you still use vim?”. Yes, I do. And I still love it. My setup also hasn’t changed that much. I still use Vim + iTerm2 for almost all of my work. My dotfiles are still public if
Jan 23, 2022
PlanetScale

How our Rails test suite runs in 1 minute on Buildkite

View this post on PlanetScale.
Jan 18, 2022

Why infrastructure engineers prefer MySQL

For years I’ve been noticing this pattern of infrastructure engineers I really respect preferring MySQL and product engineers preferring Postgres. It took quite a while for me to understand it. Especially coming from my background as a product engineer. Different types of engineers value different things Infrastructure engineers generally
Jan 16, 2022 1 min read

Why not use the most "hype" stack?

Got a great question in Twitter DMs. How do you stay motivated on working with boring/non-hype tech? I’m always hyped about a new stack and can’t make progress building a SAAS. It’s hard out there. If you read twitter, hacker news, etc, there is always something
Jan 14, 2022 3 min read

When to cache in your Rails app

I’ve been working on Rails applications for over 10 years. In that time I’ve figured out some guidelines on when and when not to use caching. Years ago, I’d cache almost everything. When joining GitHub, I remember being shocked by how little caching was actually used for
Jan 9, 2022 3 min read

Running queries in parallel with Rails 7 and load_async

Rails 7 has added the load_async method to ActiveRecord. This looks like it could be a huge performance win for many Rails applications. Normally, a Rails app will execute all of its queries serially (one after another). The execution of the request waits while the query is executed. With
Jan 8, 2022 2 min read

CORS Tester

I wrote a little CORS tester tool to make testing urls for CORS easier. Mostly I was interested in experimenting with Cloudflare workers more. The entire site is deployed as a Cloudflare worker and served by a single js file. It worked real nicely for a small site. For a
Dec 27, 2020 1 min read

How we use "ship small" to rapidly build new features at GitHub

View this post on Dev.to.
Feb 1, 2020

GitHub Actions - Deploy to Heroku

Here’s how to deploy to Heroku using GitHub Actions. Without adding any new dependencies. First, you need a Heroku auth token. You can generate one on your machine using the following: heroku authorizations:create Copy the Token value and add it as a secret to your repository (Go to
Nov 2, 2019 1 min read
Page 1 of 4 Older Posts →
Mike Coutermarsh © 2023
  • HTML/CSS to Image API
  • Twitter
  • GitHub
  • LinkedIn