This file contains 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
SELECT | |
agent_plan_id, plan_id | |
,agent_plan_cim_customer_id | |
,plan_trial_interval_price | |
,agent_plan_cim_payment_profile_id | |
FROM | |
(SELECT COUNT(agent_plan_payment_id) AS payment_count FROM agent_plan_payments JOIN agent_plan_payment_reasons ON agent_plan_payment_reasons.agent_plan_payment_reason_id = agent_plan_payments.agent_plan_payment_reason_id WHERE agent_plan_payments.agent_plan_id = agent_plans_with_modifiers.agent_plan_id AND agent_plan_payment_reasons.agent_plan_payment_reason_code='trial-interval-fee') blah | |
, agent_plans_with_modifiers | |
WHERE |
This file contains 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 'aasm' | |
require 'timers' | |
class TimedStateMachineExample | |
include AASM | |
TRANSITION_SECONDS = 5 | |
def initialize(timers) | |
@timers = timers || Timers.new |
This file contains 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
#!/bin/bash | |
set -e | |
if [[ $UID -ne '0' ]]; then | |
echo "Must be root" >&2 | |
exit 1 | |
fi | |
# Check if minion running | |
set +e |
This file contains 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 'minitest' | |
require 'minitest/autorun' | |
require 'minitest/pride' | |
class TestNumeric < Minitest::Test | |
def numeric?(arg) | |
!/\A[+-]?\d+\z/.match(arg.to_s).nil? | |
end |
This file contains 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 'socket' | |
# A semi-nice way to lock a record against multiple access for whatever reason in PostgreSQL. | |
# Uses an atomic test-and-set query to guarantee the caller has gotten a lock. | |
# Usage: | |
# | |
# require_relative 'lockable' | |
# class MyARClass < ActiveRecord::Base | |
# include Lockable | |
# lockable :locked_by |
This file contains 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 'active_record' | |
module ActiveRecord | |
class Base | |
class << self | |
def select_rows_with_params(query, *params) | |
query = sanitize_sql_array [query, *params] | |
connection.select_rows query | |
end |
This file contains 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
04d0cafedd8874f190bf83ba3a7251384eb63f3031d8a44b8f31df574c26044f1104461f42564ef52b4e284b4f66f326c15b32547655709e295c7c5dcdde2737d8 |