Hacker News new | ask | show | jobs
by mxvzr 1406 days ago

    json2yaml() {
        python3 -c "import json,sys,yaml; print(yaml.dump(json.load(sys.stdin)))"
    }
    export -f json2yaml

    yaml2json() {
        python3 -c "import json,sys,yaml; json.dump(yaml.safe_load(sys.stdin), sys.stdout, default=str)"
    }
    export -f yaml2json

    httping() {
        while true; do
            curl $@ -so /dev/null \
                -w "connected to %{remote_ip}:%{remote_port}, code=%{response_code} time=%{time_total}s\n" \
                || return $?
            sleep 1
        done
    }
    [[ ! $(>&/dev/null type httping) ]] && export -f httping

    redis-cli() {
        REDIS_HOST="${1:-127.0.0.1}"
        REDIS_PORT="${2:-6379}"  
        rlwrap -S "${REDIS_HOST}:${REDIS_PORT}> " socat tcp:${REDIS_HOST}:${REDIS_PORT} STDIO
    }
    [[ ! $(>&/dev/null type redis-cli) ]] && export -f redis-cli