defmodule ProtobufParser do
import Bitwise
require Logger
def parse(binary) 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
file_path = "/Users/you/debug" | |
# open file | |
{:ok, io_device} = File.open(file_path, [:append]) | |
# get all schemas | |
:code.all_loaded() | |
|> Enum.map(&elem(&1, 0)) | |
|> Enum.filter(&(to_string(&1) =~ "Schemas")) | |
|> Enum.map(fn schema -> |
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
# KinoCurl | |
```elixir | |
Mix.install([ | |
{:kino, "~> 0.12.3"}, | |
{:req, "~> 0.4.14"} | |
]) | |
``` | |
## Sectionw |
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
# Abusing defguard for keyword lists | |
```elixir | |
Mix.install([ | |
{:benchee, "~> 1.3"} | |
]) | |
``` | |
## Section |
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
previous_fun = Inspect.Opts.default_inspect_fun() | |
hexdump = fn | |
value, opts when not is_binary(value) -> | |
# change base to hex - this way it will show binary numbers in instead of decimal | |
previous_fun.(value, %{opts | base: :hex}) | |
value, opts -> | |
{:ok, string_io} = StringIO.open(value) |
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 AdventureWorks.TracedRepo do | |
use Ecto.Repo, | |
otp_app: :adventure_works, | |
adapter: Ecto.Adapters.Postgres | |
def all_traced(queryable, opts \\ []) do | |
{metadata, opts} = Keyword.pop(opts, :metadata, %{}) | |
{:current_stacktrace, stacktrace} = Process.info(self(), :current_stacktrace) | |
stacktrace = |
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 | |
if [ "$#" -eq 0 ]; then | |
echo "Usage: $0 <word1> <word2> <word3> ..." | |
exit 1 | |
fi | |
API_KEY="$OPENAI_API_KEY" | |
USER_INPUT="$*" |
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
# Untitled notebook | |
```elixir | |
Mix.install([:benchee]) | |
``` | |
<!-- livebook:{"output":true} --> | |
``` | |
:ok |
NewerOlder