Skip to content

Instantly share code, notes, and snippets.

View JosiahSiegel's full-sized avatar
🌌

Josiah Siegel JosiahSiegel

🌌
View GitHub Profile
@JosiahSiegel
JosiahSiegel / azure_sql_quick_analysis.sql
Last active July 18, 2024 20:18
Azure SQL Quick Analysis
SELECT
req.session_id AS [session],
ses.program_name AS [program],
sqltext.TEXT AS [query],
DB_NAME(req.database_id) AS [database],
req.status,
wg.name AS [resource_group],
req.command,
CONVERT(varchar(10), (req.cpu_time / 86400000)) + ':' +
CONVERT(varchar(10), ((req.cpu_time % 86400000) / 3600000)) + ':' +
@geekzter
geekzter / terraform-authentication-github-actions.yml
Last active May 13, 2024 19:49
Terraform authentication re-uses GitHub Azure Action credentials
- name: Get Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Get Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 'latest'
terraform_wrapper: false
@szook
szook / gist:4d56573ff7529cfeaf7c0b67f9b85902
Last active June 17, 2021 12:36
Grafana prometheus dashboard for MS SQL Server based on wmi_exporter metrics
{
"annotations": {
"list": [
{
"$$hashKey": "object:690",
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
@mattantonelli
mattantonelli / stripper_hash.rb
Last active July 19, 2017 18:17
A sexy version of Hash that strips whitespace from string keys. #StripperHash
class Hash
def strip
StripperHash.new(self)
end
end
class StripperHash < Hash
def initialize(constructor = {})
if constructor.respond_to?(:to_hash)
super
@pugsley
pugsley / mysql-backup.md
Last active July 30, 2022 22:36
MySQL dump > compress > encrypt

Generate openssl keys:

openssl req -x509 -nodes -newkey rsa:2048 -keyout mysqldump-key.priv.pem -out mysqldump-key.pub.pem

Create a mysql default file:

# ~/.mysqldump
[mysqldump]
host = host.here.com
@mattantonelli
mattantonelli / copy_backups.sh
Last active November 30, 2021 13:58
Copies backups from automysqlbackup to a remote host. Retains 1 weekly and 7 daily backups per database.
#!/usr/bin/env bash
#
# Purpose:
# Maintains 7 daily and 1 weekly database backups on a remote server.
#
# Configuration:
# Subdirectories must be created on the remote server for each database.
# (This includes status & fullschema directories if applicable.)
#
# Examples:
@JustinMcNamara74
JustinMcNamara74 / UserPermissions.sql
Last active May 1, 2024 21:49
#MSSQL List all user permissions/roles for all users
/*
********************************************************************************************************************************
Credits: @Jeremy
Posted: http://stackoverflow.com/questions/7048839/sql-server-query-to-find-all-permissions-access-for-all-users-in-a-database
********************************************************************************************************************************
Security Audit Report
1) List all access provisioned to a sql user or windows user/group directly
2) List all access provisioned to a sql user or windows user/group through a database or application role
3) List all access provisioned to the public role
@JosiahSiegel
JosiahSiegel / quick_analysis.sql
Last active May 31, 2024 14:15
#MSSQL #Research #OneStop Quick Analysis
SELECT
req.session_id AS [session],
ses.program_name AS [program],
jobs.name AS [job],
sqltext.TEXT AS [query],
DB_NAME(req.database_id) AS [database],
req.status,
wg.name AS [resource_group],
req.command,
CONVERT(varchar(10), (req.cpu_time / 86400000)) + ':' +
@JeremyMorgan
JeremyMorgan / states.sql
Last active October 3, 2023 12:55
An SQL Query to insert 50 U.S. States into a database.Make sure your auto increment is set in MySQL, and Identity_insert is set in MS-SQL.
CREATE TABLE [state](
[stateID] [int] IDENTITY(1,1) NOT NULL,
[stateCode] [nchar](2) NOT NULL,
[stateName] [nvarchar](128) NOT NULL,
CONSTRAINT [PK_state] PRIMARY KEY CLUSTERED
( [stateID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY])
ON [PRIMARY]