Skip to content

Instantly share code, notes, and snippets.

@joeytrapp
joeytrapp / LICENSE
Last active July 18, 2025 20:12
Demonstration of phoenix_test 0.7.0 uncheck/3 not working with phx-click and phx-value attributes
MIT License
© 2025 Apple Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@joeytrapp
joeytrapp / aoc_8.erl
Last active December 9, 2024 06:51
Advent of Code Day 8 Part 1 and Part 2
-module(aoc).
-export([main/1]).
main([Path]) ->
{ok, Content} = file:read_file(Path),
{Nodes, Max} = nodes(Content, 0, 0, {0,0}, #{}),
Anti = maps:fold(fun(_, L, S) ->
antinodes(L, L, Max, S)
end, sets:new(), Nodes),
@joeytrapp
joeytrapp / aoc_7.erl
Last active December 8, 2024 05:59
Advent of Code Day 7 Part 1 and Part 2 (code only solves Part 2)
-module(aoc).
-export([main/1]).
main([Path]) ->
{ok, Content} = file:read_file(Path),
Data = parse(Content),
io:format("Result: ~p~n", [lists:sum(lists:map(fun test/1, Data))]),
erlang:halt(0).
@joeytrapp
joeytrapp / aoc_6.erl
Last active December 7, 2024 19:08
Advent of Code Day 6 Part 1 and Part 2
-module(aoc).
-export([main/1]).
main([Path]) ->
{ok, Content} = file:read_file(Path),
{Grid, [Guard]} = parse(Content),
Complete = rounds(Grid, Guard),
Tests = sets:del_element(element(2, Guard), Complete),
io:format("Visited: ~p~n", [sets:size(Complete)]),
@joeytrapp
joeytrapp / aoc_5.erl
Created December 6, 2024 06:53
Advent of Code Day 5 Part 1 and Part 2
-module(aoc).
-export([main/1]).
main([Path]) ->
{ok, Content} = file:read_file(Path),
{Rules, Edits} = parse(Content),
{Correct, Incorrect} = classify_edits(Edits, Rules),
Corrected = corrections(Incorrect, Rules),
io:format("Originally Correct: ~p~n", [sum_of_middles(Correct)]),
@joeytrapp
joeytrapp / aoc_4.erl
Created December 5, 2024 04:04
Advent of Code Day 4 Part 1 and Part 2
-module(aoc).
-export([main/1]).
main([Path]) ->
{ok, Content} = file:read_file(Path),
Data = fill(Content),
YSize = array:size(Data),
XSize = array:size(array:get(0, Data)),
persistent_term:put(?MODULE, Data),
@joeytrapp
joeytrapp / aoc_3.erl
Last active December 9, 2024 06:58
Advent of Code 2024 Day 3 Part 1 and Part 2
-module(aoc).
-export([main/1]).
main([Path]) ->
{ok, Data1} = file:read_file(Path, [read, binary]),
io:format("Without modes: ~p~n", [read_char(Data1, skip, 0)]),
{ok, Data2} = file:read_file(Path, [read, binary]),
io:format("With modes: ~p~n", [read_char(Data2, do, 0)]),
erlang:halt(0).
@joeytrapp
joeytrapp / aoc_2.erl
Last active December 9, 2024 06:58
Advent of Code 2024 Day 2 Part 1 and Part 2
-module(aoc).
-export([main/1]).
main([Path]) ->
{ok, Data} = parse(Path),
io:format("Safe: ~p~n", [lists:sum(lists:map(fun is_safe/1, Data))]),
io:format("Dampened: ~p~n", [lists:sum(lists:map(fun is_less_safe/1, Data))]),
erlang:halt(0).
@joeytrapp
joeytrapp / aoc_1.erl
Last active December 9, 2024 06:57
Advent of Code 2024 Day 1 Part 1 and Part 2
-module(aoc).
-export([main/1]).
-import(file, [read_file/1]).
-import(lists, [unzip/1, map/2, zip/2, sort/1, foldl/3, filter/2, sum/1]).
-import(maps, [get/3, update_with/4]).
-import(string, [is_empty/1, split/3, trim/1]).
main([Path]) ->
@joeytrapp
joeytrapp / phoenix_test_redirect_missing_req_headers.exs
Last active September 6, 2024 23:44
Demonstrate that manually set request headers are not present in redirect/navigate requests
Mix.install(
[
{:phoenix_playground, "~> 0.1.6"},
{:phoenix_test, "~> 0.3.2"}
],
config: [
phoenix_test: [endpoint: Demo.Endpoint],
phoenix_playground: [
{Demo.Endpoint,
[