harnais_form v0.1.0

Just pushed to Hex the first cut of harnais_form.

If you do a lot of metaprogramming, you might find this package a help when testing.

Drab 0.9.1 is out - with jQueryless Bootstrap Modal!

Drab.Modal.alert does not require jQuery anymore! You may ask user anything, from the server side, and synchronously wait for the answer.

https://github.com/grych/drab/releases/tag/v0.9.1

Phoenix PubSub

Using Phoenix.PubSub to send messages across processes https://www.pompecki.com/post/phoenix-pubsub/

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.

Understanding concurrency in Elixir

https://www.jackmarchant.com/articles/understanding-concurrency-in-elixir

GraphQL Subscriptions - Connecting Phoenix Applications with Absinthe and WebSockets

We (Annkissam) just released two GraphQL-related packages CommonGraphQLClient and AbsintheWebSocket. We also created a walkthrough describing how they can be used to connect Phoenix Applications with Absinthe and WebSockets.

Practical Guide to Test Doubles in Elixir

Draw a clear line between fakes, stubs, mocks, and spies in Elixir, and learn how to use them.

https://semaphoreci.com/community/tutorials/practical-guide-to-test-doubles-in-elixir

Official release of Elixir: A Mini-Documentary!

🤙 Calling all #elixir & #erlang enthusiasts!

Honeypot’s “ELIXIR: A MINI-DOCUMENTARY”, featuring José Valim, creator of Elixir, Chris McCord, creator of the Phoenix Framework, Justin Schneck, co-author of the Nerves project, & other members of the Elixir community, has just been released!

Wrapper for the fastest Elixir JSON encode/decode library

A wrapper for the fastest Elixir JSON encode/decode library (:jiffy) with atomized keys

defmodule JSON do
  @moduledoc false

  @encode_opts [:use_nil]
  @decode_opts [:return_maps, :use_nil]

  alias :jiffy, as: Jiffy

  @doc """
  Encode and return tuple
  """
  @spec encode(any) :: {:ok, Strint.t()} | {:error, tuple()}
  def encode(nil) do
    {:ok, nil}
  end

  def encode(payload) do
    {:ok, Jiffy.encode(payload, @encode_opts)}
  catch
    {:error, reason} -> {:error, reason}
  end

  @doc """
  Encode and return encoded json
  """
  @spec encode!(any) :: Strint.t() | {:error, tuple()}
  def encode!(payload) do
    case encode(payload) do
      {:ok, json} -> json
      {:error, reason} -> {:error, reason}
    end
  end

  @doc """
  Decode and return tuple
  """
  @spec decode(String.t() | nil) :: {:ok, Map.t() | list()} | {:error, tuple()}
  def decode(payload) do
    {:ok, Jiffy.decode("#{payload}", @decode_opts)}
  catch
    {:error, reason} -> {:error, reason}
  end

  @doc """
  Decode and return decoded data
  """
  @spec decode!(String.t() | nil) :: Map.t() | list() | {:error, tuple()}
  def decode!(payload) do
    case decode(payload) do
      {:ok, data} -> data
      {:error, reason} -> {:error, reason}
    end
  end

  @doc """
  Convert map string keys to atom keys
  This function is an optional to atomize map keys instead of having
  string keys. 
  Warning: By default, the maximum number of atoms is 1,048,576.
           This function should be used responsibly. Personally,
           I recommend to use this function if you only can validate
           the JSON schemas.
  """
  @spec atomize_keys(any()) :: any()
  # Walk through the map
  def atomize_keys(map = %{}) do
    map
    |> Enum.map(fn {k, v} -> {to_atom(k), atomize_keys(v)} end)
    |> Enum.into(%{})
  end

  # Walk through the list
  def atomize_keys([head | rest]) do
    [atomize_keys(head) | atomize_keys(rest)]
  end

  # Other data types
  def atomize_keys(other) do
    other
  end

  defp to_atom(key) when is_atom(key) do
    key
  end

  defp to_atom(key) when is_binary(key) do
    String.to_atom(key)
  end

  defp to_atom(key) do
    key
  end
end

Bitcoin key derivation in Elixir

The ultimate guide to deriving child keys in Bitcoin wallet using Elixir​: https://k.lelonek.me/bitcoin-key-derivation

ElixirWeekly: The Elixir Community Newsletter, covering community news you easily miss, shared on ElixirStatus and the web, in one email every Thursday.

Maps vs Pattern Matching in Elixir

For some purposes, it is possible to use pattern matching instead of using a map to perform lookups.

This is my exploration of this, with some benchmarking, mystery and an unexpected plot twist!

https://medium.com/@amuino/maps-vs-pattern-matching-in-elixir-e69b7bb11b5d

Gentle Introduction to GraphQL with Elixir and Phoenix

The project we’re building is going to be an application that will store/retrieve Event Logs. You could use this for something like tracking requests you’re making, or tracking audit events in a log, or…well, anything that would require storing some arbitrary events with types, messages, and payloads.

How to use private hex dependencies in your docker images while building your releases

How to use private hex dependencies in your docker images while building your releases https://engineering.tripping.com/how-to-use-private-hex-dependencies-in-your-docker-images-42b2d01d8d70 #myelixirstatus

Caching DB requests with ETS

In this episode, we use ETS (Erlang Term Storage) to cache DB requests.

It’s enough to speed up a content listing page to 275 requests per second on a $5/month server.

https://alchemist.camp/episodes/ets-cache

Recurring Work with GenServer

Learn how to handle recurring work in Elixir with GenServer. Our GenServer will fetch the price of a Bitcoin at a certain interval.

https://elixircasts.io/recurring-work-with-genserver

Why You Too Should Learn Elixir

Learn Elixir not because you will get a better job out of it, but because learning functional programming will make you a better programmer.

https://mixandgo.com/learn/why-you-too-should-learn-elixir

Cypress with React, Phoenix and Ecto

I managed to get a Phoenix project with a React frontend working with Cypress, using Ecto in sandbox mode.

That means full e2e testing with an actual backend and data layer, instead of a mock server.

http://bego.hr/cypress-elixir-phoenix-ecto-sandbox

Elixir OTP Supervision "Tether"

While working on a side project, I got to try out a new supervision tree method for trapping processes that may never recover due to outside forces.

https://blog.oestrich.org/2018/07/otp-tether/

Rate Limiting library

Another rate-limiting library https://github.com/whitered/ratekeeper

case Ratekeeper.register("myapi.org", 10_000) do
  nil -> raise "Rate limits exceeded, request not allowed in next 10 seconds"
  delay ->
    :timer.sleep(delay)
    MyApi.do_request()
end

A dive into database multi-tenancy in Elixir with Ecto

A post with some tips and experiences about the migration of an application with a regular database to a multi-tenancy one in Elixir with Ecto.

http://dreamingecho.es/blog/a-dive-into-database-multi-tenancy-in-elixir-with-ecto

harnais_map v0.1.0

Just pushed to Hex the first cut of harnais_map, a small package in the Harnais family to test maps and their contents.

The package will compare two maps, key by key and report the differences.