Skip to content

Instantly share code, notes, and snippets.

View discarn8's full-sized avatar

discarn8 discarn8

View GitHub Profile
@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 / Check_for_UpperCase.XLfurmula
Created May 18, 2018 18:30
EXCEL - Check_for_UpperCase
=IF(A2=0, "", EXACT(UPPER(A2),A2))
@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_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 / 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 / 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 / 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 / Python_list_specific_filetypes_in_directory.py
Created July 30, 2018 20:41
Python_list_specific_filetypes_in_directory
import os
#Change csv to match the file extension you are searching for
path = "C:/path/to/files/*.csv"
for fname in glob.glob(path):
temp1=os.path.basename(os.path.normpath(fname))
filename=temp1.split('.')[0]
print(filename)
@discarn8
discarn8 / Python_list_specific_filetypes_with_mod-date_in_directory.py
Created July 30, 2018 20:45
Python_list_specific_filetypes_with_mod-date_in_directory
import os
#import glob
#import time
path = "C:/path/to?files/*.csv"
for fname in glob.glob(path):
temp1=os.path.basename(os.path.normpath(fname))
filename=temp1.split('.')[0]
dt=time.strftime('%Y%m%d', time.gmtime(os.path.getmtime(fname)))
print(filename+","+dt)
@discarn8
discarn8 / Python_graph_csv_files_in_directory_with_total_and_count.py
Last active July 30, 2018 21:54
Python_graph_csv_files_in_directory_with_total_and_count
%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})