Skip to content

Instantly share code, notes, and snippets.

@jason-riddle
jason-riddle / jshell_docker_snippets.sh
Last active November 19, 2020 14:01
Guide using Jshell to query CPU and memory information within a docker container #jvm #guide #complete
#!/usr/bin/env bash
# Ref: https://jaxenter.com/better-containerized-jvms-jdk-10-140593.html
set -eu
OPENJDK_IMAGE='openjdk:10-ea-jdk-slim'
JSHELL_CMD=(/bin/sh -c 'jshell -q')
# Adjust sensitivity for logitech mouse
# xinput list
# xinput list-props 17
xinput set-prop 17 144 0.400000, 0.000000, 0.000000, 0.000000, 0.400000, 0.000000, 0.000000, 0.000000, 1.000000
# Scroll speed
xinput set-prop 17 'Evdev Scrolling Distance' 1.9 1 1
@jason-riddle
jason-riddle / find_examples
Last active October 21, 2019 01:24
Examples using find #snippet #complete
# More on Performance
# Ref: https://unix.stackexchange.com/questions/41740/find-exec-vs-find-xargs-which-one-to-choose
# Ref: https://www.everythingcli.org/find-exec-vs-find-xargs
# Find all files, including hidden, that match the name "config"
find . -type f -name config
# Find all files that contain the word "git" in the filename
find . -type f -iname '*git*'

Prep Work (Google Cloud)

Visit https://console.cloud.google.com and a create project with the name of kubernetes-cluster and take note of the project id.

Or use gcloud alpha projects create kubernetes-cluster-1345 if you have access.

Update gcloud.

gcloud components install kubectl
function print_fequency() {
(echo "Package Frequency" ; \
cat | tr ' ' '\n' | sort | uniq -c | awk '{print $2"\t"$1}') | column -t
}
# https://github.com/dominikh/go-unused
function find_unused() {
unused -exported "${1}/..."
}
@jason-riddle
jason-riddle / req.sh
Last active October 21, 2019 00:38
Snippet to ensure command is available #complete
#!/usr/bin/env bash
function req() {
what=$1
which "${what}" >/dev/null || { echo "${what} required"; exit 1; }
}
req curl
req gcc
@jason-riddle
jason-riddle / burn_sdcard.sh
Last active October 21, 2019 01:37
Burn to sdcard using dd and pv #guide #complete
SD_CARD="/dev/disk1000"
LOCAL="~/Desktop/2013-09-25-wheezy-raspbian-minimal.img"
# First, unmount the disk
diskutil unmountDisk ${SD_CARD}
# If you are writing from SD card to Mac, calculate the number of bytes to skip as well as the size to pipe to pv.
# 5785600 bytes (count) * 512 (default bs) = 2962227200 bytes == 2825 Megabytes
dd if=${SD_CARD} count=5785600 | pv -s 2825M | dd of=${LOCAL} count=5785600