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
defmodule PingPong do | |
def start do | |
ping_pid = spawn __MODULE__, :ping, [] | |
pong_pid = spawn __MODULE__, :pong, [] | |
send ping_pid, {pong_pid, :ping} | |
{ping_pid, pong_pid} | |
end | |
def ping do |
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
# Stolen from TJ Stankus, ElixirConf 2017 | |
defmodule Bowling do | |
defstruct rolls: [], score: 0 | |
def new_game, do: %Bowling{} | |
def roll(game = %Bowling{}, pinfall) do | |
rolls = append_pinfall(game.rolls, pinfall) | |
%{ game | rolls: rolls, score: score(rolls) } |
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
module Transactions | |
module Posts | |
CREATE_ATTRIBUTES = %i{topic title body} | |
Create = Transactions.build(:posts, :create) do | |
step :validate | |
step :hydrate, model: :topic | |
step :set_attributes, model: :post, attributes: CREATE_ATTRIBUTES | |
step :persist, model: :post | |
step :submit_draft |
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
module Transactions | |
module Posts | |
Create = Dry.Transaction(container: {}) do | |
step :validate, with: Components::Common::Validate.call(schema: Schemas::Post::Create) | |
step :load_topic, with: Components::Common::LoadModel.call(id: :topic_id, class: Topic, model: :topic) | |
step :build_post, with: Components::Posts::Create::BuildPost | |
step :save_post, with: Components::Common::Save.call(model: :post) | |
step :extract_post, with: Components::Common::Extract::Extract(key: :post) | |
end | |
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
module Transactions | |
module Posts | |
Create = Dry.Transaction(container: {}) do | |
step :validate, with: Components::Posts::Create::Validate | |
step :load_topic, with: Components::Posts::Create::LoadTopic | |
step :build_post, with: Components::Posts::Create::BuildPost | |
step :save_post, with: Components::Posts::Create::SavePost | |
step :extract_post, with: Components::Posts::Create::ExtractPost | |
end | |
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
### Keybase proof | |
I hereby claim: | |
* I am alexpeachey on github. | |
* I am alexpeachey (https://keybase.io/alexpeachey) on keybase. | |
* I have a public key whose fingerprint is 8FE8 F2EA A0FA 2629 7D14 E47D 98D5 7A08 AE06 05A6 | |
To claim this, I am signing this object: |
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
<!DOCTYPE html> | |
<head> | |
<title>Raphael Bugs</title> | |
<link href='style.css' rel='stylesheet' type='text/css' /> | |
</head> | |
<body> | |
<button id='newButton'> | |
New | |
</button> | |
<div id='paper'></div> |
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
/home/alex/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239: warning: nested repeat operator + and ? was replaced with '*': /\bany(?:\s+)?day\b/ | |
/home/alex/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239: warning: nested repeat operator + and ? was replaced with '*': /([0-9])(?:\s+)?a\b/ | |
/home/alex/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239: warning: nested repeat operator + and ? was replaced with '*': /([0-9])(?:\s+)?p\b/ | |
/home/alex/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239: warning: nested repeat operator + and ? was replaced with '*': /this(?:\s+)?morning/ | |
/home/alex/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239: warning: nested repeat operator + and ? was replaced with '*': /^(?:\s+)?(?:right\s+)?now(?:\s+)?$/ | |
/home/alex/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.5/lib/active_supp |