Skip to content

Instantly share code, notes, and snippets.

View jstangroome's full-sized avatar

Jason Stangroome jstangroome

View GitHub Profile
@jstangroome
jstangroome / install.sh
Created April 13, 2019 02:22
WSL useful extra packages
apt-get install -y \
apt-transport-https \
binutils \
build-essential \
python-pip \
socat \
sysstat \
traceroute \
unzip \
zip
@jstangroome
jstangroome / find-long-commit-messages.sh
Created January 30, 2019 04:39
Find long commit messages
#!/bin/bash
while read -r commit_hash
do
message=$(
git cat-file commit "${commit_hash}" |
sed '1,/^$/d'
)
if [ "${message:0:5}" = 'Merge' ] || [ "${message:0:6}" = 'Revert' ]
@jstangroome
jstangroome / collect_usage_in_bytes.sh
Created January 2, 2019 04:33
Create a CSV of each cgroup's memory.usage_in_bytes and some related memory.stat values.
#!/bin/bash
printf '%s,%s,%s,%s,%s,%s,%s,%s\n' \
'dir' 'usage_in_bytes' \
'cache' 'total_cache' \
'rss' 'total_rss' \
'rss_huge' 'total_rss_huge'
cd /sys/fs/cgroup/memory/
@jstangroome
jstangroome / collect_usage_in_bytes.sh
Created January 2, 2019 04:33
Create a CSV of each cgroup
#!/bin/bash
printf '%s,%s,%s,%s,%s,%s,%s,%s\n' \
'dir' 'usage_in_bytes' \
'cache' 'total_cache' \
'rss' 'total_rss' \
'rss_huge' 'total_rss_huge'
cd /sys/fs/cgroup/memory/
@jstangroome
jstangroome / script.sh
Created August 21, 2018 08:19
Rewrite your Windows .kube/config to be usable by Linux kubectl inside WSL
#!/bin/bash
win_profile_dir=$(wslpath "$(cmd.exe /c "echo %USERPROFILE%" | tr -d '\r')")
win_dot_kube_dir="${win_profile_dir}/.kube"
win_kube_config="${win_dot_kube_dir}/config"
wsl_dot_kube_dir="${HOME}/.kube"
@jstangroome
jstangroome / minikube-docker-env-wsl.bash
Last active November 28, 2021 08:18
Minikube on WSL helper
#!/bin/bash
if [ "$_" = "${BASH_SOURCE}" ]
then
printf 'source this script, do not execute.\n' >&2
exit 1
fi
eval $(minikube docker-env --shell bash)
if [ -n "${DOCKER_CERT_PATH}" ] && [ "${DOCKER_CERT_PATH:0:1}" != '/' ]
apiVersion: v1
kind: Pod
metadata:
name: example
spec:
initContainers:
- name: file-copy
image: busybox:latest
command:
- cp
@jstangroome
jstangroome / docker-readme
Last active June 30, 2020 08:51
Container memory limits as visible to container process
# docker 17.12.1-ce
=> docker run
==> /sys/fs/cgroup/memory/memory.kmem.limit_in_bytes <==
18446744073709551615
==> /sys/fs/cgroup/memory/memory.kmem.tcp.limit_in_bytes <==
18446744073709551615
==> /sys/fs/cgroup/memory/memory.limit_in_bytes <==
18446744073709551615
@jstangroome
jstangroome / dpkg.sh
Created March 21, 2018 04:00
Default packages present on a Rackcorp Ubuntu 16.04 x64 install as at 2018-MAR-21
$ dpkg --list
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===========================-==================-==================-============================================================
ii accountsservice 0.6.40-2ubuntu11.3 amd64 query and manipulate user account information
ii adduser 3.113+nmu3ubuntu4 all add and remove users and groups
ii apt 1.2.26 amd64 commandline package manager
ii apt-utils 1.2.26 amd64 package management related utility programs
@jstangroome
jstangroome / Dockerfile
Created March 20, 2018 11:52
Build lslocks for Ubuntu Trusty
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get build-dep --assume-yes \
util-linux
RUN apt-get install --assume-yes \
wget \
gnupg