Elixir runtime configuration trap

Elixir 1.9 introduced mix release, which has standardised runtime configuration. So all the problems with runtime configuration should go away? Not exactly.

https://michaldolata.appunite.com/post/elixir-runtime-configuration-trap

Ecto.DevLogger - an alternative logger for development

It inlines bindings into the query, so it is easy to copy-paste logged SQL and run it in any IDE for debugging without manual transformation of common elixir terms to string representation (binary UUID, DateTime, Decimal, json, etc). Also, it highlights db time to make slow queries noticeable. Source table and inlined bindings are highlighted as well.

Screenshot

Links:

Elixir em Foco: Past, Present, and Future about Surface with Marlus Saraiva

Elixir em Foco interviewing Marlus Saraiva(Surface creator), and this episode it’s launched at a great moment after the TheBigElixir where we had great talks about Surface by Marlus Saraiva and Dave Lucia. You can be listed here https://youtu.be/9F_-E602w3M

Keeping Up with the Fans: Scaling for Big Events at Whatnot

This blog post details how the engineering team at Whatnot measured the capacity limits of the Elixir/Phoenix system powering Whatnot Live auctions, and the tricks we used to make sure it handles an unusual spike in traffic.

ThinkingElixir 093: Preventing Service Abuse with Michael Lubas

In episode 93 of Thinking Elixir, we talk with Michael Lubas about protecting our @ElixirPhoenix applications from common automated bot attacks. We cover API abuse to send email spam, carding attacks, credential stuffing and more!

https://podcast.thinkingelixir.com/93

Mocking External Dependencies in Elixir

A reader recently asked me about mocking external dependencies in Elixir. So, I wanted to discuss two popular mocking libraries and how to mock without a library (and which option I like best).

https://www.germanvelasco.com/blog/mocking-external-dependencies-in-elixir

Elixir’s best practices: Achieve secure authentication

In this article, we are going to go through the different vulnerabilities you may encounter with your authentication strategies and show you how to prevent them, and then we’ll look at how you can increase the security level in the context of Elixir applications.

https://medium.com/wttj-tech/elixirs-best-practices-achieve-secure-authentication-8961f60effc7

Devs For Ukraine: Free online remote conference featuring some notable elixir speakers (José Valim & more!)

We organized a small remote conference https://www.devsforukraine.io/ to raise funds for Ukraine. The lineup features notable elixir speakers and others. The goal is to raise money which will be distributed to several NGOs benefitting Ukraine.

Come join us!

Exploring Options for Storing Custom Data in Ecto

Ever wanted to store a blob of custom data on a database record? When the data is stored using Ecto there are several ways we can do it. This article explores two paths and discusses some of the pros and cons for each approach. It includes some extra tips like versioning the custom blob and creating a custom Ecto type for optionally storing it as binary. Which of the two choices is better? Well, it depends.

https://fly.io/phoenix-files/exploring-options-for-storing-custom-data-in-ecto/

How to paginate in Ecto.

https://cmdarek.com/pages/paginate-with-ecto.html

Finitomata :: a proper FSM library for Elixir

https://rocket-science.ru/hacking/2022/04/02/finitomata

The most important thing I wanted to automate would be the FSM pure description itself as well as OTP boilerplate. I wanted something, that is error-prone and easy to grasp.

EctoCellar v0.4.0 has been released🎉Store changes to your models, for auditing or versioning.

Store changes to your models, for auditing or versioning. Inspired by paper_trail.

Links

News

  • The number of stars has exceeded 50. This is a great honor 💚 💙 💜 💛 ❤️
  • Functions have been added that wrap Ecto.Repo.
insert_store/3 Ecto.Repo.insert + EctoCellar.store
update_store/3 Ecto.Repo.update + EctoCellar.store
upsert_store/3 Ecto.Repo.insert_or_update + EctoCellar.store
delete_store/3 Ecto.Repo.delete + EctoCellar.store
  • You can now get the primary key automatically.

See also CHANGELOG

Usage

1. Configuration.

Add ecto_cellar configure to your config.exs.

config :ecto_cellar, :default_repo, YourApp.Repo

2. Creates versions table.

You can generate migration file for EctoCeller. Let’s type mix ecto_cellar.gen. And migrate by mix ecto.migrate.

