Skip to content

Instantly share code, notes, and snippets.

Avatar

Brady Shea bmatthewshea

View GitHub Profile
@bmatthewshea
bmatthewshea / Collatz_Conjecture_Example.py
Last active Aug 17, 2021
Collatz Conjecture (Python Example)
View Collatz_Conjecture_Example.py
#!/usr/bin/python
#
# Collatz Conjecture:
# x → x/2 (if x is even)
# x → 3x + 1 (if x is odd)
import sys, time
# Default seed if no arguments given
seed = 27
@bmatthewshea
bmatthewshea / site_up_down.py
Last active Aug 5, 2021
Python script that does checks on apex domains from a text file. Checks status for bare apex / "www." subdomains and ssl / non-ssl. (4 checks on each domain). Outputs in CSV format.
View site_up_down.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
## Brady Shea - 04AUG2021 - (Python 3 script)
## This will read in a file list of plain APEX domains like:
## "example.com"
## If you want it in a file just pipe the script to a file.
## python3 -u ./sites-up-down.py | tee ./domain-check.csv
import requests
@bmatthewshea
bmatthewshea / copy-folders-filelist.cmd
Last active Apr 28, 2021
Copy/recurse folders/files using a text file. CMD / BATCH
View copy-folders-filelist.cmd
@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 Apr 9, 2021
Show data used by top level folders using fast FSO approach
View show-folder-sizes-fast.ps1
# 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 Dec 10, 2020
Spamassassin/SpamD Installation Guide - Ubuntu/Debian
View spamassassin-ubuntu20.md

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 Jun 20, 2021
Ubuntu-Debian APT upgrade script
View system_update.sh
#!/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 Aug 13, 2020
Cardano/ADA Node startup script
View start-ada-blocks.sh
#!/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 Jun 3, 2020
Sound activated recording using SOX
View sox-vox.sh
#!/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 Mar 15, 2020
BASH script that uses 'whois' to lookup ASN number and display all IP4 CIDR associated to it.
View whois-asn-ip
#!/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 Apr 14, 2020
Web.config - IIS - AWS/EC2 REWRITE - Rewrite APEX, NON-WWW & NON-SSL - Catchall
View web.config___.xml
<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" />