Skip to content

Instantly share code, notes, and snippets.

View guessi's full-sized avatar
🎯
Focusing

guessi guessi

🎯
Focusing
View GitHub Profile
@guessi
guessi / validate.sh
Created July 29, 2015 00:36
validation image name for docker agent
#!/bin/sh
PATTERN="^([a-z0-9]+([._-]{0,1}[a-z0-9])*\/)*[a-zA-Z0-9]+([._-]{0,1}[a-z0-9])*(:[A-Za-z0-9][A-Za-z0-9.-]*){0,1}$"
for input in \
i \
image \
i:t \
i:t::: \
image:t \
@guessi
guessi / reposync.sh
Last active March 22, 2017 09:36
a simple helper script for mirroring from one to another
#!/bin/sh
if [ $# -ne 2 ]; then
cat <<-EOF
Usage: reposync.sh <src-repo-uri> <target-repo-uri>
EOF
exit 1
fi
@guessi
guessi / email_validator_regex.sh
Last active April 23, 2024 15:08
Simple Email Validator in Bash
#!/usr/bin/env bash
#
# RFC standard of the email address could be found in rfc5322, rfc6854, etc.
#
# however, it is hard to escape all the special characters in the bash
# so, in this script, it will only check for the address syntax only
# having some valid/invalid inputs to test its result
#
# please be noted that, it is not design to detect mailbox deliverability
@guessi
guessi / get_macaddr.py
Created February 2, 2017 14:51
Get MAC address in Python
#!/usr/bin/env python
import uuid
macaddr_hex = uuid.UUID(int=uuid.getnode()).hex[-12:]
print(':'.join(macaddr_hex[i:i + 2] for i in range(0, 11, 2)))
@guessi
guessi / cleanup_untagged_images.sh
Created May 15, 2017 02:11
AWS ECR - Cleanup Untaaged Image
#!/bin/bash
CLEANUP=${1:-false}
echo
echo "CLEANUP: ${CLEANUP}"
echo
aws configure list --profile ecr >/dev/null 2>&1
if [ $? -ne 0 ]; then
$ PACKER_LOG=1 AWS_ACCESS_KEY_ID=AKIAxxxxxx AWS_SECRET_ACCESS_KEY=XXXXXX packer build packer.json
2018/01/11 10:45:40 [INFO] Packer version: 1.1.3
2018/01/11 10:45:40 Packer Target OS/Arch: darwin amd64
2018/01/11 10:45:40 Built with Go Version: go1.9.2
2018/01/11 10:45:40 Detected home directory from env var: /Users/user_name
2018/01/11 10:45:40 Using internal plugin for lxd
2018/01/11 10:45:40 Using internal plugin for parallels-pvm
2018/01/11 10:45:40 Using internal plugin for virtualbox-iso
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"LongPathsEnabled"=dword:00000001
@guessi
guessi / refresh-ecr-token-for-kubernetes.sh
Last active September 18, 2023 07:11
Refresh ECR Token for Kubernetes - Resolve ECR Token Expired Issue
#!/bin/bash
# prerequisite:
# - ec2 instance should attached proper iam role
# - awscli
# - kubectl
# Usage:
#
# define the following variales in your environment (root account)
@guessi
guessi / query-pod-name-by-ipaddr.sh
Created April 4, 2018 13:51
Find Out Pod Name by Query Pod IP Address (Kubernetes)
#!/bin/bash
for pod in $(etcdctl ls /registry/pods/default); do
printf "%-16s ==> %s\n" "$(etcdctl get ${pod} | jq -r '.status.podIP')" "$(basename ${pod})"
done
@guessi
guessi / setup-docker-ce.ps1
Last active September 27, 2021 09:13
Minimal Script for Setup Docker-CE/Docker-EE on Windows Server 2016
# for Windows Server 2016 (or above)
# reference:
# - https://github.com/docker/labs/blob/master/windows/windows-containers/Setup-Server2016.md
# - https://docs.docker.com/engine/installation/linux/docker-ce/binaries/
# - https://docs.docker.com/docker-for-windows/install/
# setup basic requirement
Install-Module -Name PowerShellGet -MinimumVersion 1.1.3.2 -Force
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.208 -Force