Personal notes from Elixir Conf 2019
Last week I attended Elixir Conf 2019 and these are my personal notes: https://pedroassumpcao.ghost.io/personal-notes-from-elixir-conf-2019/ #myelixirstatus
TIL: Understanding a specific dialyzer warning
Today I spend a good three hours trying to understand why dialyzer was yelling at me. I think I understood it at last, and I blogged about it:
ElixirMix Podcast 067 - What's New with Nerves with Frank Hunleth
In this episode of ElixirMix, we talk with Frank Hunleth to get an update on the Nerves Project. We discuss announcements, Elixir Circuits, Justin Schneck’s ElixirConf Keynote, the work to make NIFs available and safe, and much more!
Elixir Telemetry: Metrics and Reporters
Capturing individual measurements from your projects isn’t enough. For measurements to be valuable, they must be collated into metrics. Elixir’s Telemetry.Metrics library enables us to aggregate measurements from functions and processes into valuable metrics to aid us in making decisions about our projects.
Solution v1.0.0 released! - A macro-based solution to working with ok/error tuples in `case` and `with` statements and in collections.
Solution is a library to help you with working with ok/error-tuples in case and with-expressions by exposing special matching macros, as well as some extra helper functions to work with them in collections.
An example:
x = {:ok, 10}
y = {:ok, 42, "Oh, here's another argument!"}
z = {:ok, "something we do not care about"}
swith ok(res) <- x,
ok(res2) <- y,
ok() <- z do
"We have: \#{res} \#{res2}"
else
other -> "Failure at #{inspect(other)}"
end
# => "We have: 10 33"
Note how it did not matter that y contains more than one value in the tuple, or that z does not return a plain :ok. But if they would have, the outcome of the code would have been exactly the same.
Solution handles these cases for you exactly to allow you to have less of a tight coupling between the places where an ok/error tuple is returned and where it is used:
-
If at some point a caller decides to change from
:okto{:ok, some_value}, then that will not break your code. -
If at some point a caller decides to change from
{:ok, some_value}to{:ok, some_value, some_metadata}, then that will not break your code.
Besides allowing tricks like above, Solution also contains a small module containing some helper functions to combine collections of ok/error tuples in common ways.
Find it at: HexPM, GitHub, ElixirForum.
Rambo. Run your command. Send EOF. Get output.
Ever stumped trying to get output from a port?
Rambo has one mission. Start your program, pipe standard input, send EOF and return with output.
Rambo.run("ls") |> Rambo.run("sort") |> Rambo.run("head")
Pachyderm - Virtual actor framework for durable, globally unique processes
Pachyderm is built to allow developers to work with “effectively” unique processes
Testing your Phoenix + Postgres app with GitHub CI
GitHub recently released their own CI. solution recently. Its documentation is kind of overwhelming, so I wrote a step-by-step guide for testing a phoenix + postgres app in GitHub CI.
Portfolio returns with Elixir, React and Redux
I created a simple tool using Elixir, React and Redux which shows the returns of a financial portfolio over time. It enables users to change a set of parameters (e.g. region, monthly deposits, rebalancing strategy), and compare the results.
Grapevine Updates for June - August 2019
Grapevine is a community site for text based games (MUDs). It’s an open source application so you can see how it all works! The latest updates are better stats and a web chat that was rebuilt with React.
Beware of Tests et Fudicia Ferentes
Extremely biased and exaggerated writing on why I personally think the tests are overrated and in some cases bring more harm than profit.
http://rocket-science.ru/hacking/2019/08/28/beware-of-tests-et-fiducia-ferentes
ElixirMix Podcast 066 - Going with the Flow with John Mertens
In this episode of ElixirMix, we talk with John Mertens about how Change.org Elixir to deliver huge numbers of messages. We discuss Flow vs Broadway, how Plataformatec was involved, the importance of observability, and much more!
Domain holding with Elixir, Nerves, and LiveView
Use Elixir and Phoenix to host the landing pages for all of your pending projects!
erlang-rocksdb version 1.3 a binding of RocksDB for applications based on Erlang has been released.
This release brings the support of windows, the new version 6.2.2 of rocksdb and some other fixes.
Mor info about the release on Gitlab: https://gitlab.com/barrel-db/erlang-rocksdb
To get started: https://gitlab.com/barrel-db/erlang-rocksdb
Enjoy!
Benoît
Financial Portfolio rebalancing with Elixir
In this post I cover about the “Permanent Portfolio”, and how to use Elixir and real-time pricing information to rebalance the portfolio and profit from that.
https://elviovicosa.com/2019/08/25/financial-portfolio-rebalancing-with-elixir/
Scaffolds Backed Up By Behaviours
How to learn from Broadway architecture to build internal packages simplifying business logic encapsulation.
http://rocket-science.ru/hacking/2019/08/26/behaviour-backed-scaffolds
Ecto Embedded Schemas — Quick search through a JSONB array in PostgreSQL
How to create embedded schemas in Ecto to save a JSON data structure on your database + how to implement a direct database search on this same field.
Read more on Coletiv Blog
Writing your first Elixir code check
Learn how to analyze and validate Elixir code by taking a mind-blowing journey through string scanning, AST traversal and code compilation.
Read more on Cloudless Studio blog.
Avrora – convenient encoding/decoding messages with Avro
I would like to present a new library for convenient work with Avro serialization – Avrora.
It supports encoding/decoding:
- Avro Object Container Files format
- Confluent Schema Registry format
- Plain messages format (when you just want a message body)
In the case of the schema registry, it will also a register new schema. Here is an example with Object Container Files.
Let’s say you have this Payment schema stored in a file priv/schemas/io/confluent/Payment.avsc
{
"type": "record",
"name": "Payment",
"namespace": "io.confluent",
"fields": [
{
"name": "id",
"type": "string"
},
{
"name": "amount",
"type": "double"
}
]
}
To encode payment message with Payment.avsc schema
iex> {:ok, pid} = Avrora.start_link()
iex> message = %{"id" => "tx-1", "amount" => 15.99}
iex> {:ok, encoded} = Avrora.encode(message, schema_name: "io.confluent.Payment")
<<79, 98, 106, 1, 3, 204, 2, 20, 97, 118, 114, 111, 46, 99, 111,
100, 101, 99, 8, 110, 117, 108, 108, 22, 97, 118, 114, 111, 46,
115, 99, 104, 101, 109, 97, 144, 2, 123, 34, 110, 97, 109, 101,
115, 112, 97, 99, 101, 34, 58, 34, 105, 111, 46, 99, 111, 110,
102, 108, 117, 101, 110, 116, 34, 44, 34, 110, 97, 109, 101, 34,
58, 34, 80, 97, 121, 109, 101, 110, 116, 34, 44, 34, 116, 121,
112, 101, 34, 58, 34, 114, 101, 99, 111, 114, 100, 34, 44, 34,
102, 105, 101, 108, 100, 115, 34, 58, 91, 123, 34, 110, 97, 109,
101, 34, 58, 34, 105, 100, 34, 44, 34, 116, 121, 112, 101, 34, 58,
34, 115, 116, 114, 105, 110, 103, 34, 125, 44, 123, 34, 110, 97,
109, 101, 34, 58, 34, 97, 109, 111, 117, 110, 116, 34, 44, 34,
116, 121, 112, 101, 34, 58, 34, 100, 111, 117, 98, 108, 101, 34,
125, 93, 125, 0, 138, 124, 66, 49, 157, 51, 242, 3, 33, 52, 161,
147, 221, 174, 114, 48, 2, 26, 8, 116, 120, 45, 49, 123, 20, 174,
71, 225, 250, 47, 64, 138, 124, 66, 49, 157, 51, 242, 3, 33, 52,
161, 147, 221, 174, 114, 48>>
iex> {:ok, decoded} = Avrora.decode(message, schema_name: "io.confluent.Payment")
%{"id" => "tx-1", "amount" => 15.99}
Easy as it should be! Yaw ❤️
