Skip to content

Instantly share code, notes, and snippets.

View bmatthewshea's full-sized avatar

Brady Shea bmatthewshea

View GitHub Profile
@bmatthewshea
bmatthewshea / copy-folders-filelist.cmd
Last active April 28, 2021 15:27
Copy/recurse folders/files using a text file. CMD / BATCH
@ECHO off
SET FileList=.\pathlist.txt
SET LOGGING=.\robocopy-copy-logs
REM EDIT THESE TWO PATHS BEFORE RUNNING (NO QUOTES! NO TRAILING BACKSLASH!)
SET Source-Path=E:\folders-under-this-root-need-copying
SET Dest-Path=D:\folder-under-which-to-place-copied-folders-from-E
REM ** XCOPY WORKS **
@bmatthewshea
bmatthewshea / show-folder-sizes-fast.ps1
Last active April 9, 2021 13:41
Show data used by top level folders using fast FSO approach
# Default Path can be an argument - otherwise it defaults to CWD/Get-Location
# Script breaks on long filenames/path and "special" folders like C:\Users\User\Documents - needs work.
# Examples:
# ./show-folders-fast
# ./show-folders-fast "C:\Windows"
#
param([String]$folder = "$(Get-Location)")
$output_hash_table = @{}
$folder_count = (Get-ChildItem -Directory -EA 0 $folder | Measure-Object).count
@bmatthewshea
bmatthewshea / spamassassin-ubuntu20.md
Last active December 10, 2020 16:38
Spamassassin/SpamD Installation Guide - Ubuntu/Debian

Spamassassin/SpamD Installation Guide

Ubuntu 18/20 or comparable Debian dedicated server

amavisd-new

IMPORTANT: This article assumes you do not have amavisd-new installed/running on the same system.

The Ubuntu/Debian amavisd-new package already uses and suggests Spamassassin be installed. If you installed the amavisd-new package, SA was probably already installed and should not need much more tinkering.

Other than checking that the daily cron job is being run to refresh the SA rules (see below), this guide should not be needed. spamd from the Spamassassin package should NOT be a parent process if you are using amavisd-new, BUT should be installed (The spamassassin.service should not be enabled).

@bmatthewshea
bmatthewshea / system_update.sh
Last active December 8, 2023 16:24
Ubuntu-Debian APT upgrade script
#!/bin/bash
#
# Brady Shea - 18SEP2020 - conversion of system_update alias to bash script
# https://www.holylinux.net/
#
# Place this script in "/usr/local/sbin/system_update" or similar location under your $PATH
# It needs root permissions (SUDO) to execute.
#
# Change these settings to your liking:
#################################
@bmatthewshea
bmatthewshea / start-ada-blocks.sh
Last active September 6, 2022 21:37
Cardano/ADA Node startup script
#!/bin/bash
## Script to start a cardano "block producing"/"pool" node
## https://docs.cardano.org/projects/cardano-node/en/latest/stake-pool-operations/start_your_nodes.html
## Change "USER" to username needed below
# config area:
ada_bin_path=/home/USER/.local/bin
ada_config_path=/home/USER/.local/etc/cardano-node
ada_chain_path=/home/USER/cardano-blocks
ada_key_path=${ada_config_path}/keys
@bmatthewshea
bmatthewshea / sox-vox.sh
Created June 3, 2020 21:22
Sound activated recording using SOX
#!/bin/bash
tempfile1=/tmp/temp.mp3
# Baremetal/Realtek analog etc
AUDIODEV=hw:0,0
# Pi USB mic (usually):
# AUDIODEV=hw:1,0
set_filenames () {
NAME=`date +%Y-%m-%d_%H-%M-%S`
@bmatthewshea
bmatthewshea / whois-asn-ip
Last active March 11, 2024 09:41
BASH script that uses 'whois' to lookup ASN number and display all IP4 CIDR associated to it.
#!/bin/bash
# whois-asn-ip (bash script)
# By: Brady Shea - March 15th 2020
# https://www.holylinux.net
# https://gist.github.com/bmatthewshea/dc427f0c30b82429931d5896f548d550
# The whois server to use:
WHOISHOSTNAME=whois.ripe.net
# Uncomment to remove temp files
#DEL_TEMP=true
@bmatthewshea
bmatthewshea / web.config___.xml
Last active April 14, 2020 15:56
Web.config - IIS - AWS/EC2 REWRITE - Rewrite APEX, NON-WWW & NON-SSL - Catchall
<configuration>
<system.webServer>
...
<rewrite>
<rules>
<!-- To work, DNS subdomains must be wildcarded to this site. -->
<!-- Also, this first rule must be listening for all incoming requests/"default web server". -->
<!-- The first rule runs on anything that doesn't match "www.example.com". -->
<rule name="Catchall redirect to www" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
@bmatthewshea
bmatthewshea / geoip2lookup.bash
Last active December 4, 2023 20:59
GeoIP Lookup scripts for use with new Maxmind MMDB database files
#!/bin/bash
#
# By: Brady Shea - 10FEB2020 - Last update 04DEC2023
#
# Usage (ip4 only):
# geoip2lookup IP_ADDRESS
#
# ** Install GeoIP Tool and Updater **
#
# sudo add-apt-repository ppa:maxmind/ppa
@bmatthewshea
bmatthewshea / 99-unbound-custom.conf
Last active August 20, 2023 14:05
Unbound configuration file - Ubuntu 18.xx
## File location: /etc/unbound/unbound.conf.d/99-unbound-custom.conf (new file)
## I DO NOT USE UNBOUND.CONF - it can get overwritten.
# Logrotate needs this when using 'sharedscripts' command. You also need it to view stats afaik. Uses localhost only.
remote-control:
control-enable: yes
server:
access-control: 127.0.0.0/8 allow
access-control: 10.0.0.0/8 allow