Skip to content

Instantly share code, notes, and snippets.

View maxehmookau's full-sized avatar

Max Woolf maxehmookau

View GitHub Profile
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
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)
def gravatar_url(size = 50)
"https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.strip.downcase)}?d=identicon&s=#{size}&r=g"
end

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:

@maxehmookau
maxehmookau / list.md
Created August 9, 2016 18:53
Ruby Katas
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
class Film
attr_reader :title
def initialize(title)
@title = title
end
end
upstream app {
server 192.168.12.10:9292;
}
server {
listen 443 ssl;
try_files $uri @app;
location @app {
upstream rails_app {
server unix://puma.sock;
}
server {
listen 80;
server_name ip_address;
try_files $uri @app;