Skip to content

Instantly share code, notes, and snippets.

uDude / gist:da262b811ba28c8b8204daef5ff5094e
Last active Mar 17, 2018
Iteratively copy files in Elixir
View gist:da262b811ba28c8b8204daef5ff5094e
# We use streams (open the file convert the device to a stream, using 4MB chunks)
# as a demo, using this method we copied a 2.5GB file with no significant memory usage on
# an Odroid with only 2GB of RAM. Not super fast... Do line oriented by replacing the byte
# count in IO.binstream(:line), very very slow. Process line by line or chunk by chunk
# by passing a function to Stream.into(out, fn(line) -> do_someting(line) end).
fin =!("", [:read, :read_ahead]) |> IO.binstream(4194304)
fout =!("file.out", [:write] |> IO.binstream(4194304)
fin |> Stream.into(fout) |>
uDude / gist:8a8226daa8e43d83e0b5e06609ba7661
Created Feb 15, 2018
Elements compiled into nodemcu modules
View gist:8a8226daa8e43d83e0b5e06609ba7661
I periodically tinker with nodemcu firmware for the ESP chips by espressif. One of the most frustrating things is the difference between the documented methods and constants and the actual methods and constants.
The first helper function I define is a `help` function named `h()`:
function h(mod) for k,v in pairs(mod) do print(k) end end
-- Example Use#