Skip to content

Instantly share code, notes, and snippets.

View discarn8's full-sized avatar

discarn8 discarn8

View GitHub Profile
@discarn8
discarn8 / Python_graph_csv_file.py
Created July 30, 2018 20:33
Python_graph_csv_file.py
%matplotlib inline
import time
import os
import glob
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pylab as plt
from matplotlib import rcParams
rcParams.update({'figure.autolayout': False})
@discarn8
discarn8 / BASH_Check_if_program_is_running.sh
Last active January 6, 2024 22:14
BASH_Program_Check
#! /bin/bash
# Add an entry in your crontab to run this script on a timed interval
logfile="/var/log/app_check.log"
case "$(pidof app | wc -w)" in
0) echo "App found not running, (re)starting app: $(date)" >> $logfile
DISPLAY=:0 /home/jdoe/app_script &
@discarn8
discarn8 / Extract_First.Last_From_Field.XLformula
Last active May 18, 2018 21:50
EXCEL - Extract_First.Last_From_Field
#Pulls FIRST.LAST from a description field. Useful for Cisco phone description fields where the format is: LAST, FIRST XXXXX
=IF(D2=0,"",SUBSTITUTE((TRIM(LOWER(RIGHT(LEFT(D2,(LEN(D2)-6)),LEN(LEFT(D2,(LEN(D2)-6)))-FIND(", ",LEFT(D2,(LEN(D2)-6)),1)))&"."&(LOWER(LEFT(LEFT(D2,(LEN(D2)-6)),FIND(", ",D2,1)-1)))))," csf",""))
#Lower Case version
=LOWER(MID(A2,SEARCH(", ",A2)+2, SEARCH(" ",MID(A2&" ", SEARCH(", ",A2)+4,200))+1)&"."&IF(LEN(A2)=0,"",IF(ISERR(FIND(" ",A2)),A2,LEFT(A2,FIND(" ",A2)-2))))
@discarn8
discarn8 / Check_for_Valid_Employee.XLformula
Created May 18, 2018 18:33
XCEL - Check_for_Valid_Employee
=IF(A2=0,"",IFERROR(INDEX(EIDDBXXHR!$D:$D,MATCH(A2,EIDDB!D:D,0)),"X"))
@discarn8
discarn8 / Fetch_Employee_ID_Given_Name.XLformula
Created May 18, 2018 18:33
EXCEL - Fetch_Employee_ID_Given_Name
=IF(A2=0,"",IFERROR(INDEX(EIDDB!$A:$A,MATCH(A2,EIDDB!D:D,0)),"-"))
@discarn8
discarn8 / Check_for_UpperCase.XLfurmula
Created May 18, 2018 18:30
EXCEL - Check_for_UpperCase
=IF(A2=0, "", EXACT(UPPER(A2),A2))
@discarn8
discarn8 / Ribbon_Refresh_2013_Bug-fix.vba
Created May 18, 2018 18:29
EXCEL - Ribbon_Refresh_2013_Bug-fix.vba
Sub Refresh()
' THE FOLLOWING CODE ALL DUE TO EXCEL 2013 BUG ... force the window to shrink and restore back to get the ribbon etc painted correctly...
wk_Curr_Window_State = Application.WindowState
wk_Curr_Window_Width = Application.Width
wk_Curr_Window_Height = Application.Height
Application.WindowState = xlNormal 'Collapse the excel window
Application.Width = 225 ' make the window really small to force Excel rethink ribbon content ...
Application.Height = 271.5 ' both vertically and horizontally
' now restore the original window settings
Application.Width = wk_Curr_Window_Width
@discarn8
discarn8 / No_Save_Auto-Close.vba
Created May 18, 2018 18:28
EXCEL - No_Save_Auto-Close.vba
Sub Auto_Close()
ThisWorkbook.Saved = True
End Sub
@discarn8
discarn8 / Clear_sheets.vba
Created May 18, 2018 18:26
EXCEL - Clear_sheets.vba
Option Explicit
Sub CLEARDATA()
On Error GoTo ErrHandler
Dim arrSHEETS As Variant
Dim wsheets As Variant
arrSHEETS = Split("Alpha,Bravo,Charlie,Delta,Echo,Foxtrot,Golf,Hotel", ",")
@discarn8
discarn8 / shell_script_delete_folders_older_than.sh
Last active May 17, 2018 07:21
BASH - shell_script_delete_folders_older_than
# Useful for purging security camera folders
# 1 0 * * * = Run at 12:01a every day
# -name '2018*' just means - find all folders that start with 2018
# -type d = folders
# -mtime +20 = modified 20 days ago
1 0 * * * /bin/find /home -maxdepth 3 -name '2018*' -type d -mtime +20 -exec rm -rf {} \; -print >> /root/purge.log