Skip to content

Instantly share code, notes, and snippets.

@carrgilson
carrgilson / weighted_dns_test.sh
Last active April 5, 2024 09:29
Weighted DNS Test
#!/bin/bash
(( FIFTEEN=0 ))
(( THIRTYTHREE=0 ))
(( FIFTYTWO=0 ))
DNSNAME="lbtest.cluster"
for i in $(seq 1 100)
do
@carrgilson
carrgilson / ping.sh
Created April 5, 2024 09:08
Ping Range
prefix="10.10.245"
for i in {192..203}
do
echo -ne "${prefix}.$i : "
ping -c 1 ${prefix}.$i > /dev/null
if [ $? -ne 0 ]
then echo ❌
else echo ✔️
fi
done
@carrgilson
carrgilson / colours.sh
Created June 1, 2023 13:24
Shell Colours
#!/bin/bash
# Reset
ColourOff='\e[0m' # Text Reset
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
@carrgilson
carrgilson / Microsoft Excel Formula - Formatted Bytes to Bytes
Last active April 12, 2023 16:49
Microsoft Excel Formula - Formatted Bytes to Bytes
=LET(
README_,"This formula converts a formatted byte count to a raw byte count",
README1,"Adjust the below [variable] definitions to your need, where the viable options are (bracketed)",
README2,"[cell] specify the individual cell address containing the byte count to format, this should be contained within double quotation marks",
README3,"[cell_style] define if you're using the R1C1 (rowcolumn) or the A1 (alphanumeric) cell reference style",
README4,"[unit_type] define if you want the resulting output calculated to a base 2 (binary) or base 10 (metric) value",
CONSTANTS,"Do not alter these",
@carrgilson
carrgilson / Microsoft Excel Formula - Bytes to Formatted Bytes
Last active March 28, 2023 10:13
Microsoft Excel Formula - Bytes to Formatted Bytes
=LET(
README_,"This formula formats a byte count, rounding it to its significant digit and to two decimal places, applying the appropriate unit of measurement",
README1,"Adjust the below [variable] definitions to your need, where the viable options are (bracketed)",
README2,"[cell] specify the individual cell address containing the byte count to format, this should be contained within double quotation marks",
README3,"[cell_style] define if you're using the R1C1 (rowcolumn) or the A1 (alphanumeric) cell reference style",
README4,"[unit_type] define if you want the resulting output calculated to a base 2 (binary) or base 10 (metric) value",
CONSTANTS,"Do not alter these",
@carrgilson
carrgilson / array_pretty_print.sh
Created October 26, 2021 13:07
Pretty Print Bash Array
for x in "${!ARRAY[@]}"; do printf "[%s]=%s\n" "$x" "${ARRAY[$x]}" ; done
#!/bin/bash
# saner programming env: these switches turn some bugs into errors
set -o errexit -o pipefail -o noclobber -o nounset
# -allow a command to fail with !’s side effect on errexit
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
! getopt --test > /dev/null
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
echo 'I’m sorry, `getopt --test` failed in this environment.'
exit 1
@carrgilson
carrgilson / script.sh
Last active January 3, 2023 11:24
WSL CentOS7 Setup
yum -y install openssh-server
yum -y install wget
yum -y install vim
yum -y install mlocate
yum -y groupinstall "Development Tools"
yum -y install epel-release
yum -y install centos-release-scl
yum -y install rh-python36 rh-git218
alias wget='wget --no-check-certificate'
@carrgilson
carrgilson / settings.json
Last active December 1, 2021 18:38
Microsoft Terminal Settings
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": ...,
"copyOnSelect": true,
@carrgilson
carrgilson / compile_tmux.sh
Created October 10, 2019 13:32
compile tmux from source and statically link with libevent + ncurses
#!/bin/bash -e
TMUX_VERSION=2.9
NCURSES_VERSION=6.1
LIBEVENT_VERSION=2.1.11
TARGETDIR=/opt/tmux_target
rm -rf $TARGETDIR
mkdir -p $TARGETDIR