using a package locally with hex.pm

Yes it is. In your mix.exs, you can list the dependency with the :path keyword (very similarly to what you do with gems). def dependencies do [{:testing_dep, path: “/Users/me/testing_dep”}] end You can read a list of all the supported options (e.g., pulling the dependency from GitHub or from a Git repository) in the documentation for … Read more

Loop through a Map’s key-value pairs

Turns out you iterate over a Map exactly like you do over a Keyword List (i.e. you use a tuple): Enum.each(%{a: 1, b: 2, c: 3}, fn {k, v} -> IO.puts(“#{k} –> #{v}”) end) Comprehensions also work: for {k, v} <- %{a: 1, b: 2, c: 3} do IO.puts(“#{k} –> #{v}”) end Note: If you … Read more

Installing dependencies in Elixir

If you are looking for something similar to npm install –save, then this does not exist in Elixir. You install things by adding them to deps: in the mix.exs file in your project then running mix deps.get. The other way you may wish to install certain applications is via a mix archive allowing this mix … Read more

Elixir Remove Duplicates From List

Enum.uniq does what you want, for example: iex(6)> Enum.uniq([1,26,3,40,5,6,6,7]) [1, 26, 3, 40, 5, 6, 7] In terms of how you’d implement it you could write a recursive function like so: defmodule Test do def uniq(list) do uniq(list, MapSet.new) end defp uniq([x | rest], found) do if MapSet.member?(found, x) do uniq(rest, found) else [x | … Read more

What does “|>” mean in elixir?

This is the pipe operator. From the linked docs: This operator introduces the expression on the left-hand side as the first argument to the function call on the right-hand side. Examples iex> [1, [2], 3] |> List.flatten() [1, 2, 3] The example above is the same as calling List.flatten([1, [2], 3]).

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)