This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Code.ensure_loaded?(Ecto.Type) do | |
defmodule Bitstring do | |
@moduledoc """ | |
Implements the Ecto.Type behaviour for the Postgres | |
type "bit varying" | |
""" | |
use Ecto.Type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule NimbleSplit do | |
@moduledoc """ | |
Split text at a separator using [nimble_parsec](https://hex.pm/packages/nimble_parsec) | |
""" | |
import NimbleParsec | |
def test_string do | |
""" | |
some text, may also contain character "=", which is part of the separator | |
can be any number of lines long until the first separator line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Map.Helpers do | |
@moduledoc """ | |
Functions to transform maps | |
""" | |
@doc """ | |
Convert map string camelCase keys to underscore_keys | |
""" | |
def underscore_keys(nil), do: nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule FunctionClause do | |
@moduledoc """ | |
Format function clauses using Exception.blame/3 | |
""" | |
@doc """ | |
Given a `module`, `function`, and `args` see | |
if that function clause would match or not match. | |
This is useful for helping diagnose function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Decode do | |
@moduledoc """ | |
Extracted from https://github.com/ewildgoose/elixir-float_pp | |
""" | |
use Bitwise | |
@float_bias 1022 | |
############################################################################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Sanitize do | |
# Unicode sets are defined at https://unicode-org.github.io/icu/userguide/strings/unicodeset.html | |
require Unicode.Set | |
# Defines a guard that is the intersection of alphanumerics and the latin script plus the | |
# space and underscore characters. Note that the set is resolved at compile time into an | |
# integer expression and is therefore acceptably performant at runtime. | |
defguard latin_alphanum(c) when Unicode.Set.match?(c, "[[:Alnum:]&[:script=Latin:][_\\ ]]") | |
def sanitize_string(<<"">>), do: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Acc do | |
@moduledoc """ | |
Recurses through a list of maps summing the amount. | |
If the max is exceeded it returns the list up to this point. | |
""" | |
@list [ | |
%{amount: 23, asset: "USD"}, | |
%{amount: 40, asset: "USD"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Converts a list of atoms into a typespec | |
type = &Enum.reduce(&1, fn x, acc -> {:|, [], [x, acc]} end) | |
@grammatical_gender [ | |
:animate, | |
:inanimate, | |
:personal, | |
:common, | |
:feminine, | |
:masculine, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule StringIndex do | |
@newline 10 | |
@doc """ | |
Returns a map of line numbers to | |
a 2-tuple that is the index at which | |
the line starts in `string` and the | |
length of the line. | |
### Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Distance do | |
@moduledoc """ | |
Ensure that you have the following in your mix.exs | |
file: | |
def deps do | |
{:libgraph, "~> 0.13"} | |
end | |
""" |
NewerOlder