How to install homebrew in a completely isolated environment

John Bachir's Code Blog
November 10, 2021

I'm a longtime macports fan and occasional evangelist. It Just Works, installs in /opt/local with sudo, and very frequently installs binaries instead of needing to build. Homebrew is widely used and supported and pretty great, but I always feel just a little better about using macports instead and haven't had a reason to switch.

. . .

Read More

Turning off ActiveRecord query cache to improve memory consumption in background jobs

John Bachir's Code Blog
October 17, 2021

The ActiveRecord query cache can defeat effective garbage collection when working on big batches of data. Disabling it entirely in background jobs can be a solid memory consumption win. Here's how to do it:



class SidekiqArCache
 def call(worker, msg, queue)
 ActiveRecord:: . . .

Read More

How to stop yourself from accidentally switching to a git branch named "master" instead of "main"

or vice-versa

John Bachir's Code Blog
October 02, 2021

If you have various projects which used either "main" or "master" as the main branch, and also have a remote which uses the other naming (e.g. heroku or another PaaS), you might find yourself accidentally switching to the wrong branch name and working on it. Here's how to inhibit that.

Put this in . . .

Read More

ruby Thread report_on_exception and abort_on_exception

John Bachir's Code Blog
September 25, 2021

ruby Thread has two interesting settings related to behavior when an error happens: report_on_exception and abort_on_exception.

There are a few good articles out there about this, but a couple things gets overlooked a bit:

  1. behavior which depends on if a thread is joined or not
  2. the interaction of the two settings . . .

Read More

Turning off the SQL cache in rails background jobs

to improve garbage collection

John Bachir's Code Blog
September 16, 2021

Here's something about memory in Rails background jobs that I sort of encountered over the years but only recently fully figured out. I'll jump straight to the point.

The rails query cache causes ruby to be less effective at garbage collection. This is an acceptable tradeoff in web processes which do not run for a long time . . .

Read More

It's impossible to know what a unique and valuable design looks like before it is built


John Bachir's Code Blog
August 29, 2021

In a discussion recently someone was asking for feedback on how to go about expanding a system to cover more use cases without clumsily breaking the abstraction. I had these thoughts:

Maybe questions to ask are:

  • How easy is this to change later?
  • How easy is this for others to use?
  • Are there any fundamental . . .

Read More

How to create a multi-column full text search index in Postgres

For example, to cover pg_search queries

John Bachir's Code Blog
August 27, 2021

Just a quick post here about something that doesn't seem to be covered much elsewhere.

If you have a query like this (this one generated by pg_search):

FROM "things"
 (SELECT "things"."id" AS pg_search_id,
 to_tsvector('simple',  . . .

Read More

   Subscribe by email and never miss a post.