Skip to content

Instantly share code, notes, and snippets.

Prepare datasets

Zero files

#!/bin/bash
set -euo pipefail

mkdir zero
for i in {1..1000000}; do
@calebcase
calebcase / cert-check
Created August 8, 2018 12:40
Basic check of domain's certificate status.
#!/bin/bash
set -euo pipefail
name=${1?You must set the DNS name to check.}
host=${2:-$1}
port=${3:-443}
# https://www.shellhacks.com/openssl-check-ssl-certificate-expiration-date/
echo | openssl s_client -servername "$name" -connect "$host":"$port" 2>/dev/null | openssl x509 -noout -subject -issuer -startdate -enddate -ocsp_uri -fingerprint -sha256
[alias]
# Checkout a pull request branch on an upstream project. It
# handles PRs that get rebased as well.
#
# git pr 3
pr = "!f() { git checkout master; git branch -D pr/$1 || true; git fetch origin refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
# Pull a rebasing branch on a fork. Useful for viewing someones
# rebasing feature branch from a clone of their fork.
pbr = "!f() { b=$(git rev-parse --abbrev-ref HEAD); git fetch origin $b && git reset --hard origin/$b; }; f"
@calebcase
calebcase / gpg2-fingerprint
Created March 14, 2018 15:43
GPG Fingerprint
#!/bin/bash
set -euo pipefail
needle=${1?You must provide an name or email to search for.}
gpg2 --list-keys --fingerprint "$needle" |
grep 'Key fingerprint = ' |
sed -r 's/Key fingerprint = (.+)$/\1/' |
tr -d ' '
unset SSH_AGENT_PID
export SSH_AUTH_SOCK=/home/ccase/.gnupg/S.gpg-agent.ssh
cat > ~/.gnupg/gpg-agent.conf <<EOF
enable-ssh-support
default-cache-ttl 15
max-cache-ttl 15
default-cache-ttl-ssh 15
max-cache-ttl-ssh 15
EOF
alias rust='docker run -it --rm --user "$(id -u):$(id -g)" --net=host -v "$(pwd)":"/home/$USER" --workdir="/home/$USER" -e HOME="/home/$USER" -e USER="$USER" rust:latest'
cd ~/some-rust-project
rust cargo run
alias haskell='docker run -it --rm --user "$(id -u):$(id -g)" --net=host -v "$(pwd)":"/home/$USER" --workdir="/home/$USER" -e HOME="/home/$USER" -e USER="$USER" haskell:8'
cd ~/some-haskell-project
haskell cabal update
haskell cabal build

Let's go faster and just use the pre-built stuff in a docker container:

alias haskell='docker run -it --rm --user "$(id -u):$(id -g)" --net=host -v "$(pwd)":"/home/$USER" --workdir="/home/$USER" -e HOME="/home/$USER" haskell:8'

Pull down the most recent cabal index:

haskell cabal update
@calebcase
calebcase / token
Created February 2, 2018 20:03
Script for fetching yubikey oauth tokens.
#!/bin/bash
set -euo pipefail
query=${1:-amazon}
# Shut down other users of the smart card (otherwise we can't use it).
pkill scdaemon || true
if [[ -f ~/.token ]]; then
last=$(<~/.token)
#!/bin/bash
set -euo pipefail
domain=$1
ciphers=$(openssl ciphers | tr ':' ' ')
for cipher in $ciphers; do
if openssl s_client -servername "$domain" -connect "$domain":443 -cipher "$cipher" <<<'' &>/dev/null; then
printf '%s ok\n' "$cipher"
else