Skip to content

Instantly share code, notes, and snippets.

View philpennock's full-sized avatar

Phil Pennock philpennock

View GitHub Profile
// this is C99
// compile: gcc -std=c99 -ggdb -O3 -Wall guarded_memory_alloc_test.c
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@philpennock
philpennock / go-bindata.txt.asc
Created February 8, 2018 21:17
Public attestation of state witnessing regarding a Go repository ownership change
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I am Phil Pennock, I program in Go. I am writing this text on 2018-02-08.
It should be found PGP-signed from a key in the strong-set, so that this
public attestation can be verified by others.
To the best of my knowledge, I am in no way affiliated with whomever has
registered the new "jteeuwen" GitHub account.
@philpennock
philpennock / aws-vault__login.py
Last active February 28, 2018 00:57
aws-vault only runs subcommands, there's no API for other languages to use, short of running them _under_ aws-vault. Here's a workaround for Python (3.6+)
def login():
if not shutil.which('aws-vault'):
return boto3.Session()
if 'AWS_SESSION_TOKEN' in os.environ:
return boto3.Session()
if 'AWS_ACCESS_KEY_ID' in os.environ and 'AWS_SECRET_ACCESS_KEY' in os.environ:
return boto3.Session()
profile=os.environ.get('AWS_PROFILE', 'default')
rc = subprocess.run(['aws-vault', 'exec', profile, '--', 'python', '-c',
'import json,os; print(json.dumps({k:os.environ[k] for k in os.environ if k.startswith("AWS_")}))'],
@philpennock
philpennock / div.vim
Last active March 14, 2018 04:51
vimscript for a :Div command, taking a range
if has("eval")
" Insert a divider
" Start and end are line numbers.
" Sep is ordinarily the string of characters which make up the divider, but
" if the first and third characters (not bytes) are period, then the second
" character is a single-character line prefix and the third character
" onwards is the divider.
function! s:pdp_div(start, end, sep, ...) range
let l:label = a:0 >= 1 ? join(a:000, ' ') : 'cut here'
if strwidth(a:sep) >= 4 && a:sep[0] == '.' && strcharpart(a:sep, 2, 1) == '.'
#!/usr/bin/env python3
import sys
import time
def foo():
print('ni')
time.sleep(0.1)
pass
@philpennock
philpennock / SKS Privacy
Created July 13, 2018 18:26
sks.spodhuis.org Privacy text, pre-termination
Privacy
There are three categories of data relevant to privacy here: the public keys stored; the HTTP/HKP requests made to access/upload/retrieve those keys; what I as a keyserver operator might do with those requests (logs).
For the public keys: the SKS keyserver pool, run globally by disparate individuals with no formal affiliation, is currently an append-only store, designed to protect against attempts to remove data. Once a key has been uploaded, that data is part of the public record, designed to allow anyone to attempt to verify the name binding within the key, using the public attestations by others about the identity of the key (key signatures). Keys not intended for public disclosure should not be uploaded, nor shared to people who might upload the keys of others. Note that there's no protection against fraudulent keys, with bindings of any name to any email address, and there is no basis to believe any such pairing without first proceeding through evaluation of the public attestations.
The reques
@philpennock
philpennock / perlgssapi-code_GSSAPI_fix-macOS-heimdal.patch
Created July 24, 2018 21:28
perlgssapi GSSAPI module patch to fix compilation on macOS
Index: GSSAPI.xs
===================================================================
--- GSSAPI.xs (revision 73)
+++ GSSAPI.xs (working copy)
@@ -6,6 +6,8 @@
#define __GSS_KRB5_NT_PRINCIPAL_NAME &mygss_nt_krb5_principal
#define __gss_mech_krb5_v2 &mygss_mech_krb5_v2
+#define GSSKRB_APPLE_DEPRECATED(x) /**/
+
@philpennock
philpennock / aws
Created February 27, 2018 00:55
shim script for aws to use aws-vault as needed
#!/bin/sh -eu
aws=/usr/local/bin/aws
die() { printf >&2 '%s: %s\n' "$0" "$*"; exit 1; }
if ! [ -x "$aws" ]; then
case $0 in
/*) ;;
*) die "missing '${aws}' and not invoked with absolute path to skip self" ;;
@philpennock
philpennock / sh-subshell-errexit-test.sh
Created May 19, 2015 20:37
Shell sucks; tried in bash, zsh, BSD sh
#!/bin/bash
script_name="$(basename "$0")"
die() {
local rv=$?
printf >&2 "%s: %s\n" "$script_name" "$*"
exit $rv
}

GnuPG Packaging

A few items here assume zsh as shell (globs and expansion modifiers, print -l).

Required installation order:

Previously recorded:
gmp nettle gnutls npth libgpg-error libgcrypt libksba libassuan  ( pinentry , gnupg )