Skip to content

Instantly share code, notes, and snippets.

Joe Rafaniello jrafanie

Block or report user

Report or block jrafanie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jrafanie
jrafanie / clean_notification_options.rb
Created Jun 28, 2019
Hacky fix for rails 5.0.0-5.0.6 bloated serialized notification options with no longer existing constants causing bugs in rails 5.1
View clean_notification_options.rb
require_relative 'config/environment'
Notification.includes(:subject).all.each do |n|
begin
# Options could have no longer available activerecord/activemodel classes from rails 5.0.0 -> 5.0.6, which will raise an ArgumentError on deserialization
# Fixing these to use 5.0.7+ smaller serialization format without all the private attributes is too hard, especailly since you can only read their YAML strings
# and make changes as a string, not as a Hash.
opts = n.options
rescue ArgumentError
new_value = n.subject.try(:name) || n.subject.try(:description)
View gist:6ca8389fee7f4b9eab33204e3b362bbc
(gdb) call (void)rb_eval_string("puts; puts; Thread.list.each {|t| puts t.backtrace; puts }")
/opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.7.1/lib/puma/single.rb:106:in `join'
/opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.7.1/lib/puma/single.rb:106:in `run'
/opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.7.1/lib/puma/launcher.rb:171:in `run'
/opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.7.1/lib/rack/handler/puma.rb:58:in `run'
/opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/rack-2.0.5/lib/rack/server.rb:297:in `start'
/opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.7/lib/rails/commands/server.rb:104:in `start'
/var/www/miq/vmdb/app/models/mixins/miq_web_server_runner_mixin.rb:33:in `block in start_rails_server'
View debug_faraday_manageiq_api_client_request_in_workers.rb
# put me in config/initializers
# restart your appliances and it should now log all the net/http interactions
# ***** WARNING *****
# do not run in production, set_debug_output has this warning in ruby docs:
# WARNING This method opens a serious security hole. Never use this method in production code.
require 'manageiq-api-client'
require 'faraday'
require 'faraday/adapter/net_http'
@jrafanie
jrafanie / vcr-webmock-2.rb
Created Oct 26, 2017 — forked from glaszig/vcr-webmock-2.rb
converts vcr cassettes to webmock 2.0-compatible format
View vcr-webmock-2.rb
# converts URIs in vcr cassettes from uri-based basic auth
# to header-based basic auth to be compatible with webmock 2.0.
# it will create a basic auth header with an ERB tag
# to keep user and password be editable.
#
# Authorization: Basic <%= Base64.encode64("user:password").chomp %>
#
# may not work if using VCR's filter_sensitive_data.
# in that case use https://gist.github.com/ujh/594c99385b6cbe92e32b1bbfa8578a45
#
@jrafanie
jrafanie / sexp_processor_4_9_0_vs_4_10_0.diff
Created Oct 2, 2017
Diff of sexp_processor 4.9.0 vs 4.10.0
View sexp_processor_4_9_0_vs_4_10_0.diff
diff --git a/sexp_processor-4.9.0/History.txt b/sexp_processor-4.10.0/History.txt
index b8e355f..23c21e2 100644
--- a/sexp_processor-4.9.0/History.txt
+++ b/sexp_processor-4.10.0/History.txt
@@ -1,3 +1,52 @@
+=== 4.10.0 / 2017-07-17
+
+* 2 major enhancements:
+
+ * Added experimental pattern matcher to Sexp. Forked from sexp_path.
@jrafanie
jrafanie / pgbouncer_setup.txt
Created Jul 7, 2017
initial setup of pgbouncer with manageiq
View pgbouncer_setup.txt
yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
yum install pgbouncer
vim /etc/pgbouncer/pgbouncer.ini
[databases]
...
@jrafanie
jrafanie / update_settings.rb
Last active Jun 15, 2017
Change ManageIQ server settings from a single location
View update_settings.rb
# 1) you'll need https://github.com/ManageIQ/manageiq/blob/master/tools/configure_server_settings.rb
# 2) copy this file to /var/www/miq/vmdb/tools
# 3) Then cd to vmdb via the 'vmdb' command alias
# 4) Create a list of miq_servers table ids for all of the target servers. I use 1000000000001 here.
# Or just do them all:
# ids = MiqServer.pluck(:id)
# 5) run this script in bin/rails console (if copy/paste works) or put this script into a file, update_settings.rb, in vmdb and run it using bin/rails r 'update_settings.rb'
# 6) Repeat this process for each region/database.
ids = %w(
@jrafanie
jrafanie / loaded_features.txt
Created Jun 12, 2017
$LOADED_FEATURES in generic worker after for do_work loop
View loaded_features.txt
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-automation_engine-0f8c8a48f536/lib/manageiq-automation_engine.rb
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-content-706f32ca26b7/lib/manageiq-content.rb
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-gems-pending-5cc19a6b852a/lib/gems/pending/util/miq-xml.rb
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-gems-pending-5cc19a6b852a/lib/gems/pending/util/xml/miq_rexml.rb
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-gems-pending-5cc19a6b852a/lib/gems/pending/util/xml/xml_diff.rb
/Users/joerafaniello/.gem/ruby/2.4.1/bundler/gems/manageiq-gems-pending-5cc19a6b852a/lib/gems/pending/util/xml/xml_hash.rb
@jrafanie
jrafanie / worker_creation
Created May 12, 2017
ManageIQ worker creation and start
View worker_creation
...
MiqServer.start
...
server.start [1]
...
server.monitor_loop [2]
[1] server.start
deactivate/activate roles
monitor_servers and roles
View development.log
# Logfile created on 2017-03-06 17:12:44 -0300 by logger.rb/56504
[----] D, [2017-03-06T17:12:44.556723 #19943:2afa865b1980] DEBUG -- : PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
[----] D, [2017-03-06T17:12:44.680628 #19943:2afa865b1980] DEBUG -- : MiqServer Load (0.6ms) SELECT "miq_servers".* FROM "miq_servers" WHERE "miq_servers"."guid" = $1 LIMIT $2 [["guid", "dc4343be-02a7-11e7-a1b2-0242a89f1cd9"], ["LIMIT", 1]]
[----] D, [2017-03-06T17:12:44.750165 #19943:2afa865b1980] DEBUG -- :  (0.2ms) SELECT last_value FROM miq_databases_id_seq
[----] D, [2017-03-06T17:12:44.755576 #19943:2afa865b1980] DEBUG -- : MiqRegion Load (0.4ms) SELECT "miq_regions".* FROM "miq_regions" WHERE "miq_regions"."region" = $1 LIMIT $2 [["region", 0], ["LIMIT", 1]]
[----] D, [2017-03-06T17:12:44.789966 #19943:2afa865b1980] DEBUG -- : SettingsChange Load (0.4ms)
You can’t perform that action at this time.