This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'zeus' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hell | |
attr_accessor :temperature | |
end | |
hell = Hell.new | |
hell.temperature = 100 | |
hell.freeze | |
hell.temperature = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant.configure("2") do |config| | |
config.vm.define "my-db-fedora" do |vm| | |
vm.box = "chef/fedora-21" | |
vm.provision "ansible" do | |
ansible.groups = { 'ha' => 'my-ha-fedora' } | |
ansible.playbook = "my-db.yml" | |
end | |
end | |
config.vm.define "my-ha-fedora" do |vm| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# getting first item of array or empty hash, when empty: | |
# A) Without documentation: | |
def get_first_item_from_array(array) | |
unless array.blank? | |
array.each do |single| | |
return single | |
end | |
end | |
return {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wrong | |
["9.13.3", "9.3.2", "10.1.1", "9.3.5"].sort | |
# => ["10.1.1", "9.13.3", "9.3.2", "9.3.5"] | |
# right | |
["9.13.3", "9.3.2", "10.1.1", "9.3.5"].sort_by{|version| version.scan(/\d+/).map(&:to_i)} | |
# => ["9.3.2", "9.3.5", "9.13.3", "10.1.1"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hash = Hash.new("") # => {} | |
hash[1] << "Hello" # => "Hello" | |
hash[2] # => "Hello" | |
hash = Hash.new{|h,k| h[k] = ""} # => {} | |
hash[1] << "Hello" # => "Hello" | |
hash[2] # => "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pscs = { | |
["Brno", "Hradecká"] => [61200,62100], | |
["Brno", "Merhautova"] => [61300,61400], | |
["Brno", "Nezamyslova"] => [61500,63600], | |
} | |
pscs.each do |(city, street), street_pscs| | |
puts "#{street} in #{city} has following PSCs: #{street_pscs.join(", ")}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = "<div>ruby</div><div>string</div><div>methods</div>" | |
# == splitting with regexp | |
string.split(/<.*?>/) | |
# => ["", "ruby", "", "string", "", "methods"] | |
# == and keeping separator in the result | |
string.split(/(<.*?>)/) |
OlderNewer