Skip to content

Instantly share code, notes, and snippets.

@kebyn
kebyn / get_image_manifest.sh
Created April 24, 2018 12:50 — forked from alex-bender/get_image_manifest.sh
Docker Registry v2 get manifest and push\pull
#!/bin/bash
#
# Shell scripts for get image manifest from v2 registry
#
# Tested on Debian 8, curl 7.38.0, jq-1.5
#
set -e -u
# Default tag is latest
@kebyn
kebyn / get_image_manifest.sh
Created April 24, 2018 12:50 — forked from alex-bender/get_image_manifest.sh
Docker Registry v2 get manifest and push\pull
#!/bin/bash
#
# Shell scripts for get image manifest from v2 registry
#
# Tested on Debian 8, curl 7.38.0, jq-1.5
#
set -e -u
# Default tag is latest
@kebyn
kebyn / docker-save-load-images.sh
Last active September 19, 2019 02:31 — forked from mathewdgardner/docker-save-load-images.sh
Save / load compressed docker images
#!/bin/bash
# Save docker images
ds() {
docker images --format {{.Repository}}:{{.Tag}} | xargs -t -n 1 -I {} -P 4 sh -c 'docker save {} > $(echo "{}" | sed "s/^.*\///").tar.gz'
}
# Load docker images
dl() {
ls *.tar.gz | xargs -t -n 1 -I {} -P 4 sh -c 'docker load -i {}'
#!/bin/sh
set -o pipefail
set +o xtrace
red=$(tput setaf 1)
green=$(tput setaf 2)
reset=$(tput sgr0)
function os_type() {
def bytes2human(in_bytes: int) -> str:
'''
'''
suffixes = ('B', 'KB', 'MB', 'GB', 'TB', 'PB')
suffix = 0
while in_bytes > 9999 and suffix < len(suffixes):
in_bytes = in_bytes >> 10
suffix += 1
if suffix >= len(suffixes):
func bytes2human(inBytes int64) (result string) {
suffixes := []string{"B", "KB", "MB", "GB", "TB", "PB"}
suffix := 0
for inBytes > 9999 && suffix < len(suffixes) {
inBytes = inBytes >> 10
suffix++
}
if suffix >= len(suffixes) {
suffix--
@kebyn
kebyn / curl
Created October 29, 2021 08:36
curl
function __curl() {
read proto server path <<<$(echo ${1//// })
DOC=/${path// //}
HOST=${server//:*}
PORT=${server//*:}
[[ x"${HOST}" == x"${PORT}" ]] && PORT=80
exec 3<>/dev/tcp/${HOST}/$PORT
echo -en "GET ${DOC} HTTP/1.0\r\nHost: ${HOST}\r\n\r\n" >&3
(while read line; do
@kebyn
kebyn / list-tags.py
Last active December 20, 2023 03:22
from argparse import ArgumentParser, Namespace
from json import dumps, load
from logging import DEBUG, Formatter, StreamHandler, getLogger
from pathlib import Path
from urllib import parse, request
# pylint: disable=missing-class-docstring
# pylint: disable=missing-function-docstring
log = getLogger(name=__name__)
@kebyn
kebyn / SimpleHTTPServerWithUpload.py
Last active December 19, 2023 08:07 — forked from touilleMan/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload - Python3 version
#!/usr/bin/env python3
__version__ = "0.7"
__all__ = ["SimpleHTTPRequestHandler"]
import argparse
import http.server
from html import escape
from io import BytesIO
from mimetypes import add_type, guess_type, init, inited