Skip to content

Instantly share code, notes, and snippets.

View chrisandreae's full-sized avatar

Chris Andreae chrisandreae

View GitHub Profile
@chrisandreae
chrisandreae / benchmark_collection_proxies.rb
Created February 16, 2017 08:44
CollectionProxy speed test case
## Iterates a tree of a million preloaded ActiveRecord objects, using
## either the association CollectionProxy or `association(:foo).target`.
## Results:
## CollectionProxies (1000000): 31.230000 2.040000 33.270000 ( 33.840189)
## Associations (1000000): 0.130000 0.000000 0.130000 ( 0.122716)
require 'active_record'
require 'sqlite3'
require 'benchmark'
@chrisandreae
chrisandreae / active_record_master.rb
Created August 1, 2018 09:07
ActiveRecord fails to correctly merge scopes containing IN constraints on the same column
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do

Keybase proof

I hereby claim:

  • I am chrisandreae on github.
  • I am chrisandreae (https://keybase.io/chrisandreae) on keybase.
  • I have a public key ASCIZjcoYXytWOQlGZBnoWcplS8V-MafEmCosdYNBrXrVgo

To claim this, I am signing this object:

@chrisandreae
chrisandreae / bce_date_test.rb
Last active November 6, 2019 10:08
ActiveRecord fails to parse BCE dates in PostgreSQL ranges
# frozen_string_literal: true
begin
require 'bundler/inline'
rescue LoadError => e
warn 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
@chrisandreae
chrisandreae / run_vftool.rb
Created January 21, 2021 10:55
Parse nixos extlinux boot and boot a vm with vftool
require 'optparse'
require 'tempfile'
require 'json'
def parse_extlinux(file)
globals = {}
labels = {}
target = globals
@chrisandreae
chrisandreae / compare_rebase.sh
Last active June 26, 2024 13:37
Compare Rebase Script Fragment
compareRebase () {
local newbranch oldbranch newcommit oldcommit ancestor
local opts=()
if [ "$1" = "-w" ]
then
opts+=("-w")
shift
fi
newbranch=${1:-$(git rev-parse --abbrev-ref HEAD)}
oldbranch=${2:-"${newbranch}@{u}"}
@chrisandreae
chrisandreae / tilted_foot_adapter.scad
Last active June 26, 2024 13:35
Tilted Foot Adapter (OpenSCAD)
count = 6;
tilt_angle = 10;
sprues = true;
module __Customizer_Limit__ () {}
$fn = 60;
leg_diameter = 11.849;
inner_diameter = 10.554; // measured top of foot on the model: assumption that it's the same