Skip to content

Instantly share code, notes, and snippets.

@nathancyam
Created October 10, 2023 02:42
Show Gist options
  • Save nathancyam/7f1207b8541a5dec1fd41017ece388e4 to your computer and use it in GitHub Desktop.
Save nathancyam/7f1207b8541a5dec1fd41017ece388e4 to your computer and use it in GitHub Desktop.
PID to strings
# 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