Skip to content

Instantly share code, notes, and snippets.

probably definitely most likely rebasing...

Nick LaMuro NickLaMuro

probably definitely most likely rebasing...
View GitHub Profile
NickLaMuro / gitter-search.rb
Last active November 8, 2019 22:00
ruby script to search gitter archives (requires `oga` rubygem)
View gitter-search.rb
#!/usr/bin/env ruby
# gitter-search [--date YYYYMMDD] [--user @USERNAME] ORG/ROOM [PATTERN]
require 'oga'
require 'optparse'
require 'net/http'
options = {}
NickLaMuro / example.out
Created July 31, 2019 00:56
Example of the .git_transaction feature in
View example.out
$ bin/rails r tmp/test_git_transaction.rb
** Using session_store: ActionDispatch::Session::MemCacheStore
** ManageIQ master, codename: J-release
creating record... done! (id: 21)
> Process 53627 has started...
> Process 53628 has started...
> Process 53629 has started...
> Process.53628: starting .git_transaction...
> Process.53629: starting .git_transaction...
NickLaMuro / compare_define_method_with_eval.rb
Created January 4, 2018 03:12
Comparing ruby's `define_method` to each type of `eval` for defining methods
View compare_define_method_with_eval.rb
# requires installing "benchmark-ips" (`$ gem install benchmark-ips`)
# Sample result
# $ ruby compare_define_method_with_eval.rb
# Warming up --------------------------------------
# using_define_method 17.203k i/100ms
# using_eval 29.526k i/100ms
# using_module_eval 30.355k i/100ms
# using_class_eval 30.809k i/100ms
NickLaMuro / miq_server_mem_log_patch.local.rb
Created December 6, 2017 16:27
ManageIQ MiqServer mem log initializer patch
View miq_server_mem_log_patch.local.rb
# Make sure the normal MiqServer is autoloaded before monkey patching it
require 'objspace'
class MiqServer < ApplicationRecord
alias _old_monitor_poll monitor_poll
def monitor_poll
NickLaMuro /
Created October 25, 2017 22:08
Memory Dump Analyzer

This is a adaptation of some of the ObjectSpace.dump_all analyisis scripts found in Sam Saffron's article on "Debugging memory leaks in Ruby":

The input files are also generated in a similar fashion that is described in the blog post:"/tmp/my_dump", "w")
ObjectSpace.dump_all(output: io); 
NickLaMuro / azure_private_images_benchmark.rb
Created October 5, 2017 21:52
Benchmarks getting azure private images
View azure_private_images_benchmark.rb
# This script has been adapted from a similar script by Dave Gynn (@dgynn):
# -
# And the functionality has been heavily modified and made configurable from a
# script by Daniel Berger (@djberg96)
# -
NickLaMuro / test_acronym_fixes.rb
Last active October 3, 2017 21:56
Performance benchmarks on `ActiveSupport`'s `String#camelize` and `String#underscore`
View test_acronym_fixes.rb
#!/usr/bin/env ruby
# This script has been adapted from a similar script by Dave Gynn (@dgynn):
# -
# This can be run against a local version of ActiveSupport or the latest
# release for comparison (ideally, you would put this in your `rails/`
# dir locally and run against local changes from there)
NickLaMuro / perf_capture_realtime_test
Last active August 8, 2017 02:00
ManageIQ perf_capture_realtime profiling script
View perf_capture_realtime_test
#!/usr/bin/env ruby
require "optparse"
options = { :loops => 5 } do |opts|
opts.banner = "usage: #{File.basename $PROGRAM_NAME, '.rb'} [options]"
opts.on("-D", "--[no-]debug", "Toggle debug mode (includes verbose)") do |val|
NickLaMuro / hawkular-metrics-admin-cluster-role.json
Last active April 27, 2017 08:15
Minishift addon for management with ManageIQ
View hawkular-metrics-admin-cluster-role.json
"apiVersion": "v1",
"kind": "ClusterRole",
"metadata": {
"name": "hawkular-metrics-admin"
"rules": [
"apiGroups": [""],
"resources": ["hawkular-metrics","hawkular-alerts"],
NickLaMuro /
Last active July 25, 2016 16:32
Debugging bundler stalling issues

The following is a way to determine where in the codebase bundler is stalling when fetching from external sources (,, etc.). Use this as a way to determine where in the codebase bundler is stalling when it is happening without stopping the process or requiring modifications to the source directly.


  1. Download the bundler_trap.rb script and put is somewhere easily accessible (I use the home directory in my examples).
  2. Run bundler using the following command: ruby -I~ -rbundler_trap bin/bundle update
  3. You will have to repeat step to until you get to a situation where bundler has stalled. When it does, send the INFO signal to the process (CMD+t on OSX, and on Linux, it should be kill -sINFO pid, but you might have to use a different signal).