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 |
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
#!/bin/bash | |
# Thanks goes to @pete-otaqui for the initial gist: | |
# https://gist.github.com/pete-otaqui/4188238 | |
# | |
# Original version modified by Marek Suscak | |
# | |
# works with a file called VERSION in the current directory, | |
# the contents of which should be a semantic version number | |
# such as "1.2.3" or even "1.2.3-beta+001.ab" |