Skip to content

Instantly share code, notes, and snippets.

@kckrinke
kckrinke / .htaccess
Created February 28, 2019 17:17
.htaccess tester
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^htaccess_tester.php.*
RewriteRule ^.*$ htaccess_tester.php [L]
</IfModule>
ErrorDocument 404 /htaccess_tester.php
@kckrinke
kckrinke / WireGuard.md
Last active July 1, 2018 17:43
WireGuard for Edge Routers

This guide assumes the following:

  • the Local Net IP range is 10.0.0.0/24
  • the WireGuard IP range is 10.0.1.0/24
  • router is the IP address of the edgemax router
  • user is the admin username on the edgemax router
  • PEER_PUBLIC_KEY was generated already

install wireguard on an android device

Use F-Droid, install the WireGuard app like any other

@kckrinke
kckrinke / switch-window-screen.pl
Last active September 23, 2017 21:05
Switch the active window to an opposing monitor. Bind to keyboard combo for full usefulness (such as <Super>+<Enter>). Depends upon the following programs: wmctrl xdpyinfo xrandr xprop xwininfo xdotool. Works with Qubes-OS - copy to dom0 and then you can bind to a keyboard combo.
#!/usr/bin/env perl
###############################################################################
# switch-window-screen - Move active window to the opposite monitor.
#
# Inspired by:
# https://chaosprevails7707.wordpress.com/2015/07/15/xfce-move-window-to-next-
# monitor-with-vertical-and-horizontal-setup/
#
# The MIT License (MIT)
#
@kckrinke
kckrinke / ssh-profile
Created August 18, 2017 06:41
CLI for listing, viewing profiles and modifying ~/.ssh/config
#!/usr/bin/env perl
use strict;
use warnings;
use diagnostics;
use Getopt::Long;
use Pod::Usage;
use constant {true=>1,false=>0};
our $SSH_CONFIG_PATH = $ENV{'HOME'} . '/.ssh/config';
my $usage = false;
@kckrinke
kckrinke / qvm-expose-port
Last active June 14, 2018 03:50
Expose a Qubes AppVM port to the public networks.
#!/usr/bin/env perl
use strict;
use warnings;
use Pod::Usage;
use IPC::Open3;
use Getopt::Long;
use File::Basename;
use constant { True => 1, False => 0 };
use Symbol 'gensym';
$|=1; #unbuffered
@kckrinke
kckrinke / git-whoami.sh
Created March 24, 2017 03:20
Just in case you wanted to know who GIT thinks you are...
#!/bin/bash
MODE_SHOW=short
SHOW_MAIL=1
SHOW_NAME=1
while [ $# -gt 0 ]
do
case "$1" in
"-h"|"--help")
@kckrinke
kckrinke / fullpath.sh
Created March 24, 2017 03:11
Yes I know realpath exists, but it's not installed by default and sometimes it's easier to tuck a script somewhere convenient...
#!/bin/bash
###############################################################################
# fullpath.sh - Find the absolute path to the given file or directory.
#
# updated: 2017-03-23
# created: 2005-05-25
# author: Kevin C. Krinke <kevin@krinke.ca>
# license: LGPL-2.1
###############################################################################
@kckrinke
kckrinke / black_perl-520.pl
Created February 7, 2017 16:38
My take on Larry Wall's classic work of art; the Black Perl poem. Parses and runs with perl v5.20.
#!/usr/bin/env perl
no warnings;
BEFOREHAND: close door, each window & exit; wait until time.
open spellbook, study, read (scan, $elect, tell us);
write it, print the hex while each watches,
reverse its, length, write, again;
kill spiders, pop them, chop, split, kill them.
unlink arms, shift, wait & listen (listening, wait),
sort the flock (then, warn "the goats" & kill "the sheep");
@kckrinke
kckrinke / grep-src.sh
Last active November 9, 2016 22:27
Like the find-src.sh script but greps the files found via find-src.sh mechanics.
#!/bin/bash
usage() {
while [ $# -gt 0 ]; do echo "$1"; shift; done
echo "usage: $(basename $0) [options] <PATTERN> [path ...]"
echo "options:"
echo " -? This usage information screen"
echo " -N Dry run, just print command"
echo " -t Explicit source file extn"
echo " -i Case-insensitive (egrep)"
@kckrinke
kckrinke / find-src.sh
Last active November 9, 2016 21:07
Conveniently find source code files (based on file extensions).
#!/bin/bash
usage() {
while [ $# -gt 0 ]; do echo "$1"; shift; done
echo "usage: $(basename $0) [options] [path ...]"
echo "options:"
echo " -h This usage information screen"
echo " -n Dry run, just print command"
echo " -t Explicit source file extn"
echo