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
root@vbox3:~# rvm info | |
ree-1.8.7-2011.03: | |
system: | |
uname: "Linux vbox3 2.6.32-29-generic-pae #58-Ubuntu SMP Fri Feb 11 19:15:25 UTC 2011 i686 GNU/Linux" | |
bash: "/bin/bash => GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)" | |
zsh: " => not installed" | |
rvm: |
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 File.expand_path(File.dirname(__FILE__) + "/../../config/environment") | |
ManualUpdate::by('stearns') do | |
# We got this from a tenant: | |
## I made my first online payment using your website this afternoon. Somehow | |
## two payments in the amount of $1150 were processed and are scheduled to | |
## come out of my checking account tomorrow. Can you please cancel one of | |
## the payments to my account? | |
LineItem.delete(3471) |
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
module ManualUpdate | |
def self.by(login_name) | |
ActiveRecord::Base.transaction do | |
ActiveRecord::Base.current_user = User.find_by_login!(login_name) | |
PaperTrail.whodunnit = login_name | |
puts "Running update..." | |
yield | |
puts "Checking database validity..." |
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 | |
# | |
# Don't run this - it's a waste of time... | |
# | |
# We got ourselves into a situation where we had several undeployed migrations | |
# that depended on intermediate versions of our models to evolve production | |
# data, which prevented easy deployment. | |
# | |
# I wrote this script, assuming that it could "figure out" how to check out | |
# intermediate revisions and migrate in several steps. Unfortunately, this |
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
# "Ascertain" the revision we're running (so named so it'll come before | |
# the cache initializer, which uses this info). | |
def determine_revision | |
# Note the revision number we're running, and a | |
# more-informative string containing it. | |
revision_path = File.dirname(__FILE__) + "/../../REVISION" | |
begin | |
digits = 8 | |
if File.exist? revision_path |
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
# Conditionally delay outgoing mail | |
class DelayedMailerBase < ActionMailer::Base | |
class << self | |
def method_missing(method_symbol, *parameters) | |
# If this is "deliver_xx", maybe delay it; if we do, change | |
# its name so that we don't delay in the worker. | |
method_name = method_symbol.to_s | |
if matches_deliver_method?(method_name) and delaying_mail? | |
return self.send_later("delayed_#{method_name}".to_sym, *parameters) | |
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
# In spite of the proscription at the end of Recipe 69, "Upload Custom Maintenance | |
# Pages" in Mike Clark's excellent Advanced Rails Recipes, I wanted to generate my | |
# maintenance page with the full awesome power of Rails (ok, well, I wanted to use | |
# a real template, to avoid having to maintain the look of the maintenance page | |
# separately). | |
# | |
# My solution was to render the page using this rake task, which goes in: | |
# lib/tasks/render_maintenance.rake | |
task :render_maintenance => :environment do | |
# Render the maintenance page into tmp/maintenance.html, |
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
module EnumeratedAttributes | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def enumeration(attr_name, options) | |
# Declare a mapping of symbols to integer values for an attribute: | |
# | |
# enumeration :ghost, | |
# :in => {:past => 0, :present => 12, :yet_to_come => -5}, |
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/python | |
# | |
# startvpn: Automatically connect to a VPN when associating with a | |
# wireless network | |
# | |
# Once you've successfully set up an OpenVPN connection in NetworkManager, | |
# configure the settings below, then install this script as | |
# /etc/NetworkManager/dispatcher.d/02startvpn (it seems to be happiest | |
# when chowned root:root) | |
# |
NewerOlder