I hereby claim:
- I am keithtom on github.
- I am keithtom (https://keybase.io/keithtom) on keybase.
- I have a public key ASCvDQu_mbvktf1WOr11_QRDnSgOqxv1bbEPAhysEHLpVAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
# A user submits their loan application | |
class SubmitApplication | |
def initialize(applicant, loan) | |
... | |
end | |
def execute | |
update_loan_workflow | |
charge_applicant_credit_card | |
check_applicant_fico_score |
# A user submits their loan application | |
class SubmitApplication | |
# store any state that you'll need to do your action | |
def initialize(applicant, loan) | |
@applicant = applicant | |
@loan = loan | |
end | |
end |
# Copyright (C) [2014] by Keith Tom <keith dot tom at gmail> | |
# Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE | |
module Rack | |
# disable CSS3 and jQuery animations in test mode for speed, consistency and avoiding timing issues. | |
# Usage for Rails: | |
# in config/environments/test.rb | |
# config.middleware.use Rack::NoAnimations | |
class NoAnimations |
def valid_triangle?(a, b, c) | |
if ((a == 0 or b == 0 or c == 0) or (a == nil or b == nil or c == nil)) | |
return false | |
end | |
if a + b > c | |
puts "case 1" | |
return true |
def leap_year?(year) | |
if year % 4 == 0 | |
puts "I am divisible by 4!" | |
true | |
elsif year % 100 == 0 | |
puts "I am divisible by 100!" | |
false | |
elsif year % 100 == 0 && year % 400 == 0 | |
puts "I am divisible by 100 and 400!" | |
true |
We have been contracted to write a piece of software for a restaurant. They want to easily be able to enter orders that come in, and be told how long the wait time will be for that order. That is, we are going to write a simple program for placing an order at a restaurant and it will print to the screen how long the wait is.
You can order the following items:
Pairing is when two programmers work together on a problem. We do it a lot at DBC.
Since we'll be pairing with you, if you don't know something, like some fact or detail, that's fine. You should really focus on how to think and talk about the challenge (the technical problem), ie. how to explain what you're thinking, follow what we do together and talk about it, and be able to recognize when we've succeeded!
Most of all just try to relax and enjoy working with us through this process.
require_relative "rules" | |
# An object which represents the checkout process or cash register. | |
# It scans items, which are added to an internal list of items, | |
# which are then used to return the #total at any given moment. | |
# This total tries to use the rules which lead to the cheapest price. | |
class CheckOut < Struct.new(:rules) | |
attr_accessor :rules # list of available pricing rules (passed on initialization) | |
attr_accessor :items # hash of scanned items and quantities | |
# { "A" => 0, "B" => 1 } means we have scanned one "A" and zero "B"s |
require 'sqlite3' | |
require_relative 'user_db' # Setup user table | |
# Open a database | |
db = SQLite3::Database.new "test.db" | |
while true | |
# Get user input. | |
puts "Add user:" | |
user_name = gets.strip |