Skip to content

Instantly share code, notes, and snippets.

🤙
https://redtrout.cc

Chris McKelt chrismckelt

🤙
https://redtrout.cc
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
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'
@chrismckelt
chrismckelt / mac-hyper-v-bios-fix.txt
Created Apr 14, 2018
MAC Hyper V Virtualization ON in bios on boot
View mac-hyper-v-bios-fix.txt
http://nuts4.net/post/hack-force-vt-x-to-be-always-on-when-booting-to-windows-on-your-macbook
HACK: Force VT-x to be always on when booting to Windows on your MacBook
05 APRIL 2016 JOE
Warning: While this worked on my 15" MacBook Pro (mid 2014, EMC 2881), and newer models based on the comments below, this messes with the Model Specific Registers on your Intel processor. Also, this WILL NOT WORK on AMD-based systems...should Apple ever release one. Before proceeding, ensure that rEFInd is supported for your specific Mac/processor. By following any of the steps outlined below, you agree to not hold me liable for any damages. You've been warned!
Ok, if you're at this point, you've agreed to chance fate. So, I got fed up that Apple's UEFI BIOS doesn't set VT-x enabled by default when a Boot Camp partition is started by default. Having to boot into OS X, then reboot into Windows just so I can use Hyper-V/Docker is a huge time suck, and a bit ridiculous.
I sat out to find a solution, and had a hard time d
@chrismckelt
chrismckelt / AssemblyVersionAnalyser.cs
Last active Dec 21, 2017
Assembly Version Analyser
View AssemblyVersionAnalyser.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime;
namespace ScratchPad.Host.AssemblyAnalyser
You can’t perform that action at this time.