Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Chris Keathley keathley

I may be slow to respond.
View GitHub Profile
View ets_vs_process.exs
defmodule PCache do
def start do
# data = for i <- 0..1_000, do: {i, i}, into: %{}
spawn(fn ->
def get(pid) do
us = self()
keathley / application.ex
Created October 22, 2019 14:29
Example of elixir runtime configuration
View application.ex
defmodule Huddle.Application do
@moduledoc false
use Application
def start(_type, _args) do
children = [
{RedisClient, redis_config()}
keathley / .credo.exs
Last active November 22, 2021 17:47
Keathley's credo file
View .credo.exs
# This file contains the configuration for Credo and you are probably reading
# this after creating it with `mix credo.gen.config`.
# If you find anything wrong or unclear in this file, please report an
# issue on GitHub:
# You can have as many configs as you like in the `configs:` field.
configs: [
keathley / rabbit.ex
Created May 22, 2019 15:39
Rabbit connection statemachine
View rabbit.ex
defmodule RabbitConnection do
@moduledoc """
RabbitMQ client connection
@behaviour :gen_statem
use AMQP
alias AMQP.Basic
@exchange "messages_exchange"
keathley / stateful_server.ex
Last active May 9, 2019 03:58
stateful_server example
View stateful_server.ex
defmodule Demo do
def demo do
_once_per_second = Demo.start(:once, 200)
_ten_per_second = Demo.start(:ten, 220)
_hundret_per_second = Demo.start(:hundret, 250)
IO.puts("Launced processes")
[:once, :ten, :hundret] |> show() |> IO.inspect()
keathley / retry.ex
Created April 16, 2019 14:49
Tesla Middleware with exponential backoff
View retry.ex
defmodule Huddle.Tesla.Retry do
@moduledoc """
Adds exponential backoff + retry logic to tesla
# Maximum times to retry
@max_retries 5
# Base delay retry value is 50ms
@delay 50
keathley /
Last active November 1, 2021 20:07
A description of how to take advantage of the dry-monad gem.

How we're using dry-monad

Imagine that we have an application where user's have a location. We want to find the weather for their current location using an external service call. We want to provide this functionality in a json api. A basic implementation might look like this.

def create
 user = User.find(params[:id])

Keybase proof

I hereby claim:

  • I am keathley on github.
  • I am keathley ( on keybase.
  • I have a public key whose fingerprint is 127E 4801 6473 B025 9666 DDEC 646E F51E 2C11 C8A1

To claim this, I am signing this object:

keathley / sift.hs
Created February 2, 2016 03:04
Fuzz file matching with haskell
View sift.hs
import Data.List
type Query = String
type Choice = String
type Score = Int
data Match = Found String String Int Int
| Boundary String String Int Int
| Sequential String String Int Int