Skip to content

Instantly share code, notes, and snippets.

@mrandri
mrandri / ipsec-monitor.sh
Created October 6, 2021 15:52 — forked from winhamwr/ipsec-monitor.sh
Script to check the status of ipsec tunnels and refresh them if they're down. This should be run from cron every minute. To add monitoring on a tunnel, add a commented-out `monitor` line with the IP and port to use for establishing connection status. eg. `#monitor 172.17.105.80 9898` Adapted from a script posted by user "c b" on Strongswan [issu…
#!/bin/bash
function main()
{
monitor_from_file $*
}
function monitor_vpn_ip_port()
{
local CONN_NAME=$1
@mrandri
mrandri / helm-cheatsheet.md
Created May 23, 2020 00:18 — forked from tuannvm/argo.md
#Helm #Kubernetes #cheatsheet, happy helming!
@mrandri
mrandri / youtube-dl.md
Created May 9, 2020 12:08
Using youtube-dl to download courses from Pluralsight

Download courses from learning sites with youtube-dl

You can download whole courses from an array of tutorial sites with the CLI tool youtube-dl. In the example further down I'm using my Pluralsight account to get videos from a course at their site. Here is a list of all supported sites that you can download from with this tool

The flags you have to supply may vary depending on which site you make a request to.

You can get a free 3 month trial to Pluralsight by signing up for free to Visual Studio Dev Essentials

Installation

@mrandri
mrandri / squid-xff-log.conf
Created May 25, 2019 18:58 — forked from alvarow/squid-xff-log.conf
Sets Squid Proxy to log IP address from X-Forwarded-For header instead of the real client ip address if the X-Forwarded-For header exists.
# Has XFF header with a value
acl has-xff req_header X-Forwarded-For ^(([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)|(\[([0-9a-f]+)?:([0-9a-f:]+)?:([0-9a-f]+|0-9\.]+)?\]))
# default logformat
logformat squid %ts.%03tu %6tr %>a %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt
# default logformat using XFF instead of client IP address
logformat squid-xff %ts.%03tu %6tr %{X-Forwarded-For}>h %Ss/%03>Hs %<st %rm %ru %[un %Sh/%<a %mt
@mrandri
mrandri / openssl-file-encrypt.sh
Created May 25, 2019 18:58 — forked from alvarow/openssl-file-encrypt.sh
Encrypts & Decrypts single files using OpenSSL
# Source it on .bash_profile
# run with "encrypt a.file" or "decrypt a.file.aes-128-cbc"
# You can adjust encryption cipher (say aes-256-cbc) to your needs
function encrypt() {
if [ $# -eq 0 ]; then
echo "Provide a filename to encrypt"
exit 1
fi
# SHA256 the given file
openssl dgst -sha256 "$1" > "$1.sha256"