Skip to content

Instantly share code, notes, and snippets.

View rms1000watt's full-sized avatar

Ryan M Smith rms1000watt

View GitHub Profile
@rms1000watt
rms1000watt / mongo-wildcard-index-single-field.md
Last active April 12, 2024 18:36
Hello World MongoDB Create Wildcard Index on Single Field
@rms1000watt
rms1000watt / mongo-index-on-fields-in-array.md
Last active April 12, 2024 18:37
Hello World of MongoDB playing with Index on Embedded Document Fields within Arrays
@rms1000watt
rms1000watt / remount-storage.sh
Created March 25, 2024 15:44
remount my removable storage on my raspberry pi
#!/usr/bin/env bash
set -e
# check if disk is attached
sda1_attached=false
sdb1_attached=false
if lsblk | grep -q "sda1"; then
sda1_attached=true
@rms1000watt
rms1000watt / main.js
Created March 15, 2024 23:08
nodejs list, cleanup, create event listeners on process sigint
// from chatgpt
// list all event listeners on process
const eventNames = process.eventNames();
eventNames.forEach((eventName) => {
const listeners = process.listeners(eventName);
console.log(`Event: ${eventName}`);
console.log(`Listeners:`);
listeners.forEach((listener, index) => {
console.log(` Listener ${index + 1}: ${listener.toString()}`);
// Note: listener.toString() might not always give meaningful information,
@rms1000watt
rms1000watt / docker-run-init-sigint-success.sh
Created July 13, 2023 18:03
docker run with --init so SIGINT ctrl+c succeeds
docker run -it --rm --init "${DOCKER_IMAGE}"
@rms1000watt
rms1000watt / pause-and-resume-process.sh
Created July 12, 2023 00:00
Pause & Resume a Process
kill -STOP "${PID}"
kill -CONT "${PID}"
@rms1000watt
rms1000watt / benchmark.js
Created March 29, 2023 16:45
benchmark in nodejs
const Benchmark = require('benchmark');
suite
.add('test1', function() {
console.log('stuff');
})
.add('test2', function() {
console.log('stuff');
})
.on('cycle', function(event) {
@rms1000watt
rms1000watt / gcloud-install-usage.sh
Last active August 15, 2023 07:27
gcloud install and usage
asdf plugin add gcloud https://github.com/jthegedus/asdf-gcloud
echo "gcloud 410.0.0" >> ~/.tool-versions
asdf install
gcloud auth login
gcloud projects list
gcloud config set project $GCP_PROJECT_ID
# pull logs from cloudbuild
# add grep to this command for specific hash.. then cut -d' ' -f1 for the ID.. maybe can filter directly
@rms1000watt
rms1000watt / xfs-aws-eks-k8s-no-space-left-on-device-unknown.md
Last active August 5, 2022 23:38
XFS AWS EKS K8s no space left on device: unknown

If you're using AWS EKS and for some reason you get:

no space left on device: unknown

Check if:

  • you're using XFS
  • your disk usage is < 85% (At 85%, k8s triggers GC)
  • you're pulling large 2GB docker images OR docker images with node_modules with hundreds of thousands of files

Then consider inode contiguous fragmentation issue:

@rms1000watt
rms1000watt / hello-world-dpkg.sh
Created July 20, 2022 22:10
hello world dpkg
#!/usr/bin/env bash
if type -a ryan; then
echo ryan already installed
sudo apt remove ryan -y
fi
version="0.0.1"
sudo rm -rf "ryan-${version}" ||: