This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |