This file contains hidden or 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 KeyError do | |
defexception [:key, :term, :message] | |
@impl true | |
def message(exception = %{message: nil}), do: message(exception.key, exception.term) | |
def message(%{message: message}), do: message | |
defp message(key, term) do | |
message = "key #{inspect(key)} not found" |
This file contains hidden or 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 Frontix.Payments.Parsers.Xlsx do | |
@moduledoc """ | |
Парсер xlsx файлов платежей | |
""" | |
# Координаты начала твблицы, которую парсим. Zero-based {строка, столбец} | |
@top_left {8, 0} | |
# Имя и тип поля в таблице, skip: true - пропустить эту колонку | |
@fields [ | |
date: :date, |
This file contains hidden or 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 MapUtilities do | |
@moduledoc false | |
@doc """ | |
Convert map string keys to :atom keys | |
""" | |
def atomize_keys(map = %{}) do | |
map | |
|> Enum.map(fn | |
{k, v} when is_atom(k) -> {k, atomize_keys(v)} |
This file contains hidden or 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
# tested on macOS 10.12.4 | |
# based on https://elixirforum.com/t/how-to-change-a-phoenix-project-name-smoothly/1217/6 | |
# replace values as necessary | |
current_otp="hello_phoenix" | |
current_name="HelloPhoenix" | |
new_otp="" | |
new_name="" | |
git grep -l $current_otp | xargs sed -i '' -e 's/'$current_otp'/'$new_otp'/g' |