Skip to content

Instantly share code, notes, and snippets.

View Icidis's full-sized avatar
👓
Keeping watch

Ryan Gunn Icidis

👓
Keeping watch
View GitHub Profile
@Icidis
Icidis / Enable-TLS-RabbitMQ.ps1
Created July 12, 2021 06:14 — forked from skewl84/Enable-TLS-RabbitMQ.ps1
Enable TLS on RabbitMQ instance
<#
.Synopsis
Automates the TLS Enablement of RabbitMQ.
.DESCRIPTION
This script will use provided certs to create the TLS configuration for the RabbitMQ. Unless provided will generate the selfsigned certficate to do so.This script uses OpenSSL to generate certficates and test SSl.
If not installed the script will download and install OpenSSL.
.PARAMETER RabbitMQver
The version of the RabbitMQ installed at "C:\Program Files\RabbitMQ Server\" to manipulate the service.
.PARAMETER CA
The certficate authority chain to be used.
@Icidis
Icidis / keyvault-secret-sample.cs
Created June 11, 2020 15:45
Fetching private key from Azure Key Vault Certificates
const string CLIENT_ID = "MY AzureAD App Registration Application (Client) Id";
const string CLIENT_SECRET = "My AzureAD App Registration Application Secret";
static KeyVaultClient GetClient() => new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(async (string authority, string resource, string scope) =>
{
var context = new AuthenticationContext(authority, TokenCache.DefaultShared);
ClientCredential clientCredential = new ClientCredential(CLIENT_ID, CLIENT_SECRET);
var authResult = await context.AcquireTokenAsync(resource, clientCredential);
return authResult.AccessToken;
}));
@Icidis
Icidis / create-crt.txt
Created March 23, 2020 13:12
OpenSSL - Create Public CRT from PEM
openssl x509 -outform der -in public_key.pem -out public_key.crt
@Icidis
Icidis / create-pfx.txt
Last active March 23, 2020 13:12
OpenSSL - Create PFX from PEM
openssl pkcs12 -inkey private_key.pem -in public_key.pem -export -out private_key.pfx
@Icidis
Icidis / new_cert.txt
Created March 3, 2020 10:37
OpenSSL - Create PEM
req -x509 -newkey rsa:4096 -keyout private_key.pem -out public_key.pem -days 365 -nodes -subj '/CN=localhost'
@Icidis
Icidis / Solution-Two-Delete-Query.sql
Last active August 26, 2019 10:41
SQL - Deleting duplicate rows using ROW_NUMBER() - Solution Two - Delete
WITH CTE
AS (SELECT FirstNames,
Surname,
ROW_NUMBER() OVER (PARTITION BY FirstNames, Surname ORDER BY FirstNames, Surname) AS RowNum
FROM #STUDENTS)
DELETE FROM CTE
WHERE CTE.RowNum > 1;
@Icidis
Icidis / Solution-Two-Query.sql
Created August 26, 2019 10:37
SQL - Deleting duplicate rows using ROW_NUMBER() - Solution Two - Query
WITH CTE
AS (SELECT FirstNames,
Surname,
ROW_NUMBER() OVER (PARTITION BY FirstNames, Surname ORDER BY FirstNames, Surname) AS RowNum
FROM #STUDENTS)
SELECT CTE.FirstNames,
CTE.Surname,
CTE.RowNum
FROM CTE;
@Icidis
Icidis / Solution-One-Query.sql
Last active August 26, 2019 10:31
SQL - Deleting duplicate rows using ROW_NUMBER() - Solution One
SELECT DISTINCT
FirstNames,
Surname
INTO #STUDENTS_TEMP
FROM #STUDENTS;
DELETE FROM #STUDENTS;
INSERT INTO #STUDENTS
(
FirstNames,
Surname
@Icidis
Icidis / Schema.sql
Created August 26, 2019 10:24
SQL - Deleting duplicate rows using ROW_NUMBER() - Schema
CREATE TABLE #STUDENTS
(
FirstNames VARCHAR(50) NOT NULL,
Surname VARCHAR(50) NOT NULL
);
INSERT INTO #STUDENTS
(
FirstNames,
Surname
@Icidis
Icidis / LEAD_LAG_Query.sql
Created August 20, 2019 16:11
LEAD and LAG Query
SELECT Region,
FORMAT([Quarter], 'yyyy') + ' Q' + CONVERT(VARCHAR(1), DATEPART(qq, [Quarter])) AS [Quarter],
LAG(TotalSales, 1, NULL) OVER (PARTITION BY Region ORDER BY Quarter ASC) AS [Previous Quarter Sales],
TotalSales AS [Quarter Sales],
LEAD(TotalSales, 1, NULL) OVER (PARTITION BY Region ORDER BY Quarter ASC) AS [Next Quarter Sales]
FROM #TempSales
ORDER BY [Quarter];