Skip to content

Instantly share code, notes, and snippets.

Avatar
:bowtie:
probably definitely most likely rebasing...

Nick LaMuro NickLaMuro

:bowtie:
probably definitely most likely rebasing...
View GitHub Profile
@NickLaMuro
NickLaMuro / gitter-search.rb
Last active Nov 8, 2019
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 = {}
View example.out
$ bin/rails r tmp/test_git_transaction.rb
** Using session_store: ActionDispatch::Session::MemCacheStore
** ManageIQ master, codename: J-release
starting...
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
NickLaMuro / compare_define_method_with_eval.rb
Created Jan 4, 2018
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
NickLaMuro / miq_server_mem_log_patch.local.rb
Created Dec 6, 2017
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
MiqServer
require 'objspace'
class MiqServer < ApplicationRecord
alias _old_monitor_poll monitor_poll
def monitor_poll
begin
@NickLaMuro
NickLaMuro / README.md
Created Oct 25, 2017
Memory Dump Analyzer
View README.md

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":

https://samsaffron.com/archive/2015/03/31/debugging-memory-leaks-in-ruby

The input files are also generated in a similar fashion that is described in the blog post:

io=File.open("/tmp/my_dump", "w")
ObjectSpace.dump_all(output: io); 
@NickLaMuro
NickLaMuro / azure_private_images_benchmark.rb
Created Oct 5, 2017
Benchmarks getting azure private images
View azure_private_images_benchmark.rb
#
# This script has been adapted from a similar script by Dave Gynn (@dgynn):
#
# - https://gist.github.com/dgynn/bd54e970f8942ce2ca532e4adc3fd30a
#
# And the functionality has been heavily modified and made configurable from a
# script by Daniel Berger (@djberg96)
#
# - https://gist.github.com/djberg96/809562e6e7868966a22032935ee6e5e8
#
@NickLaMuro
NickLaMuro / test_acronym_fixes.rb
Last active Oct 3, 2017
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):
#
# - https://gist.github.com/dgynn/bd54e970f8942ce2ca532e4adc3fd30a
#
# 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
NickLaMuro / perf_capture_realtime_test
Last active Aug 8, 2017
ManageIQ perf_capture_realtime profiling script
View perf_capture_realtime_test
#!/usr/bin/env ruby
require "optparse"
options = { :loops => 5 }
OptionParser.new do |opts|
opts.banner = "usage: #{File.basename $PROGRAM_NAME, '.rb'} [options]"
opts.on("-D", "--[no-]debug", "Toggle debug mode (includes verbose)") do |val|
@NickLaMuro
NickLaMuro / hawkular-metrics-admin-cluster-role.json
Last active Apr 27, 2017
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
NickLaMuro / README.md
Last active Jul 25, 2016
Debugging bundler stalling issues
View README.md

The following is a way to determine where in the codebase bundler is stalling when fetching from external sources (rubygems.org, github.com, 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.

Usage

  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).