Skip to content

Instantly share code, notes, and snippets.

ps -ef | grep <filter-here> | grep -v grep | awk '{print $2}' | xargs kill -9
@gregjhogan
gregjhogan / tc-limit-bandwidth
Created May 17, 2018 22:10
tc traffic shaping (limit bandwidth)
# setup
sudo tc qdisc add dev $1 root tbf rate 1.0mbit latency 50ms burst 50kb mtu 10000
# remove
sudo tc qdisc del dev $1 root
@gregjhogan
gregjhogan / tensor-flow-gpu-cpu-compare.py
Last active June 8, 2018 06:24
tensor flow gpu vs cpu
# docker run -runtime=nvidia --rm -ti -v "${PWD}:/app" tensorflow/tensorflow:latest-gpu python /app/test.py gpu 10000
import sys
import numpy as np
import tensorflow as tf
from datetime import datetime
device_name = sys.argv[1] # Choose device from cmd line. Options: gpu or cpu
shape = (int(sys.argv[2]), int(sys.argv[2]))
if device_name == "gpu":
@gregjhogan
gregjhogan / hdd-blink.sh
Created July 2, 2018 20:49
make hard drive lights blink
@gregjhogan
gregjhogan / python-fork-skip-finally.py
Last active July 5, 2018 19:18
python fork and skip finally blocks
import os
try:
child_pid = os.fork()
if child_pid == 0:
# finally block runs twice
#exit(1)
# finally block runs once on exception
#try:
# raise Exception('bang!')
@gregjhogan
gregjhogan / delete-files-older-than-date.sh
Created July 25, 2018 23:52
delete files older than a date
find /path/to/dir ! -newermt 2018-01-01 ! -type d -delete
@gregjhogan
gregjhogan / delete-broken-links.sh
Last active July 26, 2018 21:50
delete broken links
@gregjhogan
gregjhogan / mitmproxy-local-proxy.sh
Last active June 21, 2023 21:24
setup mitmproxy local proxy for inspecting traffic
#!/bin/bash -ex
# first go to http://mitm.it/ and follow instructions
# then got to chrome://settings/certificates -> Authorities and import: ~/.mitmproxy/mitmproxy-ca-cert.pem
docker run --rm -it -v ~/.mitmproxy:/home/mitmproxy/.mitmproxy -p 8080:8080 -p 127.0.0.1:8081:8081 mitmproxy/mitmproxy mitmweb --web-host 0.0.0.0
@gregjhogan
gregjhogan / az-cli-mitmproxy.sh
Created August 19, 2018 20:48
azure cli through mtimproxy
REQUESTS_CA_BUNDLE=~/.mitmproxy/mitmproxy-ca-cert.cer HTTPS_PROXY=http://localhost:8080 az "$@"
@gregjhogan
gregjhogan / files-deleted-but-still-referenced.sh
Created August 19, 2018 21:12
files deleted but still referenced
lsof -nP +L1