Created
October 10, 2023 02:42
-
-
Save nathancyam/7f1207b8541a5dec1fd41017ece388e4 to your computer and use it in GitHub Desktop.
PID to strings
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
# See https://youtu.be/E315pukytFI?t=1251 | |
defmodule PidString do | |
def to_string(pid \\ self()) do | |
pid | |
|> :erlang.term_to_binary() | |
|> Base.encode64() | |
end | |
def to_pid(s) do | |
s | |
|> Base.decode64!() | |
|> :erlang.binary_to_term() | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment