Elixir

  # to turn tracing on for a pid
  :sys.trace pid, true
  # super handy, returns the state of?! the GenServer?!@
  :sys.get_state Stack.Server 
  #get the routes
  mix phoenix.routes
  #extend timeout in test environment - from https://til.hashrocket.com/posts/36208f16ff-ecto-20-ownership-timeout-myelixirstatus

  config :my_app, MyApp.Repo,
    adapter: Ecto.Adapters.Postgres,
    #...
    ownership_timeout: 60_000
# cast a struct to anohter struct. Bit horrible and doesn't do proper checking, but it works
struct(CustomCast, Map.from_struct(c))
#broadcast a message on a channel
Caster.Endpoint.broadcast("cast:cast65", "downloaded", %{msg: "it has been downlaoded 65"})
# say you want to call a GenServer like this:

GenServer.call(:pid, { :sometuple })

# if you have args like this
args = [:pid, {:sometuple}]

# then you can do
apply(&GenServer.call/2,  args)

Page created on 6 Jun 2020