Skip to content

Instantly share code, notes, and snippets.

View eksperimental's full-sized avatar

Eksperimental eksperimental

  • Available for hire
  • Remote
View GitHub Profile
eksperimental / enum_DESC.txt
Created May 12, 2022 04:22
Optimization for Enum.sort_by/3 when sorter is `:desc`.
Elixir 1.14.0-dev
Erlang 24.3
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
memory time: 5 s
reduction time: 0 ns
parallel: 1
inputs: keyword_100_desc, keyword_1000_desc, keyword_10000_desc, keyword_100000_desc, map_100_desc, map_1000_desc, map_10000_desc, map_100000_desc
eksperimental / enum_sort_by_default_sorter.txt
Created May 10, 2022 00:53
num.sort_by/3 -- &<=/2 vs :asc
Operating System: Linux
Elixir 1.14.0-dev
Erlang 24.3
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 2 s
memory time: 2 s
eksperimental /
Created December 22, 2021 18:29
Exit with error INMEDIATELY if a script if a warning is generated and matches the given string.
# Original idea taken from:
exit_on_warning() {
sed '/atom ::: must be written between quotes, as in :"::", to avoid ambiguity/{q 2}' || kill "$BASHPID"
run() {
make docs_elixir
echo "Docs successfully generated!"
defmodule Variadic do
def spread_combine(h, f, g) do
{:arity, f_arity} =, :arity)
{:arity, g_arity} =, :arity)
args = Macro.generate_arguments(f_arity + g_arity, __MODULE__)
{f_args, g_args} = Enum.split(args, f_arity)
fn_ast =
eksperimental / variadic.exs
Last active March 19, 2021 14:13
Build anonymous functions with a variable length of arguments
defmodule Variadic do
@moduledoc """
Solution for
defmacro spread_combine(h, f, g) do
quote bind_quoted: [h: h, f: f, g: g, module: __CALLER__.module],
location: :keep do
{:arity, f_arity} =, :arity)
{:arity, g_arity} =, :arity)
eksperimental / typespec_example.ex
Last active July 2, 2020 18:36
Broken types in Elixir Issue #10140
# Downloaded from:
# Lists all the types that have the problem reported in
# create an Elixir project, and save this file in lib/typespec_example.ex
# Start IEx with: iex -S mix
# then run: TypespecExample.types()
# and paste the output into the shell.
defmodule TypespecExample do
eksperimental / gist:701103fc9e723fddc0bfeb757ecb1e7d
Created May 25, 2017 20:00
What modules implement the Enumerable and Collectable protocols in Elixir
elixir$ ag "defimpl\s+Collectable" -G ".ex$"
247:defimpl Collectable, for: HashDict do
35: defimpl Collectable do
eksperimental / .editorconfig
Last active August 21, 2022 12:14
.editorconfig for Elixir projects
# EditorConfig is awesome:
# .editorconfig for Elixir projects
# top-most EditorConfig file
root = true
indent_style = space
eksperimental / record_file.exs
Created September 23, 2016 14:43
How to parse a text file with pattern matching, and converted to a nested list
defmodule RecordFile do
def read(file) do
{:ok, data} =
|> String.split("\n")
|> filter
eksperimental / guard_helpers.ex
Last active August 13, 2016 13:07 — forked from christhekeele/guard_helpers.ex
A defguard macro written for Elixir v0.11.something a while back. I don't remember anything breaking at the time. Written for a library that was supposed to help AST transformations, in part by creating guards for particular AST constructs.
defmodule Guard.Helpers do
@moduledoc """
Tools for creating custom guards.
@doc """
Creates a macro that's aware of its presence in a guard.
Taken from,