Skip to content

Instantly share code, notes, and snippets.

View donnoman's full-sized avatar

Donovan Bray donnoman

View GitHub Profile

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
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
@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
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
SELECT MAKEDATE(YEAR(CURRENT_DATE()),DAYOFYEAR(CURRENT_DATE()) - rn.id + 1) as `date`,
(
SELECT SUM(ROUND(rp.amount/(rp.interval * 30) * IF(spay.service_end_date,1,0),2)) as dv
FROM subscribers sub
JOIN subscriptions s ON s.subscriber_id = sub.id AND s.is_suspended = false AND s.autobill_failure_count = 0
JOIN subscription_plans sp ON sp.id = s.subscription_plan_id AND sp.id NOT IN (6,12)
JOIN renewal_periods rp ON s.renewal_period_id = rp.id
JOIN subscription_payments spay ON spay.subscription_id = s.id
WHERE s.deleted_at IS NULL
AND DATE(spay.service_begin_date) <= `date`
@donnoman
donnoman / ruby_recursive.rb
Created February 3, 2011 19:17
Just a simple recursion test
#faking the rails class to keep the test simple
class Rails
def self.env
"development"
end
end
def get_descriptor(descriptor, descriptor_keys = Rails.env, i = 0)
if descriptor.is_a?(Array) || descriptor.is_a?(String)
descriptor
@donnoman
donnoman / gist:1112161
Created July 28, 2011 18:19
Sample Cucumber Spec
Story: Visitor should be able to log in
As a visitor
I should be able to login
So that I can have access to the application
Scenario: Visitor visits the home page
Given a logged out visitor
When visitor goes to the home page
Then visitor should see the sessions/new page
@donnoman
donnoman / gist:1112243
Created July 28, 2011 18:50
Cucumber Template
# http://rspec.info/
# http://peepcode.com/products/rspec-user-stories
# http://dannorth.net/whats-in-a-story
# http://www.lukeredpath.co.uk/2006/8/29/developing-a-rails-model-using-bdd-and-rspec-part-1
# http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/
# http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/
# http://www.chariotsolutions.com/slides/pdfs/ete2008-IntegrationTestingWithRSpec.pdf
# http://www.joesniff.co.uk/ruby/telling-a-good-story-rspec-stories-from-the-trenches.html
# How does using stories help testing?
@donnoman
donnoman / raise-in-a-block.rb
Created December 29, 2011 00:42
Ruby Raise in a block test
ree-1.8.7-2010.02 :001 > def me
ree-1.8.7-2010.02 :002?> yield
ree-1.8.7-2010.02 :003?> end
=> nil
ree-1.8.7-2010.02 :004 >
ree-1.8.7-2010.02 :005 > me do
ree-1.8.7-2010.02 :006 > begin
ree-1.8.7-2010.02 :007 > raise "goobers"
ree-1.8.7-2010.02 :008?> rescue
ree-1.8.7-2010.02 :009?> p "I caught the goober"
@donnoman
donnoman / gist:1643445
Created January 19, 2012 22:41
God Init Script for Ubuntu/Debian
#! /bin/sh
### BEGIN INIT INFO
# Provides: god
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: God initscript
### END INIT INFO