Skip to content

Instantly share code, notes, and snippets.

View seamusabshere's full-sized avatar

Seamus Abshere seamusabshere

View GitHub Profile
class FriendsController
def index
@friends = @user.friends
@friends_of_friends = slow { @user.friends_of_friends }
end
def import
@result = slow { @user.friends.import(params[:big_csv]) }
end
end
class Gem::Dependency
def to_bundler
args = []
args << name
args << specification.version.to_s if specification.version.to_s.present?
options = {}
options[:require_as] = lib if lib.present?
str = "gem '#{args.join "', '"}'"
str << ", #{options.inspect.gsub(/[\{\}]/, '')}" if options.present?
str
#!/usr/bin/env ruby
require 'rubygems'
require 'activesupport'
class StringReplacer
NEWLINE = "AijQA6tD1wkWqgvLzXD"
START_MARKER = '# START StringReplacer %s -- DO NOT MODIFY'
END_MARKER = "# END StringReplacer %s -- DO NOT MODIFY#{NEWLINE}"
# (1) clone app_production to app_staging
# (2) hit it a couple times so it can cache any s3/etc. data it needs to start up (once you change the data, s3/etc. won't work)
# (3) cap y2k:set DATE="2010-01-01"
# (4) ...test the site...
# (5) cap y2k:unset
task :app_staging do
set :rails_env, 'production'
set :deploy_to, '/data/app'
role :app, "ec2-X-X-X-X.compute-1.amazonaws.com"
role :app, "ec2-Y-Y-Y-Y.compute-1.amazonaws.com"
my-macbook:~/app $ cap y2k:set DATE="2009-12-31 20:59:40"
* executing `y2k:set'
* executing `app_staging'
* executing "sudo -p 'sudo password: ' sh -c \"echo 1 > /proc/sys/xen/independent_wallclock\""
servers: ["ec2-X-X-X-X.compute-1.amazonaws.com", "ec2-X-X-X-X.compute-1.amazonaws.com", "ec2-X-X-X-X.compute-1.amazonaws.com"]
[ec2-X-X-X-X.compute-1.amazonaws.com] executing command
[ec2-X-X-X-X.compute-1.amazonaws.com] executing command
[ec2-X-X-X-X.compute-1.amazonaws.com] executing command
command finished
* executing "sudo -p 'sudo password: ' date --set=\"2009-12-31 20:59:40\""
if File.exists?(File.join(RAILS_ROOT,'tmp', 'passenger_debug.txt'))
require 'ruby-debug'
Debugger.wait_connection = true
Debugger.start_remote
File.delete(File.join(RAILS_ROOT,'tmp', 'passenger_debug.txt'))
end
(in our app)
class Automobile < ActiveRecord::Base
[...]
include BrighterPlanet::Automobile
end
(in an open source repo/gem)
module BrighterPlanet
require 'net/imap'
require 'tmail'
class ImapChecker
include Singleton
SERVER = 'secure.emailsrvr.com'
USERNAME = 'A'
PASSWORD = 'A'
SEARCH_CRITERIA = %w{ TO offset }
#!/usr/bin/env ruby
require 'rubygems'
require 'daemon_spawn' # currently seamusabshere-daemon-spawn
# BASEDIR = '/var/www/html/offset1'
BASEDIR = '/home/vagrant/offset1'
PID_PATH = "#{BASEDIR}/daemons/offset1_imap_checker.pid"
LOG_PATH = "#{BASEDIR}/log/offset1_imap_checker.log"
TIMEOUT = 60
# SIGNAL = 'INT'
diff --git a/VERSION b/VERSION
index 0c62199..53a75d6 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.2.1
+0.2.6
diff --git a/lib/daemon_spawn.rb b/lib/daemon_spawn.rb
index 2e3d628..f032d55 100644
--- a/lib/daemon_spawn.rb