Skip to content

Commit

Permalink
Add elixir encoding TIL
Browse files Browse the repository at this point in the history
  • Loading branch information
acdibble committed Apr 20, 2021
1 parent f79451d commit 7d321f0
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ others" and "this is something really annoying that took forever to find out and
I know I'll come across it again at some point so I want it committed for
posterity".

32 TILs and growing!
33 TILs and growing!

---

Expand Down Expand Up @@ -38,6 +38,7 @@ posterity".

### Elixir

- [Base encoding methods](elixir/base-encoding-methods.md)
- [Get last value in IEx](elixir/get-last-value-in-iex.md)
- [Test coverage](elixir/test-coverage.md)
- [Test setup](elixir/test-setup.md)
Expand Down
19 changes: 19 additions & 0 deletions elixir/base-encoding-methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Base encoding methods

With the methods of the `Base` module, you can pass which case you want the
output string to be encoded in. Default is upper, but lower can be achieved
without `String.downcase/1`:

```elixir
iex(1)> bytes = :crypto.strong_rand_bytes(32)
<<10, 172, 2, 91, 154, 240, 89, 162, 143, 96, 28, 69, 174,
179, 223, 221, 232, 248, 28, 193, 159, 57, 142, 148, 188,
215, 14, 42, 69, 35, 225, 48>>
iex(2)> bytes |> Base.encode16()
"0AAC025B9AF059A28F601C45AEB3DFDDE8F81CC19F398E94BCD70E2A4523E130"
iex(3)> bytes |> Base.encode16(case: :lower)
"0aac025b9af059a28f601c45aeb3dfdde8f81cc19f398e94bcd70e2a4523e130"

```

[source](https://hexdocs.pm/elixir/Base.html)
62 changes: 61 additions & 1 deletion structure.json
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
{"C++":["Scoped enums"],"JavaScript":["File system flags in Node","Readline interface","Readline interface 2","Regular expression flags"],"shell":["List directories only","`mv` Tips and Tricks","Oh My Zsh Aliases","String manipulation","`which`"],"vim":["Ruler"],"WebAssembly":["Break statements","Global variables","Memory management","Tables"],"Rails":["Active record attributes","`select` vs `pluck`"],"PostgreSQL":["Filter clause"],"VS Code":["External terminal"],"Ruby":["`squeeze`"],"Linux":["Force quit hung ssh","Killing other ssh connections","U2F","Yubico Authenticator on Fedora"],"git":["Find file creation date","Push commit with tags","Set commit message editor"],"nginx":["Redirect requests to new domain"],"Elixir":["Get last value in IEx","Test coverage","Test setup","Turn on history in IEx"]}
{
"C++": [
"Scoped enums"
],
"JavaScript": [
"File system flags in Node",
"Readline interface",
"Readline interface 2",
"Regular expression flags"
],
"shell": [
"List directories only",
"`mv` Tips and Tricks",
"Oh My Zsh Aliases",
"String manipulation",
"`which`"
],
"vim": [
"Ruler"
],
"WebAssembly": [
"Break statements",
"Global variables",
"Memory management",
"Tables"
],
"Rails": [
"Active record attributes",
"`select` vs `pluck`"
],
"PostgreSQL": [
"Filter clause"
],
"VS Code": [
"External terminal"
],
"Ruby": [
"`squeeze`"
],
"Linux": [
"Force quit hung ssh",
"Killing other ssh connections",
"U2F",
"Yubico Authenticator on Fedora"
],
"git": [
"Find file creation date",
"Push commit with tags",
"Set commit message editor"
],
"nginx": [
"Redirect requests to new domain"
],
"Elixir": [
"Base encoding methods",
"Get last value in IEx",
"Test coverage",
"Test setup",
"Turn on history in IEx"
]
}

0 comments on commit 7d321f0

Please sign in to comment.