Verge Studios Graphic and Web Design

From our blog, articles tagged: Elixir

A naive leaky bucket in Elixir

We recently had to optimize API calls for the Shopify API which implements a Leaky Bucket algorithm to limit the amount of calls that you can make with a certain period of time. According to their documentation:

The bucket size is 40 calls (which cannot be exceeded at any given time), with a "leak rate" of 2 calls per second that continually empties the bucket. If your app averages 2 calls per second, it will never trip a 429 error ("bucket overflow").

Read more ...

Elixir ETS Logger

Below is some sample code for a fixed size memory logger in Elixir using ETS as the back end. The idea was to create a a temporary log that could exist across requests and handle multiple channels.

With very little effort we came up with the following solution:

Read more ...

Autoloading data in IEx

One often overlooked feature of using IEx to debug your code is to pre-load data into IEx using a .iex.exs file. In a nutshell, IEx will run the file before it completes loading and the execution is exactly like an other .exs scripts you may use.

Read more ...

Elixir behaviours and compile time errors

One interesting feature of Elixir is its use of Behaviours to define implementation contracts for modules. For example we can specify a behaviour like this:

defmodule MyBehaviour do
  @callback default(params :: map) :: :ok | :error

Read more ...

Finding HTTPS Expiry dates using Elixir

At Verge we are huge fans of making sure all our sites are using SSL/TLS for the additional security it provides to our clients and their visitors. In addition, Google has indicated that sites missing the HTTPS protocol implementation may be ranked lower than sites that do. What used to be an expensive and cumbersome process in the past has become an absolute breeze due to the advent of auto-install solutions such as Let's Encrypt. The one downside of these solutions is that the certificates are often only valid for short periods of time - 3 months in the case of Let's Encrypt.

Read more ...

Read more at our Verge Studios Blog