Skip to content

Instantly share code, notes, and snippets.

View rms1000watt's full-sized avatar

Ryan M Smith rms1000watt

View GitHub Profile
@rms1000watt
rms1000watt / check-blocking-dependencies-systemd.sh
Created September 20, 2024 23:16
why isn't my systemd service starting? why is my systemd service hanging when i restart it?
# if myservice hangs when you run
sudo systemctl restart myservice
# the check it's dependencies and whats trying to run
sudo systemctl list-dependencies myservice
sudo systemctl list-jobs
# The job that's "start running" is the blocker
@rms1000watt
rms1000watt / git-find-commit-string-changed-in-file.sh
Created May 22, 2024 20:22
git command to find commit when string changed in a file
git log -S 'this string changed in this file' -- main.sh
@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