Skip to content

Instantly share code, notes, and snippets.

Phil Pennock philpennock

Block or report user

Report or block philpennock

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@philpennock
philpennock / admin.py
Created Jan 28, 2018
Passwords/admin to manage the passwords repo. You'll need to update `DEFAULT_IDENTITY` at the very least.
View admin.py
#!/usr/bin/env python3
"""
admin: Passwords repo admin tool
Passwords repo has a bunch of actions which are common; copy/paste is
annoying. So manage the common actions.
"""
__author__ = 'phil.pennock@spodhuis.org (Phil Pennock)'
@philpennock
philpennock / freebsd-whois.patch
Created Aug 17, 2017
Fix FreeBSD's whois to handle Verisign whois referral change
View freebsd-whois.patch
--- usr.bin/whois/whois.c.orig 2017-08-17 14:00:08.917506928 -0400
+++ usr.bin/whois/whois.c 2017-08-17 14:00:28.975792449 -0400
@@ -76,7 +76,7 @@
#define GERMNICHOST "de.whois-servers.net"
#define FNICHOST "whois.afrinic.net"
#define DEFAULT_PORT "whois"
-#define WHOIS_SERVER_ID "Whois Server: "
+#define WHOIS_SERVER_ID "Registrar WHOIS Server: "
#define WHOIS_ORG_SERVER_ID "Registrant Street1:Whois Server:"
@philpennock
philpennock / ps_byjail
Last active Aug 15, 2017
ps_byjail: ps(1) wrapper for FreeBSD, showing which jail each process is in
View ps_byjail
#!/usr/bin/env perl
use strict;
use warnings;
#ps axdro user,pid,ppid,pgid,jid,stat,time,%cpu,%mem,vsz,rss,command ::
# $F[2] is PPID
# 0 means in-kernel process, all "real" processes (except init) have a positive integer as PPID
# Skip those where parent is this script
# $F[1] is PID
# Skip this script
@philpennock
philpennock / S
Created Jul 3, 2017
screen/tmux wrapper script
View S
#!/bin/zsh -f
# TODO: systemd support
# systemd is transitioning to terminating processes when a user session ends,
# so we'll need to start a new scope.
#
# Launching the initial screen/tmux should be prefixed with:
# systemd-run --scope --user [$CMD...]
#
# This should go into plexer_new() as a contextual prefix.
View chromium_profiles_vacuum.sh
#!/bin/sh -eu
set -eu
clean_here() {
find . -type f -execdir sh -c \
'f="{}";
t=$(file -hb "$f");
[ "$t" = "SQLite 3.x database" ] || exit 1;
printf "%s/%s\n" "$(pwd)" "$f";
ls -ld 2>/dev/null "$f" "${f}-journal";
View packaging-gnupg.md

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 )
@philpennock
philpennock / update_mail_cdbs.pl
Last active Feb 27, 2017
An old script for building CDB files for Exim, registed as `bi_command` in exim.conf
View update_mail_cdbs.pl
#!/usr/bin/env perl
# BUG: "#" can not appear in a value
BEGIN { @INC = grep {$_ ne '.'} @INC };
use warnings;
use strict;
# XXX: make these overrideable with getopt, together with "rebuild all", etc.
my $flat_dir = '/etc/mail/flat';
@philpennock
philpennock / prompt-stuff.zsh
Created Feb 6, 2017
Extracts from 'prompt pdp' for SSH
View prompt-stuff.zsh
function prompt_query_ssh_status {
local suffix oIFS ss keycount
local -a keylines
if [[ -z ${SSH_AUTH_SOCK:-} ]]; then print "n/a"; return; fi
suffix=R
[[ -n ${SSH_AGENT_PID:-} ]] && suffix=L
if [[ $OSTYPE == darwin* ]]; then
case $SSH_AUTH_SOCK in
(/tmp/launch-*) suffix=D ;;
@philpennock
philpennock / dkim-generate.bash
Created Feb 5, 2017
DKIM key generation and DNS fragment generation script.
View dkim-generate.bash
#!/bin/bash -eu
# http://www.keylength.com/en/3/ -- ECRYPT II "smallest general purpose level"
# is 1248 bits symmetric; we're pretty stuck on RSA right now
: "${KEYSIZE_RSA:=1248}"
: "${DKIM_SIGN_DOMAINS_FILE:=/etc/exim/dkim/domains-mapping}"
: "${DATE:=$(date +%Y%m)}"
declare -r KEYSIZE_RSA DKIM_SIGN_DOMAINS_FILE DATE
View top-left-prompt.zsh
topleft="$(tput cup 0 0)"; nl="$(tput el)"$'\n'; invis="$(tput civis)"; vis="$(tput cvvis)"
push="$(tput sc)"; pop="$(tput rc)"
PS1="${topleft}%F{green}%D{%D %r}%f${nl}%~${nl}%# "
eval "TRAPUSR1() { print -Pn '${push}${invis}${topleft}%F{green}%D{%D %r}%f${nl}${pop}${vis}' }"
unset topleft nl invis vis push pop
p=$$; while sleep 1; do kill -s USR1 $p || exit; done &! unset p
# modified to do "|| exit" after the kill, so that if the kill fails, the child exits, so when parent dies, child will too.
# center-align version
You can’t perform that action at this time.