Skip to content

Instantly share code, notes, and snippets.

@jwhb
jwhb / podman.yml
Last active February 1, 2022 12:34
Rootful Podman on RockyLinux for lima-vm
# Example to use Podman instead of containerd & nerdctl
# $ limactl start ./podman.yaml
# $ limactl shell podman podman run -it -v $HOME:$HOME --rm docker.io/library/alpine
# To run `podman` on the host (assumes podman-remote is installed):
# $ export CONTAINER_HOST=$(limactl list podman --format 'unix://{{.Dir}}/sock/podman.sock')
# $ podman --remote ...
# To run `docker` on the host (assumes docker-cli is installed):
# $ export DOCKER_HOST=$(limactl list podman --format 'unix://{{.Dir}}/sock/podman.sock')
@jwhb
jwhb / extract_sa_token.sh
Last active November 24, 2021 14:56
kubectl: extract serviceaccount token
#!/bin/sh
NAMESPACE=default
SERVICE_ACCOUNT=mysa
# kubectl -n $NAMESPACE create sa $SERVICE_ACCOUNT
kubectl -n $NAMESPACE get secret `kubectl -n $NAMESPACE get serviceaccount $SERVICE_ACCOUNT -ojsonpath="{.secrets[0].name}"` -ojsonpath="{.data.token}" | base64 -d
# BONUS: use kubectl with the service account token:
kubectl --token="${TOKEN}" -s https://api.<cluster-domain>:6443 --insecure-skip-tls-verify=true get pod
@jwhb
jwhb / wait.yaml
Created November 25, 2020 10:35
Ansible: Wait for OpenShift Cluster to be installed
---
- name: Wait for OpenShift Cluster to be installed
hosts: localhost
tasks:
- name: Wait for Cluster to be installed
k8s_info:
api_version: config.openshift.io/v1
kind: ClusterVersion
name: version
register: ocp_clusterversion_result
@jwhb
jwhb / .bashrc
Created July 26, 2020 17:07
WSL: init gpg-agent in Bash
export GPG_TTY=$(tty)
pgrep -U $UID gpg-agent > /dev/null || gpg-connect-agent /bye > /dev/null 2>&1
@jwhb
jwhb / keepalive.sh
Last active February 10, 2020 13:41
Bash KeepAlive script. This is useful to avoid freezing of Eclipse Che terminals.
#!/bin/sh
while true; do >&2 printf '\x00'; sleep 20; done &
@jwhb
jwhb / search_pdf.sh
Last active April 29, 2019 08:11
Search all PDF files in directory, show all matches for specified search text.
#!/bin/sh
if [ ! "$#" -eq "2" ]; then
echo "Usage: $0 <path> <search_text>"
exit 1
fi
find "$1" -name '*.pdf' -exec sh -c "pdftotext -q '{}' - | grep --with-filename --label='{}' --color -i '$2'" \;
@jwhb
jwhb / ansible.sh
Created October 7, 2018 11:55
Run Ansible via Docker
#!/bin/sh
# start ansible container with working directory mounted as /ansible
# then run ping on targets from inventory file
docker run --rm -v $(pwd):/ansible -it webdevops/ansible:alpine ansible -m ping -i /ansible/inventory all
@jwhb
jwhb / ip-regex.js
Last active October 2, 2018 13:14
IP address octet manipulation with regex
// manipulate octets of IP address with Javascript regular expressions
var regex = /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.)(\d{1,3})(\/[1-3]?\d)$/;
var ip = '169.254.0.17/30';
var octet4 = ip.match(regex)[2] - 1; // match and manipulate octet
var ip2 = ip.replace(regex, '$1' + octet4 + '$3'); // reassemble IP
console.log(ip2); //169.254.0.16/30
@jwhb
jwhb / epk-preview.png
Last active March 20, 2019 14:25
GraphML shapes for EPC/EPK process modeling in yED
epk-preview.png
@jwhb
jwhb / tipp10-solarized-dark.css
Last active January 25, 2021 16:55
Solarized Dark style for TIPP10 online touch typing trainer (https://online.tipp10.com)
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("online.tipp10.com") {
#training, .lightsel0 {
background-color: #002b36;
}
#ticker, #status {
background-color: #073642;
}
#fingers {