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
| #production.rb | |
| if defined?(PhusionPassenger) | |
| PhusionPassenger.on_event(:starting_worker_process) do |forked| | |
| # Only works with DalliStore | |
| Rails.cache.reset if forked | |
| end | |
| end | |
| #config/initializers/i18n.rb |
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 ActiveRecord::Base | |
| establish_connection YAML.load_file("#{Rails.root}/config/database.yml")[Rails.env].symbolize_keys | |
| 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
| class Hash | |
| def keep_on_trying(*args) | |
| args.inject(self.dup){|memo, e| memo.dup.delete(e) if memo.is_a?(Hash) } | |
| end | |
| end | |
| ruby-1.9.2-head :109 > a | |
| => {:test=>{:this=>"aaa"}} | |
| ruby-1.9.2-head :110 > a.keep_on_trying(:test) | |
| => {:this=>"aaa"} |
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 Hash | |
| define_method '[]_with_try_on', do |*args| | |
| if args.size == 1 and (args.is_a?(Symbol) or args.is_a?(String)) | |
| self.send(:'[]_with_try_on', args.first) | |
| else | |
| args.inject(self.dup){|memo, e| memo.dup.delete(e) if memo.is_a?(Hash) } | |
| 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
| { | |
| "name": "some_project", | |
| "version": "0.0.1", | |
| "dependencies": { | |
| "coffee-script": "1.1.1" | |
| } | |
| } |
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
| feature "correct syntax in project" do | |
| scenario "validate coffeescript files for errors" do | |
| Dir["#{Rails.root}/**/*.coffee"].each do |file| | |
| %x[coffee --lint -p #{file} ] | |
| $?.success?.should be_true | |
| end | |
| end | |
| scenario "validate haml files" do |
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 ApplicationController < ActionController::Base | |
| extend DecentDecorate | |
| 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
| class KittenMailer < ActionMailer::Base | |
| def mail *args | |
| attachments['cat.jpeg'] = open("http://placekitten.com/#{rand(300)+300}/#{rand(300)+300}").read | |
| super | |
| 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
| cli53 = '/home/ubuntu/.local/bin/cli53' | |
| zones_on_aws = `#{cli53} list`.lines.select{|e| e =~ /Name/ }.map{|e| e.split(":").last.strip.sub(/\.$/, '') } | |
| Dir.glob('zones/*.bind').each do |zone| | |
| zone_name = File.basename(zone, '.bind') | |
| unless zones_on_aws.include?(zone_name) | |
| system("#{cli53} create #{zone_name}") | |
| puts "#{zone_name} created." | |
| end | |
| abort("Can't sync #{zone_name}...") unless system("#{cli53} import #{zone_name} --file #{zone} --replace") |
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
| machine: | |
| environment: | |
| AWS_ACCESS_KEY_ID: | |
| AWS_SECRET_ACCESS_KEY: | |
| dependencies: | |
| pre: | |
| - pip install cli53 --user | |
| test: | |
| override: | |
| - "rake" |
OlderNewer