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
#!/bin/bash | |
# This script provides easy way to debug remote Erlang nodes that is running in a kubernetes cluster. | |
# Usage: ./erl-observe.sh -l app=my_all -n default -c erlang_cookie | |
# | |
# Don't forget to include `:runtime_tools` in your mix.exs application dependencies. | |
set -e | |
# Trap exit so we can try to kill proxies that has stuck in background | |
function cleanup { | |
echo " - Stopping kubectl proxy." |
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 OpenIDConnect do | |
@moduledoc """ | |
Handles a majority of the life-cycle concerns with [OpenID Connect](http://openid.net/connect/) | |
""" | |
alias OpenIDConnect.Document | |
@typedoc """ | |
URL to a [OpenID Discovery Document](https://openid.net/specs/openid-connect-discovery-1_0.html) endpoint. | |
""" | |
@type discovery_document_uri :: String.t() |
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 Firezone.OpenAPIDocsWriter do | |
@keep_req_headers [] | |
@keep_resp_headers ["content-type", "location"] | |
def write(conns, path) do | |
file = File.open!(path, [:write, :utf8]) | |
open_api_spec = %{ | |
openapi: "3.0.0", | |
info: %{ |
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 MyApp.Config do | |
@moduledoc """ | |
This module provides set of helper functions that are useful when reading application runtime configuration overrides | |
in test environment. | |
""" | |
if Mix.env() != :test do | |
def maybe_put_env_override(_key, _value), do: :ok | |
def fetch_env!(app, key), do: Application.fetch_env!(app, key) | |
else |
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 DynamicChangeset do | |
@moduledoc """ | |
This module provides helper functions to extend `Ecto.Changeset` to support | |
dynamic embeds. | |
""" | |
alias Ecto.Changeset | |
@doc """ | |
Casts the given embed with the embedded changeset and field which is used to define it's type. |
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
## You can use this set or rules to parse Elixir logs in DataDog Logger | |
# 16:01:37.511 request_id=2khj5fsrc3lpk86dh8000g5h [debug] Processing with TwilioProxy.RequestController.create | |
router %{date("HH:mm:ss.SSS"):date} (%{data::keyvalue("=", " ")} )?\[+%{word:level}\] Processing (with|by) +%{data:controller.callback} | |
# 16:04:07.995 request_id=u8m11nptsmsjc282k3l1133u6evmljer [info] Sent 200 in 16ms | |
# 16:04:07.995 request_id=u8m11nptsmsjc282k3l1133u6evmljer [info] Sent 200 in 16µs | |
# 00:05:30.048 request_id=sXax4ynq8i+zU90Emg84 [info] Sent 400 in 1ms |
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
#!/bin/bash | |
command -v fswatch >/dev/null 2>&1 || { echo >&2 "fswatch is not installed. To install it use 'brew install fswatch'. Aborting."; exit 1; } | |
command -v mix >/dev/null 2>&1 || { echo >&2 "mix is not installed. Aborting."; exit 1; } | |
PROJECT_PATH=$(git rev-parse --show-toplevel) | |
[[ "$?" != "0" ]] && echo "Stale test watch works only within git project." && exit 1; | |
declare -a IGNORED_PATHS | |
declare -i throttle_by=2 |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<Response> | |
<Dial> | |
<Number>+15671112233</Number> | |
<Number>+15671112234</Number> | |
</Dial> | |
</Response> |
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 Mix.Tasks.Xref2 do | |
use Mix.Task | |
import Mix.Compilers.Elixir, | |
only: [read_manifest: 2, source: 0, source: 1, source: 2, module: 1] | |
@shortdoc "Performs cross reference checks" | |
@recursive true | |
@manifest "compile.elixir" |
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
def book_trip(attrs) do | |
with {:ok, exchange_rates} <- BillingAPI.fetch_currency_exchange_rates(attrs), | |
{:ok, card_authorization} <- BillingAPI.authorize_card(exchange_rates, attrs), | |
{:booking, {:ok, hotel_booking}, _} <- {:booking, HotelsBookingAPI.book_hotel(attrs), []}, | |
{:booking, {:ok, car_booking}, _} <- {:booking, CarsBookingAPI.book_hotel(attrs), [hotel_booking]}, | |
{:booking, {:ok, flight_booking}, _} <- {:booking, FlightsBookingAPI.book_hotel(attrs), [hotel_booking, car_booking]}, | |
:ok <- Mailer.send_email_confirmation(card_authorization, hotel_booking, attrs), | |
{:charge, {:ok, charge}, _} <- {:charge, BillingAPI.charge_card(card_authorization), [...]} do | |
{:ok, %{charge: charge, bookings: [hotel_booking, car_booking, flight_booking]}} | |
else |
NewerOlder