Skip to content

Instantly share code, notes, and snippets.

View jacobat's full-sized avatar

Jacob Atzen jacobat

  • Copenhagen, Denmark
View GitHub Profile
@jacobat
jacobat / dual_arch.md
Last active November 17, 2023 10:06
Jacobs dual architecture shell setup

Jacobs dual architecture setup

This document is for people using an Apple MacBook based on the Apple ARM architecture, ie. M1 or newer, who wants to run Ruby on Rails applications that does not work on the ARM architecture. The current use case is applications using Oracles instant client libraries which are not ARM compatible.

Overview

Enum.reduce_while(list, [], fn x, acc ->
if Enum.member?(acc, x), do: {:halt, x}, else: {:cont, [x | acc]}
end)
$ docker build .
Sending build context to Docker daemon 95.05MB
...
Step 16/42 : WORKDIR /app
---> Using cache
---> 6169e33fecef
Step 17/42 : RUN apt-get update
---> Running in 4805303d6953
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
@jacobat
jacobat / result.log
Created March 7, 2020 13:43
Nokogiri blocks Ruby threads
I, [2020-03-07T14:40:36.587947 #90282] INFO -- : *** Threaded ***
I, [2020-03-07T14:40:36.588335 #90282] INFO -- : Still running
I, [2020-03-07T14:40:36.588399 #90282] INFO -- : Start Nokogiri
I, [2020-03-07T14:40:36.588566 #90282] INFO -- : Start Nokogiri
I, [2020-03-07T14:40:36.589041 #90282] INFO -- : Start Nokogiri
I, [2020-03-07T14:40:36.589079 #90282] INFO -- : Start Nokogiri
I, [2020-03-07T14:40:36.589113 #90282] INFO -- : Start Nokogiri
I, [2020-03-07T14:40:36.589138 #90282] INFO -- : Start Nokogiri
I, [2020-03-07T14:40:36.589157 #90282] INFO -- : Start Nokogiri
I, [2020-03-07T14:40:36.589175 #90282] INFO -- : Start Nokogiri
@jacobat
jacobat / Dockerfile
Created October 2, 2019 07:27
Dockerfile with optimized Gem installs
# The prepare stage extracts the versions of some heavy gems into
# individual files enabling us to preinstall these gems in the build stage
# below. Thus we won't have to install the heavy gems everytime the
# Gemfile.lock changes, only when heavy gem versions are changed.
FROM ruby:2.6.3 AS prepare
RUN mkdir /gem_versions
COPY Gemfile.lock /gem_versions/Gemfile.lock
RUN grep "^ nokogiri " /gem_versions/Gemfile.lock | awk -F '[()]' '{print $2}' > /gem_versions/nokogiri.version
RUN grep "^ sassc " /gem_versions/Gemfile.lock | awk -F '[()]' '{print $2}' > /gem_versions/sassc.version
### Keybase proof
I hereby claim:
* I am jacobat on github.
* I am jacobatz (https://keybase.io/jacobatz) on keybase.
* I have a public key ASCXkgitadJqqAAfP8ZVs_g0deD4gxDnw03ggDjKquZclQo
To claim this, I am signing this object:
@jacobat
jacobat / README.md
Last active April 29, 2019 10:58
Rails 6 database config gotcha

With the new multiple database support in Rails 6 connecting to more than one database from Rails becomes easier. There is a small gotcha to be aware of though. Take the following configuration:

development:
  primary:
    adapter: postgresql
    encoding: unicode
    pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
 host: &lt;%= ENV["PG_HOST"] || "/tmp" %&gt;
def a(name:, email:)
...
end
def b(email:, phone:)
...
end
def f(name:, email:, phone:)
a(...)
def group_continuous(io)
result = []
range_start = nil
offset = 0
io.each_line do |line|
id = line.to_i
puts "#{id}\t#{range_start}\t#{offset}"
if !range_start.nil? && id == range_start + offset + 1
offset = offset + 1
@jacobat
jacobat / macros_quick_list_vim.md
Last active November 6, 2016 11:16
Description of automating a big refactoring using a macro and the quick list in vim

Macros and the quick list in vim

The problem

Yesterday I was looking at some Ruby code that I wanted to change. For context here is the gist of it:

module UserInstrumentation