Skip to content

Instantly share code, notes, and snippets.

@YongHuax
YongHuax / testAWS
Last active February 15, 2018 06:01
LG01-P Linux Script to AWSIot
#!/bin/sh
#when connecting to AWSIOT , a cert , privatekey and certificate authority file is required .
#after downloading the cert files when creating a thing , it is possible rename the files so that it is easier to
#call the file when writing the script and cli
#also note that aws things shadow update requires message to be in json to update
#to catch messages sent to things but are rejected due to improper json format , subscribe to things shadow update through mqtt.
# do remember to check the activity page for the AWsiot " thing" u have created to see whether the message is accepted or rejected
HOST="a1k3lzqvylq236.iot.ap-southeast-1.amazonaws.com"
@uDude
uDude / gist:da262b811ba28c8b8204daef5ff5094e
Last active March 17, 2018 19:10
Iteratively copy files in Elixir
# 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 = File.open!("file.in", [:read, :read_ahead]) |> IO.binstream(4194304)
fout = File.open!("file.out", [:write] |> IO.binstream(4194304)
fin |> Stream.into(fout) |> Stream.run