Skip to content

Instantly share code, notes, and snippets.

View gist:0ffc7a9e7db256e7ebbb37edcfb0c8fb
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
View gist:40a6dabd9edeca63034c32c4fe453305
$ docker stats --no-stream | awk '{ gsub("%", "", $7); print $7 }' | tail +2 | paste -sd+ - | bc
View gist:231ddc8c4b24c43b093a5c7520b452d4
shasum -b -a 384 assets/static/js/codemirror.min.js | awk '{ print $1 }' | xxd -r -p | base64
@jamesduncombe
jamesduncombe / config.ru
Last active Nov 13, 2018
Sinatra basic setup
View config.ru
# Mock app for Timber.io
# Ruby v2.2.1p85
# Sinatra v1.4.7
# Started with just `rackup`
require 'bundler'
Bundler.require
require 'json'
@jamesduncombe
jamesduncombe / amnesia.sh
Last active Sep 16, 2020
Amnesia.io bash alias
View amnesia.sh
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
@jamesduncombe
jamesduncombe / sample new mailbox response.json
Last active Sep 11, 2020
Sample response for new mailbox - Letterb.in
View sample new mailbox response.json
{
"email": ":bin_public_id@letterbin.io",
"bin_url": "https://letterbin.io/m/:bin"
}
@jamesduncombe
jamesduncombe / letterbin - stream download attachments.sh
Last active Sep 11, 2020
Letterb.in - Stream downloading attachments
View letterbin - stream download attachments.sh
curl -s https://letterbin.io/m/:bin_key/stream --no-buffer \
| jq --unbuffered --raw-output '.attachments[0].data' \
| xargs -I {} open "https://letterbin.io/{}"
View curl download - letterbin.sh
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 Sep 11, 2020
Sample letterb.in JSON response
View sample response.json
[
{
"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 / vaultoro api signature.exs
Last active May 5, 2016
Function for generating the API signature for Vaultoro's API - https://api.vaultoro.com
View vaultoro api signature.exs
defmodule Vaultoro do
@doc """
secret = The Vaultoro secret generated along with your API key
endpoint = The full URL that you are requesting (with all params) e.g: https://api.vaultoro.com/1/balance?nonce=9&apikey=_MY_API_KEY_
"""
def signature(secret, endpoint) do
:crypto.hmac(:sha256, secret, endpoint)
|> Base.encode16(case: :lower)
end
You can’t perform that action at this time.