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
@iNecas
iNecas / freeze.rb
Created October 16, 2014 14:18
freeze
class Hell
attr_accessor :temperature
end
hell = Hell.new
hell.temperature = 100
hell.freeze
hell.temperature = 0
gem 'zeus'
@iNecas
iNecas / custom_plan.rb
Last active August 29, 2015 13:56
Put this files into the foreman dir, run `bundle exec zeus start`, and then `zeus test ../katello/test/actions/` to run all the action tests
require 'zeus/rails'
class CustomPlan < Zeus::Rails
# def my_custom_command
# # see https://github.com/burke/zeus/blob/master/docs/ruby/modifying.md
# end
def test_environment
require 'minitest/unit'
MiniTest::Unit.class_variable_set("@@installed_at_exit", true)
SCRATCH_REPO=http://inecas.fedorapeople.org/dynflow-scratch/
# Install Katello as usual + following commands before katello-intaller
yum install -y\
$SCRATCH_REPO/ruby193-rubygem-algebrick-0.4.0-2.el6.noarch.rpm\
$SCRATCH_REPO/ruby193-rubygem-apipie-params-0.0.3-1.el6.noarch.rpm\
$SCRATCH_REPO/ruby193-rubygem-dynflow-0.2.0-1.git.0.03c40d9.el6.noarch.rpm\
$SCRATCH_REPO/ruby193-rubygem-foreman-tasks-0.1.3-1.el6.noarch.rpm
diff --git a/app/models/katello/concerns/organization_extensions.rb b/app/models/katello/concerns/organization_extensions.rb
index 39a6480..294097d 100644
--- a/app/models/katello/concerns/organization_extensions.rb
+++ b/app/models/katello/concerns/organization_extensions.rb
@@ -19,7 +19,11 @@ module Katello
ALLOWED_DEFAULT_INFO_TYPES = %w(system distributor)
- include ForemanTasks::Concerns::ActionSubject
+ # We need this to be able to scratch build in koji
@iNecas
iNecas / fixed_size_keys.rb
Created September 2, 2013 19:25
The moment, when all the string/symbol keys in a hash have the same length
{ :invalid_system => 20,
:invalid_values => 21,
:manifest_error => 22,
:no_answer_file => 23,
:unknown_module => 24,
:defaults_error => 25 }
@iNecas
iNecas / hash.java
Last active December 14, 2015 12:49
Surprise: hash function in Ruby returns different values across processes
class Hash {
public static void main(String[] args) {
System.out.println(Integer.toString("Hello World!".hashCode()));
}
}
// $ java Hash
// $ -969099747
// $ java Hash
// $ -969099747
@iNecas
iNecas / major_contributor.sh
Created December 4, 2012 13:53
How to become the major contributor to a project
git filter-branch -f --env-filter '
export GIT_AUTHOR_NAME="$ME";
export GIT_COMMITTER_NAME="$ME";
export GIT_AUTHOR_EMAIL="$MY_MAIL";
export GIT_COMMITTER_EMAIL="$MY_MAIL";
' HEAD
git push origin --force
@iNecas
iNecas / misused_meta.rb
Created June 27, 2012 20:03
Misusing ruby metaprogramming part I
%w[one two three].each do |method|
define_method method do |*args|
"My uebercool method #{method}"
end
end
@iNecas
iNecas / align_indented.rb
Created May 28, 2012 15:08
Align indented
# shift indented text to the left as much as possible
def align_indented(text)
shift_left = text.lines.map { |l| l[/^\s*/].size }.min
text.lines.map { |l| l[shift_left..-1] }.join
end
puts align_indented(<<TEXT)
this is some
indented text
we would like to