Skip to content

Instantly share code, notes, and snippets.

View alvises's full-sized avatar

Alvise Susmel alvises

View GitHub Profile
@alvises
alvises / README.md
Last active March 30, 2019 01:37
Chunks to Lines
@alvises
alvises / bench_hash.exs
Created April 9, 2019 11:08
Elixir File.stream! lines vs chunks
lines = File.stream!("file_path")
chunks = File.stream!("file_path",[],2_048)
hash_fun = fn enum ->
enum
|> Enum.reduce(:crypto.hash_init(:sha),&(:crypto.hash_update(&2, &1)))
|> :crypto.hash_final()
|> Base.encode16()
end
@alvises
alvises / app.css
Last active April 28, 2024 07:57
Phoenix LiveView Gallery with Slideshow
/* to add to assets/css/app.css */
.thumb-selected {
border: 4px solid #0069d9;
}
.thumb-unselected {
opacity: 0.5;
}
@alvises
alvises / app.exs
Created November 22, 2019 17:42
app.exs test script which connects two Elixir nodes running in two containers
IO.puts("I'm here! Sleeping for 2 seconds")
Process.sleep 2_000 # waiting for the other node
nodes = MapSet.new([:app@app1, :app@app2])
other_node =
nodes
|> MapSet.delete(Node.self())
|> MapSet.to_list()
|> List.first()
@alvises
alvises / aoc2022.exs
Last active December 7, 2022 21:33
AoC 2022 in Elixir
# AoC 2022 in Elixir