Skip to content

Instantly share code, notes, and snippets.

View NickLaMuro's full-sized 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 December 19, 2023 05:02
ruby script to search gitter archives (requires `oga` rubygem)
#!/usr/bin/env ruby
#
# gitter-search [--date YYYYMMDD] [--user @USERNAME] ORG/ROOM [PATTERN]
#
require 'oga'
require 'optparse'
require 'net/http'
options = {}
@NickLaMuro
NickLaMuro / example.out
Created July 31, 2019 00:56
Example of the .git_transaction feature in https://github.com/ManageIQ/manageiq/pull/19074
$ 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 January 4, 2018 03:12
Comparing ruby's `define_method` to each type of `eval` for defining methods
# 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 December 6, 2017 16:27
ManageIQ MiqServer mem log initializer patch
# 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 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":

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 October 5, 2017 21:52
Benchmarks getting azure private images
#
# 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 October 3, 2017 21:56
Performance benchmarks on `ActiveSupport`'s `String#camelize` and `String#underscore`
#!/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 August 8, 2017 02:00
ManageIQ perf_capture_realtime profiling script
#!/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 April 27, 2017 08:15
Minishift addon for management with ManageIQ
{
"apiVersion": "v1",
"kind": "ClusterRole",
"metadata": {
"name": "hawkular-metrics-admin"
},
"rules": [
{
"apiGroups": [""],
"resources": ["hawkular-metrics","hawkular-alerts"],
@NickLaMuro
NickLaMuro / README.md
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 (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).