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 LVCallTime do | |
@moduledoc """ | |
Best used sparingly. | |
LVCallTime.start() | |
:timer.sleep(:timer.seconds(20)) | |
LVCallTime.dump() | |
LVCallTime.stop() | |
or just |
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
:dbg.stop_clear() | |
{:ok, _} = | |
:dbg.tracer( | |
:process, | |
{fn | |
{:trace, pid, :call, {mod, fun, args} = call}, stacks -> | |
mfa = Exception.format_mfa(mod, fun, Enum.count(args)) |> Pretty.inspect(label: ":call") | |
Smuggle.dump({mod, fun, args}, wrapper: :gfm) | |
stack = Map.get(stacks, pid, []) |
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
{:ok, _} = | |
:dbg.tracer( | |
:process, | |
{fn | |
{:trace, pid, :call, {mod, fun, args} = call}, stacks -> | |
mfa = Exception.format_mfa(mod, fun, Enum.count(args)) | |
stack = Map.get(stacks, pid, []) | |
if match?({Phoenix.PubSub, :broadcast, _}, call) do | |
Pretty.inspect(stack, label: "broadcast stack") |
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 PidSnitchFormatter do | |
@moduledoc """ | |
Report test PIDs? | |
```bash | |
mix test --formatter PidSnitchFormatter | |
``` | |
See `ExUnit.CLIFormatter` for protocol details. | |
""" |
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
# docker build -t start_span . | |
# docker run --rm -ti start_span | |
FROM elixir:1.10.3-alpine | |
RUN cd /usr/local/src && mix new start_span | |
WORKDIR /usr/local/src/start_span | |
COPY mix.exs README.md ./ | |
COPY start_span.ex lib/ | |
RUN mix local.hex --force && mix local.rebar --force && mix deps.get | |
CMD ["mix", "dialyzer"] |
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 TelemetryTracingExperimentTest do | |
use ExUnit.Case, async: true | |
@doc """ | |
Dump a variable to standard output, ANSI formatted, and pretty. | |
""" | |
def dump(v) do | |
opts = IEx.Config.inspect_opts() | |
[:reset, "\n", get_in(opts, [:syntax_colors, :reset]) || :reset, inspect(v, opts), :reset] |
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 AutoRecords do | |
defmacro __using__(_opts) do | |
quote do | |
require OpenTelemetry.Records.Auto | |
import OpenTelemetry.Records.Auto, only: [auto_record: 2] | |
end | |
end | |
defmacro auto_record(name, from_lib) do |
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
FROM amazonlinux:2 | |
COPY scalyr.key /etc/pki/rpm-gpg/RPM-GPG-KEY-scalyr-1 | |
COPY scalyr.repo /etc/yum.repos.d/ | |
RUN yum install -y jq systemd-python python2-pip scalyr-agent-2 | |
RUN pip2 install docker-py | |
CMD ["python2", "-c", "import docker; docker.APIClient"] |
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
#! /usr/bin/env elixir | |
defmodule FindEmoji do | |
def find_emoji_in_git_log do | |
:ok = | |
stream_executable("git", ["log"]) | |
|> Stream.filter(&contains_emoji?/1) | |
|> Stream.each(&IO.puts/1) | |
|> Stream.run() | |
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
wait4eth1() { | |
CNT=0 | |
until ip a show eth1 | grep -q UP | |
do | |
[ $((CNT++)) -gt 60 ] && break || sleep 1 | |
done | |
sleep 1 | |
} | |
wait4eth1 |