Skip to content

Instantly share code, notes, and snippets.

View bmatthewshea's full-sized avatar

Brady Shea bmatthewshea

View GitHub Profile
@bmatthewshea
bmatthewshea / whattomine-hashtimes.py
Last active January 11, 2024 05:55
Python script to calculate time to win full block and revenue per day. (GPU MINING)
#!/usr/bin/python
# -*- coding: utf-8 -*-
# "Whattomine GPU Hash time calculator"
#
# This is not for CPU or ASIC calculations.
# Author: Brady Shea
# Email: Use github user: bmatthewshea or gist comments
# Origin: https://gist.github.com/bmatthewshea/90b120722e0561dd235adcdc231b6765
#
@bmatthewshea
bmatthewshea / backup-sqlexpress-db.cmd
Last active April 7, 2018 13:16
SQLExpress simple CMD backup
:: sqlcmd command mostly taken from https://stackoverflow.com/questions/880487/sql-server-command-line-backup-statement
@echo off
setlocal EnableExtensions EnableDelayedExpansion
set DATABASENAME=MyDatabase
set SERVERNAME=MYSERVER
set HOME=C:\Users\Administrator\Documents\Backup and Logs
call :dotimestamp
set BACKUPFILENAME=D:\SQLExpress-Backups\%DATABASENAME%-%TIMESTAMP%.bak
set LOGFILE=backup-sqlexpress-%DATABASENAME%.log
@bmatthewshea
bmatthewshea / .bash_prompt
Last active September 23, 2018 17:54
BASH prompt function / color prompt with time
# add this to end of ~/.bashrc:
# if [ -f ~/.bash_prompt ]; then
# . ~/.bash_prompt
# fi
# prompt function
function myprompt {
local BLUE="\[\033[0;34m\]"
local LIGHT_BLUE="\[\033[1;34m\]"
local RED="\[\033[0;31m\]"
@bmatthewshea
bmatthewshea / boot-space-watcher.sh
Created December 6, 2018 17:29
Watch the space on /boot
#!/bin/sh
# Use level (80 = 80% used)
alertlevel=80
# /boot = sda2
drivewarning="/dev/sda2"
df -H | grep -vE '^Filesystem|tmpfs|cdrom|udev|cgmfs' | awk '{ print $5 " " $1 " " $6}' | while read output;
do
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
@bmatthewshea
bmatthewshea / show_ssl_expire
Last active March 1, 2023 22:13
Retrieve/Check SSL certificate expiration date(s)
#!/bin/bash
# By B Shea Dec2018 & Mar2020
# https://www.holylinux.net
# Test for OpenSSL - if not installed stop here.
if ! [[ -x $(which openssl) ]]; then
printf "\nOpenSSL not found or not executable.\nPlease install OpenSSL before proceeding.\n\n"
exit 1
fi
@bmatthewshea
bmatthewshea / - postfix-geoip.pl
Last active July 29, 2024 12:14
Postfix GeoIP Blocking
#!/usr/bin/perl
# Brady Shea Feb 25 2019
# starting point:
# http://web.archive.org/web/20151128083440/https://www.kutukupret.com/2011/05/29/postfix-geoip-based-rejections/
use strict;
use warnings;
use Sys::Syslog qw(:DEFAULT setlogsock);
use Geo::IP;
use Regexp::Common;
@bmatthewshea
bmatthewshea / create-vhost-redirects-site.conf.sh
Last active April 22, 2019 20:59
Create Apache redirects sites file from file list of subdomains
#!/bin/bash
inputfile=./subdomains-list.txt
outputfile=./my-apache.conf
host_names=""
# start fresh
if [ -a "$outputfile" ]
then
rm $outputfile
@bmatthewshea
bmatthewshea / sonicwall-exp2text.py
Last active May 9, 2019 02:13
Convert EXP SonicWall Settings File to Windows Text
#!/usr/bin/python
# -*- coding: utf-8 -*-
# "Convert Sonicwall Settings EXP to Windows TXT"
# Author: Brady Shea
# Email: Use github user: bmatthewshea or gist comments
# Origin: https://gist.github.com/bmatthewshea/c038a0d38ce8804ac6eae39ae8f814f3
#
# If this script helps you, please consider a small donation!
#
@bmatthewshea
bmatthewshea / just port 80
Last active June 10, 2019 15:54
Sample redirect from apache
<VirtualHost *:80>
ServerName domain.com
ServerAlias *.domain.com *.www.domain.com
ErrorLog ${APACHE_LOG_DIR}/domain.com-error.log
CustomLog ${APACHE_LOG_DIR}/domain.com-access.log common
Redirect 301 / https://www.domain.com/
</VirtualHost>
<VirtualHost *:443>
ServerName www.domain.com
ServerAlias *.domain.com *.www.domain.com
@bmatthewshea
bmatthewshea / show-repos.sh
Created June 23, 2019 13:24
Show all APT repositories in use.
#!/bin/bash
# https://askubuntu.com/a/924587/169878
echo
echo "APT Repositories In Use"
echo
echo "Please wait while I update apt command.."
echo
sudo apt update > /dev/null 2>&1 && \
echo "Current repositores:" && \
sudo apt-cache policy | grep http | awk '{print $2 $3}' | sort -u