Skip to content

Instantly share code, notes, and snippets.

benlinton /
Last active September 23, 2023 09:38
Multiple MySQL Versions with Homebrew

Multiple MySQL Versions for Development

Options included below:

  • Using Docker docker-compose
  • Using Homebrew brew

Using Docker (recommended)

This gist was originally created for Homebrew before the rise of Docker, yet it may be best to avoid installing mysql via brew any longer. Instead consider adding a barebones docker-compose.yml for each project and run docker-compose up to start each project's mysql service.

Keybase proof

I hereby claim:

  • I am benlinton on github.
  • I am benlinton ( on keybase.
  • I have a public key whose fingerprint is 6DF0 3A79 3FF8 CD11 9381 5109 5B6F DE77 4527 E6F5

To claim this, I am signing this object:

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

benlinton / testify_helper.rb
Created May 4, 2017 14:35
Rails Test Helper
# Only outputs block if preceeded by `=` in rails views
# Preferred.
def testify(value = nil, &block)
return unless Rails.env.development? || Rails.env.test?
block_given? ? capture(&block) : value
# Outputs block for both `-` and `=` in rails views
def testify(value = nil, &block)
return unless Rails.env.development? || Rails.env.test?
# Provides: lcd
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Update LCD display
# Description: Update LCD display on the front of the machine.