Skip to content

Instantly share code, notes, and snippets.

@jstangroome
jstangroome / set-drag.ps1
Created Jun 17, 2020
Change the mouse drag distance required to initiate a drag operation, e.g. moving files in Explorer
View set-drag.ps1
param (
[int]$drag = 4
)
# https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa
$importDefinition= @'
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
'@
$importType = Add-Type -MemberDefinition $importDefinition -Name WinAPICall -Namespace SetDragSystemParametersInfo –PassThru
@jstangroome
jstangroome / docker-content-tag.sh
Created Apr 18, 2020
Generate a tag derived from the inputs to a Docker image, without needing to build the image itself.
View docker-content-tag.sh
#!/bin/bash
cat <<'EOF' >.dockerfile.content-tag
FROM busybox:1
WORKDIR /src/
ENTRYPOINT ["/bin/sh", "-c", "find . -type f \\! -path ./.dockerfile.content-tag -exec sha256sum -b {} +"]
COPY . /src/
EOF
iid=$( docker image build -q -f .dockerfile.content-tag . )
@jstangroome
jstangroome / kubectl-evict
Created Mar 4, 2020
kubectl evict in bash
View kubectl-evict
#!/bin/bash
print_usage () {
printf 'Usage: kubectl evict -n <namespace> <pod>\n' >&2
}
main () {
if [ "-n" != "$1" ] && [ "--namespace" != "$1" ]
then
print_usage
@jstangroome
jstangroome / install.sh
Created Apr 13, 2019
WSL useful extra packages
View install.sh
apt-get install -y \
apt-transport-https \
binutils \
build-essential \
python-pip \
socat \
sysstat \
traceroute \
unzip \
zip
View find-long-commit-messages.sh
#!/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 Jan 2, 2019
Create a CSV of each cgroup's memory.usage_in_bytes and some related memory.stat values.
View collect_usage_in_bytes.sh
#!/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/
View collect_usage_in_bytes.sh
#!/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 Aug 21, 2018
Rewrite your Windows .kube/config to be usable by Linux kubectl inside WSL
View script.sh
#!/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"
View minikube-docker-env-wsl.bash
#!/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}" != '/' ]
View pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: example
spec:
initContainers:
- name: file-copy
image: busybox:latest
command:
- cp
You can’t perform that action at this time.