Skip to content

Instantly share code, notes, and snippets.

View divergentdave's full-sized avatar

David Cook divergentdave

  • Minneapolis, MN
View GitHub Profile
@divergentdave
divergentdave / .gitignore
Last active May 26, 2020 13:30
Inheritance with PLY (Python Lex-Yacc)
*.pyc
@divergentdave
divergentdave / crate-diff.sh
Last active December 4, 2020 01:22
Diff between two crate versions
#!/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 / post-receive
Created December 26, 2020 23:03
NearlyFreeSpeech.net Jekyll post-receive git hook
#!/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 / Demographics.ipynb
Created May 29, 2021 03:58
ACS population demographics
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@divergentdave
divergentdave / Minneapolis Mean Center of Population 2000.ipynb
Last active November 18, 2021 00:49
Minneapolis Mean Center of Population
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@divergentdave
divergentdave / Example.java
Last active April 26, 2022 08:13
Ignoring Expired TLS Certificates in Java
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
@divergentdave
divergentdave / poker.py
Last active August 25, 2022 23:15
Solving logic puzzles with Z3
#!/usr/bin/env python3
from z3 import (
Solver,
Function,
EnumSort,
IntSort,
Const,
Distinct,
And,
Or,
@divergentdave
divergentdave / recover_pubkey.py
Last active December 9, 2022 05:15
Recover an RSA public key from its signatures
#!/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 / Uninsurance Spells.ipynb
Created March 19, 2023 00:41
Health insurance rates over time from SIPP data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@divergentdave
divergentdave / .gitignore
Last active November 27, 2023 22:31 — forked from ooovi/generate_test_vectors.py
A script to generate test vectors for the discrete gaussian sampler using seeded randomness from TurboSHAKE128
__pycache__
/test_vec