Skip to content

Instantly share code, notes, and snippets.

🤙
https://mckelt.com

Chris McKelt chrismckelt

🤙
https://mckelt.com
Block or report user

Report or block chrismckelt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chrismckelt
chrismckelt / arm-resource-group-cleaner.json
Created Jul 14, 2019
arm-resource-group-cleaner.json
View arm-resource-group-cleaner.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { },
"variables": { },
"resources": [ ],
"outputs": { }
}
View sp_blitz_without_stored_proc.sql
drop table #dbcc_events_from_trace
declare @Help TINYINT = 0
declare @CheckUserDatabaseObjects TINYINT = 1
declare @CheckProcedureCache TINYINT = 0
declare @OutputType VARCHAR(20) = 'TABLE'
declare @OutputProcedureCache TINYINT = 0
declare @CheckProcedureCacheFilter VARCHAR(10) = NULL
declare @CheckServerInfo TINYINT = 0
View logic-app-cleanup.linq
/*
Parse logic app json and reorder logically
*/
string Json = string.Empty;
IList<string> Paths = new List<string>();
IDictionary<string, string> RunAfter = new Dictionary<string, string>();
void Main() {
@chrismckelt
chrismckelt / miniprofiler
Created May 17, 2019
profile sql stored procedure using miniprofiler
View miniprofiler
/*
Profile results returned from a stored procedure using https://miniprofiler.com
https://github.com/MiniProfiler/dotnet/blob/master/samples/Samples.Console/Program.cs
*/
static string sproc = "ProjectTracking_GetForReport";
static volatile int count = 0;
static MiniProfiler mp;
public async System.Threading.Tasks.Task Main()
View fibonnaci
void Main()
{
// 0,1,1,2,3,5
Fib(10).Dump();
Fib2(10).Dump();
Fib3(10).Dump();
}
// mutate in loop
int Fib(int x)
@chrismckelt
chrismckelt / flash-database.bat
Last active Feb 26, 2019
drop all tables from a sql database
View flash-database.bat
sqlcmd -s localhost -d SupportSiteDB -E -Q "EXEC sp_msforeachtable 'ALTER TABLE [?] NOCHECK CONSTRAINT ALL'"
TIMEOUT 1
sqlcmd -s localhost -d SupportSiteDB -E -Q "DECLARE @Sql NVARCHAR(500) DECLARE @Cursor CURSOR SET @Cursor = CURSOR FAST_FORWARD FOR SELECT DISTINCT sql = 'ALTER TABLE [' + tc2.TABLE_NAME + '] DROP [' + rc1.CONSTRAINT_NAME + ']' FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc1 LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc2 ON tc2.CONSTRAINT_NAME =rc1.CONSTRAINT_NAME OPEN @Cursor FETCH NEXT FROM @Cursor INTO @Sql WHILE (@@FETCH_STATUS = 0) BEGIN Exec SP_EXECUTESQL @Sql FETCH NEXT FROM @Cursor INTO @Sql END CLOSE @Cursor DEALLOCATE @Cursor EXEC sp_MSForEachTable 'DROP TABLE ?' "
TIMEOUT 1
@chrismckelt
chrismckelt / resco-util.ts
Created Dec 11, 2018
typescript utils for Resco D365 Field Services
View resco-util.ts
import './constants';
import {
Logger
} from "./logger";
import {
Question,
Answer,
ResponseRouting,
ResponseCondition,
ResponseAction
View deadlocks.sql
SELECT L.request_session_id AS SPID,
DB_NAME(L.resource_database_id) AS DatabaseName,
O.Name AS LockedObjectName,
P.object_id AS LockedObjectId,
L.resource_type AS LockedResource,
L.request_mode AS LockType,
ST.text AS SqlStatementText,
ES.login_name AS LoginName,
ES.host_name AS HostName,
TST.is_user_transaction as IsUserTransaction,
View shrink-databases.sql
SELECT
'USE [' + d.name + N']' + CHAR(13) + CHAR(10)
+ 'DBCC SHRINKFILE (N''' + mf.name + N''' , 0, TRUNCATEONLY)'
+ CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10)
FROM
sys.master_files mf
JOIN sys.databases d
ON mf.database_id = d.database_id
WHERE d.database_id > 4;
View last-backups.sql
;with backup_cte as
(
select
database_name,
backup_type =
case type
when 'D' then 'database'
when 'L' then 'log'
when 'I' then 'differential'
else 'other'
You can’t perform that action at this time.