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 / first_is_not_gcing.rb
Created October 8, 2015 19:24
Rails 4.2.4 version a bug where Relation#first is not GC'ing, based on https://gist.github.com/jrafanie/1a6a58ac00c0996f1ab2
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.4"
@jrafanie
jrafanie / first_not_gcing.rb
Created October 8, 2015 19:20
GC After Relation#first not working
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', github: 'rails/rails'
@jrafanie
jrafanie / silence_debug_ruby_parser.diff
Created July 7, 2015 20:41
Silence debug ruby_parser
diff --git a/lib/extensions/as_const_missing_with_sti.rb b/lib/extensions/as_const_missing_with_sti.rb
index 4537163..8fc2d33 100644
--- a/lib/extensions/as_const_missing_with_sti.rb
+++ b/lib/extensions/as_const_missing_with_sti.rb
@@ -33,12 +33,21 @@ module AsConstMissingWithSti
def self.classes_in(filename)
content = File.read(filename)
+
+puts "before cleanup: #{ENV.key?("DEBUG")}"
@jrafanie
jrafanie / gist:8dcd75a9a6d220afb6e4
Created July 7, 2015 16:20
Timeout error during rake assets:clean
DEPRECATION WARNING: You did not specify a `log_level` in `production.rb`. Currently, the default value for `log_level` is `:info` for the production environment and `:debug` in all other environments. In Rails 5 the default value will be unified to `:debug` across all environments. To preserve the current setting, add the following line to your `production.rb`:
config.log_level = :info
. (called from block in tsort_each at /opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:226)
{:lineno=>[1, "/opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/ruby_parser-3.7.0/lib/ruby_lexer.rb:855", nil]}
{:lineno=>[1, "/opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/ruby_parser-3.7.0/lib/ruby_lexer.rb:855", nil]}
{:scan=>["class", "/opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/ruby_parser-3.7.0/lib/ruby_parser_extras.rb:919"]}
{:scan=>[" ", "/opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/ruby_parser-3.7.0/lib/ruby_parser_extras.rb:919"]}
{:scan=>["UiTaskSet", "/opt/rubies/ruby-2.2.2/lib/ruby/gems/2.2.0/gems/ruby_parser-3.
@jrafanie
jrafanie / gist:34313d97a9e5c5238e3d
Last active February 16, 2024 16:17
Extract build and system from manageiq.git
  • build and system directories extracted to manageiq-appliance repo.
  • Make that work by building off a fork of manageiq with build and system removed
  • Split manageiq-appliance(build/system) to manageiq-appliance-build and manageiq-appliance, removing the leading build/system directories.
    • Apply manageiq build directory commits to manageiq-appliance-build.
    • Apply manageiq-appliance build directory commits to manageiq-appliance-build.
    • Save off the system commits from manageiq-appliance. (NONE)
    • Delete manageiq-appliance, recreate it.
    • Apply manageiq system directory commits to manageiq-appliance.
    • Apply old manageiq-appliance system directory commits to manageiq-appliance. (NONE)
  • Make the build work(like step 2) but with the 3 repos.
@jrafanie
jrafanie / gist:5424bc23a5c5fcbe5047
Last active August 7, 2016 04:57
bundler: no place like gem home
$ bundler -v
Bundler version 1.9.7

Add git based rake to Gemfile:

$ cat Gemfile
source 'https://rubygems.org'
@jrafanie
jrafanie / a_output.md
Last active August 29, 2015 14:20
Ruby timeout, httpclient, and Syncs

All versions of httpclient after 2.2.7 seem to exhibit a timeout at some point that seems to prevent the lock from being released, as evidenced by MANY (R)eceive timeouts in a row... where I have to interrupt the process to make it stop.

From the results below, it appears that something changed from 2.2.7 to 2.3.0 that's causing a single timeout raised at the "right" place to never release the lock.

Perhaps this: https://github.com/nahi/httpclient/compare/v2.2.7...v2.3.0?diff=split&name=v2.3.0#diff-9c128a1e92647c91c6efad47c0709bf7R877

04:58:35 ~/Code/playground/timeout_and_locks (2.0.0-p643) - be ruby timeout_test.rb
Ruby: 2.0.0
@jrafanie
jrafanie / a_summary.md
Last active August 29, 2015 14:20
Require timing logging with virtual memory logging

We were seeing 500+ MB of increased virtual memory usage compared to older versions of ManageIQ per process.

Using ManageIQ and require logging, we can measure how long and how much memory EACH require takes:

REQUIRE_LOG=true bin/rails r ""

This writes a log file in vmdb/log/require_DATEXYZ.log.

Note, require_with_logging is required in the preinitializer.rb

@jrafanie
jrafanie / output.sh
Created April 6, 2015 21:40
Detect binary gems in your bundle programmatically
bundle package # downloads all .gem files in your bundle to vendor/cache
# use gem spec A.gem extensions to print the extensions property in the gemspec
for i in `ls vendor/cache`; do echo $i; gem spec vendor/cache/$i extensions; done
CFPropertyList-2.3.0.gem
--- []
Platform-0.4.0.gem
--- []
@jrafanie
jrafanie / gist:8256d85bd439b0750d7a
Created March 12, 2015 16:02
Using OSX's say and bash to find a rspec seed to recreate test order dependency bugs
#!/bin/bash
#
# usage:
# Pass the tests/directories you want to tests in random order:
# ./test_until_failure.sh spec/models"`
#
# For example, if you think the connections method is suspect:
# ./test_until_failure.sh `git grep -l connections spec/lib spec/models/ spec/controllers/ |grep "_spec.rb"`
for i in `seq 1 500`;
do