Skip to content

Instantly share code, notes, and snippets.

View ShimShtein's full-sized avatar

Shimon Shtein ShimShtein

View GitHub Profile
@ShimShtein
ShimShtein / Dynflow bottlenecks.md
Last active January 13, 2018 04:27
Dynflow performance analysis.

break /home/shim/Documents/foreman/dynflow/lib/dynflow/utils.rb:60

Why do we need indifferent_hash while saving?

 "/home/shim/Documents/foreman/dynflow/lib/dynflow/utils.rb:60:in `indifferent_hash'",
 "/home/shim/Documents/foreman/dynflow/lib/dynflow/persistence_adapters/sequel.rb:268:in `extract_metadata'",
 "/home/shim/Documents/foreman/dynflow/lib/dynflow/persistence_adapters/sequel.rb:226:in `prepare_record'",
 "/home/shim/Documents/foreman/dynflow/lib/dynflow/persistence_adapters/sequel.rb:236:in `save'",
 "/home/shim/Documents/foreman/dynflow/lib/dynflow/persistence_adapters/sequel.rb:125:in `save_action'",
@ShimShtein
ShimShtein / gems.diff
Created May 3, 2017 09:04
Pin gems for Foreman 1.6
diff --git a/Gemfile b/Gemfile
index b86d9ec..9eb4275 100644
--- a/Gemfile
+++ b/Gemfile
@@ -22,6 +22,14 @@ gem 'deep_cloneable', '~> 2.0'
gem 'foreigner', '~> 1.4.2'
gem 'validates_lengths_from_database', '~> 0.2.0'
+gem 'public_suffix', '<= 1.4.6'
+gem 'nokogiri', '<= 1.6.8'
@ShimShtein
ShimShtein / 000 - preformance deep dive resources.md
Last active December 3, 2018 14:41
Foreman performance analysis deep dive
  1. rack-mini-profiler: Swiss-army knife profiler for rails apps
  2. flamegraph: Nice and useful timeline visualizer for debugging long methods.
  3. memory_profiler: Easy to use memory profiler for memory consuming methods.
  4. heapy: Memory dump analyzer for advanced memory analysis.
  5. foreman-tracer: great tool for unintrusive tracing by lzap.
rubygems = @sources.rubygems_sources.first
rubygems.replace_remotes([URI('http://my_new_local_gemsource:8808')])
@ShimShtein
ShimShtein / erb_strip.rb
Last active August 13, 2017 18:24
Inspecting provisioning templates with Rubocop
class ErbStrip
ERB_REGEX = /(?<start_tag><%[-=]?)(?<script>([^#]).*?)(?<end_tag>-?%>)/m
def initialize(source)
@source = source
end
def strip
out = ''
current_position = 0
Nic::Base.where('identifier LIKE ?', pattern)
class InterfaceCleaner
include ActiveRecord::Sanitization
ESCAPE_CHAR = '\\'
def self.nic_pattern_to_like(nic)
sanitize_sql_like(nic, ESCAPE_CHAR).tr('*', '%')
end
def self.ignored_interface_like_patterns
arel = Nic::Base.arel_table
like_ast = arel[:identifier].matches(pattern, InterfaceCleaner::ESCAPE_CHAR, true)
Nic::Base.where(like_ast).pluck(:identifier)