Elixir Blog Posts



Brahaha, that’s awesome! ^.^



artilce Image




I wrote another blog post: CSRF Protection in Plug and Phoenix!


Have you ever needed to search through HTML nodes text but didn’t know how?

Here is my tip on how to find HTML nodes by text using Floki and a regex


There’s also Meeseeks, it has a large variety of searching options.

And yes I know that this is not strictly related, but anytime I see the words ‘HTML’ and ‘Regex’ in the same paragraph I immediately think of:



@OvermindDL1 yeah I posted the same SO link on reddit few minutes ago :smiley:

I know Meeseekes and it’s my HTML parser of choice right now mainly for the XPath support

I was working on a project that used Floki heavily and this was just a quick trick to make it work without rewriting a lot of code.

Lucky me the author of the fl-contains pseudo class used =~ and not String.contains?


Enable tracing using the debug option.

This explains how to debug the messages and log to the console with a simple option.


Running distributed Erlang & Elixir applications on Docker


The practical guide on how to get back the GenServer previous state.

Article Image

Deep understanding of the usage of Supervisors and GenServer together to achieve the fault tolerance.


Careful with that though, the terminate/2 callback is not always called…


I save to stash on each call instead of terminate.

  def handle_call(..., state) do
    reply_success(state, :ok)

  defp reply_success(state, reply) do
    name = state.uuid
    persist_state(name, state)
    {:reply, reply, state, @timeout}

As mentionned, terminate is not always executed. It allows me to configure call replies on one spot.


Well, Thanks for the information. :bouquet:


That is a great approach :clap: .

I appreciate that. However, I have a doubt on this. Will that be a duplication of state? As we are saving state for every request? What makes difference with GenServer state ?

Thank you.


The stash used is a public ets table… There is one state in the server, and one copy in an ets table, under a given key (Here I use the worker uuid). The solution does not survive a reboot, but the read/write are fast enough.

I start worker from a master GenServer, linked to each worker and trapping exit.

So when a worker dies with :normal reason, I delete stash entry from the exit call_back of the master GenServer. This is how I clean up old state…


11 posts were split to a new topic: Opinionated vs modular web frameworks


Be careful with saving the entire state to a stash: the point of restarting the process, rather than just doing a try/catch, is to start from a clean slate so the system can recover from a bad state. When possible it’s better to recompute things or refetch them from database during the process startup.

See for instance The Onion Layer Theory and On Erlang, State and Crashes.


The workers I have in this example are db-less… they hold dynamic state for a game of go.

For something related to retrieve state from db, there is this excellent talk.


Gotcha… :smile:


Hi there, I am new to Elixir and like to share a post about my first impressions of getting started and a basic example application that might be interesting for others just starting with Elixir. All feedback is welcome!