Skip to content

Instantly share code, notes, and snippets.

View noelworden's full-sized avatar

Noel Worden noelworden

View GitHub Profile
iex> Repo
MyApp.Repo
iex> example_variable
["a", "b", "c"]
@noelworden
noelworden / week_july27_broken_example.ex
Last active September 14, 2020 15:22
#blog_snippets
example_variable = ["a", "b", "c"]
Error while evaluating: /opt/app/myapp/.iex.exs
** (TokenMissingError) .iex.exs:64: missing terminator: ] (for "[" starting at line 1)

COPY mix.exs mix.lock ./

COPY .iex.exs mix.exs mix.lock ./

iex> Repo
MyApp.Repo
@noelworden
noelworden / week_july27_volume.yml
Last active August 8, 2020 22:28
#blog_snippets
- ./.iex.exs:/opt/app/my_app/.iex.exs
@noelworden
noelworden / week_march30_script.ex
Last active August 8, 2020 23:25
#blog_snippets
["path", "to", "file"]
|> CSVUtil.data_from_csv()
|> Enum.each(fn attrs ->
%Product{}
|> Product.changeset(attrs)
|> Repo.insert!()
end)
@noelworden
noelworden / week_march30_error.ex
Last active August 8, 2020 23:26
#blog_snippets
** (Ecto.InvalidChangesetError) could not perform insert because changeset is invalid.
Errors
%{
vendor_id: [{"can't be blank", [validation: :required]}]
}
Applied changes
%{
expense_account_number: 500000,
income_account_number: 400000,
name: "Discount"
@noelworden
noelworden / week_march30_command.sh
Last active August 8, 2020 23:25
#blog_snippets
head -n 4 ~/downloads/data_dump.csv | xxd