AstonJ

AstonJ

Share an Elixir or dev-env tip a day

..or as and when you can think of one :icon_cool:

This thread my also be of interest: What took you way too long to figure out? :003:

Most Liked

mudasobwa

mudasobwa

Creator of Cure
export ERL_AFLAGS='-kernel shell_history enabled  -kernel shell_history_path \".erl.history\"'

The above makes iex sessions to store their history on a per-project basis in project directories. ,gitignore should be also updated to include /.erl.history/.

25
Post #6
hauleth

hauleth

I have already said it few times in different places, but do yourself a favour, and if you are using Git, then have globally (in ~/.config/git/attributes) or per project (in .gitattributes):

mix.lock merge=binary

This will make conflict resolution of mix.lock much easier.


Explanation

This will tell Git to treat Mix lock file as a binary file when doing merges/rebases. This mean, that if there is a conflict, there will be stop (so you need to resolve such conflict), but it will leave file as is (with no conflict markers). This makes my life much easier, as you can then just do mix deps.update --all (as it is most of the time source of such conflicts) and then just git add mix.lock && git rebase --continue.

13
Post #7
codeanpeace

codeanpeace

Handy way to pipe a result from within IEx to your macOS system clipboard when you have pbcopy installed and shell history enabled

defmodule Helpers do
  # pipe expression result to clipboard e.g. ... |> Helpers.copy
  def copy(term) do
    text =
      if is_binary(term) do
        term
      else
        inspect(term, limit: :infinity, pretty: true)
      end

    port = Port.open({:spawn, "pbcopy"}, [])
    true = Port.command(port, text)
    true = Port.close(port)

    IO.inspect(term, label: "copied to clipboard")
    IEx.dont_display_result()
  end
end
phcurado

phcurado

Talking about git, I like to configure mine based article: How Core Git Developers Configure Git | Butler's Log. It contains some good info and recommendations you can use to improve the git defaults in your dev env.

gmile

gmile

One small from me - I’ve added a function in my fish-shell that looks like this:

function dbg
  set test_path $argv[1]
  iex --dbg pry -S mix test $test_path --trace
end

Provided there’s a dbg() macro anywhere in the Elixir code under test, this allows me to enter an interactive debugging session quickly by going from:

mix test test/my_app/permissions/api_test.exs:627

to:

dbg test/my_app/permissions/api_test.exs:627

Where Next?

Popular in Guides/Tuts Top

kokolegorille
Hello dear alchemists, There was this question some days ago here about the deployment to a VPS. As I was in the process of deploying t...
New
nelsonic
When we were figuring out how to use Phoenix LiveView we got stuck a few times. So in order to save other people time, we created a comp...
New
Eiji
Hey, today I give amnesia library a try and found a few problems. I would like describe how to setup it properly and solve problems which...
New
dmitriid
This is not a question, but a post for anyone who may need it in the future. Sometimes some browsers may mangle the filename if it’s non-...
New
anuragg
Hi everyone, I’m the founder of Render and we just released a guide to deploying Phoenix apps with Mix releases. Most of it is generali...
New
jshprentz
Geoffrey Lessel’s 2019 book, Phoenix in Action, was written for Phoenix 1.4. I found that the book’s code examples did not match the cur...
New
f0rest8
Hi, TLDR: form attribute set on the input fields and button submit. I just wanted to share a solution I discovered when making live inl...
New
emilsoman
Hello, While answering a StackOverflow question on how to debug an elixir node running remotely, I thought it may be helpful to write a...
New
TwistingTwists
This is a thread to note down things/best practices encountered in LiveBeats App as I explore the source code. Found this usage of r...
New
dennisreimann
I wrote a guide for implementing Passwordless Authentication a.k.a. "Magic Login Links": Feedback welcome!
New

Other popular topics Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement