Skip to content

Instantly share code, notes, and snippets.

phil-monroe /
Created Jul 1, 2011
This shell script facilitates the creation of a signed SSL certificate. The SSL certificate is signed using a Certificate Authority(CA) that is generated.
# Basic Config
echo '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
echo '%% Creating Directory to hold Certs %%'
phil-monroe / routes.rb
Created Sep 23, 2011
Routes file for App-Runway
View routes.rb
AppRunway::Application.routes.draw do
constraints(:subdomain => "") do
devise_for :users do
get "/login" => "devise/sessions#new"
delete "/logout" => "devise/sessions#destroy"
resources :users do
resources :apps do
resources :emails, only: [:index]
phil-monroe / cap_tail_logs.rb
Created Jun 8, 2012
Capistrano task to tail log files
View cap_tail_logs.rb
# Based off of this stack overflow answer, but has a nicer output
# Set max_hostname_length and tag to whatever you wish. I currently have it for pretty EC2 output
desc "tail log files"
task :logs, :roles => ENV['ROLE'] || :web do
last_host = ""
run "tail -f #{shared_path}/log/#{rails_env}.log" do |channel, stream, data|
phil-monroe / tag_deploy.rb
Created Jun 12, 2012
Capistrano tasks to deploy from commit references and separate repos
View tag_deploy.rb
# Have `cap deploy` ask for tag to deploy from. Can be automated like this `cap deploy TAG=some-tag-name`
set :branch do
if ENV['REF'] # Tag passed in via arg
ref = ENV['REF']
else # Prompt for reference to use
default_ref = `git tag`.split("\n").last
ref = Capistrano::CLI.ui.ask "Tag to deploy (make sure repo is up to date): [#{default_ref}] "
ref = default_ref if ref.empty?
phil-monroe / rails_c_cap.rb
Created Jun 16, 2012
Capistrano task to remotely connect to rails console
View rails_c_cap.rb
# Based off of
desc "Remote console on the production appserver"
task :console, :roles => ENV['ROLE'] || :web do
hostname = find_servers_for_task(current_task).first
puts "Connecting to #{hostname}"
exec "ssh -l #{user} #{hostname} -t 'source ~/.profile && cd #{current_path} && bundle exec rails c #{rails_env}'"
phil-monroe /
Created Jul 17, 2012
Repeatedly hits a website
while true; do
curl -b cookies.txt $URL -o out
phil-monroe / Rails Models.rb
Created Aug 14, 2012
Collect all Model Classes
View Rails Models.rb
def models
Module.constants.inject([]) do |models, k|
klass = Kernel.const_get k
models << klass if klass.respond_to? :ancestors and klass.ancestors.include? ActiveRecord::Base
phil-monroe / db_lag.rb
Created Sep 29, 2012
Calculate the lag in WAL transmission for postgres databases
View db_lag.rb
# math based on
dbname = ""
dbuser = ""
host_master = ""
host_slave = ""
previous_recieved_lags = []
previous_replated_lags = []
View clone_vm.rb
identity = RbVmomi::VIM.CustomizationLinuxPrep({
hostName: RbVmomi::VIM.CustomizationFixedName(name: "test"),
domain: ""
global_ip_settings = RbVmomi::VIM.CustomizationGlobalIPSettings({
dnsServerList: [""],
dnsSuffixList: [""]
phil-monroe / rails_2_papertrail.rb
Created Dec 19, 2012
Things needed to log rails to papertrail.
View rails_2_papertrail.rb
class MultiIO
def initialize(*targets)
@targets = targets
def write(*args)
puts "writing"
@targets.each { |t| t.write(*args) }