Skip to content

Instantly share code, notes, and snippets.

View jrafanie's full-sized avatar

Joe Rafaniello jrafanie

  • New Jersey
View GitHub Profile
@jrafanie
jrafanie / lazy_timestamping_assets.log
Last active June 2, 2016 15:35
Lazy evaluating asset timestamps on sprockets on 3.6.0 https://github.com/rails/sprockets/pull/211
# Using sprockets 3.6.0 with spocket-rails 3.0.4
# 171 - 177 MB of memory used booting rails before
11:24:33 ~/Code/manageiq (master) (2.2.5) + RAILS_ENV=production bin/rails r 'top = `/usr/bin/top -l 1 -pid #{Process.pid} | grep -E "ruby.+M"`; memory = top.split[7].to_i; puts memory'
177
11:24:43 ~/Code/manageiq (master) (2.2.5) + RAILS_ENV=production bin/rails r 'top = `/usr/bin/top -l 1 -pid #{Process.pid} | grep -E "ruby.+M"`; memory = top.split[7].to_i; puts memory'
171
11:25:31 ~/Code/manageiq (master) (2.2.5) + RAILS_ENV=production bin/rails r 'top = `/usr/bin/top -l 1 -pid #{Process.pid} | grep -E "ruby.+M"`; memory = top.split[7].to_i; puts memory'
177
@jrafanie
jrafanie / 0001_inline_test.rb
Last active May 31, 2016 21:09
Rails 5.0.0.rc1 throws NotImplementedError on update if select is missing target column or updated_* columns
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '5.0.0.rc1'
@jrafanie
jrafanie / 000_joe_test.rb
Last active May 31, 2016 17:35
Rails 5 raises NotImplementedError without updated_on, updated_at, and "the column you want to update" if you call .update
require 'cases/helper'
require 'models/parrot'
# create_table :parrots, force: true do |t|
# t.column :name, :string
# t.column :color, :string
# t.column :parrot_sti_class, :string
# t.column :killer_id, :integer
# if subsecond_precision_supported?
# t.column :created_at, :datetime, precision: 0
@jrafanie
jrafanie / gist:0d6740b29afed7ae6213e5d186c157d6
Created May 22, 2016 15:15
static analysis idea: where exactly was complexity added in the last sprint/release
I have a belief that code duplication, while a useful metric, is often done
because of code complexity. In other words, complicated code is more likely to
be duplicated. It doesn't mean that simple code can't be duplicated but that
it's less likely and less of a problem. Along with this thinking, I'm asserting
that if you limit complexity increase spikes, you will slowly remove duplication
with it. Therefore, it might be less useful to target duplication except as a
way to measure the impact of decreased complexity on duplication.
With a large legacy codebase, it's nearly impossible to remove all complexity.
One, it takes many resources many hours/days/weeks/months to do this. Two, you'd
@jrafanie
jrafanie / sorted_by_count.log
Created May 19, 2016 19:07
manageiq_top_allocations_size_and_count_by_line_number loading config/enviornment.rb in dev mode
m: 1,250,309 | c: 24,829 | String /Users/joerafaniello/.gem/ruby/2.2.4/bundler/gems/rails-044e35f87379/activesupport/lib/active_support/dependencies.rb:293
m: 1,418,546 | c: 20,182 | String poparser.ry:139
m: 1,261,765 | c: 20,182 | String poparser.ry:219
m: 805,240 | c: 20,131 | ActionDispatch::Journey::Nodes::Cat /Users/joerafaniello/.gem/ruby/2.2.4/bundler/gems/rails-044e35f87379/actionpack/lib/action_dispatch/journey/parser.rb:137
m: 550,080 | c: 13,752 | String /Users/joerafaniello/.gem/ruby/2.2.4/bundler/gems/rails-044e35f87379/activesupport/lib/active_support/core_ext/numeric/conversions.rb:126
m: 550,040 | c: 13,751 | Hash /Users/joerafaniello/.gem/ruby/2.2.4/bundler/gems/rails-044e35f87379/activesupport/lib/active_support/core_ext/numeric/conversions.rb:105
m: 13,509,240 | c: 10,946 | RubyVM::InstructionSequence /Users/joerafaniello/.gem/ruby/2.2.4/bundler/gems/rails-044e35f87379/activesupport/lib/active_support/dependencies.rb:293
m: 347,120 | c: 8,678 | Array /Users/
@jrafanie
jrafanie / 5-0-stable_at026e73d70e.rb
Last active May 11, 2016 15:57
rails 5.0 stable - remove_connection from subclass drops primary pool ???
11:38:58 ~/Code/manageiq (remove_connection_specification_name_rails_5_workaround) (2.2.4) + be rails c
** Using session_store: ActionDispatch::Session::MemCacheStore
DEPRECATION WARNING: You didn't set `secret_key_base`. Read the upgrade documentation to learn more about this new config option. (called from validate_secret_key_config! at /Users/joerafaniello/.gem/ruby/2.2.4/gems/railties-5.0.0.rc1/lib/rails/application.rb:509)
Loading development environment (Rails 5.0.0.rc1)
irb(main):001:0>
irb(main):002:0*
irb(main):003:0*
irb(main):004:0*
irb(main):005:0* MiqRegionRemote.connection_handler.connection_pool_list.collect {|pool| pool.spec.name}
=> ["primary"]
@jrafanie
jrafanie / test_for_swapping_connection_pools.diff
Last active May 10, 2016 15:46
Connection pool swapping back to the AR::Base pool requires new step as of rails commit fcb223d (merge of #24844)
diff --git a/activerecord/test/cases/connection_adapters/connection_handler_test.rb b/activerecord/test/cases/connection_adapters/connection_handler_test.rb
index fc5ca88..d171ea7 100644
--- a/activerecord/test/cases/connection_adapters/connection_handler_test.rb
+++ b/activerecord/test/cases/connection_adapters/connection_handler_test.rb
@@ -21,6 +21,34 @@ def test_establish_connection_uses_spec_name
@handler.remove_connection('readonly')
end
+ def test_a_class_using_custom_pool_and_switching_back_to_primary
+ klass2 = Class.new(Base) { def self.name; 'klass2'; end }
@jrafanie
jrafanie / a_recreation_script.rb
Last active May 6, 2016 16:20
t.references polymorphic: true, index: true changes from 4.0, 4.1, 4.2, 5.0.0.beta4
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# gem 'rails', '~>4.2.0'
@jrafanie
jrafanie / 0_references_polymorphic_out_of_order.rb
Created May 5, 2016 16:33
Rails 5.0.0.beta4 creates references, polymorphic => true id/type columns in reverse order
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '~>4.2.0'
@jrafanie
jrafanie / cached_column_test.rb
Created April 27, 2016 18:35
WAT cached column on join
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# gem 'sqlite3'