Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Fresh afresh1

View GitHub Profile
View acing-the-technical-interview.pl
use v5.24.0;
use warnings;
use feature 'signatures';
no warnings 'experimental::signatures';
# https://aphyr.com/posts/340-acing-the-technical-interview
sub true() { 1 }
sub false() { 0 }
@afresh1
afresh1 / plenv-install-latest.sh
Last active Sep 19, 2019
Installs the latest available of each release version of perl plus the latest development version with https://github.com/tokuhirom/plenv
View plenv-install-latest.sh
https://github.com/afresh1/dotfiles/blob/master/plenv/libexec/plenv-install-latest
@afresh1
afresh1 / start_inet6.sh
Last active May 8, 2020
Find the default IPv6 gateway and start forwarding traffic on OpenBSD and Comcast (XFinity)
View start_inet6.sh
#!/bin/sh
egress=$1
internal=$2
# This should set up ipv6 on XFinity or Comcast on OpenBSD 6.1
# Stop everything
/usr/bin/pkill dhcp6c
route -qn delete -inet6 default
ifconfig $egress -inet6
@afresh1
afresh1 / sysutils-rclone-Makefile
Created Mar 10, 2017
OpenBSD port Makefile for rclone
View sysutils-rclone-Makefile
# $OpenBSD$
COMMENT = rsync for cloud storage
GH_ACCOUNT = ncw
GH_PROJECT = rclone
GH_TAGNAME = v1.35
CATEGORIES = sysutils
View get_dns_blacklists.sh
#!/bin/sh
# "include: /var/unbound/etc/ad-blacklist.conf" in /var/unbound/etc/unbound.conf
# run script as daily cron
TMPFILE=$( mktemp get_dns_blacklists-XXXXXXXXX )
trap 'rm -f $TMPFILE; exit 1' EXIT KILL INT QUIT TERM
(
ftp -VM -o- https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts | grep ^0.0.0.0 | awk '{ print $2 }'
@afresh1
afresh1 / tssh.sh
Last active Apr 24, 2018
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 / c_rehash.sh
Last active Sep 22, 2016
This script replaces the c_rehash perl script from openssl, at least the main functionality of it. From http://man.openbsd.org/SSL_CTX_load_verify_locations
View c_rehash.sh
#!/bin/sh
# replaces the c_rehash perl script from openssl.
# by afresh1
rm -f *.[0-9]* *.r[0-9]*
for c in *.pem; do
[ "$c" = "*.pem" ] && continue
hash=$(openssl x509 -noout -hash -in "$c")
if egrep -q -- '-BEGIN( X509 | TRUSTED | )CERTIFICATE-' "$c"; then
suf=0
@afresh1
afresh1 / create_github_labels.js
Created Jun 4, 2016
Creates "Sane GitHub Labels", paste into the javascript console on the issue page for your project. https://medium.com/@dave_lunny/sane-github-labels-c5d2e6004b63
View create_github_labels.js
labels = [
{ "name": "Priority: Low", "color": "#009800" },
{ "name": "Priority: Medium", "color": "#fbca04" },
{ "name": "Priority: High", "color": "#eb6420" },
{ "name": "Priority: Critical", "color": "#e11d21" },
{ "name": "Status: Abandoned", "color": "#000000" },
{ "name": "Status: Accepted", "color": "#009800" },
{ "name": "Status: Available", "color": "#bfe5bf" },
{ "name": "Status: Blocked", "color": "#e11d21" },
{ "name": "Status: Completed", "color": "#006b75" },
@afresh1
afresh1 / lock_screen
Created May 15, 2016
Lock screen and dpms off monitor. I have `command lock "lock_screen"` in ~/.cwmrc and `*/5 * * * * $HOME/bin/monitors_off` in my crontab.
View lock_screen
#!/bin/sh
if ! pgrep xlock >/dev/null 2>&1; then
xlock -lockdelay 0 &
sleep 1
fi
sudo -k
ssh-add -D
@afresh1
afresh1 / wtf.cgi
Created Jan 20, 2016
This simple program displays an issue with either slowcgi or httpd. It appears that the headers end after the first read instead of after the first blank line.
View wtf.cgi
#!/usr/bin/perl
use strict;
use warnings;
$| = 1;
print "foo: bar\r\n" for 1 .. 15;
print "\r\n";
print "quux\r\n";