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
| Accountant.product_of_equals_twenty_twenty([979, 1721, 366, 299, 675, 1456]) | |
| => 514_579 |
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
| defmodule Accountant do | |
| @sum 2020 | |
| def product_of_equals_twenty_twenty([_head | tail] = list) do | |
| product = get_two(list) | |
| # coming soon! | |
| 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
| ##### PROMPT ##### | |
| # Find the two entries in a given list that sum to 2020 and then multiply those two numbers together | |
| defmodule Accountant do | |
| @sum 2020 | |
| defguard equals_twenty_twenty(first, second) when first + second == @sum | |
| def product_of_equals_twenty_twenty(list, product \\ nil) | |
| def product_of_equals_twenty_twenty(_list, product) when product != nil, do: product |
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
| defmodule SpyRadio.IntegrationTest do | |
| use ExUnit.Case | |
| test "the consumer receives a message when one is published to its queue" do | |
| consumer_pid = start_supervised!(SpyRadio.RabbitMQ.Consumer) | |
| :erlang.trace(consumer_pid, true, [:receive]) | |
| SpyRadio.RabbitMQ.Publisher.publish("some message") | |
| assert_receive {:trace, ^consumer_pid, :receive, {:basic_consume_ok, %{consumer_tag: _tag}}}, | |
| 1000 |
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
| {:trace, consumer_pid, :receive, {:basic_consume_ok, %{consumer_tag: _tag}} |
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
| defmodule SpyRadio.IntegrationTest do | |
| use ExUnit.Case | |
| test "the consumer receives a message when one is published to its queue" do | |
| consumer_pid = start_supervised!(SpyRadio.RabbitMQ.Consumer) | |
| :erlang.trace(consumer_pid, true, [:receive]) | |
| SpyRadio.RabbitMQ.Publisher.publish("some message") | |
| 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
| defmodule SpyRadio.IntegrationTest do | |
| use ExUnit.Case | |
| test "the consumer receives a message when one is published to its queue" do | |
| consumer_pid = start_supervised!(SpyRadio.RabbitMQ.Consumer) | |
| :erlang.trace(consumer_pid, true, [:receive]) | |
| 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
| defmodule SpyRadio.IntegrationTest do | |
| use ExUnit.Case | |
| test "the consumer receives a message when one is published to its queue" do | |
| consumer_pid = start_supervised!(SpyRadio.RabbitMQ.Consumer) | |
| 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
| ```insights | |
| some text | |
| ``` |
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
| func MergeCOntributors(primaryAccount, secondaryAccount) error { | |
| // Create a WaitGroup to manage the goroutines. | |
| var waitGroup sync.WaitGroup | |
| c := make(chan error) | |
| // Perform 3 concurrent transactions against the database. | |
| waitGroup.Add(3) | |
| go func() { | |
| waitGroup.Wait() |