Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
gregjhogan / find-pcie-devices-with-nonzero-aer-stats.sh
Created October 9, 2024 23:03
Find PCIe devices that have non-zero AER stats
ls -1d /sys/bus/pci/devices/* | xargs -I {} sh -c "echo {}; cat {}/aer_dev_* 2>/dev/null|grep -v 0"
@gregjhogan
gregjhogan / gpu-burn.py
Last active March 21, 2024 06:26
gpu burn
import time
import torch
torch.backends.cuda.matmul.allow_tf32 = True
def get_flops(bs, n, t):
flops = (n ** 2) * (2 * n - 1) / t * bs
print(f"{flops/1e12:.2f} TFLOP/s")
def burn_pytorch(dt, n, bs, runtime=10):
@gregjhogan
gregjhogan / jstatd-in-logstash-docker-container.sh
Created February 8, 2024 18:18
run jstatd in logstash docker container
/usr/share/logstash/jdk/bin/jstatd -p 1099 -J-Djava.security.policy=<(echo 'grant codebase "jrt:/jdk.jstatd" { permission java.security.AllPermission; }; grant codebase "jrt:/jdk.internal.jvmstat" { permission java.security.AllPermission; };')
@gregjhogan
gregjhogan / install-ghidra-v850-extension-into-flatpak-installation.sh
Created January 14, 2024 21:41
Install Ghirdra v850 extension into flatpak installation
cd /var/lib/flatpak/app/org.ghidra_sre.Ghidra/current/active/files/lib/ghidra/Ghidra/Extensions/
sudo git clone https://github.com/esaulenka/ghidra_v850
sudo ./lib/ghidra/support/sleigh ./ghidra_v850/data/languages/v850e[23].slaspec
cd ghidra_v850/
# TODO: install appropriate version of openjdk first
sudo make
@gregjhogan
gregjhogan / XS748T-disable-short-reach-energy-detect.txt
Last active January 13, 2024 00:15
Netgear XS748T ProSAFE 48-Port 10G switch disable Short Reach Mode and Energy Detect Mode
# short reach mode and energy detect mode can cause ports to turn off even when an ethernet cable is plugged in
# note that this cannot be disabled from the web management interface under System -> Management -> Green Ethernet
# (changing "Auto Power Down Mode" and "Short Cable Mode" settings is disabled)
# enabled telnet from web interface under Maintenance -> Trouble Shooting -> Remote Diagnostics -> Enable
# connect via telnet: `telnet <switch-ip> 60000` (same username/password as web interface)
# only needed if your prompt doesn't end with '#'
enable
# enter config mode
@gregjhogan
gregjhogan / xpra_server_client_example.sh
Last active October 2, 2023 02:22
xpra server and client example
# install latest from custom apt repo
# https://bytexd.com/xpra/#install-xpra-on-ubuntu
# start server sharing existing desktop (add for html server: --bind-tcp=0.0.0.0:9876 --html=on)
xpra shadow :1 --pulseaudio=no --mdns=no
# start client connecting to server
xpra shadow ssh://<user>@<host>/1 --ssh="ssh -i ~/.ssh/id_rsa" --pulseaudio=no --mdns=no
@gregjhogan
gregjhogan / ghidra_flatpak_x11_forwarding.sh
Created October 2, 2023 02:08
ghidra flatpak app through ssh x11 forwarding
flatpak run --share=network --command=sh org.ghidra_sre.Ghidra -c "DISPLAY=$DISPLAY ghidra"
@gregjhogan
gregjhogan / bash-git-status-prompt.sh
Last active August 17, 2023 00:45
bash prompt with git status
source ~/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
PS1='\[\033[1;32m\]\u@\h \[\033[0;36m\]\w\[\033[1;33m\]$(__git_ps1 " (%s)")$([ $? -ne 0 ] && echo -n " \[\e[0;31m\]!")\n\[\033[0m\]$ '
@gregjhogan
gregjhogan / combine-pdf-files.sh
Created June 30, 2023 08:26
combine PDF files into single PDF
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=output.pdf -dBATCH input1.pdf input2.pdf
@gregjhogan
gregjhogan / debmirror-nvidia-drivers.sh
Created May 21, 2023 00:28
ubuntu deb mirror of nvidia drivers
HOST=us.archive.ubuntu.com
VERSION=530
#debmirror --host=${HOST} --dist=focal --arch=amd64,all --section=restricted --root=/ubuntu --exclude='/.*' --include='/n/nvidia-graphics-drivers-.*' --no-source --no-check-gpg --progress ./mirror/${HOST}
debmirror --host=${HOST} --dist=focal,focal-security,focal-updates --arch=amd64,all --section=restricted --root=/ubuntu --exclude='/.*' --include='/n/nvidia-graphics-drivers-${VERSION}/.*' --no-source --no-check-gpg --progress ./mirror/${HOST}