Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Fresh afresh1

View GitHub Profile
@afresh1
afresh1 / HTTP-Tiny-nc.pm
Last active Aug 19, 2022
A monkey patch to let perl's HTTP::Tiny to use the OpenBSD netcat with TLS support to access https sites without installing IO::Socket::SSL and Net::SSLeay.
View HTTP-Tiny-nc.pm
use v5.16;
use warnings;
package HTTP::Tiny::nc;
use parent 'HTTP::Tiny';
our $VERSION = v0.0.2;
# Copyright (c) 2019, 2020 Andrew Hewus Fresh <afresh1@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / vmctl-ssh
Created May 4, 2022
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.
View vmctl-ssh
#!/usr/bin/perl
use v5.30;
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
# Copyright (c) 2021 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / Installing_an_OpenBSD_VM_under_FreeNAS.md
Last active May 4, 2022
Installing OpenBSD in a bhyve VM under FreeNAS
View Installing_an_OpenBSD_VM_under_FreeNAS.md
@afresh1
afresh1 / tmup.sh
Created May 15, 2013
I use this in my .bashrc to update my shell environment from tmux
View tmup.sh
tmup () {
echo -n "Updating to latest tmux environment...";
local IFS=",";
for line in $(tmux showenv -t $(tmux display -p "#S") | tr "\n" ",");
do
if [[ $line == -* ]]; then
unset $(echo $line | cut -c2-);
else
export $line;
@afresh1
afresh1 / post_dmesg_to_nycbug.pl
Last active Dec 22, 2021
This script posts an OpenBSD dmesg to the NYC*BUG archive at http://www.nycbug.org/index.cgi?action=dmesgd
View post_dmesg_to_nycbug.pl
#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use feature 'signatures';
no warnings 'experimental::signatures';
use Sys::Hostname;
use HTTP::Tiny;
@afresh1
afresh1 / teetime
Last active Dec 22, 2021
A perl implementation of "tee" that prefixes each line to the teed file with a timestamp relative to the start of ths script.
View teetime
#!/usr/bin/perl
use strict;
use warnings;
use v5.10;
use Time::HiRes qw< gettimeofday tv_interval >;
# Copyright (c) 2020 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / tssh.sh
Last active Dec 22, 2021
A simple clusterssh clone to ssh into many machines at once in a single tmux session. Use `set synchronize-panes` to send commands to all panes at once.
View tssh.sh
#!/bin/sh
# tssh -- Andrew Fresh <andrew AT AFresh1.com>
set -e
if [ -z "$*" ]; then
echo "usage: tssh server1 [[[server2] server3] ...]"
exit 2
fi
new=""
@afresh1
afresh1 / fill-chroot.sh
Last active Dec 22, 2021
fill-chroot - Add files and their needed libs to a chroot directory
View fill-chroot.sh
#!/bin/sh
chroot=/var/www # ${PWD}
copy_recurse() {
file=$1
[ -e "${chroot}${file}" ] && return
mkdir -p $( dirname "${chroot}${file}" )
cp -p "$file" "${chroot}${file}"
@afresh1
afresh1 / vmctl-ssh
Last active Dec 22, 2021
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.
View vmctl-ssh
#!/usr/bin/perl
use v5.30;
use warnings;
use OpenBSD::Pledge;
use OpenBSD::Unveil;
# Copyright (c) 2021 Andrew Hewus Fresh <andrew@afresh1.com>
#
# Permission to use, copy, modify, and distribute this software for any
@afresh1
afresh1 / clean-dupes.pl
Last active Dec 22, 2021
A perl duplicate file finder based on size and hash. Uses only core perl modules.
View clean-dupes.pl
#!/usr/bin/env perl
use v5.16;
use warnings;
#
# Copyright (c) 2021 Andrew Hewus Fresh <andrew@afresh1.com>
#
# 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.