Skip to content

Instantly share code, notes, and snippets.

View iNecas's full-sized avatar
💭
Happy hacking 👨 ⌨️ 💻

Ivan Necas iNecas

💭
Happy hacking 👨 ⌨️ 💻
View GitHub Profile
#!/usr/bin/env sh
i3lock -i ~/.config/i3/lock_screen.png
@iNecas
iNecas / rest_client_2_log.patch
Last active October 19, 2018 15:15
RestClient 2.0 patch for more readable debug logging
commit 13c25907e7c750eb1f4e19508e6e7aa528dd2f3a
Author: root <[email protected]>
Date: Fri Oct 19 16:47:55 2018 +0200
add more logging
diff --git a/lib/restclient.rb b/lib/restclient.rb
index bdb53f0..588318b 100644
--- a/lib/restclient.rb
+++ b/lib/restclient.rb
@iNecas
iNecas / capsule-sync-analyze.rb
Created October 10, 2018 10:46
capsule-sync-analyze.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'set'
require 'yaml'
require 'time'
# Usage:
#
# # run inside a directory with extracted task export
@iNecas
iNecas / $*_vs_$@
Last active August 15, 2018 13:46
Difference between $* and "$@"
./test_args.sh "one two" three
with $*
["one", "two", "three"]
with "$@"
["one two", "three"]
@iNecas
iNecas / orhpaned_execution_plans_cleanup.sh
Created June 19, 2018 20:55
orhpaned_execution_plans_cleanup.sh
cat <<EOF | foreman-rake console
conf.return_format = ""
batch_size = 1000
persistence = ForemanTasks.dynflow.world.persistence
adapter = persistence.adapter
plans_without_tasks = adapter.db.fetch("select dynflow_execution_plans.uuid from dynflow_execution_plans left join foreman_tasks_tasks on (dynflow_execution_plans.uuid = foreman_tasks_tasks.external_id) where foreman_tasks_tasks.id IS NULL")
deleted = 0
total = plans_without_tasks.count
plans_without_tasks.all.map{|x| x[:uuid]}.in_groups_of(batch_size, false).each do |uuids|
delete_count = persistence.delete_execution_plans({ 'uuid' => uuids }, batch_size)
@iNecas
iNecas / tasks-action-times.rb
Last active June 18, 2018 14:00
tasks-action-times.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
# Usage:
#
# # extract the data to csv
# ruby tasks-action-times.rb my-tasks-export/*.html > action_times.csv
#
# # get top 20 actions with the highest execution time:
@iNecas
iNecas / fips_workaround.sh
Last active July 20, 2018 13:30
FIPS Ruby MD5 workaround
# WARNING: for testing only: don't apply to production without testing.
# A set of workaround patches to use different hash algorithm in Foreman and log the usage instead of failing right away.
# https://bugzilla.redhat.com/show_bug.cgi?id=1552159#c5
function puppet-certs {
if grep empty-password /usr/share/katello-installer-base/modules/certs/manifests/ssltools/nssdb.pp
then
echo "Puppet - certs already patched"
return
@iNecas
iNecas / rex_outputs.rb
Created August 10, 2017 14:02
script for collecting outputs from rex commads to csv via hammer
#!/usr/bin/env ruby
require 'json'
require 'csv'
unless ARGV.first
puts "Usage: HAMMER_USER=admin HAMMER_PASSWORD=changeme rex_outputs.rb JOB_INVOCATION_ID"
exit 1
else
@job_invocation_id = ARGV.first
end
@iNecas
iNecas / pry-remote-setup.txt
Created July 31, 2017 12:27
pry-remote-setup
scl enable tfm bash
gem install pry-remote
setenforce 0
# in code:
# require 'pry-remote'; binding.remote_pry
$(dirname $(gem which pry-remote))/../bin/pry-remote
@iNecas
iNecas / foreman_tasks_extract_data.rb
Created June 26, 2017 15:13
Get raw action data from task in JSON format.
# Get raw action data from task in JSON format.
#
# usage:
#
# TASK_IDS="TASK_ID_1,TASK_ID_2" \
# foreman-rake console 2>/dev/null < foreman_tasks_extract_data.rb | \
# grep "^OUT: " | sed "s/^OUT: //g"
task_ids = ENV['TASK_IDS'].split(',').map(&:strip)