Skip to content

Instantly share code, notes, and snippets.

namespace(:pb) do
desc "Symlink the databse config file from shared drectory to current release directory."
task :symlinks do
run "ln -nsf #{shared_path}/config/database.yml #{release_path}/config/database.yml"
run "ln -nsf #{shared_path}/config/initializers/site_keys.rb #{release_path}/config/initializers/site_keys.rb"
end
end
namespace(:deploy) do
desc "Tell Passenger to restart the server"
// Instance method in my XML Reader to easily read dates from the XML
// Pretty sure I have the date formatting right, per the link from the Apple documentation
// http://unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns
-(NSDate *)dateWithString:(NSString *)dateString {
NSDateFormatter * formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"yyyy-MM-DD HH:mm:ss ZZ"];
NSLog(@"Converting '%@' to '%@'", dateString, [formatter dateFromString:dateString]);
return [formatter dateFromString:dateString];
}
--type-set=bin=.pdf
--nobin
--ignore-dir=tmp
--ignore-dir=coverage
@pbyrne
pbyrne / sss
Created July 18, 2011 22:09
Simple script to perform SCM (svn, hg, git) commands across your workspace
#!/usr/bin/env ruby
#
# Simple script to perform SCM (svn, hg, git) commands across your workspace
# Edit the SHARED_WORKSPACE environment variable if your code isn't checked out to ~/workspace
# Skip to the end for the actual execution ... to keep it all in one file, had to define the class first
# Get the latest version from https://gist.github.com/1090808
USAGE = <<-end_usage
SSS performs SCM commands on all projects in your workspace. Set the
SHARED_WORKSPACE environment variable if your workspace is not ~/workspace.
@pbyrne
pbyrne / test
Created August 22, 2011 17:59
something
testing download
@pbyrne
pbyrne / comment.rb
Created September 5, 2011 01:49
Demonstrating Custom Validations to Prevent Specific Text
# Assumes a Comment model with a message attribute contianing the text of the
# comment. Change these to suit your needs.
class Comment
validate :disallow_phone_numbers_and_email_addresses
# possibly not the most performant, but it's clear
# assumes you have arrays of regexes you want to dissalow
def disallow_phone_numbers_and_email_addresses
if PHONE_NUMBERS.any? { |regex| message =~ regex }
errors.add(:message, "cannot contain phone numbers.")
@pbyrne
pbyrne / setup.sh
Created October 6, 2011 20:50
Set Up Work Laptop
#!/bin/bash
echo "Updating Homebrew and bash completion"
brew update
echo "
# homebrew completion files for installed libraries
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
" >> ~/.bash_profile
79c79
< let s:code = "print ($: + begin; require %q{rubygems}; Gem.all_load_paths.sort.uniq; rescue LoadError; []; end).join(%q{,})"
---
> let s:code = "print ($:)"
@pbyrne
pbyrne / rspec-documentation.txt
Created March 18, 2012 20:51
RSpec --format=documentation Output
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
Automation::CLI
.perform(command)
passes the given command to the shell
.say(message)
displays the given message
.perform_in(dir, &block)
@pbyrne
pbyrne / gist:3183751
Created July 26, 2012 18:46
first draft, untested, and doing terrible things with negative indexes
# desired_cluster is a hash of roles and their counts (e.g., {web: 2, redis: 1}
def equalize_servers fog, app, environment, desired_cluster
current_cluster = filtered_servers(fog, app, environment).group_by { |server| server.tags["role"] }
to_build = {}
to_destroy = []
current_cluster.each do |role, servers|
if desired_cluster.has_key? role
# we want some, but do we have the right amount?
difference = desired_cluster[role] - servers.count