Skip to content

Instantly share code, notes, and snippets.

View discarn8's full-sized avatar

discarn8 discarn8

View GitHub Profile
@discarn8
discarn8 / bash_history_backup.sh
Last active May 2, 2018 07:32
bash_history_backup.sh
#!/bin/sh
# This script creates daily backups of the root and user's bash history file. This backup
# is non-destructive.
# Typical usage in a bash profile:
#
# Forked from https://lukas.zapletalovi.com/2013/03/never-lost-your-bash-history-again.html
#
# How many lines do you want to save?
KEEP=1000
@discarn8
discarn8 / hdd_temp_shutdown_with_log.sh
Created May 2, 2018 07:52
hdd_temp_shutdown_with_log.sh
#!/bin/bash
HDDS="/dev/sda /dev/sdb /dev/sdc"
HDT=/usr/sbin/hddtemp
LOG=/usr/bin/logger
DOWN=/sbin/shutdown
ALERT_LEVEL=55
for disk in $HDDS
do
if [ -b $disk ]; then
HDTEMP=$($HDT $disk | awk '{ print $4}' | awk -F '°' '{ print $1}')
@discarn8
discarn8 / hddtemp_wrapper_for_nagios.sh
Created May 2, 2018 07:57
hddtemp_wrapper_for_nagios.sh
#!/bin/sh
#February 09, 2008 Vincent Danen
usage() {
echo "${0} -w [warn] -c [crit] [drives]"
}
if [ "${1}" == "-h" -o "${1}" == "--help" ]; then
usage
exit 0
@discarn8
discarn8 / wx_underground_average.sh
Created May 2, 2018 08:08
wx_underground_average.sh
#!/bin/bash
# Use this to pull in up to 5 weather stations and grep the temp reading from them. Average only the ones
# that you get dater back from and then dump that to a file. Use Conky to read it or dump it to a db
#
#Change the station id's to valid stations in your area
wAvg=0
wSum=0
n=0
weatherA=0
@discarn8
discarn8 / Raspberry_PI_CPU_GPU_TEMP_in_FAHRENHEIT.sh
Last active January 14, 2019 07:19
Raspberry_PI_CPU_GPU_TEMP_in_FAHRENHEIT_write_to_mysql
#!/bin/bash
#using: awk '{print $1/1000 * 1.8 + 32}' /sys/class/thermal/thermal_zone0/temp
CPUSOURCE=`cat /sys/class/thermal/thermal_zone0/temp`
GPUSOURCE=`vcgencmd measure_temp | cut -c 6-9`
CPUCALC=`expr $CPUSOURCE / 1000`
CPU=`echo “scale=2;((9/5) * $CPUCALC ) + 32”| bc`
GPU=`echo “scale=2;((9/5) * $GPUSOURCE ) + 32”| bc`
#Or use
@discarn8
discarn8 / NanoPi Neo Blue LED
Last active May 3, 2018 04:18
NanoPi Neo Blue LED
#Make a backup:
cp /etc/rc.local /etc/rc.local.bac
#Edit:
nano /etc/rc.local
#Add following lines before "exit 0 ":
@discarn8
discarn8 / EXCEL_VBA_CleanPhoneNumber.vba
Created May 3, 2018 21:19
EXCEL_VBA_CleanPhoneNumber_Function
Function cleanPhoneNumber(thisNumber As String) As String
' this function aspires to clean any phone number format
' to standard format (+9999) 999-999-9999 or 999-999-9999
' works with almost all phone number formats stored in text
Dim retNumber As String
For i = 1 To Len(thisNumber)
If Asc(Mid(thisNumber, i, 1)) >= Asc("0") And Asc(Mid(thisNumber, i, 1)) <= Asc("9") Then
retNumber = retNumber + Mid(thisNumber, i, 1)
@discarn8
discarn8 / EXCEL_FORMULA_Convert_to_e164.vba
Last active May 3, 2018 21:28
EXCEL_FORMULA_Convert_to_e164
=LEFT(CONCATENATE("+1(",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE((SUBSTITUTE(C2,"(","")),")","")," ",""),"-",""),".",""),"x",";ext=")),6)
@discarn8
discarn8 / EXCEL_FORMULA_Convert_to_e164_non-hypenated.vba
Last active May 3, 2018 21:28
EXCEL_FORMULA_Convert_to_e164_non-hypenated
=CONCATENATE("+1",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE((SUBSTITUTE(C2,"(","")),")","")," ",""),"-",""),".",""),"x",";ext="))
Adds leading parenthesis
=CONCATENATE("+1(",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE((SUBSTITUTE(C2,"(","")),")","")," ",""),"-",""),".",""),"x",";ext="))
@discarn8
discarn8 / EXCEL_FORMULA_Convert_first_dot_last.vba
Last active May 3, 2018 21:27
EXCEL_FORMULA_Convert_first_dot_last
last.first
=LOWER(IF(LEN(A12)=0,"",IF(ISERR(FIND(" ",A12)),A12,LEFT(A12,FIND(" ",A12)-2)))&"."&MID(A12,SEARCH(", ",A12)+2, SEARCH(" ",MID(A12&" ", SEARCH(", ",A12)+4,200))+1)))))
first.last
=LOWER(MID(A14,SEARCH(", ",A14)+2, SEARCH(" ",MID(A14&" ", SEARCH(", ",A14)+4,200))+1)&"."&IF(LEN(A14)=0,"",IF(ISERR(FIND(" ",A14)),A14,LEFT(A14,FIND(" ",A14)-2))))