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 ShuntingYard do | |
@doc """ | |
Implementation of https://en.wikipedia.org/wiki/Shunting-yard_algorithm | |
## Examples | |
iex> ShuntingYard.to_rpn( | |
...> [ | |
...> value: 4, | |
...> operator: :*, |
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 SafeEval do | |
def valid_data do | |
""" | |
%{ | |
recipient: %{first_name: "John", age: 18}, | |
employments: [%{start_year: 2020}, %{start_year: 2020}], | |
valid: true, | |
status: :archived, | |
date: ~D[2011-01-01], | |
datetime: ~U[2021-06-10 10:57:51.929284Z], |
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
Mix.install([:ratatouille]) | |
defmodule ReorderMigrations do | |
@behaviour Ratatouille.App | |
alias Ratatouille.Runtime.Command | |
import Ratatouille.View | |
import Ratatouille.Constants, only: [key: 1] | |
@enter key(:enter) | |
@arrow_up key(:arrow_up) |
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 Ecto.Extension.Query.API do | |
defmacro cond_(do: block) do | |
bindings = | |
Enum.reduce(block, [], fn | |
{:->, _, [[clause], branch]}, acc -> | |
[branch, clause | acc] | |
end) | |
|> Enum.reverse() | |
bindings_number = length(bindings) |
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 SQL do | |
defmodule LogParser do | |
import NimbleParsec | |
defcombinatorp( | |
:string, | |
ascii_char([?"]) | |
|> ignore() | |
|> repeat_while( | |
choice([ |
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 MyProject.Macro do | |
@doc """ | |
@doc """ | |
## Examples: | |
iex> query |> update([t], set: [unread_message_ids: array_substract(t.unread_message_ids, ^message_ids)]) | |
""" | |
defmacro array_substract(first, second) do |