Skip to content

Instantly share code, notes, and snippets.

@jamesduncombe
jamesduncombe / gist:40a6dabd9edeca63034c32c4fe453305
Created July 8, 2020 17:40
Find total percentage of containers
$ docker stats --no-stream | awk '{ gsub("%", "", $7); print $7 }' | tail +2 | paste -sd+ - | bc
for _x <- 1..100 do
for {name, pid, _type, _whatever} <- Supervisor.which_children(Process.whereis(__MODULE__.Supervisor)) do
{_msg, n } = Process.info(p, :message_queue_len)
IO.puts("#{name}: #{String.duplicate("#", n)}")
end
:timer.sleep(1000)
end
@jamesduncombe
jamesduncombe / sample new mailbox response.json
Last active September 11, 2020 16:41
Sample response for new mailbox - Letterb.in
{
"email": ":bin_public_id@letterbin.io",
"bin_url": "https://letterbin.io/m/:bin"
}
@jamesduncombe
jamesduncombe / letterbin - stream download attachments.sh
Last active September 11, 2020 16:43
Letterb.in - Stream downloading attachments
curl -s https://letterbin.io/m/:bin_key/stream --no-buffer \
| jq --unbuffered --raw-output '.attachments[0].data' \
| xargs -I {} open "https://letterbin.io/{}"
@jamesduncombe
jamesduncombe / curl download - letterbin.sh
Last active September 11, 2020 16:44
Letterb.in cURL example
curl https://letterbin.io/m/$(curl -s https://letterbin.io/m/:bin/json \
| jq -r '.[0].attachments[0].data') > mydownload
@jamesduncombe
jamesduncombe / sample response.json
Last active September 11, 2020 16:45
Sample letterb.in JSON response
[
{
"to": "2LrV4qq@letterbin.io",
"text": "The text version of the email if it exists or an empty string",
"subject": "Test",
"received": "2016-04-29T14:26:24Z",
"raw_mime": "raw_mime/bf7900f6d3077859ba649ad5b4556512e8de7fc…",
"original_html": "Unmodified HTML from the email OR the raw text version (liable to change)",
"id": "a3e2b1e0-cd13-48a8-bd51-abcf5c99f137",
"html": "Modified HTML of the email - all attachments that were inlined are changed to <img> tags etc",
@jamesduncombe
jamesduncombe / amnesia.sh
Last active September 16, 2020 01:08
Amnesia.io bash alias
amn() {
if [ $# -ge 1 -a ! -f $1 ]; then
input=$(cat -)
temp=$(mktemp)
echo $input > $temp
curl -sF "file=@$temp;filename=xyz.$1" https://amnesia.io
rm $temp
elif [ $# -ge 1 -a -f $1 ]; then
curl -sF "file=@$1" https://amnesia.io
else