Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Fresh afresh1

View GitHub Profile
@afresh1
afresh1 / serve_this.sh
Last active Dec 1, 2021
A Mojolicious One Liner to serve static files from the current directory
View serve_this.sh
#!/bin/sh
exec perl -Mojo -E '$m=a("/");$m->static->paths(["."]);$m->start' daemon
@afresh1
afresh1 / drop_privileges_fcgi_app.psgi
Last active Jul 25, 2019
This is a proof of concept for an FCGI::ProcManager that will chroot into a directory and drop privileges for each child process.
View drop_privileges_fcgi_app.psgi
#!/usr/bin/env plackup -s FCGIDropPrivs
use strict;
use warnings;
my ($user, $group) = qw( nobody nogroup );
my $uid = getpwnam($user);
my $gid = getgrnam($group);
my $root = '/var/empty';
package Plack::Handler::FCGIDropPrivs;
@afresh1
afresh1 / tmux.rc
Created Jul 9, 2015
Start tmux on login. This would go in your kshrc or bashrc
View tmux.rc
if [ ! "$TMUX" ]; then
echo "Starting tmux . . ."
sleep 3
[ "$TERM" = "xterm" ] && TERM=xterm-256color
tmux -2 attach || tmux -2
exit
fi
@afresh1
afresh1 / reprove.pl
Last active Jun 29, 2016
This script watches your tests and your files and re-runs "prove" to help with perl TDD -- http://perldoc.perl.org/prove.html
View reprove.pl
#!/usr/bin/perl
# Copyright (c) 2015 Andrew 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.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@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 / icb_twitter_bot.pl
Created Feb 11, 2015
An ICB bot that watches for twitter URLs and fills out the text.
View icb_twitter_bot.pl
#!/usr/bin/perl
use strict;
use warnings;
# On OpenBSD, I have a port for p5-Bot-ICB and p5-Net-ICB
# pkg_add p5-Bot-ICB p5-LWP-Protocol-https p5-HTML-Tree p5-Text-Unidecode
use Bot::ICB;
use LWP::Simple;
use HTML::Tree;
@afresh1
afresh1 / openbsd_knf.perltidyrc
Created Jan 8, 2015
A perltidyrc that mostly seems to give me OpenBSD knf in my perl. While it isn't perfect it is certainly closer than what I normally use.
View openbsd_knf.perltidyrc
--indent-columns=8
--entab-leading-whitespace=8
--continuation-indentation=4
--cuddled-else
--opening-sub-brace-on-new-line
@afresh1
afresh1 / unifi.sh
Last active Jan 11, 2018
Command-line interface for the OpenBSD Ubiquiti [unifi port](http://ports.su/net/unifi)
View unifi.sh
#!/bin/sh
basename $0 |&
IFS=- read -p name cmd
if [ -z "$cmd" -a $# -gt 0 ]; then
cmd=$1
shift
fi
cmd=${cmd%svc}
@afresh1
afresh1 / reprove.pl
Created Nov 24, 2014
A script that checks for changed files and re-runs prove if they have changed.
View reprove.pl
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use File::Find;
my %options_that_take_arguments = map { $_ => 1 }
qw( I P M e exec harness formatter source a archive j jobs state rc );
@afresh1
afresh1 / lock_screen
Last active Aug 29, 2015
A set of scripts to lock my screen and turn off the laptop screen
View lock_screen
#!/bin/sh
if ! pgrep xlock >/dev/null 2>&1; then
xlock -lockdelay 0 -endCmd ssh-add &
sleep 1
fi
sudo -k
ssh-add -D