Display channel users count with Elixir/Phoenix + React/Redux

A few months ago, we decided to implement a users count feature on CaptainFact’s videos pages. It had to be reliable, light and simple. We also wanted to differentiate between logged-in and anonymous users.

The most interesting read I had at the time on this subject was a medium article which has one major flaw: the full users list is returned from the backend and the count occurs on the frontend (which actually respects the default behaviour of Phoenix.Presence).

Depending on your business, it can represent a privacy issue (you don’t especially want anyone to be able to know who’s connected to your channel) as well as a performance issue.

In the following article, I’ll show you how I implemented Phoenix.Presence in such a way that it only returns the total of connected / anonymous users. We’ll then see how to bind it to Redux.


MapRewire <~>: Syntactic sugar to quickly bulk rekey maps

Simple sugar to make changing keys on maps less ugly.

What’s the why? When you consume information from a lot of API’s/sources, you get data streaming in with the keys from other applications, other applications naming conventions might not fit your app.

left <~> right, left is your map from outside your app, right is the rewrite rules.

It looks a little something like this: %{"id"=>"234923409", "title"=>"asdf"}<~>["title=>name", "id=>shopify_id"]

Rewrite rules can be an Elixir List or a whitespace-separated list. They follow a format of left=>right, left is the old key, and right representing the new.

Add it as a dep: {:map_rewire, "~> 0.1.0"}

Hex.pm ~~ GitHub

Talk: Embedded Elixir with Nerves - Code BEAM STO

My recent Nerves talk from Code BEAM STO: https://www.youtube.com/watch?v=IVCQvcCEjkU Want to learn more? Sign up for Nerves training at ElixirConf!

Shameless plug: Check out @elixirstatus' other community project:

Credo, a new static code analysis tool that acts as a code linter, but also focusses on teaching coding practices and code consistency.

Spawning linked processes in Elixir

In this short episode, we continue exploring Elixir processes.

We build a countdown timer and another function that spawns it as a linked process. We see what happens when a linked process dies and how to handle such events without killing the parent process.



But what if you would like to clean out your mix.lock file?

You know the drill, you stumble across some tutorial to do something you’d like to add to your Phoenix app, you update dependencies, try it out, then maybe decide it’s not what you want, or worth the effort.

Read on to clean out your mix.lock file

Win a copy of Phoenix in Action

SmoothTerminal is giving away a copy of Phoenix in Action!

Phoenix in Action is an example-based tutorial that teaches you how to use the Phoenix framework to build production-quality web apps.

What I have learned working 1 year full-time using Elixir

I wrote a blog post to wrap up my year as full-time Elixir developer, hope you like it https://medium.com/@lorenzo_sinisi/what-i-have-learned-working-1-year-with-full-time-using-elixir-51efd4c1f66

IntelliJ Elixir 8.0.0

  • New and improved Run/Debug configurations:

    • Distillery Release CLI,
    • elixir
    • iex
    • mix
    • mix test
    • iex -S mix.
  • Evaluate in the debugger.
  • More module filtering controls for debugger.
  • Elixir 1.7 compatibility for debugger.
  • All OTP 21 bytecodes can be disassembled.
  • Spell Checking

Installation Instructions

Algorithmically Fingering Guitar Chords with Elixir

Piggy-backing off my last post on generating all possible voicings for a given guitar chord, this week I used a “sieve”-inspired algorithm to generate all possible* fingerings for a given chord.

  • For some values of “possible.”

Shameless plug: Check out @elixirstatus' other community project:

Credo, a new static code analysis tool that acts as a code linter, but also focusses on teaching coding practices and code consistency.

Early Bird Pricing to GigCityElixir ends today

It’s an excellent conference season and GigCityElixir is going to make your choices even harder. We’re bringing John Hughes (one of the creators of Haskell), Chris McCord (Phoenix), Prag Dave, James E Gray II and Bruce Tate with many others to scenic Chattanooga. https://www.gigcityelixir.com/

Performing Bulk Updates using Ecto and Elixir

Performing bulk updates with Ecto and Elixir can be a pain. I compare three ways that you can do them. https://adamdelong.com/bulk-update-ecto

A Proposal: Elixir-Style Modules in JavaScript

Organizing our Elixir code into modules, with related structs and functions all in one place, is great. Why not do that in JavaScript too?


Cognitex - Library for managing user acounts through AWS Cognito service.

I have recently created a small library for managing user accounts through AWS Cognito service.


The following functionality is covered;

  • User registration
  • Confirm registration (with the confirmation code received from AWS, by email)
  • User authentication
  • Fetch user data by an access token
  • Fetch user data by username
  • Change user password
  • Update user attributes
  • Reset a forgotten password

Link to project https://github.com/Skoda091/cognitex

Elixir Cowboy Websocket Handler

For my side project Gossip, I wanted to have a websocket connection for non-Phoenix connections. To do this I used Cowboy to create a socket handler.


Control one process with another (challenge solution)

Solution to Processes Challenge 1: Control one process with another

The challenge from last time was to create a module with two spawnable processes. One process is a counter and the second is a controller that spawns, starts it and terminates the counter.

Elixium - A fast, anonymous, and scriptable blockchain written in Elixir


Win a ticket to The Big Elixir Conference

SmoothTerminal is giving away two tickets to The Big Elixir conference in New Orleans, November 8-9!

I’m a keynote speaker (first time!) so I’m super excited to meet up with people there and see old friends!

Generating Excel Friendly CSV Exports with Elixir

Microsoft Excel and CSV don’t always play nicely together, especially when there’s non-ASCII characters involved.

Here’s an overview of how to generate CSV files that work well with Excel:


The simplest Elixir process example

This screencast is an intro to Elixir processes. First we make the very simplest example of Elixir processes possible, and then we build on it.

The episode covers how to send, receive, spawn and kill Elixir processes.

Simplify Your Phoenix Controllers with action_fallback

In this episode we’ll look at one way to simplify an existing Phoenix controller using Phoenix.Controller.action_fallback/1