Skip to content

Instantly share code, notes, and snippets.

View hartsock's full-sized avatar

Shawn Hartsock hartsock

View GitHub Profile
@hartsock
hartsock / Jenkinsfile
Created May 15, 2019 17:48
A Jenkins Declarative Pipeline with parallel execution and coordination based on actions in each parallel node.
/**
* 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
hartsock / prune-all.sh
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
done
@hartsock
hartsock / node-ips.sh
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}")";
done
@hartsock
hartsock / .profile
Created October 17, 2018 13:14
Shawn's Bash 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 $ "
fi
echo ""
fi
@hartsock
hartsock / sync.sh
Last active August 10, 2017 17:54
A stupid bash script I wrote because I'm not clever enough to not have to write this.
#!/bin/bash
SRC=$1
DST=$2
if [[ -z ${SRC} ]]; then echo "No source dir"; exit 1; fi
if [[ -z ${DST} ]]; then echo "No destination dir"; exit 1; fi
for d in $(ls $SRC); do
if [ -d "$SRC/$d" ]; then
CMD="rsync -r $SRC/$d/ $DST/$SRC/$d"
@hartsock
hartsock / 2014.09.BioHacking.txt
Created July 3, 2017 15:41
List I made for myself when I started researching BioHacking in 2014. One question I had was... why at 6'2" and 240 lbs did I not look like a thing like Arnold?
1. Lift Weights
2. Sleep Well
3. Intermittent Fasting? Dietary Ketosis?
4. Cholesterol / Zinc / Magnesium / Vitamin D3
5. Lower Estrogen: Weight Loss, No BPA
6. Reduce Stress
7. Increase Androgen Receptors: L-Carnitine & L-Tartrate / Reduce over stimulation
@hartsock
hartsock / sketch_add_disk.py
Created April 17, 2017 19:28
adding a disk code sketch
from pyVmomi import vim
spec = vim.vm.device.VirtualDiskSpec()
spec.operation = vim.vm.device.VirtualDeviceSpec.Operation.add
spec.fileOperation = vim.vm.device.VirtualDeviceSpec.FileOperation.create
spec.device = vim.vm.device.VirtualDisk(
capacityInBytes=capacity_bytes,
capacityInKB = capacity_kb,
connectable = vim.vm.device.VirtualDevice.ConnectInfo(
startConnected = True,
@hartsock
hartsock / github_contributor_commands
Created February 2, 2017 17:06
Standard GitHub Practice
git clone git@github.com:[your fork of the upstream repo]
cd [repo name]
git remote add upstream https://github.com/[upstream repo]
git fetch --all
git pull upstream master
git push origin master
git checkout -b issue12345
# ... edit files ...
git commit -a -m 'fixed issue12345'
git push -u origin issue12345
# How to create an RPM repository
# This is for Redhat 64 bit versions of Linux. You can create your own RPM repository # to host your custom RPM packages.
#
# See "How to create an RPM from source with spec file" for more information.
# https://gist.github.com/1376973
# Step: 1
# Install createrepo
@hartsock
hartsock / photon_developer_boxen_static_ip.txt
Created September 8, 2016 16:44
Static IP for the old Photon developer boxen
$ sudo gvim /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf
host phodev {
hardware ethernet 00:0c:29:ab:9a:11;
fixed-address 192.168.218.10;
}