Skip to content

Instantly share code, notes, and snippets.


Jason Riddle jason-riddle

View GitHub Profile
jason-riddle / custom-error.js
Created Jul 11, 2020 — forked from justmoon/custom-error.js
Creating custom Error classes in Node.js
View custom-error.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor); =;
this.message = message;
this.extra = extra;
require('util').inherits(module.exports, Error);
jason-riddle /
Last active Oct 22, 2019
Examples using keytool #keytool
# List certs in keystore
keytool -list -v -keystore /etc/ssl/certs/java/cacerts
# Grep for a specific certificate
echo -n 'changeit' | keytool -list -keystore /etc/ssl/certs/java/cacerts 2>/dev/null | grep -B1 -i 01:18
jason-riddle /
Last active Oct 21, 2019
Convert dmesg timestamps to UTC format
# Translate dmesg timestamps to human readable format
# desired date format
# [ 3.469072] EXT4-fs (xvda1): mounted filesystem with ordered data mode. Opts: (null)
# [ 3.483769] dracut: Remounting /dev/disk/by-label/\x2f with -o noatime,ro
# [ 3.495019] EXT4-fs (xvda1): mounted filesystem with ordered data mode. Opts: (null)
# [ 3.506417] dracut: Mounted root filesystem /dev/xvda1
jason-riddle /
Created Oct 21, 2019
Examples for Curl #snippet #complete
# Robust curl command to retry, timeout, and save the output to a file
curl --silent --show-error \
--location --max-redirs 3 \
--retry 3 --retry-connrefused --retry-delay 2 \
--max-time 30 \
jason-riddle / gist:d2bf6de8b25a70c05a6570232da9d0c9
Last active Oct 21, 2019
Snippet using tcpdump to listen on an http port #snippet #complete
View gist:d2bf6de8b25a70c05a6570232da9d0c9
# Ref:
# Ref:
HTTP_FILTER="(((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)"
tcpdump -i any -s 0 -A "tcp port $HTTP_PORT and $HTTP_FILTER"
jason-riddle /
Last active Oct 21, 2019
Snippet to keep idle ssh connection busy to avoid disconnecting #snippet #complete
# !/usr/bin/env bash
while :; do sleep 59; echo -n ' ' >&2; done &
jason-riddle /
Last active Oct 21, 2019
Interview Practice #interviewing #complete
#!/usr/bin/env python3
I have an ordered historical list of daily prices of quizlet coin - the hot new cryptocurrency.
[100, 50, 120, 100, 300, 250, 1]
What is the best profit I could have made from 1 purchase and 1 sale of Quizlet Coin?
cryptsetup luksOpen /dev/nvme0n1p2 cryptkey
cryptsetup luksOpen --key-file=/dev/mapper/cryptkey /dev/nvme0n1p3 cryptswap
cryptsetup luksOpen --key-file=/dev/mapper/cryptkey /dev/nvme0n1p4 cryptroot
Then for a not fun bit, matching entries in =/dev/disk/by-uuid/= to
the partitions we want to mount where. Running ~ls -l
/dev/disk/by-uuid/~ shows which devices have which UUIDs. To determine
what =dm-1= and =dm2=, I ran ~ls -la /dev/mapper~:
jason-riddle /
Last active Oct 21, 2019
Guide using Jshell to query CPU and memory information within a docker container #jvm #guide #complete
#!/usr/bin/env bash
# Ref:
set -eu
JSHELL_CMD=(/bin/sh -c 'jshell -q')
You can’t perform that action at this time.