Skip to content

Instantly share code, notes, and snippets.

@jmnsf
jmnsf / forever.sh
Created April 22, 2017 12:30
Keep any command running forever
#!/bin/sh
# Reruns any command when it exits.
while :
do
eval $@
echo "Died... Re-running in 1 second."
sleep 1
done
@jmnsf
jmnsf / retry.sh
Created August 15, 2018 12:09
Rerun any command that exists with non-zero status.
#!/bin/sh
# Reruns any command when it exits with non-zero status.
while :
do
if eval $@ ; then
break
fi
echo "Died... Re-trying in 1 second."
@jmnsf
jmnsf / dynamic_supervisor.exs
Created February 26, 2021 13:58
DynamicSupervisor: always creating a child vs checking first benchmark
import ExUnit.Assertions
defmodule TestChild do
use GenServer
def start_link(child_id) do
GenServer.start_link(__MODULE__, child_id, name: {:via, Registry, {TestRegistry, child_id}})
end
@impl true