Skip to content

Instantly share code, notes, and snippets.

View wbhinton's full-sized avatar

Weston Hinton wbhinton

View GitHub Profile
@wbhinton
wbhinton / timeseries-scripts.sql
Created December 3, 2019 16:24
A list of time related SQL scripts
--Date and Time
--These statements are tested with T-SQL under MS SQL Server.
---Months
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 1, 0) -- First day of previous month
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), - 1) -- Last Day of previous month
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0) -- First day of this month
@wbhinton
wbhinton / table-col-def.sql
Created December 3, 2019 16:21
List all tables and columns in a DB with column definitions
-- Table Columns
SELECT @@Servername AS Server ,
DB_NAME() AS DBName ,
isc.Table_Name AS TableName ,
isc.Table_Schema AS SchemaName ,
Ordinal_Position AS Ord ,
Column_Name ,
Data_Type ,
Numeric_Precision AS Prec ,
@wbhinton
wbhinton / table-desc.sql
Created December 3, 2019 16:20
List all tables in a database with descriptions
EXEC sp_tables;
-- Note this method returns both table and views.
--OR
SELECT @@Servername AS ServerName ,
TABLE_CATALOG ,
TABLE_SCHEMA ,
TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
@wbhinton
wbhinton / list-all-dbs.sql
Created December 3, 2019 16:18
List All Databases on a server (MSSQL)
EXEC sp_helpdb;
--OR
EXEC sp_Databases;
--OR
SELECT @@SERVERNAME AS Server ,
name AS DBName ,
recovery_model_Desc AS RecoveryModel ,
Compatibility_level AS CompatiblityLevel ,
create_date ,
@wbhinton
wbhinton / green-pbi.json
Created December 3, 2019 16:16
Dark Green Power BI Theme
{
"name": "GlobalLevelTemplate",
"dataColors": [
"#217c60",
"#009fae",
"#00a99c",
"#00b27e",
"#56b75a",
@wbhinton
wbhinton / df-to-html.py
Created December 3, 2019 16:08
Export Pandas DataFrame as a HTML Table
# Set the HTML Header with Bootstrap4 CSS for table formatting
html_string = """
<html>
<head><title>HTML Pandas Dataframe with CSS</title></head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<body>
{table}
</body>
</html>
@wbhinton
wbhinton / awake.py
Created December 3, 2019 13:35
Python Script to keep your screen alive
import pyautogui
import time
import sys
from datetime import datetime
pyautogui.FAILSAFE = False
numMin = None
print('We will keep you computer awake by moving the mouse every 3 minutes. ¯\_(ツ)_/¯')
if ((len(sys.argv)<2) or sys.argv[1].isalpha() or int(sys.argv[1])<1):
numMin = 3
@wbhinton
wbhinton / pdf_summarizer.py
Last active November 27, 2019 19:52
Loop through a folder and summarize all PDFs
import PyPDF2
import textract
import nltk
import re
from tika import parser
import heapq
import glob
path = "pdf/*.pdf"
.mystyle {
font-size: 11pt;
font-family: Arial;
border-collapse: collapse;
border: 1px solid silver;
}
.mystyle td, th {
@wbhinton
wbhinton / drive_monitor.py
Created October 20, 2019 20:27
Google Drive Shared Folder Monitor Using Python
from pydrive.auth import GoogleAuth
import io
from pydrive.drive import GoogleDrive
import datetime
from datetime import timedelta
import email, smtplib, ssl
from email import encoders
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText