Skip to content

Instantly share code, notes, and snippets.

@Mr920
Mr920 / parse-access-log.sh
Created May 30, 2015 03:06
Makes your default access_log look much more beautiful
#! /bin/bash
URL_SIZE='160';
USER_AGENT_SIZE='142';
REFERER_URL_SIZE='142';
US="${URL_SIZE}";
UAS="${USER_AGENT_SIZE}";
RUS="${REFERER_URL_SIZE}";
@Mr920
Mr920 / gen-gist-url-list.sh
Created December 6, 2014 22:25
Generate Gist URL List
#! /bin/bash
if [[ -z "${1}" ]]; then
read -p "Please Enter your github/gist username: " GIST_USER
else
GIST_USER="${1}";
fi
cat <<EOF | bash -s
curl --include "https://gist.github.com/${GIST_USER}/" 2>/dev/null | grep -Eo 'href="/${GIST_USER}/[^"]*"' | grep -vi forks | grep -vi comments | grep -vi stars | grep -vi forked | grep -vi starred | sort -u | sed -r -e 's/href="/https:\/\/gist.githubusercontent.com/g' -e 's/"$/\/raw\//g'
@Mr920
Mr920 / ansi-escape-reminder-automated.sh
Created November 27, 2014 10:18
A *slightly* cleaner version of ansi-escape-reminder
#! /bin/bash
USSAGE_STATEMENT=$(echo -e "\nUssage:\n\t${0} verbal"\
"\n\t${0} verbal no-color"\
"\n\n\t${0} enviroment-variables"\
"\n\t${0} enviroment-variables make-active"\
"\n\t${0} enviroment-variables make-permanent")
ANSI_ACTIONS=("NORMAL" "BOLD" "UNDERLINE" "BLINK" "REVERSE_VIDEO" "NONDISPLAYED"\
"BLACK" "RED" "GREEN" "YELLOW" "BLUE" "MAGENTA" "CYAN" "WHITE"\
@Mr920
Mr920 / ansi-escape-reminder.sh
Last active August 29, 2015 14:10
ANSI Color Escape Reminder Script
#! /bin/bash
USSAGE_STATEMENT=$(echo -e "\nUssage:\n\t${0} verbal\n\t${0} verbal no-color\n\n\t${0} enviroment-variables\n\t${0} enviroment-variables make-active\n\t${0} enviroment-variables make-permanent")
if [[ ! -z "${2}" ]] && [[ "${2}" == "no-color" ]]; then
NORMAL=''
BOLD=''
UNDERLINE=''
BLINK=''
REVERSE_VIDEO=''
@Mr920
Mr920 / edit_iframe_source.js
Created November 13, 2014 06:14
[old] Files to revive my custom implementation of the ACE editor
function getRequestForEditor(){
var encodedURIVar=document.getElementById('urlinput').value;
var prefixURIString="./engine.html?content-type=".concat(document.getElementById('selContentType').value).concat("&theme=").concat(document.getElementById('selTheme').value).concat('&url=');
var requestURIVar=prefixURIString.concat(encodedURIVar);
document.getElementById('editorIframe').src=requestURIVar;
}
@Mr920
Mr920 / Log_Engine.bash
Last active August 29, 2015 14:09
[old] Apache Access Log Custom Formatting Script.
#! /bin/bash
cat /etc/apache2/logs/access_log | sed -r -e 's/\s/\t/g' \
-e 's/\t-\t-\t\[/\t\t\t/g' \
-e 's/\t\t\t(..)\/(...)\/(....):(..):(..):(..)\t-...../\t\t\t\2 \1, \3\t\4:\5/g' \
-e 's/\t.*\t\t\t/\t\t/g' \
-e 's/"\t.*//g' \
-e 's/\t"/\t\t/g' \
-e 's/HTTP\/1.1//g' \
-e 's/HTTP\/1.0//g' \
-e 's/(..:..)(\t\t)/\1\2\t/g' | grep -vi "POST\|PUT\|HEAD" | sed -r -e 's/^/<div class="Meta">/g' \
@Mr920
Mr920 / audit.log file viewer
Created October 28, 2014 05:30
audit.log file viewer
#! /bin/bash
while read line;
do echo "${line}" | sed -r -e 's/(\S*)\s*(msg=audit[^)]*[)][:]).*/\n\1\n\2/g' && echo "${line}" | sed -r -e 's/\S*\s*msg=audit[^)]*[)][:](.*)msg[=].*/\1/g' | sed -r -e 's/ /\n\t/g' && echo "${line}" | sed -r -e "s/.*(msg=')[ ]?/\1\n/g" | sed -r -e 's/^/ /g' -e "s/'//g" | sed -r -e 's/[ ]/\n\t\t/g'; done <<<"$(cat /var/log/audit/audit.log)" 2>/dev/null | sed -r -e '/^\s*$/d' -e 's/type/\n&/g'
# This script just makes /var/log/audit/audit.log slightly easier to look at.
# But nothing fancy. Also note this thing is pretty slow because i'm inefficient
# At scripting sometimes.
@Mr920
Mr920 / List firewall-cmd options (centos 7)
Last active August 29, 2015 14:08
List firewall-cmd options (centos 7)
#! /bin/bash
cat /usr/share/bash-completion/completions/firewall-cmd | grep -v '^#' | tr '\n' '\r' | sed -r -e 's/[\]\r//g' | tr '\r' '\n' | grep -Eio '^[a-z_]*[=]{1}["][^"]*["]{1}' | sed -r -e 's/[=]["]/&\n/g' -e 's/["]$/\n&/g' | grep -v '"' | sed -r -e 's/\s/\n/g' | sed -r -e '/^\s*$/d' | grep -v '${'
#! /bin/bash
userinput="";
while [ "$userinput" != "exit" ]
do
echo -e -n "\e[1;32myoutube-dl: \e[1;36m" && read userinput;
if [ "$userinput" == "exit" ]
then
break;
fi
@Mr920
Mr920 / docker thing
Last active August 29, 2015 14:06
Barebones Docker/LinuxContainer That You Can Actually Get Into
yum install docker-io
docker pull centos
docker run centos bash -c 'yum install -y openssh-server openssl passwd && echo "docker" | passwd --stdin root && /usr/bin/ssh-keygen -A && echo -e "\n\n##################\nPlease run:\n\nssh root@$(ip addr show | grep -Eio "inet [^/]*" | grep -Eio "[0-9.]*" | grep -v "127.0.0.1")\n\nand type \"docker\" as your password\n##################\n\n" && /usr/sbin/sshd -D' & disown