Mix.install([
{:kino, "~> 0.7.0"}
])
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
"google.com" | |
|> String.to_charlist() | |
|> :inet_res.lookup(:in, :a) | |
|> Enum.reduce([], fn ip, acc -> | |
[ | |
ip | |
|> Tuple.to_list() | |
|> Enum.join(".") | |
| acc | |
] |
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
:inets.start(:httpd, [port: 0, server_name: 'monkl', server_root: '.', document_root: './docs', bind_address: {127,0,0,1}]) |
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
:net_kernel.start([:"main@127.0.0.1"]) | |
:erlang.set_cookie(:cook) | |
{:ok, peer, peername} = | |
:peer.start(%{connection: 0, name: :peer, host: ~C'127.0.0.1'}) | |
:peer.call(peer, :erlang, :set_cookie, [:cook]) | |
Node.connect(peername) | |
# add code paths | |
:rpc.call(peername, :code, :add_paths, [:code.get_path()]) |
.
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
defmodule Console.Helpers do | |
defmacro capture_io(filename, do: block) do | |
quote do | |
filename = unquote(filename) | |
current_leader = Process.group_leader() | |
{:ok, fh} = File.open(filename, [:write]) | |
Process.group_leader(self(), fh) | |
unquote(block) | |
Process.group_leader(self(), current_leader) | |
end |
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
iex --sname a | |
{:ok, hostname} = :inet.gethostname() | |
:slave.start(hostname, :b) | |
:rpc.block_call(hostname, :code, :add_paths, [:code.get_path()]) | |
:rpc.block_call(hostname, :application, :start, [:compiler]) | |
:rpc.block_call(hostname, :application, :start, [:elixir]) | |
:rpc.block_call(hostname, :application, :start, [:iex]) |
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
export ERL_AFLAGS="-kernel shell_history enabled" | |
export KERL_BUILD_DOCS="yes" | |
export KERL_DOC_TARGETS=chunks | |
export KERL_BUILD_DOCS=yes | |
export WX_CONFIG="/usr/local/bin/wx-config" | |
export KERL_CONFIGURE_OPTIONS="--with-wx-config=$WX_CONFIG" |
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
# ATTENTION: This is now supported in plug_cowboy as of 2.1.0: | |
# https://hexdocs.pm/plug_cowboy/Plug.Cowboy.Drainer.html | |
defmodule DrainStop do | |
@moduledoc """ | |
DrainStop Attempts to gracefully shutdown an endpoint when a normal shutdown | |
occurs. It first shuts down the acceptor, ensuring that no new requests can be | |
made. It then waits for all pending requests to complete. If the timeout | |
expires before this happens, it stops waiting, allowing the supervision tree | |
to continue its shutdown order. |
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
ARG MIX_ENV="prod" | |
# build stage | |
FROM hexpm/elixir:1.12.3-erlang-24.1.2-alpine-3.14.2 AS build | |
# install build dependencies | |
RUN apk add --no-cache build-base git python3 curl | |
# sets work dir | |
WORKDIR /app |
NewerOlder