Skip to content

Instantly share code, notes, and snippets.

View afresh1's full-sized avatar

Andrew Hewus Fresh afresh1

View GitHub Profile
@afresh1
afresh1 / s5-to-pdf
Last active October 23, 2024 03:29
Convert an [s5](https://meyerweb.com/eric/tools/s5/) slideshow to PDF with images of the actual slides.
#!/usr/bin/perl
use v5.36;
use Firefox::Marionette;
use File::Copy qw< cp >;
use MIME::Base64 qw< encode_base64 >;
my $url = 'https://cvs.afresh1.com/~andrew/talks/2024-EuroBSDcon/';
my $firefox = Firefox::Marionette->new( visible => 1 );
@afresh1
afresh1 / ips_in_range
Last active December 24, 2023 01:07
A simple IPv4 calculator. Takes an IP and netmask and calculates some details about the network in ksh.
#!/bin/ksh
set -o errexit -o pipefail -o nounset -o noclobber -o noglob
set +o monitor
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# Convert the IP to an integer so do calculations on it
dottedQuad2int() {
local IFS=.
local ip
set -A ip $* 0 0 0 0
@afresh1
afresh1 / agent-TWP-refactor.pl
Last active September 13, 2023 01:03
mwl posted a script on his blog (https://mwl.io/archives/23082) that seems to indicate that he actually runs it.
#!/usr/bin/env perl
use v5.16;
use warnings;
#manages the narcissistic bibliography MIB
#deploy as:
#rocommunity megadweeb 0.0.0.0/0 1.3.6.1.4.1.55030
#rocommunity6 megadweeb 0::/0 1.3.6.1.4.1.55030
#pass_persist .1.3.6.1.4.1.55030.1.1.1 /usr/local/scripts/persistwp.pl
@afresh1
afresh1 / workaround_vlan_trunk_bug.sh
Created February 26, 2023 20:15
A small shellscript to work around a FreeBSD bug (208910) that requires you to move the vlan onto an epair member of the bridge, not on the physical interface in the bridge.
#!/bin/sh
set -o errexit -o pipefail -o nounset -o noclobber -o noglob
# Copyright (c) 2023 Andrew Hewus Fresh <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
@afresh1
afresh1 / vmctl-ssh
Created May 4, 2022 02:46
Provide a helper to ssh into an OpenBSD vmm vm by name without knowing what IP vmm assigned. It doesn't allow scp or things like that, haven't figured out how yet.
#!/usr/bin/perl
use v5.30;
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
# Copyright (c) 2021 Andrew Hewus Fresh <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / force_rsync.sh
Created August 25, 2021 15:55
A script to use as an SSH ForceCommand that only lets root connect to run rsync in the way FreeNAS/TrueNAS does it.
#!/bin/sh
expect='rsync --server --sender -logDtprze.LsfxC . /'
dir="/${SSH_ORIGINAL_COMMAND#$expect}"
# Try without compression
if [ "$dir" = "/${SSH_ORIGINAL_COMMAND}" ]; then
expect='rsync --server --sender -logDtpre.LsfxC . /'
dir="/${SSH_ORIGINAL_COMMAND#$expect}"
fi
@afresh1
afresh1 / clean-dupes.pl
Last active December 22, 2021 22:08
A perl duplicate file finder based on size and hash. Uses only core perl modules.
#!/usr/bin/env perl
use v5.16;
use warnings;
#
# Copyright (c) 2021 Andrew Hewus Fresh <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.

I thought perhaps you might like to hear my somewhat unique perspective, although definitely not saying anything others haven't already said. My perspective comes from my three hats, as a perl hobbyist and CPAN author, the maintainer of /usr/bin/perl in OpenBSD, and as someone who has written perl professionally for just short of ten years (the fifteen before that I wrote more and more perl as a sysadmin).

Overall, I think the plan is excellent and hope it mostly moves forward. There's only one tiny issue that might keep me from coming along for the ride.

tl;dr: if the default, without concious indication of something else, for bin/perl is anything but a "best effort at perl5" I believe I, and many other people will be stuck on perl5 forever and never be able to use v7, or v8, or anything later.

First, I should probably explain what I mean by a "best effort perl5". It is the thing we have gotten from perl on code without "use v5;" specified, likely since perl 5 was first released. Most things work, s

@afresh1
afresh1 / dyndns-matches
Last active January 18, 2021 19:28
Some helpers to set dynamic dns on an OpenBSD firewall on namecheap.com. Usage is `dyndns-matches $interface $host $domain || namecheap-dyndns $host $domain` (with your namecheap dyndns password in /etc/namecheap-dyndns). Should be suitable for putting in cron.
#!/bin/sh
set -e
if=$1
host=$2
domain=$3
lastip="/tmp/dyndns-$host-$domain"
ttl=3600
@afresh1
afresh1 / vmctl-ssh
Last active December 22, 2021 22:10
A helper to look up the IP for and ssh into an OpenBSD vmd vm that uses the standard tap interface in a bridge setup. Lots of setups this won't work for, but the one where vmd provides the IP seems to work OK.
#!/usr/bin/perl
use v5.30;
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
# Copyright (c) 2021 Andrew Hewus Fresh <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any