Skip to content

Instantly share code, notes, and snippets.

View maxehmookau's full-sized avatar

Max Woolf maxehmookau

View GitHub Profile
class Film
attr_reader :title
def initialize(title)
@title = title
end
end
class Bottles
def song
verses(99, 0)
end
def verses(from, to)
from.downto(to).map { |i| verse(i) }.join("\n")
end
class Bottles
def song
verses(99, 0)
end
def verses(from, to)
from.downto(to).map { |i| verse(i) }.join("\n")
end
@maxehmookau
maxehmookau / list.md
Created August 9, 2016 18:53
Ruby Katas

Keybase proof

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:

def gravatar_url(size = 50)
"https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.strip.downcase)}?d=identicon&s=#{size}&r=g"
end
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)
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
@maxehmookau
maxehmookau / example.rb
Created April 21, 2016 09:19
HTTParty GET Request where two parameters have the same key
include HTTParty
query = {}
query["x"] = ['value1', 'value2']
response = HTTParty::Basement.get(__URL__, query: query,
query_string_normalizer: HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER)
@maxehmookau
maxehmookau / nginx.conf
Created March 1, 2016 15:27
Secure nginx config
server {
listen 80;
listen [::]:80;
listen 443 default ssl;
server_name YOURDOMAIN.com;
if ($ssl_protocol = "") {
rewrite ^ https://$server_name$request_uri? permanent;
}