Files
something-erlang/notebook.livemd

49 lines
719 B
Plaintext
Raw Permalink Normal View History

2024-03-29 15:54:42 +01:00
# Soemthing Erlang Diagnosix
## Intro
Fork this or die!
```elixir
alias SomethingErlang.Accounts.User
alias SomethingErlang.Repo
alias SomethingErlang.AwfulApi.Client
:ok
```
```elixir
%User{bbuserid: "21234"}
|> Repo.insert!()
```
<!-- livebook:{"branch_parent_index":0} -->
## database
```elixir
for user <- Repo.all(User) do
user.email
end
```
<!-- livebook:{"branch_parent_index":0} -->
## client
```elixir
res = Client.login()
```
```elixir
cookies = res.headers["set-cookie"]
for cookie <- cookies, String.starts_with?(cookie, "bb"), into: %{} do
cookie
|> String.split(";", parts: 2)
|> List.first()
|> String.split("=")
|> then(fn [k, v] -> {String.to_existing_atom(k), v} end)
end
```