#!/bin/bash _asciiart() { img2txt -W 1599 logo.png | ansifilter --html | tail -n +20 | head -n -3 | sed 's/>=/>/
/g' | tee logo.html
}
_aboutascii() {
	img2txt -W 1184 img/BASH.png | ansifilter --html | tail -n +20 | head -n -3 | sed 's/>=/>/
/g' | tee aboutascii.html
	echo  | tee -a aboutascii.html
	img2txt -W 1061 img/Go-Logo.png | ansifilter --html | tail -n +20 | head -n -3 | sed 's/>=/>/
/g' | tee -a aboutascii.html
}
_cats() {
awk -F',' '$4 == "TRUE" {print $14}' products.csv | sort | uniq -c | sort -nr | awk -F" " '{print$2$3$4$5$6$7$8$9$10}' | grep -v -e '^$'
}
_subcats() {
[[ -z "$1" ]] && awk -F',' '$4 == "TRUE" {print $15}' products.csv | sort | uniq -c | sort -nr | awk -F" " '{print$2$3$4$5$6$7$8$9$10}' | grep -v -e '^$' | while read _i ; do
_i=${_i#*' '}
_i=${_i//"¼"/"quarter-"}
_i=${_i//"½"/"half-"}
_i=${_i//"1/16"/"sixteenth-"}
_i=${_i//"%"/"-pct"}
_i=${_i//"  "/" "}
_i=${_i//" "/"-"}
_i=${_i//" "/"-"}
_i=${_i//"--"/"-"}
_i=${_i//"watt1"/"watt-1"}
_i=${_i//"watt5"/"watt-5"}
echo "${_i}"
done || CATEGORY=$1 awk -F',' '$4 == "TRUE" && $14 == ENVIRON["CATEGORY"] {print $15}' products.csv | sort | uniq -c | sort -nr | awk -F" " '{print$2$3$4$5$6$7$8$9$10}' | grep -v -e '^$' | while read _i ; do
_i=${_i#*' '}
_i=${_i//"¼"/"quarter-"}
_i=${_i//"½"/"half-"}
_i=${_i//"1/16"/"sixteenth-"}
_i=${_i//"%"/"-pct"}
_i=${_i//"  "/" "}
_i=${_i//" "/"-"}
_i=${_i//" "/"-"}
_i=${_i//"--"/"-"}
_i=${_i//"watt1"/"watt-1"}
_i=${_i//"watt5"/"watt-5"}
echo "${_i}"
done
}
_subcat() {
[[ "$1" == "" ]] && return
[[ "$2" == "" ]] &&	return
CATEGORY=$1 SUBCATEGORY=$2  awk -F',' '$4 == "TRUE" && $14 == ENVIRON["CATEGORY"] {print}' products.csv  | while IFS="," read 	_image1	_partno	_name	_enable	_price	_quantity	_shippable	_minorder	_maxorder	_defaultquantity	_stepquantity	_mfgpartno	_mfgname	_category	_subcategory	_location	_msrp	_cost	_type	_packagetype	_technology	_materials	_value	_valunit	_resistance	_resunit	_tolerance	_voltsrating	_ampsrating	_wattsrating	_temprating	_tempunit	_description1	_description2	_color1	_color2	_sourceinfo	_datasheet	_docs	_reference	_attributes	_year	_condition	_note	_warning	_cablelengthinches	_lengthinches	_widthinches	_heightinches	_weightlb	_weightoz ; do
_subcategory=${_subcategory//"¼"/"quarter-"}
_subcategory=${_subcategory//"½"/"half-"}
_subcategory=${_subcategory//"1/16"/"sixteenth-"}
_subcategory=${_subcategory//"%"/"-pct"}
_subcategory=${_subcategory//"  "/" "}
_subcategory=${_subcategory//" "/"-"}
_subcategory=${_subcategory//" "/"-"}
_subcategory=${_subcategory//"--"/"-"}
_subcategory=${_subcategory//"watt1"/"watt-1"}
_subcategory=${_subcategory//"watt5"/"watt-5"}
[[ "${_subcategory}" != "$2" ]] && continue
[[ "${_category}" != "" ]] && _category="${_category}/"

echo "
${_name}

$(echo ${_name} | ansifilter -w 100 --html |tail -n +20 | head -n -3)
Read More
Price: \$${_price}
In stock: ${_quantity}
partno: ${_partno}

" done } _cat() { [[ $1 != "" ]] && CATEGORY=$1 awk -F ',' '$4 == "TRUE" && $14 ~ ENVIRON["CATEGORY"] {print}' products.csv | while IFS="," read _image1 _partno _name _enable _price _quantity _shippable _minorder _maxorder _defaultquantity _stepquantity _mfgpartno _mfgname _category _subcategory _location _msrp _cost _type _packagetype _technology _materials _value _valunit _resistance _resunit _tolerance _voltsrating _ampsrating _wattsrating _temprating _tempunit _description1 _description2 _color1 _color2 _sourceinfo _datasheet _docs _reference _attributes _year _condition _note _warning _cablelengthinches _lengthinches _widthinches _heightinches _weightlb _weightoz ; do [[ "${_category}" != "" ]] && _category="${_category}/" echo "
${_name}

$(echo ${_name} | ansifilter -w 100 --html |tail -n +20 | head -n -3)
Read More
Price: \$${_price}
In stock: ${_quantity}
partno: ${_partno}

" done } _prod() { [[ $1 != "" ]] && PRODUCT=$1 awk -F ',' '$4 == "TRUE" && $2 ~ ENVIRON["PRODUCT"] {print}' products.csv | head -n1 | while IFS="," read _image1 _partno _name _enable _price _quantity _shippable _minorder _maxorder _defaultquantity _stepquantity _mfgpartno _mfgname _category _subcategory _location _msrp _cost _type _packagetype _technology _materials _value _valunit _resistance _resunit _tolerance _voltsrating _ampsrating _wattsrating _temprating _tempunit _description1 _description2 _color1 _color2 _sourceinfo _datasheet _docs _reference _attributes _year _condition _note _warning _cablelengthinches _lengthinches _widthinches _heightinches _weightlb _weightoz ; do [[ "${_category}" != "" ]] && _category="${_category}/" echo "${_name}
$(echo ${_name} | ansifilter -w 100 --html |tail -n +20 | head -n -3) $([[ "${_description1}" != *"${_name}"* ]] && echo ${_description1} | ansifilter -w 100 --html |tail -n +20 | head -n -3)
Price: \$${_price}
In stock: ${_quantity}
partno: ${_partno}
" || true [[ "${_mfgname}" != "" ]] && echo "
Brand: ${_mfgname}
" || true [[ "${_mfgpartno}" != "" ]] && echo "
MPN: ${_mfgpartno}
" || true [[ "${_category}" != "" ]] && echo "
Category: ${_category/'/'}
" || true _subcategorylink=${_subcategory//"¼"/"quarter-"} _subcategorylink=${_subcategorylink//"½"/"half-"} _subcategorylink=${_subcategorylink//"1/16"/"sixteenth-"} _subcategorylink=${_subcategorylink//"%"/"-pct"} _subcategorylink=${_subcategorylink//" "/" "} _subcategorylink=${_subcategorylink//" "/"-"} _subcategorylink=${_subcategorylink//" "/"-"} _subcategorylink=${_subcategorylink//"--"/"-"} _subcategorylink=${_subcategorylink//"watt1"/"watt-1"} _subcategorylink=${_subcategorylink//"watt5"/"watt-5"} [[ "${_subcategory}" != "" ]] && echo "
Subcategory: ${_subcategory}
" || true [[ "${_voltsrating}" != '0' ]] && [[ "${_voltsrating}" != '0.0' ]] && [[ "${_voltsrating}" != '' ]] && echo -n "
Voltage: " && echo "${_voltsrating}
" || true [[ "${_val}" != '0' ]] && [[ "${_val}" != '0.0' ]] && [[ "${_val}" != '' ]] && echo -n "
Value: " && echo #"${_val}${_valunit}
" || true [[ "${_ampsrating}" != '0' ]] && [[ "${_ampsrating}" != '0.0' ]] && [[ "${_ampsrating}" != '' ]] && echo "
Amperage: ${_ampsrating}
" || true [[ "${_tolerance}" != '0' ]] && [[ "${_tolerance}" != '0' ]] && [[ "${_tolerance}" != '' ]] && echo "
Tolerance: $(echo "scale=2; ${_tolerance} * 100.0" | bc)%
" || true [[ "${_type}" != "" ]] && echo "
Type: ${_type}
" || true [[ "${_packagetype}" != "" ]] && echo "
Package Type: ${_packagetype}
" || true [[ "${_technology}" != "" ]] && echo "
Technology: ${_technology}
" || true [[ "${_materials}" != "" ]] && echo "
Materials: ${_materials}
" || true [[ "${_wattsrating}" != '0' ]] && [[ "${_wattsrating}" != '0.0' ]] && [[ "${_wattsrating}" != '' ]] && echo "
watts rating: ${_wattsrating}
" || true [[ "${_year}" != "0" ]] && [[ "${_year}" != "" ]] && echo "
Year: ${_year}
" || true [[ "${_cablelength}" != '0' ]] && [[ "${_cablelength}" != '0.0' ]] && [[ "${_cablelength}" != '' ]] && echo "
Cable Length: ${_cableLength}inches
" || true [[ "${_weightoz}" != '0' ]] && echo "
Weight: ${_weightoz}oz
" || true [[ "${_temprating}" != '0' ]] && echo "
Temp rating: ${_temprating}
" || true [[ "${_condition}" != "" ]] && echo "
Condition: ${_condition}
" || true [[ "${_datasheet}" != "" ]] && echo "
Datasheet: ${_datasheet}
" || true [[ "${_docs}" != "" ]] && echo "
Documentation: ${_docs}
" || true [[ "${_note}" != "" ]] && echo "
Note: ${_note}
" || true [[ "${_warning}" != "" ]] && echo "
Warning: ${_warning}
" || true [[ "${_description2}" != "" ]] && echo "
Additional Description: ${_description2}
" || true done } _prodhead() { [[ $1 != "" ]] && PRODUCT=$1 awk -F ',' '$4 == "TRUE" && $2 ~ ENVIRON["PRODUCT"] {print}' products.csv | head -n1 | while IFS="," read _image1 _partno _name _enable _price _quantity _shippable _minorder _maxorder _defaultquantity _stepquantity _mfgpartno _mfgname _category _subcategory _location _msrp _cost _type _packagetype _technology _materials _value _valunit _resistance _resunit _tolerance _voltsrating _ampsrating _wattsrating _temprating _tempunit _description1 _description2 _color1 _color2 _sourceinfo _datasheet _docs _reference _attributes _year _condition _note _warning _cablelengthinches _lengthinches _widthinches _heightinches _weightlb _weightoz ; do echo -n "magnetosphere electronic surplus | partno: $_partno" echo -n "" || true echo "" done } _prods() { awk -F ',' '$4 == "TRUE" {print $2}' products.csv } _catslinks() { awk -F',' '$4 == "TRUE" {print $14}' products.csv | sort | uniq -c | sort -nr | while read _i ; do echo "
${_i%' '*} ${_i#*' '}
" done } _subcatslinks() { [[ $1 != "" ]] && CATEGORY=$1 awk -F ',' '$4 == "TRUE" && $14 ~ ENVIRON["CATEGORY"] {print $15}' products.csv | grep -v -e '^$'| sort | uniq -c | sort -nr | while read _i ; do echo -n "
${_i%%' '*} "
_link=${_i#*' '}
_link=${_link//"¼"/"quarter-"}
_link=${_link//"½"/"half-"}
_link=${_link//"1/16"/"sixteenth-"}
_link=${_link//"%"/"-pct"}
_link=${_link//"  "/" "}
_link=${_link//" "/"-"}
_link=${_link//" "/"-"}
_link=${_link//"--"/"-"}
_link=${_link//"watt1"/"watt-1"}
_link=${_link//"watt5"/"watt-5"}
echo "${_i#*' '}
" done } _sitemapxml() { _update="$(date +%Y-%m-%d)" echo " " _cats | while read _category ; do echo " https://magnetosphere.net/cat/${_category} ${_update} daily 0.8 " _subcats ${_category} | while read _subcategory ; do echo " https://magnetosphere.net/cat/${_category}/${_subcategory} ${_update} daily 0.8 " done done awk -F ',' '$4 == "TRUE" {print $2}' products.csv | while read _partno ; do echo " https://magnetosphere.net/p/${_partno} ${_update} daily 0.8 " done echo "" } _yearcalendar() { seq 01 12 | while read -r _month ; do unbuffer cal --color "$_month" "$(date +%Y)" | ansifilter --html | tail -n +20 | head -n -3 ; done | tee } _rainbowcal() { unbuffer cal --color | lolcat -f -F '0.5' | ansifilter --html | tail -n +20 | head -n -3 } _skywireclihelp() { unbuffer skywire-cli --help | ansifilter --html | tail -n +20 | head -n -3 | tee } _dayscalc() { printf 'There are %s days in the month of %s.\n' "$(cal "$(date +%m)" "$(date +%Y)" | awk 'NF {DAYS = $NF}; END {print DAYS}')" "$(date +%B)" printf 'Today is %s %s.\n' "$(date +%B)" "$(date +%d)" printf '%s days remain in the month of %s.\n' "$(echo "$(cal "$(date +%m)" "$(date +%Y)" | awk 'NF {DAYS = $NF}; END {print DAYS}')" - "$(date +%d)" | bc -l)" "$(date +%B)" printf '%s days in the year %s.\n' "$(seq 01 12 | while read -r _month ; do cal "$_month" "$(date +%Y)" | awk 'NF {DAYS = $NF}; END {print DAYS}' ; done | paste -sd+ | bc -l)" "$(date +%Y)" printf 'Today is day %s.\n' "$(date +%j)" printf 'There are %s days remaining in %s\n' "$(echo "$(echo "$(date --date="January 1 next year" +%s)" - "$(date +%s)" | bc -l)" / 60 / 60 / 24 | bc)" "$(date +%Y)" }