Skip to content

Instantly share code, notes, and snippets.


Shawn Hartsock hartsock

View GitHub Profile
hartsock /
Created October 4, 2022 13:50
Repeat the rest of the CLI 30 times. Example: ` echo "foo"`
#!/usr/bin/env bash
while [ $i -le $STOP ]
echo -n "${i} :"
exec "$@"&
hartsock /
Created May 14, 2021 18:03
A super generic Python3
import io
import os
from setuptools import find_packages, setup
# Author @hartsock
# Why: copy into a directory with some python scripts you want to call a "library"
# How: pip3 install -e .
hartsock / upgrade-photon.yml
Created October 22, 2019 17:38
An Ansible playbook for upgrading VMware Photon OS 2.x to 3.x
View upgrade-photon.yml
- hosts: photon
remote_user: root
- name: pip prerequisite
command: bash -c "tdnf -y install python-pip"
- name: python prerequisites
command: bash -c "pip install -I pexpect"
hartsock / sshd.go
Created August 14, 2019 17:07 — forked from jpillora/sshd.go
Go SSH server complete example - Read more here
View sshd.go
// A small SSH daemon providing bash sessions
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
// Client:
hartsock / gist:9199a1382423fa46305d92d74b0d5838
Created August 14, 2019 16:42 — forked from devinodaniel/gist:8f9b8a4f31573f428f29ec0e884e6673
Generate SSH RSA Private/Public Key pair with Golang
View gist:9199a1382423fa46305d92d74b0d5838
// This shows an example of how to generate a SSH RSA Private/Public key pair and save it locally
package main
import (
hartsock /
Created July 5, 2019 15:08

Keybase proof

I hereby claim:

  • I am hartsock on github.
  • I am hartsocks ( on keybase.
  • I have a public key ASBDED6lN9AWuOs6q22wMJr0mV5Bzxv2nTeTIuO-W7O01wo

To claim this, I am signing this object:

hartsock / Jenkinsfile
Created May 15, 2019 17:48
A Jenkins Declarative Pipeline with parallel execution and coordination based on actions in each parallel node.
View Jenkinsfile
* Problem:
* I have some action occurring on several parallel nodes. The action may have a diffrent result on each node non-deterministically.
* I need to act from the master depending on the result at each node.
* For a contrived example, we record the name of each node used to act on the parallel actions specified in this pipeline. The
* names are collected in a global string and a global `Map<String,String>` object for use by the master.
value = ':'
hartsock /
Created February 25, 2019 17:02
Docker Swarm - Prune all Stopped containers on all Nodes in swarm
for NODE in $(docker node ls --format '{{.Hostname}}'); do
IP_ADDR="$(docker node inspect --format '{{.Status.Addr}}' "${NODE}")";
echo -e "${NODE} - $(docker node inspect --format '{{.Status.Addr}}' "${NODE}")";
# Presumes your manager node can SSH into all worker nodes
ssh ${IP_ADDR} docker container prune -f
hartsock /
Created February 25, 2019 16:59
Docker Swarm - List all Node IP addresses
for NODE in $(docker node ls --format '{{.Hostname}}'); do
echo -e "${NODE} - $(docker node inspect --format '{{.Status.Addr}}' "${NODE}")";
hartsock / .profile
Created October 17, 2018 13:14
Shawn's Bash Profile
View .profile
if [ -d $HOME/bin ]; then export PATH=$HOME/bin:$PATH ; fi
# interactive only below this point
if [ -t 1 ]; then
export SOURCE_IP=`echo $SSH_CONNECTION | awk '{print $1}'`
export CURRENT_IP=`echo $SSH_CONNECTION | awk '{print $3}'`
if [[ ! -z "${CURRENT_IP}" ]]; then
export PS1="${CURRENT_IP}:\w $ "
echo ""