Skip to content

Instantly share code, notes, and snippets.

View wils3005's full-sized avatar

Jack Wilson wils3005

View GitHub Profile
### 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:
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'benchmark/ips'
def num
@num ||= 2**18
end
def foo
#!/usr/bin/env ruby
require 'benchmark/ips'
require 'securerandom'
class MyClass
FOO = -> { SecureRandom.hex }
def bar
-> { SecureRandom.hex }
#!/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
# frozen_string_literal: true
Rails.application.eager_load!
class MyFind
LIMIT = 1000.0
class << self
def call(*args)
new(*args).call
# frozen_string_literal: true
################################################################################
# class MyClass
# include Attributable
# attr(:foo) { SecureRandom.uuid }
# attr(:bar) { Time.current }
# attr(:baz) { MyClass.new }
# end
@wils3005
wils3005 / raise.rb
Last active December 29, 2019 03:57
# 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
# 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)
module Analyze
def analyze
connection.execute("EXPLAIN ANALYZE #{to_sql}").values.flatten
end
end
ActiveRecord::Relation.include(Analyze)
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!