It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
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
# TODO: | |
# Runner like https://github.com/elixir-lang/ecto/blob/master/lib/ecto/migration.ex (does it have state?) | |
defmodule Ecto.Runner do | |
def start_command({:create, table}) do | |
IO.puts "create table: #{table}" | |
end | |
def subcommand({:add, column, type}) do | |
IO.puts "add column: #{column}(#{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
FROM elixir:1.4.5 as asset-builder-mix-getter | |
ENV HOME=/opt/app | |
RUN mix do local.hex --force, local.rebar --force | |
# Cache elixir deps | |
COPY config/ $HOME/config/ | |
COPY mix.exs mix.lock $HOME/ | |
COPY apps/myproject_web/mix.exs $HOME/apps/myproject_web/ | |
COPY apps/myproject_web/config/ $HOME/apps/myproject_web/config/ |
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 DateTimeGenerators do | |
use ExUnitProperties | |
@time_zones ["Etc/UTC"] | |
def date do | |
gen all year <- integer(1970..2050), | |
month <- integer(1..12), | |
day <- integer(1..31), | |
match?({:ok, _}, Date.from_erl({year, month, day})) 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
files: | |
"/etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.dockerlogs.conf": | |
mode: "000644" | |
owner: root | |
group: root | |
content: | | |
/var/lib/docker/containers/*/*.log { | |
size 100M | |
rotate 14 | |
missingok |
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 Util.Ecto do | |
def export(model = %{__meta__: _meta, __struct__: _struct}) when is_map(model) do | |
stripped = | |
model | |
|> Map.from_struct() | |
|> Map.delete(:__meta__) | |
associations = model.__struct__.__schema__(:associations) | |
Enum.reduce(associations, stripped, fn assoc, model -> |
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 MyApp.Factory do | |
use ExUnitProperties | |
alias MyApp.{Repo, User, Comment} | |
### Generators | |
def generator(:user) do | |
gen all name <- string(:alphanumeric, min_length: 2), | |
email <- generator(:email), | |
age <- integer(10..130) do |
GraphQL document is parsed:
- Lexer: https://github.com/absinthe-graphql/absinthe/blob/master/lib/absinthe/lexer.ex
- Parser (Yecc): https://github.com/absinthe-graphql/absinthe/blob/master/src/absinthe_parser.yrl
This returns a tree of Absinthe.Language nodes (structs), effectively the AST:
This tree is converted to a tree of Absinthe.Blueprint nodes (structs):
This repo is my experiment in deploying a basic Phoenix app using the
release
feature from elixir 1.9 (https://elixir-lang.org/blog/2019/06/24/elixir-v1-9-0-released/)
and docker, via a multi-stage Dockerfile (https://docs.docker.com/develop/develop-images/multistage-build/)
leveraging bitwalker's docker images for Elixir and Phoenix.
The simplest way to manage Elixir versions is to use asdf
.
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 AbsintheCollector do | |
@moduledoc """ | |
Module to collect absinthe telemetry events | |
""" | |
use Prometheus.Metric | |
require Prometheus.Contrib.HTTP | |
@events [ | |
[:absinthe, :resolve, :field, :start], | |
[:absinthe, :resolve, :field], |
OlderNewer