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
list = "Alban Leveau-Vallier | |
Wa Wa | |
Jan Gondol | |
Jozef Vaclavik | |
Igor Hlina | |
Ivka Drábiková | |
Pavol Bielik | |
Peter Dubec | |
Tibor Arpas | |
Michal Macejko |
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
require 'rspec' | |
require 'nokogiri' | |
class Scraper < Struct.new(:downloader, :persistor) | |
def scrape(id) | |
html = downloader.download("http://www.statistics.sk/pls/wregis/detail?wxidorg=#{id}") | |
doc = Nokogiri::HTML(html) | |
subject = { original_id: id } |
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
require 'rspec' | |
class CachedRepository | |
def initialize(repository) | |
@repository = repository | |
@cache = {} | |
end | |
def find(id) | |
unless @cache.include?(id) |
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 Number < Struct.new(:value) | |
def print | |
value | |
end | |
end | |
class Binary < Struct.new(:left, :right) | |
end | |
class Plus < Binary |
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
require 'minitest/autorun' | |
ARABIC_VALUES = { | |
'I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000 | |
} | |
def from_roman(roman) | |
chars = roman.chars << 'I' | |
chars.each_cons(2).inject(0) do |sum, (c1, c2)| | |
sum + (ARABIC_VALUES[c1] < ARABIC_VALUES[c2] ? -ARABIC_VALUES[c1] : ARABIC_VALUES[c1]) |
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
require 'minitest/autorun' | |
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 InviteController < ApplicationController | |
# The controller's responsibility is to build an object graph | |
# that will do the hard work. | |
def accept | |
scenario = InvitationScenario.new | |
scenario.accept_invite_token_for_user(current_user, params[:token], bus.when( | |
inviting_succeeded: ->(user) { redirect_to invite.item, notice: "Welcome!" }, | |
inviting_failed: ->(error) { redirect_to '/', alert: "Oopsy!" } | |
)) |
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 link_to_notifiable(notifiable) | |
notifiable.link_to_notifiable(self) | |
end | |
# concerns/notifiable_presenters.rb | |
class Answer | |
def link_to_notifiable(helper) | |
helper.link_to_answer, question | |
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
# sandi | |
module GildedRose | |
DEFAULT_CLASS = Item | |
SPECIALIZED_CLASSES = { | |
'normal' => Normal, | |
'Aged Brie' => Brie, | |
'Backstage passes to ...' => Backstage | |
} | |
def self.for(name, quality, days_remaining) |
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 DonationsController # < ActionController::Base | |
def create | |
donation_service.add_donation(current_user, params, bus.on( | |
donation_created: ->(donation) { send_user_to_payment_gateway(donation) }, | |
donation_invalid: ->(donation) { render donation.errors, status: :bad_request } | |
)) | |
end | |
private | |
def donation_service |