3. Stores changes to model.

Stores after a model is changed or created. These are stored as recoverable versions for the versions table.

By Repo.insert + EctoCellar.store/2.

iex> with {:ok, post} <- %Post{title: "title", views: 0} |> @repo.insert(),
...>      {:ok, _post} <- EctoCellar.store(post) do # or store!/2
...>   # do something
...> end

or

There is also a function that wraps EctoRepo.insert, update, insert_or_update and delete.

By EctoCellar.insert_store/3. (Uses EctoCellar.update_store/3 when updated.)

iex> case EctoCellar.insert_store(post) do # or update_store/3, upsert_store/3, delete_store/3
...>   {:ok, _post} -> # do_somesing
...>   error -> error
...> end

4. Gets versions and can restore it.

Uses EctoCellar.all/2 and EctoCellar.one/3, you can get past changes versions. And use it, you can restore.

iex> post = Post.find(id)
%Post{id: 1, body: "body3"...etc}

iex> post_versions = EctoCellar.all(post) # Can get all versions.
[%Post{id: 1, body: "body3"...etc}, %Post{id: 1, body: "body2"...etc}, %Post{id: 1, body: "body1"...etc}]

iex> version_1_inserted_at = ~N[2022-12-12 12:00:12]
iex> post_version1 = EctoCellar.one(post, version_1_inserted_at)
%Post{id: 1, body: "body1", inserted_at: ~N[2022-12-12 12:00:12]...etc}

iex> post_version1
iex> |> Post.changeset([])
iex> |> Repo.update() # Restored!!!

Options

The last argument of each function accepts the following options.

  • repo: You can select a repo other than the one specified in Config.

For contributers

You can test locally in these steps.

  1. make setup
  2. mix test

Bugs and Feature requests

Feel free to open an issues or a PR to contribute to the project.

Simple, Effective Elixir Test Setup in VSCode

A short blog post / note on how to setup elixir testing tasks and keybindings in VSCode. https://www.gatlin.io/notes/elixir-test-setup-in-vscode

[Announcement] Existence - asynchronous dependency health checks library

Library features:

  • User defined dependencies checks with flexible settings.
  • Dependencies checks functions are executed asynchronously.
  • Built-in Plug module providing customizable response for a http health-check endpoint.
  • Support for multiple independent Existence instances and associated health-checks endpoints (example use case: separate Kubernetes readiness and liveness http probes).
  • Checks states are stored and accessed using a dedicated ETS tables per Existence instance, which means practically unlimited requests per second processing capacity.

https://github.com/Recruitee/existence

Doctest functions with side effects

How to write doctests for public functions that have side effects in elixir on the example from Mox’s documentation. https://manusachi.com/blog/doctests-with-side-effects

Finitomata — a proper FSM library for Elixir

Finitomata provides a boilerplate for FSM implementation, allowing to concentrate on the business logic rather than on the process management and transitions/events consistency tweaking.

It reads a description of the FSM from a string in PlantUML format.

https://github.com/am-kantox/finitomata

Diving into the macros that make Phoenix controllers work

You’ve made a Phoenix controller before, but do you know how it actually works? Let’s explore some code together. https://www.brewinstallbuzzwords.com/posts/phoenix-controller-macros/

ThinkingElixir 092: Temple with Mitchell Hanberg

In episode 92 of Thinking Elixir, we talk with Mitchell Hanberg and learn about why he created the alternate Phoenix templating language called “Temple”. He explains how Temple works, some of its unique benefits and where he’s going with it in the future. Mitchell also took over maintenance of the testing project Wallaby from Chris Keathley. We revisit what Wallaby is and the special place it can have when building automated full system tests for our projects.

https://podcast.thinkingelixir.com/92

Phoenix LiveView Under The Hood: The Form Function Component

Let’s demystify LiveView’s form function component by taking a look under the hood.

https://blog.appsignal.com/2022/03/29/phoenix-liveview-under-the-hood-the-form-function-component.html

🎉 SmartLogic is Hiring!

ISO a Staff Engineer and a Mid Level Ruby on Rails or Elixir Developer. Both roles are full time and fully remote (within the US). SmartLogic is a great place to work - come join our team! https://smartlogic.io/about/jobs

Previous page Next page