Skip to content

Instantly share code, notes, and snippets.

View donnoman's full-sized avatar

Donovan Bray donnoman

View GitHub Profile
SELECT s.id as SubID, s.subdomain AS Subdomain, s.name AS Company, u.email AS UEmail, u.first_name AS First_name, u.last_name AS Last_name,
subs.subscription_plan_id AS PlanID, rp.amount AS Amount, s.created_at AS Created_At, current_login_at AS Last_Login, i_s.mtdb_id AS MtdbID, s.identity AS Identity
FROM users u
JOIN subscribers s ON s.id = u.subscriber_id
JOIN infrastructure_production.subscribers i_s ON i_s.id = s.id AND i_s.referral_token_id != 4
JOIN infrastructure_production.subscriptions subs ON i_s.id = subs.subscriber_id
JOIN infrastructure_production.subscription_plans sub_p ON sub_p.id = subs.subscription_plan_id AND sub_p.id NOT IN (6,12) AND sub_p.category != 'beta'
JOIN infrastructure_production.renewal_periods rp ON rp.id = renewal_period_id
WHERE UPPER(s.subdomain) NOT LIKE 'NBB'
AND u.admin = 1
@donnoman
donnoman / gist:739524
Created December 13, 2010 20:10
capistrano.rb
before "deploy:update_code", "deploy:clear_release_path"
namespace :deploy do
desc "Clear the release_path for a new checkout"
task :clear_release_path, :roles=>[:app] do
run "rm -rf #{release_path}"
end
end
module Capistrano
class Configuration
module Servers
# Identifies all servers that the given task should be executed on.
# The options hash accepts the same arguments as #find_servers, and any
# preexisting options there will take precedence over the options in
# the task.
def find_servers_for_task(task, options={})
find_servers(task.options.merge(options))
end

YARD CHEATSHEET yardoc.org

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

# Namespace for classes and modules that handle serving documentation over HTTP
# @since 0.6.0
group :development, :test do
gem 'ruby-debug'
gem "rspec-rails", ">= 2.0.0.beta.17"
end
@donnoman
donnoman / explanation issue with logging 1.2.2
Created July 30, 2010 21:23
Discovered Issue with Bundler with Logging 1.2.2
boot.rb patches the initialzer to memoize the Bundler.require
the preinitializer runs
The environment.rb is loaded
logging is required before the Rails::Initializer.run
@donnoman
donnoman / api_controller_spec.rb
Created July 29, 2010 22:43
post bundler upgrade with 1.0.0.rc.1 getting seemingly random segfaults, see http://gist.github.com/488261 for config
describe Api::ApiController, "base controller" do
integrate_views
before(:all) do
$api_token = User.first.single_access_token
end
after(:all) do
ApplicationGlobals.subscriber = subscriber = Subscriber.find(0)
subscriber.create_default_preferences! unless subscriber.preferences_set?
@donnoman
donnoman / Gemfile
Created July 24, 2010 00:50
causing script/server and rake db:migrate to hang with bundler 0.9.24, 1.0.0.beta.9, and 1.0.0.rc.1
# bundle update vendor/bundler_gems
# Sources
source "http://gemcutter.org"
source "http://gems.github.com"
# Stack
gem "rails", "2.3.4"
gem "rack", "1.0.1"
gem 'mysql', "2.7"
@donnoman
donnoman / capistrano-filter.rb
Created December 7, 2009 20:29
capistrano skip NoMatchingServers
# Allows Tasks that have no servers to be skipped instead of raising a NoMatchingServersError
module Capistrano
class Configuration
module Connections
def execute_on_servers(options={})
raise ArgumentError, "expected a block" unless block_given?
if task = current_task
servers = find_servers_for_task(task, options)
namespace :bundler do
task :install do
run("#{sudo} gem install bundler --source=http://gemcutter.org")
end
task :symlink_vendor do
shared_gems = File.join(shared_path, 'vendor/gems')
release_gems = "#{release_path}/vendor/gems/"
%w(cache gems specifications).each do |sub_dir|
shared_sub_dir = File.join(shared_gems, sub_dir)