This file contains 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
case class AuthorBuilder(familyName: String = "John", | |
givenNames: Seq[String] = Seq("Doe"), | |
books: Seq[String] = Seq(), | |
affiliations: Seq[String] = Seq()) { | |
def asXML = | |
<Author> | |
<FamilyName>{familyName}</FamilyName> | |
<GivenNames> | |
{for (name <- givenNames) yield <GivenName>{name}</GivenName>} |
This file contains 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
(ns euler) | |
(def grid | |
[ | |
[8 2 22 97 38 15 0 40 0 75 4 5 7 78 52 12 50 77 91 8] | |
[49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 4 56 62 0] | |
[81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 3 49 13 36 65] | |
[52 70 95 23 4 60 11 42 69 24 68 56 1 32 56 71 37 2 36 91] | |
[22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80] | |
[24 47 32 60 99 3 45 2 44 75 33 53 78 36 84 20 35 17 12 50] |
This file contains 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
data Position = Position Int Int Direction | |
deriving (Show, Eq, Read) | |
data Direction = N | E | W | S | |
deriving (Show, Eq, Enum, Bounded, Read) | |
data Command = L | R | M | |
deriving (Show, Eq, Enum, Bounded, Read) | |
data DeltaPosition = DeltaPosition Int Int | |
data State = State { |
This file contains 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
(defn get-change [coins value] | |
(->> (tree-seq #(> value (reduce + %)) | |
#(map (fn [c] (sort (conj % c))) coins) | |
[]) | |
(filter #(= 10 (reduce + %))) | |
distinct)) | |
(get-change [1 2 3] 10) |
This file contains 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
RSpec.configure do |c| | |
# Enable profiling on the spec | |
c.before(:all) do |x| | |
RubyProf.start | |
end | |
c.after(:all) do |x| | |
results = RubyProf.stop | |
results.eliminate_methods!([/RSpec::Core/]) |
This file contains 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 login_with(username, password) | |
click '#login' | |
sleep 5 | |
fill_in 'username', username | |
fill_in 'password', password | |
sleep 10 | |
end |
This file contains 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 login_with(username, password) | |
click '#login' | |
expect(page).to have_css('#login-popup') | |
fill_in 'username', username | |
fill_in 'password', password | |
expect(page).to have_no_css('#login-popup') | |
expect(page).to have_css('header .username', text: username) | |
end |
This file contains 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
Capybara::Poltergeist::Driver.new(app, phantomjs_options: ['--load-images=false', '--ignore-ssl-errors=yes']) |
This file contains 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
page.driver.browser.url_blacklist = ['http://www.google-analytics.com', 'https://ssljscdn.airbrake.io'] |
This file contains 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 LocalPricingEngine | |
def estimate(param1, param2, param3) | |
... | |
PriceEstimate.new(..) | |
end | |
end |
OlderNewer