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
| if defined?(PhusionPassenger) | |
| PhusionPassenger.on_event(:starting_worker_process) do |forked| | |
| if forked | |
| MyModel.connection.reconnect! | |
| else | |
| # We're in conservative spawning mode. We don't need to do anything. | |
| end | |
| 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
| create_file ".rvmrc" do | |
| <<-RVMRC | |
| rvm_gemset_create_on_use_flag=1 | |
| rvm gemset use #{app_name} | |
| RVMRC | |
| end | |
| remove_file 'Gemfile' | |
| create_file 'Gemfile' do | |
| <<-GEMFILE |
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
| remove_file 'Gemfile' | |
| create_file 'Gemfile' do | |
| <<-GEMFILE | |
| source 'http://rubygems.org' | |
| gem 'rails', '3.0.1' | |
| # The ORM which we will stake our application | |
| gem "mongoid", ">= 2.0.0.beta.19" | |
| gem "bson_ext", ">= 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
| app_home = "/home/mi/production" | |
| workers = 5 | |
| Bluepill.application("mi_delayed_job", :log_file => "#{app_home}/shared/log/bluepill.log") do |app| | |
| (0...workers).each do |i| | |
| app.process("delayed_job.#{i}") do |process| | |
| process.working_dir = "#{app_home}/current" | |
| process.start_grace_time = 10.seconds | |
| process.stop_grace_time = 10.seconds | |
| process.restart_grace_time = 10.seconds |
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
| curl https://github.com/beautifulcode/ssh-copy-id-for-OSX/ssh-copy-id.sh -o /usr/local/bin/ssh-copy-id | |
| chmod +x /usr/local/bin/ssh-copy-id |
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 'pathname' | |
| class Pathname | |
| def hashes | |
| children.map do |entry| | |
| if entry.directory? | |
| sha1 = [Digest::SHA1.hexdigest(entry.hashes.sort.join("")), entry] | |
| else | |
| sha1 = [Digest::SHA1.hexdigest(entry.read), entry] | |
| 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
| import org.eclipse.swt.widgets.Display; | |
| import org.eclipse.swt.widgets.Shell; | |
| public class HelloWindows { | |
| public static void main(String[] args) { | |
| Display display = new Display(); | |
| Shell shell = new Shell(display); | |
| shell.setText("Hello, world!"); |
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
| begin | |
| descriptors = [] | |
| files = [] | |
| ARGV.each do |filename| | |
| io = IO.sysopen(filename, 'r') | |
| descriptors << io | |
| i = IO.open(io) | |
| i.seek(0, IO::SEEK_END) # TODO: go back a few lines so we have context | |
| files << i |
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 ruby | |
| require 'fileutils' | |
| require 'tempfile' | |
| def replace_in_file(filename,oldvalue,newvalue) | |
| temp_file = Tempfile.new(File.basename(filename)) | |
| contents = File.read(filename) | |
| changed_contents = contents.gsub(oldvalue,newvalue).gsub(oldvalue.downcase,newvalue.downcase) | |
| temp_file.print(changed_contents) |