- My blink is that in 2012 Puppet is safer and more productive.
- Puppet is declarative, Chef procedural.
- Puppet brings system into compliance (state), Chef "does" things (recipes).
- Puppet has strong security practices; Chef has a toleration for loose security in Chef itself.
- Puppet makes it very hard to get "outside the lines" or violate its strong opinions; in Chef this is routine.
This file contains hidden or 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 'erb' | |
| When /\A\(erb\) (.*)\z/ do |*matches| | |
| s = ERB.new(matches[0]).result(binding) | |
| if matches.size > 1 | |
| s = <<-MULTI | |
| #{s} | |
| """ | |
| #{ERB.new(matches[1]).result(binding)} | |
| """ |
This file contains hidden or 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
| ActiveRecord::SchemaDumper.ignore_tables = ActiveRecord::Base.connection.tables - ['table_name'] | |
| ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, $stdout) |
This file contains hidden or 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 'active_support/version' | |
| require 'active_support/core_ext/time/zones' | |
| require 'active_support/core_ext/time/calculations' | |
| require 'active_support/time_with_zone' | |
| puts "ActiveSupport: #{ActiveSupport::VERSION::STRING}" | |
| Time.zone = 'Eastern Time (US & Canada)' | |
| def show_time user_time |
This file contains hidden or 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
| drop table if exists student; | |
| create table student ( | |
| sno integer, | |
| sname varchar(10), | |
| age integer | |
| ); | |
| drop table if exists courses; | |
| create table courses ( | |
| cno varchar(5), |
This file contains hidden or 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
| def assert_equality(example, actual, expected) | |
| print "example #{example}: " | |
| if actual == expected | |
| puts 'Pass' | |
| else | |
| puts "Fail: got #{actual.inspect}; expected #{expected.inspect}" | |
| end | |
| end | |
| examples = [ |
This file contains hidden or 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 HalfAdder | |
| attr_reader :sum, :carry | |
| def initialize(augend, addend) | |
| @augend, @addend = augend, addend | |
| end | |
| def compute | |
| end | |
| end |
This file contains hidden or 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
| example [0, 0, 0, 0]: Fail: got nil; expected 0 | |
| example [0, 0, 0, 0]: Fail: got nil; expected 0 | |
| example [1, 0, 0, 1]: Fail: got nil; expected 0 | |
| example [1, 0, 0, 1]: Fail: got nil; expected 1 | |
| example [0, 1, 0, 1]: Fail: got nil; expected 0 | |
| example [0, 1, 0, 1]: Fail: got nil; expected 1 | |
| example [1, 1, 1, 0]: Fail: got nil; expected 1 | |
| example [1, 1, 1, 0]: Fail: got nil; expected 0 |
This file contains hidden or 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 HalfAdder | |
| attr_reader :sum, :carry | |
| def initialize(augend, addend) | |
| @augend, @addend = augend, addend | |
| end | |
| def compute | |
| @carry = @augend & @addend | |
| @sum = @augend ^ @addend |