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 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
@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 / 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 / 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 / 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 / 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 / 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 / verify_self_signed_key.py
Created March 19, 2018 01:57
Verify a self signed certificate's signature
#!/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 November 23, 2018 17:05
Calendar time zone check - Google Apps Script
// 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