In test/test_helper.rb
...
### Bullet (N+1 queries)
if ENV['BULLET']
Bullet.enable = true
require 'minitest/unit'
’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!” |
In test/test_helper.rb
...
### Bullet (N+1 queries)
if ENV['BULLET']
Bullet.enable = true
require 'minitest/unit'
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 |
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 |
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!
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
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 |