Skip to content

Instantly share code, notes, and snippets.

View kerrizor's full-sized avatar
🏍️
BRAAAAAAAAP!

Kerri Miller kerrizor

🏍️
BRAAAAAAAAP!
View GitHub Profile
’Twas brillig, and the slithy git repos
Did gyre and gimble in the wecks:
All mimsy were the borogoves,
And the mome raths Mutex.
“Beware the legacy code, my son!
The classes that bite, the patches that catch!
Beware the Gemfile.lock, and shun
The frumious monkey patch!”
@kerrizor
kerrizor / bullet_and_minitest.md
Last active January 31, 2024 00:07
Trigger MiniTest failures in Rails when Bullet detects N+1 query violations

In test/test_helper.rb...

### Bullet (N+1 queries)

if ENV['BULLET']
  Bullet.enable = true

  require 'minitest/unit'
@kerrizor
kerrizor / gist:4165372
Created November 28, 2012 23:00
The Orc and the Pie

"The Orc and the Pie"

by Monte Cook

The World's Shortest (Yet Technically Complete) Adventure

Adventure Background: An orc has a pie.

Adventure Synopsis: The PCs kill the orc and take his pie.

@kerrizor
kerrizor / ss1k.md
Created July 12, 2019 17:00
SaddleSore 1000 Planning
context "when the moon is rising" do
let(:moon_phase) { ->(){ planet.moons.first.blah.baz.bat[0].phase } }
it "looks it up" do
expect { change_moon_phase }.to change( moon_phase.call }
end
end
def link_to_github(rubygem)
[rubygem.linkset.code, rubygem.linkset.home].detect do |linkset|
URI(linkset.to_s).host == "github.com"
end
rescue URI::InvalidURIError
nil
end
@kerrizor
kerrizor / orphans.rake
Last active March 20, 2019 12:45
ActiveRecord Orphans
desc "Check for ActiveRecord orphans"
task orphan_check: :environment do
# Silly housekeeping.. I'm sure there's a better way to spin up the app before
# we run the rake task but I A) can't remember and B) can't be bothered I'm
# just spiking some code here. Only PITA here is it makes us Rails specific.
#
Rails.application.eager_load!
ActiveRecord::Base.descendants.each{ |k| k.connection }
# Load up all the AR models in our app
@kerrizor
kerrizor / 2019-winter-ruby-abstract.md
Created December 27, 2018 21:33 — forked from searls/2019-winter-ruby-abstract.md
Winter 2019 Ruby talk proposal

The Selfish Programmer

Using Ruby at work is great… but sometimes it feels like a job!

This year, I rediscovered the joy of writing Ruby apps for nobody but myself—and you should, too! Solo development is a great way to learn skills, to find inspiration, and to distill what matters most about programming.

Building an entire app by yourself can be overwhelming, but this talk will make it easier. We'll start with a minimal toolset that one person can maintain. You'll learn how many "bad" coding practices can actually reduce complexity. You may be surprised how selfish coding can make you a better team member, too!

Details

@kerrizor
kerrizor / gist:3a125b656cc74bc447c0
Last active September 9, 2018 22:54 — forked from jimbojsb/gist:1630790
copying colorized code

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@kerrizor
kerrizor / zom.rb
Created July 17, 2017 18:27 — forked from michaelfeathers/zom.rb
Find the number of calls in Ruby code that have happened no times, just once, or many times.
require 'set'
require 'find'
class Array
def to_h; Hash[self]; end
def to_set; Set.new(self); end
def freq; group_by {|e| e }.map {|k,v| [k,v.count] }.to_h; end
end