Skip to content

Instantly share code, notes, and snippets.

@davidmroth
davidmroth / comm_port.text
Created September 8, 2022 04:10
Connect to a comm port (Ubuntu)
busybox microcom -t 9600 /dev/xxxx
@davidmroth
davidmroth / terminate.sh
Last active October 4, 2023 23:55
Force delete all pods stuck in 'terminating' state
kubectl delete pods --field-selector=status.phase=Failed
kubectl get replicaset --all-namespaces -o=jsonpath='{range .items[?(@.spec.replicas==0)]}{.metadata.name}{"\t"}{.metadata.namespace}{"\n"}{end}' | awk '{print $1 " --namespace=" $2}' | xargs -n 2 -d '\n' bash -c 'kubectl delete replicaset $0 $1'
kubectl delete pod --grace-period=0 --force $(k get pods | grep -v Running | grep -v ContainerCreating | tail -n +2 | awk '{print $1}')
# Fix terminating NS
NS=<NS> kubectl get namespace "$NS" -o json | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" | kubectl replace --raw /api/v1/namespaces/$NS/finalize -f -
@davidmroth
davidmroth / usage.jsx
Last active April 30, 2022 22:53
Popup Window in React
// https://medium.com/hackernoon/using-a-react-16-portal-to-do-something-cool-2a2d627b0202
imports [...]
import usePopupWindow from '<your path>/usePopupWindow'
export default function () {
const PopupWindow = usePopupWindow()
return (
<div>
@davidmroth
davidmroth / update_time.sh
Created February 14, 2022 03:56
Update Time (Ubuntu)
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
@davidmroth
davidmroth / firewall.pf.conf
Last active December 3, 2021 03:37
Fix for multipass using Cisco Anyconnect VPN
nat on <vpn tun device> proto {tcp, udp, icmp} from 192.168.64.0/24 to any -> <vpn tun device>
pass in log on <multipass bridge IP address> inet all flags S/SA keep state tag cisco_anyconnect_vpn_pass
# Example usage: pfctl -f ./firewall.pf.conf -v
# Find device names and ip info: netstat -nra -f inet
@davidmroth
davidmroth / upgrade_all_node_modules.sh
Last active February 13, 2022 01:16
Upgrade All NPM Modules in One Shot
#https://stackoverflow.com/a/56723462/3697224
node -e "const pk = JSON.parse(require('fs').readFileSync('package.json', 'utf-8'));require('child_process').spawn('npm', ['install', ...Object.keys(Object.assign({},pk.dependencies, pk.devDependencies)).map(a=>a+'@latest')]).stdout.on('data', d=>console.log(d.toString()))"
# Simple Bash Script
for package in $(npm outdated | tail -n+2 | awk '{print $1"@"$4}'); do npm i $package; done
@davidmroth
davidmroth / instructions.txt
Created November 4, 2021 23:54
Podman w/ docker-compose on MacOS
# Get ssh configuration to find port
podman system connection ls
# Create ssh tunnel [PORT] found in the above command
ssh -nNT -L/tmp/podman.sock:/run/user/1000/podman/podman.sock -i ~/.ssh/podman-machine-default ssh://core@localhost:[PORT]
# Export socket location for docker-compose
export DOCKER_HOST='unix:///tmp/podman.sock'
@davidmroth
davidmroth / resize.txt
Last active October 15, 2021 06:35
RESIZE SDCARD EXT4 IMAGE
#RESIZE SDCARD IMAGE
# $ fdisk -l img/2021-05-07-raspios-buster-armhf-lite.img
# Disk img/2021-05-07-raspios-buster-armhf-lite.img: 1.76 GiB, 1874853888 bytes, 3661824 sectors
# Units: sectors of 1 * 512 = 512 bytes
# Sector size (logical/physical): 512 bytes / 512 bytes
# I/O size (minimum/optimal): 512 bytes / 512 bytes
# Disklabel type: dos
# Disk identifier: 0x9730496b
@davidmroth
davidmroth / index.py
Created May 17, 2021 06:11
Linux Dash Python Script and Systemd Startup
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer, test as _test
import subprocess
from SocketServer import ThreadingMixIn
import argparse
import base64
@davidmroth
davidmroth / compile_cpuminer-multi.sh
Last active February 25, 2021 00:08
Compile cpuminer-multi for Raspberry Pi
#!/bin/bash
#
# WARNING: CPU MINING IS UNPROFITABLE! (FOR HOBBY / EXPERIMENT / RESEARCH ONLY)
#
# RASPBERRY PI CPUMINER-MULTI SETUP SCRIPT
#
# RASPBERRY PI, DOGE, DOGECOIN, PROHASHING.COM, LITECOIN, MINING
#