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
| puts 'in original, not to be modified' | |
| begin | |
| require 'aws-sdk' | |
| rescue LoadError | |
| puts "aws-sdk gem not found" | |
| throw :aws_sdk | |
| end | |
| puts ">>> to execute only if 'aws-sdk' is found" |
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
| #!/usr/bin/env bash | |
| # needed for the chef ruby cookbook to run without errors the second time | |
| if [ -s /etc/profile.d/rbenv.sh ]; then | |
| source /etc/profile.d/rbenv.sh | |
| fi | |
| # can pass-in variables like | |
| # CHEF_DEPLOY_USER=deployer | |
| # and access it in ruby (role files etc) |
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
| ** [out :: server1] [2013-01-24T11:33:05+00:00] INFO: ohai plugins will be at: /etc/chef/ohai_plugins | |
| ** [out :: server1] [2013-01-24T11:33:05+00:00] INFO: Processing remote_directory[/etc/chef/ohai_plugins] action create (ohai::default line 27) | |
| ** [out :: server1] [2013-01-24T11:33:05+00:00] INFO: Processing cookbook_file[/etc/chef/ohai_plugins/README] action create (dynamically defined) | |
| ** [out :: server1] | |
| ** [out :: server1] ================================================================================ | |
| ** [out :: server1] Recipe Compile Error in /vagrant/cookbooks/ruby/recipes/default.rb | |
| ** [out :: server1] ================================================================================ | |
| ** [out :: server1] | |
| ** [out :: server1] Errno::ENOENT | |
| ** [out :: server1] ------------- |
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
| % echo $FOO | |
| % cat /tmp/foo.sh | |
| FOO=12 | |
| % source /tmp/foo.sh | |
| % echo $FOO | |
| 12 |
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
| # TODO: extracted from uuidtools | |
| UUID_REGEX = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})$/ | |
| resources :checkout, :only => [:show, :create], :constraints => { :id => UUID_REGEX } |
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 'irb/completion' | |
| require 'irb/ext/save-history' | |
| IRB.conf[:SAVE_HISTORY] = 1000 | |
| IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" | |
| IRB.conf[:PROMPT_MODE] = :SIMPLE | |
| IRB.conf[:USE_READLINE] = true | |
| # Just for Rails... | |
| if ENV['RAILS_ENV'] |
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 BooleanValidator < ActiveModel::EachValidator | |
| def validate_each(record, attribute, value) | |
| unless is_a_boolean? value | |
| record.errors[attribute] << (options[:message] || "is not valid") | |
| end | |
| end | |
| def is_a_boolean? value | |
| !!value == value | |
| 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
| We are looking for senior web designer. You should be creative and should love your work. | |
| Should be proficient with: | |
| Technical Skillset | |
| * writing semantic HTML | |
| * writing modular CSS | |
| * HTML5 | |
| * AJAX, jQuery | |
| * Building cross browser compatible websites |
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
| name "basebox" | |
| description "A basic box with some packages, ruby and rbenv installed" | |
| deploy_user = ENV['CHEF_DEPLOY_USER'] | |
| # puts "== deploy user is: #{deploy_user.inspect}" | |
| # cannot access node attributes in roles. will have to use | |
| # chef-server's search as in http://wiki.opscode.com/display/chef/Search#Search-FindNodeswithaRoleintheExpandedRunList | |
| # but i want to use chef-solo not chef-server and cannot use search | |
| # deployer_user = node['users']['names'].find {|k,v| v['role'] == "deploy" } |
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 'pp' | |
| Dir["#{RAILS_ROOT}/app/models/*.rb"].each { |model_path| require model_path } | |
| models = Module.constants.select do |constant_name| | |
| begin | |
| constant = eval constant_name.to_s | |
| next if constant.nil? | |
| match = (constant < ActiveRecord::Base) rescue nil | |
| if match |