Skip to content

Instantly share code, notes, and snippets.

View willclark's full-sized avatar

Will Clark willclark

View GitHub Profile
class BowlingGame
def initialize
@rolls = []
end
def roll(pins)
@rolls << pins
end
def score
{
"Outputs": {
"RDSHost": {
"Description": "Database endpoint address",
"Value": { "Fn::GetAtt": ["RDSDatabase", "Endpoint.Address"] }
},
"RDSPort": {
"Description": "Database endpoint port",
"Value": { "Fn::GetAtt": ["RDSDatabase", "Endpoint.Port"] }
},
class ProtectedObject
def say_hi(object)
object.hi
end
def say_hello(object)
object.hello
end
private
a = Account.first
date_range = (Date.today.at_beginning_on_month..Date.today)
# => Returns a collection of all the click events for that account
a.stats_for(:click_events)
# => Returns a collection of all the spam events for that account that occurred in the date range
a.stats_for(:spam_events, date_range: date_range)
# => Returns the last open event (order by occurred_at asc)
#...
named_scope :root, conditions: { parent_claim_id: nil }
named_scope :with_zero_charges, conditions: { total_charges: 0 }
named_scope :for_client, ->(client_id) { { conditions: { client_id: client_id } } }
named_scope :since, ->(date_time) {
if date_time.present?
{ conditions: ["claims.created_at >= ?", date_time]}
end
}
# generates an activity in memory representing the service location for episodic claims
def pseudo_episodic_service_location_activity
return unless first_activity = self.activities.order_by_date.first
client.activities.new(agency: client.agency,
charges: 0.01,
units: 1,
current_service_rate: hipps_service_location_rate(first_activity),
activity_on: first_activity.activity_on)
end
module DefaultAutomobileProperties
def engine_type
:gasoline
end
def front_wheel_drive
true
end
def passengers
describe Scheduler::DayLightSavings do
before { Time.zone = 'UTC' }
subject { Scheduler::DayLightSavings.new(time, current_time) }
let(:current_time_dst) { Time.new(2013, 05, 01).in_time_zone('Central Time (US & Canada)') }
let(:current_time_not_dst) { Time.new(2013, 02, 01).in_time_zone('Central Time (US & Canada)') }
describe "#get_time" do
context "when current time is dst" do
let(:current_time) { current_time_dst }
$j(document).on('click', 'a.remove_planned_service', function() {
var id = $j(this).parents('tr').data("plannedServiceId");
if ($j(this).text() == 'Remove') {
scheduler.showDeletePlannedServiceForm(id);
} else {
scheduler.hideDeletePlannedServiceForm(id);
};
});
//....
# When using asset_packager, assets can be moved from to a different directory.
# 3rd party controls often use relative paths, which can cause resources to
# no longer be found when a file is moved from it's original directory.
#
# These tasks are intended to be run locally once a control has been upgraded.
# It will process the css files, replacing the relative paths with
# absolute paths.
#
# After running the tasks, be sure to commit the processed css files
# to source control.