Skip to content

Instantly share code, notes, and snippets.

View jb08's full-sized avatar

Jason B. jb08

  • Checkr, Inc.
  • Denver, CO
View GitHub Profile
@jb08
jb08 / Animal.rb
Last active March 22, 2024 23:45
Mongoid subclass indicies not created in Atlas
class Animal
field :color, type: String
field :mammal, type: Boolean
...
index({ mammal: 1, color: 1 }, background: true)
end
@jb08
jb08 / package_ecosystem.rb
Created November 15, 2023 23:49
"Demystifying the Ruby package ecosystem" notes
> $LOAD_PATH
=> [".rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rbidl-1.824.0/lib/_idl/generated/ruby",
"/opt/homebrew/Cellar/rbenv/1.2.0/rbenv.d/exec/gem-rehash",
".rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.4.13/lib",
".rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/will_paginate_mongoid-2.0.1/lib",
".rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/will_paginate-3.3.1/lib", ...]
$ gem install puma
Fetching puma-6.4.0.gem
Building native extensions. This could take a while...
@jb08
jb08 / date_enumeration.rb
Last active November 15, 2023 23:29
Date enumeration example
> s = Date.new(2023, 11, 12)
=> #<Date: 2023–11–12>
> e = Date.new(2023, 11, 15)
=> #<Date: 2023–11–15>
> (s..e).map(&:to_s)
=> ["2023–11–12", "2023–11–13", "2023–11–14", "2023–11–15"]
@jb08
jb08 / severity_scale.csv
Last active March 29, 2022 22:07
Incident Severity Scale
Severity Description
Sev0 A critical incident with very high impact that prevents majority of user from using product
Sev1 A major incident with significant impac that prevents many users from using product
Sev2 Customer-impacting issues that require immediate attention
Sev3 A minor inconvenience to customers with a workaround available. Can be treated as “just a bug” unless it requires increased visibility.
@jb08
jb08 / ruby_tools.rb
Last active November 12, 2021 03:14
ruby tool examples
## Sorbet
# typed: true
extend T::Sig
sig {params(name: String).returns(Integer)}
def main(name)
puts "Hello, #{name}!"
name.length
end
@jb08
jb08 / ruby_3.0.1.rb
Last active November 12, 2021 02:33
new Ruby 3 language features
## "Pattern matching (for use in case/switch statements)
## is a feature allowing deep matching of structured values"
# version 2.6.5
> {chicago: :cubs, stlouis: :cardinals, denver: :rockies} => {stlouis:} #=> SyntaxError
> 1 in 1 #=> SyntaxError
> 0 in 1 #=> SyntaxError
# version 3.0.1
> {chicago: :cubs, stlouis: :cardinals, denver: :rockies} => {stlouis:}
@jb08
jb08 / accounts.rb
Last active September 22, 2021 20:21
accounts.rb
FactoryBot.define do
factory :account do
name 'Checkr test'
uri_name 'checkr-test'
transient do
packages nil
test_packages nil
end
end
@jb08
jb08 / packages_v1_spec.rb
Created September 3, 2021 17:18
packages_v1_spec.rb
PackagesV1Spec::LIST /v1/packages::account with sub-accounts
[platform/checkr/spec/api/packages_v1_spec.rb:149]
Minitest::Assertion: --- expected
+++ actual
@@ -1 +1 @@
-["motor_vehicle_973769", "health_screening_511139"]
+["health_screening_511139", "motor_vehicle_973769"]
@jb08
jb08 / requires_time_freezing.rb
Created September 3, 2021 17:16
requires_time_freezing
def requires_time_freezing(time = Time.now)
before { Timecop.freeze(time) }
after { Timecop.return }
end
@jb08
jb08 / models.rb
Created March 2, 2021 17:42
models.rb
class Account < ActiveRecord::Base
regional_replicable
...
end
class Candidate < ActiveRecord::Base
...
end