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

Using Multi-Node Elasticache with Rails

When using multi-node Elasticache memcached with Rails, it's critically important to get your setup correct. If you don't, your application will connect to memcached nodes at random (!!!). Resulting in low cache hit rates. How to setup Conveniently, there is a gem for this, dalli-elasticache. gem "dalli-elasticache" Using the gem for
May 4, 2023 1 min read

Sidekiq connecting logs in test

Sidekiq 7.0.6 connecting to Redis with options If you have these all over your Rails test logs, here is how you can disable them for test. In test/test_helper.rb, add the following: Sidekiq.logger.level = Logger::WARN Now your test logs will be clean. This took
Apr 21, 2023

New index name generation in Rails 7.1

For as long as I can remember Rails has had this little quirk where it will auto generate index names that are too long. A couple weeks ago Andrew Culver tweeted out his wish for this to be improved. I'll contribute $500 to the bounty for anyone who is willing
Apr 8, 2023 1 min read

Top 5 Ruby gems for Rails apps

I recently shared a couple of my favorite gems on Twitter. And people asked for more! These are my top 5 must have gems for any Rails app + my reasoning and some tips on how to best use them. 1. Pry 2. Flipper 3. Sidekiq 4. Rack::Attack 5. Prometheus
Apr 2, 2023 4 min read

No fear Rails schema changes

Over on the PlanetScale blog I just wrote up how we handle schema changes in our own Rails app. It's the best workflow I've ever used for Rails migrations. It's both inspired by and better than the custom tooling I had access to when working for GitHub. Click the big
Apr 2, 2023 1 min read

There was an error parsing Gemfile: windows is not a valid platform

I hit this error recently. To fix this, you need to update to a newer version of bundler. gem update bundler Good luck, hope this saved you some time. Error There was an error parsing `Gemfile`: `windows` is not a valid platform.
Mar 23, 2023

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
Page 1 of 4 Older Posts →
Mike Coutermarsh © 2023
  • HTML/CSS to Image API
  • Twitter
  • GitHub
  • LinkedIn