Sign in

Tyler Barker

@tylerbarker.com
308 followers 342 following 46 posts

Dev in Aus 🇦🇺 Building with #ElixirLang tylerbarker.com

PostsRepliesMedia
Tyler Barker @tylerbarker.com · 19/07/2025
The real reason to get a split keyboard 🧠
An office desk with two KRK studio monitors, a MacBook Pro and external display, a midi piano keyboard and split ergo keyboard, with Reason open for music making.
060
Tyler Barker @tylerbarker.com · 18/02/2025
Maybe the most amazing thing about Elixir to me pattern matching on binaries. Parsing a WAV file is almost as simple as writing down the file spec verbatim - look at this! #ElixirLang
Plaintext formatted to read as a table, outlining the WAV file specification. It reads:
```
WAV File Format Structure
------------------------

Position  | Sample Value | Description
----------|-------------|-------------
1-4       | "RIFF"      | Marks the file as a riff file. Characters are each 1 byte long.
5-8       | File size   | Size of the overall file - 8 bytes, in bytes (32-bit integer).
          | (integer)   | Typically, you'd fill this in after creation.
9-12      | "WAVE"      | File Type Header. For our purposes, it always equals "WAVE".
13-16     | "fmt "      | Format chunk marker. Includes trailing null
17-20     | 16         | Length of format data as listed above
21-22     | 1          | Type of format (1 is PCM) - 2 byte integer
23-24     | 2          | Number of Channels - 2 byte integer
25-28     | 44100      | Sample Rate - 32 bit integer. Common values are 44100 (CD),
          |            | 48000 (DAT). Sample Rate = Number of Samples per second, or Hertz.
29-32     | 176400     | (Sample Rate * BitsPerSample * Channels) / 8
33-34     | 4          | (BitsPerSample * Channels) / 8
          |            | 1 - 8 bit mono
          |            | 2 - 8 bit stereo/16 bit mono
          |            | 4 - 16 bit stereo
35-36     | 16         | Bits per sample
37-40     | "data"     | "data" chunk header. Marks the beginning of the data section.
41-44     | File size  | Size of the data section.
          | (data)     |

Note: Sample values shown are for a 16-bit stereo source.
``` An Elixir code sample that showcases the power of pattern matching binaries as bitstrings - in this case for a WAV audio file. The code reads:
```
<<"RIFF",
  chunk_size::little-size(32), 
  "WAVE", 
  "fmt ", 
  subchunk1_size::little-size(32),
  audio_format::little-size(16), 
  num_channels::little-size(16), 
  sample_rate::little-size(32),
  byte_rate::little-size(32), 
  block_align::little-size(16), 
  bits_per_sample::little-size(16), 
  data_chunk::binary>> = File.read!("./banger.wav")
```
6478
Tyler Barker @tylerbarker.com · 08/02/2025
Saving this for the dozens of us in the NBA <> Elixir Venn diagram when that day comes.
Elixir Lang's logo superimposed over Jayson Tatum exclaiming "What they gonna say now?" after winning an NBA championship, referencing instead Elixir after getting a type system.
030
Tyler Barker @tylerbarker.com · 14/01/2025
Ever wanted your LiveView components to sparkle? Use this hook: gist.github.com/tylerbarker/... #ElixirLang #LiveView
0110
Tyler Barker @tylerbarker.com · 26/11/2024
Cloak is rad! I'm rebuilding my wife's website which handles some sensitive data. Last I checked, cloak_ecto doesn't support SQLite - but it didn't take much to do it myself 🔒 github.com/danielberkom...
Cloak vault module.Ecto schema with binary values, marked encrypted fields.Context module leveraging the vault.
020