This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am wils3005 on github. | |
* I am wils3005 (https://keybase.io/wils3005) on keybase. | |
* I have a public key ASBgUj1fxw1-sgkOMQ6KB8oy5nzS6aEKoQD_bJYv9Lzvhgo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require 'benchmark/ips' | |
def num | |
@num ||= 2**18 | |
end | |
def foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'benchmark/ips' | |
require 'securerandom' | |
class MyClass | |
FOO = -> { SecureRandom.hex } | |
def bar | |
-> { SecureRandom.hex } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require 'benchmark/ips' | |
Arr = Array.new(1000) { rand }.freeze | |
class MyClass | |
def self.call(arg) | |
new(arg).call |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
Rails.application.eager_load! | |
class MyFind | |
LIMIT = 1000.0 | |
class << self | |
def call(*args) | |
new(*args).call |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
################################################################################ | |
# class MyClass | |
# include Attributable | |
# attr(:foo) { SecureRandom.uuid } | |
# attr(:bar) { Time.current } | |
# attr(:baz) { MyClass.new } | |
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module Raise | |
def raise(*args) | |
error_class = args.find { |it| it.is_a?(Class) } | |
message = | |
args | |
.find { |it| it.is_a?(String) } | |
.to_s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'pstore' | |
module Transporter | |
BUCKET_NAME = 'REPLACE ME' | |
def self.transport!(object_name) | |
s3_object_key = File.join('tmp', "#{object_name}.pstore") | |
pathname = Rails.root.join(s3_object_key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Analyze | |
def analyze | |
connection.execute("EXPLAIN ANALYZE #{to_sql}").values.flatten | |
end | |
end | |
ActiveRecord::Relation.include(Analyze) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FamilyTree | |
def family_tree | |
{ name => (subclasses.sort_by(&:name).map(&:family_tree).reduce(&:merge) || {}) } | |
end | |
end | |
ActionController::Base.extend(FamilyTree) | |
Rails.application.eager_load! |
OlderNewer