- http://codekata.com/
- git clone --depth=1 --branch=exercise [email protected]:skmetz/99bottles.git
This file contains hidden or 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
class Film | |
attr_reader :title | |
def initialize(title) | |
@title = title | |
end | |
end |
This file contains hidden or 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
class Bottles | |
def song | |
verses(99, 0) | |
end | |
def verses(from, to) | |
from.downto(to).map { |i| verse(i) }.join("\n") | |
end |
This file contains hidden or 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
class Bottles | |
def song | |
verses(99, 0) | |
end | |
def verses(from, to) | |
from.downto(to).map { |i| verse(i) }.join("\n") | |
end |
I hereby claim:
- I am maxehmookau on github.
- I am maxw (https://keybase.io/maxw) on keybase.
- I have a public key whose fingerprint is A0CA D8D7 B215 6D1D D4D2 31A2 CD2D B662 5F7E 18B3
To claim this, I am signing this object:
This file contains hidden or 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
def gravatar_url(size = 50) | |
"https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.strip.downcase)}?d=identicon&s=#{size}&r=g" | |
end |
This file contains hidden or 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
VAT_RATE = 20.0 | |
# Public: Get the total amount for an invoice taking additional users in to | |
# account. | |
# | |
# Params | |
# ex_vat - if true, subtract 20% from amount | |
# | |
# Returns a number | |
def total_amount(ex_vat = false) |
This file contains hidden or 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
class Organisation < ApplicationRecord | |
NUMBER_OF_PERMITTED_USERS = 10 | |
has_many :users, before_add: :validate_user_limit | |
private | |
def validate_user_limit(user) | |
raise Exception.new if users.size >= NUMBER_OF_PERMITTED_USERS | |
end | |
end |
This file contains hidden or 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
include HTTParty | |
query = {} | |
query["x"] = ['value1', 'value2'] | |
response = HTTParty::Basement.get(__URL__, query: query, | |
query_string_normalizer: HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER) |
This file contains hidden or 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
server { | |
listen 80; | |
listen [::]:80; | |
listen 443 default ssl; | |
server_name YOURDOMAIN.com; | |
if ($ssl_protocol = "") { | |
rewrite ^ https://$server_name$request_uri? permanent; | |
} |