81 lines
1.4 KiB
Markdown
81 lines
1.4 KiB
Markdown
# Something Erlang
|
|
|
|
## Intro
|
|
|
|
It's nice.
|
|
|
|
## Routes
|
|
|
|
```elixir
|
|
alias SomethingErlangWeb.Router.Helpers, as: Routes
|
|
```
|
|
|
|
```elixir
|
|
initial_state = %{
|
|
lv_pid: 123,
|
|
thread_id: 123_456,
|
|
page_number: 1
|
|
}
|
|
|
|
%{initial_state | page_number: 23}
|
|
```
|
|
|
|
## Grover's GenServer
|
|
|
|
```elixir
|
|
DynamicSupervisor.count_children(SomethingErlang.Supervisor.Grovers)
|
|
```
|
|
|
|
```elixir
|
|
SomethingErlang.Grover.mount(%{bbuserid: 12345, bbpassword: "deadbeaf"})
|
|
```
|
|
|
|
## Client stuff
|
|
|
|
```elixir
|
|
defmodule Client do
|
|
def cookies(args) when is_map(args) do
|
|
Enum.map_join(args, ";", fn {k, v} -> "#{k}=#{v}" end)
|
|
end
|
|
end
|
|
|
|
Client.cookies(%{a: "123", b: "anc"})
|
|
```
|
|
|
|
```elixir
|
|
SomethingErlang.Accounts.get_user!(1)
|
|
```
|
|
|
|
```elixir
|
|
user = %{id: "162235", hash: "1542e8ab8b6cf65b766a32220143b97f"}
|
|
SomethingErlang.AwfulApi.parsed_thread(3_898_279, 51, user)
|
|
```
|
|
|
|
<!-- livebook:{"branch_parent_index":3} -->
|
|
|
|
## Bookmarks
|
|
|
|
```elixir
|
|
doc = SomethingErlang.AwfulApi.Client.bookmarks_doc(1, user)
|
|
html = Floki.parse_document!(doc)
|
|
|
|
for td <- Floki.find(html, "tr.thread td") do
|
|
case td do
|
|
{"td", [{"class", <<"icon", _rest::binary>>} | _attrs], _} -> "icon"
|
|
{"td", attrs, _} -> attrs
|
|
end
|
|
end
|
|
```
|
|
|
|
```elixir
|
|
bookmarks = SomethingErlang.AwfulApi.bookmarks(user)
|
|
```
|
|
|
|
```elixir
|
|
url = SomethingErlang.AwfulApi.Client.thread_lastseen_page(3_898_279, user)
|
|
```
|
|
|
|
```elixir
|
|
url = SomethingErlang.AwfulApi.Client.thread_lastseen_page(3_898_279, user)
|
|
```
|