Testing Mathjax
$$E = mc^2$$
$v = 1/2 mv^2$
Testing Prism
Displaying Python code:
def hello():
print("Hello, Prism!")
Displaying C++ code:
#include \
using namespace std;
int main() {
cout << "Hello, Prism!" << endl;
}
Display of nnkill Bash script:
The nnkill scripts terminate processes by name, not by process number. It will show you a list of one or more processes that match the name and ask if you want to terminate them.
#!/bin/sh
if [ "$1" == "-y" ]; then
yn="y"
shift
echo "1 = $1"
else
yn="u"
fi
#echo "yn = $yn and arg1 = $1"
clear
echo "[....] NNKILL Matching Processes: $1"
echo "[....]"
ps aux | grep $1 | awk '$0 !~ /grep|nkill/ {for(i=3;i<11; i++) { $i=""; }; print "[....] " $0; }'
if [ "$yn" == "u" ]; then
echo ""
echo "ENTER y to terminate processes -- else ENTER n to break (yn=$yn)"
read yn
fi
if [ "$yn" == "y" ]; then
echo "[....]"
echo "[....] Terminating ALL $1 processes..."
echo "[....]"
ps aux | grep -i $1 | awk '$0 !~ /grep|nkill/ {print "[....] " $0; system("kill -9 " $2 " >/dev/null"); print "[....] Process " $2 " terminated..."}'
fi
Displaying the Logview AWK script:
The logview AWK script displays a colorized version of a log4j or log4c log file. It makes it easier to spot RED errors in a given run.
Logview utilizes ASCII terminal codes to change text color.
NOTE: It is commonly used in conjunction with the Linux less command.
$$ logview | less
#!/usr/bin/awk -f
###
# The LOGVIEW script pretty prints application logs to the system console
# coloring the log for readability.
#
# Syntax:
#
# logview
#
# -- Jim McArdle, ARL:UT June 2011
#
##
BEGIN {
# reset the colors back to default screen colors
colorReset=0
# text color for the start of a log4j line
prefixColor = 35 # color me MAGENTA
# log4j coloring based on severity of log4j error code:
fatalColor = 31; fatalBgnd = 45 # color me RED on YELLOW background
errorColor = 31; errorBgnd = 40 # color me RED on screen background
warnColor = 33; warnBgnd = 40 # color me YELLOW on screen background
infoColor = 32; infoBgnd = 40 # color me GREEN on screen background
debugColor = 36; debugBgnd = 40 # color me CYAN on screen background
traceColor = 34; traceBgnd = 40 # color me BLUE on screen background
noteColor = 35; noteBgnd = 40
passColor = 36; passBgnd = 40
# flag for MAVEN specific output set by finding text "Scanning for projects"
scanningMavenOutput = 0
# maven build stats keyed to BUILD SUCCESSFUL and BUILD FAILURE
mavenProjectsBuilt=0
mavenProjectsFailed=0
}
/Scanning for projects/ { scanningMavenOutput=1; print CS() CF(passColor) $0; next }
/BUILD FAILURE/ { mavenProjectsFailed = mavenProjectsFailed + 1 }
/BUILD SUCCESSFUL/ { mavenProjectsBuilt = mavenProjectsBuilt + 1 }
/at edu.utexas.arlut/ { sub(/edu.utexas.arlut/, CF(noteColor) "edu.utexas.arlut"); sub(/\(/, CF(debugColor) "(") }
#/[^\[]*FATAL/ { sub(/FATAL/,"[FATAL]") }
/FATAL/ {
sub(/.?FATAL.?]/,CC(fatalColor,fatalBgnd) "[FATAL]")
print CF(prefixColor) $0 CF(colorReset)
next
}
#/[^\[]*ERROR/ { sub(/ERROR/,"[ERROR]") }
/ERROR/ {
sub(/.?ERROR.?]/,CF(errorColor) "[ERROR]")
print CF(prefixColor) $0 CF(colorReset)
next
}
#/[^\[]*WARN/ { sub(/WARN/,"[WARN]") }
/WARN/ {
sub(/.?WARN.?/,CF(warnColor) "[WARN]")
print CF(prefixColor) $0 CF(colorReset)
next
}
#/[^\[]*INFO/ { sub(/INFO/,"[INFO]") }
/INFO/ {
sub(/.?INFO.?/,CF(infoColor) "[INFO]")
# maven specific message adjustments
if (scanningMavenOutput > 0) {
sub(/Compilation failure/, CF(errorColor) "Compilation failure")
sub(/Building/, CF(noteColor) "Building")
sub(/Installing/, CF(noteColor) "Installing")
sub(/BUILD SUCCESSFUL/, CF(passColor) "BUILD SUCCESSFUL")
}
print CF(prefixColor) $0 CF(colorReset)
next
}
#/[^\[]*DEBUG/ { sub(/DEBUG/,"[DEBUG]") }
/DEBUG/ {
sub(/.?DEBUG.?/,CC(debugColor,debugBgnd) "[DEBUG]")
print CF(prefixColor) $0 CF(colorReset)
next
}
#/[^\[]TRACE/ { sub(/TRACE/,"[TRACE]") }
/TRACE/ {
sub(/.?TRACE.?/,CC(traceColor,traceBgnd) "[TRACE]")
print CF(prefixColor) $0 CF(colorReset)
next
}
/^\// { print CF(noteColor) $0 CF(colorReset); next }
{
# print non log4j textlines in the default screen colors
print CF(colorReset) $0 CF(colorReset)
next
}
END {
if(scanningMavenOutput > 0) {
print ""
print CF(passColor) "###############################################" CF(colorReset)
print CF(passColor) "#### ####" CF(colorReset)
print CF(passColor) "#### Maven Projects built: " mavenProjectsBuilt " ####" CF(colorReset)
print CF(passColor) "#### ####" CF(colorReset)
failColor=passColor
if(mavenProjectsFailed > 0) failColor=31
print CF(passColor) "#### " CF(failColor) "Maven Projects failed: " mavenProjectsFailed CF(passColor) " ####" CF(colorReset)
print CF(passColor) "#### ####" CF(colorReset)
print CF(passColor) "###############################################" CF(colorReset)
print ""
print ""
}
}
## -------------------------------------------------------------------
#
# CC/CF/CP/CS Use ANSI screen codes to set color, position, or clear screen
#
## Description:
#
# CC changes to foreground/background color attributes
# CF changes the foreground color only
# CP changes the cursor positioning
# CS clears the screen
#
## Usage:
#
# # changes the text to red (background the same), clears the screen and position the cursor at 0,0
# print CF(31) CS() CP(0,0)
#
# # in general CC doesn't work well since the trailing space background color is not changed
# print CC(37,40)
#
# # CF(0) resets the XTERM color scheme to the original colors
#
## Notes:
#
# BLK RED GRN YEL BLU MAG CYA WHI
# ===== ===== ===== ===== ===== ===== ===== =====
# 30/40 31/41 32/42 33/43 34/44 35/45 36/46 37/47
###
function CC(fg,bg) { return "\x1b[1;" fg ";" bg "m" }
function CF(fg) { return "\x1b[1;" fg "m" }
function CP(row,col) { return "\x1b[" row ";" col "f" }
function CS() { return "\x1b[2J" CP(0,0) }