Skip to content

Instantly share code, notes, and snippets.


Josh Enders joshenders

View GitHub Profile
joshenders /
Last active Jan 14, 2019
Simple Bash function to visualize PKI chain-of-trust
function certchain() {
# Usage: certchain
# Display PKI chain-of-trust for a given domain
# GistID:
if [[ "$#" -ne 1 ]]; then
echo "Usage: ${FUNCNAME} <ip|domain[:port]>"
return 1
local host_port="$1"
joshenders /
Created Dec 14, 2015
YAML syntax checker
function ylint() {
if [[ "$#" -ne 1 ]]; then
echo "Usage: ${FUNCNAME} <infile>"
return 1
ruby -e "require 'yaml'; YAML.load_file('$1')"
joshenders /
Last active Feb 6, 2021
mitmproxy configuration for iPad

Successful mitmproxy-3.7 setup tested on OS X 10.13.6 and iPhone X running 12.1.4

Enable IP forwarding and disable ICMP redirects to keep the iPad sending traffic to the proxy

sudo sysctl -w net.inet.ip.forwarding=1
sudo sysctl -w net.inet.ip.redirect=0

Enable IP forwarding between interfaces

joshenders /
Last active Dec 17, 2020
Poor man's smokeping for OS X
# This script uses the BSD variants of commands and is intended to
# be run on an unmodified installation of OSX.
pmset noidle &
now=$(date +%s)
duration=$((86400*3)) # 3days
View gist:1e80d260047687ab6132
jenders@jenders-mba threadedfractals :) $ make
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o utils.o utils.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 pngify.c utils.o -o pngify -lz
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 resample.c utils.o -o resample
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 render.c utils.o -o render -lm
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 palette.c utils.o -o palette -lm
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o circularlist.o circularlist.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o loader.o loader.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 -c -o mapper.o mapper.c
cc -Ofast -Wall -Wextra -Wshadow -Werror -ansi -pedantic -std=c99 threaded.c circularlist.o loader.o mapper.o utils.o -o threaded -lm -lpthread -ldl
View bash word splitting issue
$ var=$(echo ' ab')
$ echo $var
$ echo $var | xxd
0000000: 6162 0a ab.
$ if [[ "$var" =~ ^a ]]; then echo match; else echo not match; fi
not match
$ var=$(echo 'ab')
$ echo $var | xxd
joshenders /
Last active Jan 5, 2016
ddrescue recovery script
function exit_with_usage() {
# usage: exit_with_usage
echo "Usage: ${0##*/} <src> <dest>" >&2
exit 1
function prompt() {
View gist:10ee8cd1c240b38b2dfe
if a1 and a2:
# Answers from both servers, compare rrsets
if a1 != a2:
header(args.ns1_name, ns1_port, args.ns2_name, ns2_port)
removed(a1, color=args.color_flag)
added(a2, color=args.color_flag)
# else:
# # Records both exist and match
# pass
elif a1 and not a2:
View dns_diff.txt
In [90]: str(r0.answer[0])
Out[90]: ' 60 IN A\ 60 IN A\ 60 IN A\ 60 IN A\ 60 IN A\ 60 IN A\ 60 IN A\ 60 IN A'
In [91]: str(r1.answer[0])
Out[91]: ' 60 IN A\ 60 IN A\ 60 IN A\ 60 IN A\ 60 IN A\ 60 IN A\ 60 IN A\ 60 IN A'
In [92]: if str(r0.answer[0]) == str(r1.answer[0]):
print('No problem')
View gist:bcf44e6dfba37e317793
(dnsdiff)jenders@collaris/pts/0: dnsdiff $ ./ --help
usage: [-h] -f FILENAME --from-ns NAMESERVER1 --to-ns NAMESERVER2
optional arguments:
-h, --help Show this help message and exit
-f FILENAME, --filename FILENAME
File containing resource records to verify. File is
expected to be a valid zone master file as described
--from-ns NAMESERVER1