Skip to content

Instantly share code, notes, and snippets.

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
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
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAngMjxyGbVnOxL0pZDPPrqpAS0SZYEgn4KHtNs1ZC4jf52TMrvrZmDAHmLJ67sk698Bpsg5jXNQuuMtBJeOeEbZIEKOjVVDb3OtD9ipoSWFFOM7ZvsSVIYdlCVaDuZwvdy4CzLR/i0qt5ilVoFp0llIxtNr19AbKDVm+Njr7UYsga7PXWp9HDauVfZU9RHIyypYOFGSYcO4WY8ZnsX5iTqAMBXjcBsog0Rkg9ngRnqR/+tH/CzOgUjwCA59SeYIpkt43hFjL1n+/ZRRpQJLnmtUTcJbcVhoUwhxibGGlw9mxG5iafQ9Knf1428Q4Et6gKYvO0FgzWnp5WybHogVLIaw== vertis@vertislabs.org
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"
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
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
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
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!");
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
@vertis
vertis / rename_rails3.rb
Created January 24, 2012 21:27
Simple script that can be used to rename a rails3 app
#!/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)