Skip to content

Instantly share code, notes, and snippets.

@smj10j
smj10j / .gitignore
Last active April 24, 2023 16:24
Converts Bubbli Bubbles into flat, portable panoramic photos usable by other 360 apps such as Google Photosphere
*/*.tif
*/*.jpg
*/*.json
@smj10j
smj10j / iperf3-daemon
Last active November 27, 2016 17:12
detach an iperf3 server daemon
#!/usr/bin/env bash
LOGFILE=${1:-/var/log/iperf3.log}
killall iperf3 2>/dev/null
nohup iperf3 --server >>"${LOGFILE}" 2>&1 &
ps -A | grep iperf3
@smj10j
smj10j / README.md
Last active November 22, 2016 16:29
create a basic cert with letsencrypt's certbot
We couldn’t find that file to show.
@smj10j
smj10j / website-to-pdf.sh
Created October 1, 2016 11:47
Downloads a website and converts the HTML files to a single PDF with a table of contents
#!/bin/bash
URL=$1
DIR=$2
# Download a website
wget --show-progress --recursive --convert-links --page-requisites --no-parent \
--user-agent="User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:32.0) Gecko/20100101 Firefox/32.0" \
−−directory−prefix="$DIR" \
"$URL"
@smj10j
smj10j / encode-mp3s.sh
Created October 1, 2016 11:42
Compresses mp3 files with lame
#!/bin/zsh
# http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html
# exec 4>&2 3>&1 2>&1 1>>$0.log
find . -regex '.*\.mp3$' -exec bash -c 'echo "{}" && lame --nohist --mp3input -V4 --vbr-new "{}" && rm "{}" && mv "{}.mp3" "{}"' \;
@smj10j
smj10j / fix-osx-openssh-7.3p1-sandbox-dir.sh
Last active October 13, 2016 15:59
Fix Sandbox Child Path on OSX for OpenSSH's sshd 7.3p1
#!/bin/bash
#
# Patch for error message:
# ssh_sandbox_child: sandbox_init: @PREFIX@/share/openssh/org.openssh.sshd.sb: profile not found [preauth]
#
# Fix based on https://github.com/Homebrew/homebrew-dupes/issues/641
#
set -e
@smj10j
smj10j / adhoc-port-redirector.command
Created August 26, 2016 04:02
Redirects local ports on the fly
ROUTER="ncat --sh-exec 'ncat $(sudo route -n get default -interface utun0 | sed -nre 's/.*?gateway: (.*?)$/\1/p') 7200' \
--wait 30 \
--output ncat-forward-tcp.dump \
--verbose \
--listen 10020 "
pids=""
CMD=$(echo ${ROUTER}{'& ; pids="$pids $!"; ','--udp & ; pids="$pids $!"; '})
@smj10j
smj10j / build-and-install-squid4.command
Last active August 23, 2016 17:33
Fetches, builds, and installs the Squid4 proxy on Ubuntu/Debian
#!/bin/bash
set -e
set +x
wget http://www.squid-cache.org/Versions/v4/squid-4.0.13.tar.gz
tar -xvzf squid*
cd squid*
prefix=/usr
@smj10j
smj10j / build-and-install-squid4.command
Created August 23, 2016 17:31
Fetches, builds, and installs the Squid4 proxy on Ubuntu/Debian
#!/bin/bash
set -e
set +x
#wget http://www.squid-cache.org/Versions/v4/squid-4.0.13.tar.gz
#tar -xvzf squid*
#cd squid*
prefix=/usr
@smj10j
smj10j / dnsmasq-status.command
Last active August 23, 2016 13:07
Get dnsmasq cache status
#!/usr/bin/env bash
# activate debugging
#set -x
# fail on any errors
set -e
# OSX
tac <(sudo killall -SIGUSR1 dnsmasq && tac /usr/local/var/log/dnsmasq/dnsmasq.log | grep -m1 -B1000 ": time ")