Skip to content

Instantly share code, notes, and snippets.

Avatar

David Cook divergentdave

View GitHub Profile
@divergentdave
divergentdave / Demographics.ipynb
Created May 29, 2021
ACS population demographics
View Demographics.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@divergentdave
divergentdave / post-receive
Created Dec 26, 2020
NearlyFreeSpeech.net Jekyll post-receive git hook
View post-receive
#!/bin/bash
REPONAME='davidsherenowitsa.party'
export GEM_HOME=/home/protected/gems
PATH=$PATH:/home/protected/gems/bin
GIT_REPO=$HOME/$REPONAME.git
TMP_GIT_CLONE=$HOME/tmp_clone/$REPONAME
TMP_OUTPUT=$HOME/tmp_output/$REPONAME
PUBLIC_WWW=/home/public
@divergentdave
divergentdave / crate-diff.sh
Last active Dec 4, 2020
Diff between two crate versions
View crate-diff.sh
#!/usr/bin/env bash
set -e
CRATES_IO_REGISTRY="$HOME/.cargo/registry/src/github.com-1ecc6299db9ec823"
display_usage() {
echo "Usage: crate-diff.sh CRATE_NAME OLD_VERSION NEW_VERSION"
}
if [ $# -ne 3 ]
@divergentdave
divergentdave / poker.py
Last active Apr 20, 2021
Solving logic puzzles with Z3
View poker.py
#!/usr/bin/env python3
from z3 import (
Solver,
Function,
EnumSort,
IntSort,
Const,
Distinct,
And,
Or,
@divergentdave
divergentdave / recover_pubkey.py
Last active Sep 27, 2020
Recover an RSA public key from its signatures
View recover_pubkey.py
#!/usr/bin/env python3
"""
This script recovers the RSA public key that was used to make signatures, given
any two such signatures in X.509 certificates. Python 3 is required, along with
recent versions of pyasn1, pyasn1-modules, and pyprimes. Runtime is nearly
instantaneous when the public key uses e=3, and 3+ hours when the public key
uses e=65537. (This could be vastly improved by using a more efficient GCD
library function) To recover a public key, run this script with the file names
of two certificates as command line arguments. Certificates can be in PEM or
DER format.
@divergentdave
divergentdave / verify_self_signed_key.py
Created Mar 19, 2018
Verify a self signed certificate's signature
View verify_self_signed_key.py
#!/usr/bin/env python3
"""
This script verifies whether a given X.509 certificate is self-signed, while
ignorng the subject and issuer distinguished names. Python 3 is required,
along with recent versions of pyasn1 and pyasn1-modules. To check a
certificate, run this script with the file name of that certificate as a
command line argument. Certificates can be in PEM or DER format. Only RSA
signatures are supported.
To verify whether a certificate is self-signed, this script parses the
@divergentdave
divergentdave / Code.gs
Last active Nov 23, 2018
Calendar time zone check - Google Apps Script
View Code.gs
// This script checks for Google Calendar events with non-default
// time zones, and sends an email whenever it finds one.
// Usage:
// 1. Create a new Google Docs spreadsheet
// 2. Click on Tools -> Script editor...
// 3. In the script editor, click on Resources -> Advanced Google services...
// 4. Click on the enable toggle for "Calendar API", and use the default name "Calendar"
// 5. Click on the "Google API Console" link in the Advanced Google Services dialog box
// 6. In the Google API Console, click on the link to "View All" APIs
@divergentdave
divergentdave / .gitignore
Last active May 26, 2020
Inheritance with PLY (Python Lex-Yacc)
View Deduplicated Cisco Umbrella 1 Million.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View ig_charsets.sh
#!/bin/sh
set -e
jq -r '.[] | .homepage_url | select(. != null)' ~/oversight.garden/config/inspectors.json | while IFS= read -r line
do
echo $line
curl -ikL $line | (grep -i charset= || true)
echo
done