Skip to content

Instantly share code, notes, and snippets.

defmodule Appsignal.Plug.JSExceptionCatcher do
@behaviour Plug
import Plug.Conn
alias Appsignal.Transaction
@defaults [
path: "/appsignal_error_catcher",
namespace: :frontend
]
defmodule Twin do
@moduledoc """
See http://teamon.eu/2017/different-approach-to-elixir-mocks-doubles/
Example usage
defmodule MyApp.Main do
@api Twin.get(MyApp.Api)
def run do
@teamon
teamon / bin-bob-1.sh
Created April 18, 2017 09:45
Single and two phased docker build scripts
#!/bin/bash
set -e
VERSION="1"
IMAGE="hello/simple"
_run(){
echo "----> $@"
$@
defmodule Double do
@moduledoc """
See http://teamon.eu/2017/different-approach-to-elixir-mocks-doubles/
"""
## GEN SERVER
use GenServer
## CLIENT API
@teamon
teamon / exometer-elixir-alpine.md
Last active February 25, 2017 12:05
Installing elixometer and exometer on alpine inside docker with elixir 1.3.4 and erlang r18

versions

Alpine: 3.4 Elixir: 1.3.4 Erlang: R18

packages

linux-headers erlang-snmp
@teamon
teamon / repo.ex
Last active January 15, 2020 11:15
defmodule Recruitee.Repo do
use Ecto.Repo, otp_app: :recruitee
import Ecto.Query
@doc """
Stream query results
Example:
iex> Candidate
...> |> where([c], c.foo > 4)
defmodule Sync.Middleware.RateLimit do
@defaults [
delay: 2000,
max_retries: 5
]
def call(env, next, opts) do
opts = opts || []
delay = Keyword.get(opts, :delay, @defaults[:delay])
max_retries = Keyword.get(opts, :max_retries, @defaults[:max_retries])
# ~/.gitconfig
[core]
excludesfile = /Users/[YOUR USER NAME]/.gitignore_global
@teamon
teamon / avatar.ex
Created September 9, 2016 21:30
Quickly create avatar image from user name (initials)
# Much simplified version based on https://github.com/zhangsoledad/alchemic_avatar
# Avatar.generate/2 returns a Plug.Upload that can be passed directly
# into Ecto.Changeset (as for example fallback image)
defmodule Avatar do
@defaults [
size: 300,
font_path: Application.app_dir(:my_app, "priv/fonts/Roboto.ttf"),
font_size: 40,
font_weight: 500,