Skip to content

Instantly share code, notes, and snippets.

ClusterPlayground.hello()
# => :world
# Start peer node
{:ok, peer, node_name} = :peer.start(%{connection: :standard_io})
# try call some functions
:peer.call(peer, :rand, :uniform, [100])
:peer.call(peer, ClusterPlayground, :hello, [])
@RudolfMan
RudolfMan / humanized_weather.ex
Last active March 29, 2022 06:03
Doctest of a functions that have side effects
defmodule MyApp.WeatherAPI do
@callback temp(MyApp.LatLong.t()) :: {:ok, integer()}
@callback humidity(MyApp.LatLong.t()) :: {:ok, integer()}
def temp(lat_long), do: impl().temp(lat_long)
def humidity(lat_long), do: impl().humidity(lat_long)
defp impl, do: Application.get_env(:my_app, :weather, MyApp.ExternalWeatherAPI)
end
defmodule MyApp.HumanizedWeather do
@RudolfMan
RudolfMan / build_elixir.sh
Last active May 29, 2021 05:37
Builds and installs erlang and elixir from sources for CentOS
#!/bin/sh
if [[ -z $1 ]] || [[ -z $2 ]]; then
echo """
Usage: ./build_elixir.sh ELIXIR_VERSION OTP_VERSION
"""
exit 1
fi
set -xe