Skip to content

Instantly share code, notes, and snippets.

View jasoncable's full-sized avatar

Jason Cable jasoncable

View GitHub Profile
@jasoncable
jasoncable / gist:07e1f9a9ebab460e89a13b04d4da730e
Created May 2, 2022 19:21 — forked from shsteimer/gist:7257245
Tip to delete tags by pattern
#delete all the remote tags with the pattern your looking for, ie. DEV-
git tag | grep <pattern> | xargs -n 1 -i% git push origin :refs/tags/%
#delete all your local tags
git tag | xargs -n 1 -i% git tag -d %
#fetch the remote tags which still remain
git fetch
CultureSpecificFormats
= ====================================== ======================================
d short date 12/10/2019
D long date Tuesday, December 10, 2019
f full date (long date + short time) Tuesday, December 10, 2019 10:18 AM
F full date (long date + long time) Tuesday, December 10, 2019 10:18:28 AM
g general date (short date + short time) 12/10/2019 10:18 AM
G general date (short date + long time) 12/10/2019 10:18:28 AM
m Month/Day date December 10
M Month/Day date December 10
@jasoncable
jasoncable / ValidWindowsFileNameRegex.cs
Created October 29, 2020 19:26
Valid Windows File Name Regex
Regex r = new Regex("[<>:\"/|?*~]|\\.\\.");
// if it matches, you have bad characters in your Windows file name
_NT_SYMBOL_PATH
srv*d:\symbols*https://msdl.microsoft.com/download/symbols
srv*c:\temp\symbols*https://msdl.microsoft.com/download/symbols
.sympath srv*c:\temp\symbols*https://msdl.microsoft.com/download/symbols
.reload
_NT_SYMBOL_PATH=SRV*C:\temp\symbols*https://msdl.microsoft.com/download/symbols;SRV*C:\temp\symbols*https://chromium-browser-symsrv.commondatastorage.googleapis.com
"\Program Files (x86)\Windows Kits\8.1\Debuggers\x64\adplus.exe" -iis -hang -o d:\dump -mss d:\symbols
@jasoncable
jasoncable / msi_trace.bat
Created November 21, 2019 13:22
Windows Installer - MSI verbose logging
msiexec /i MyApplication.msi /l*v MyLogFile.txt
@jasoncable
jasoncable / using.cs
Last active November 21, 2019 13:09
C# - standard "using" statements
// these should cover 99% of what you need in C#.
// I find it easier to just copy/paste them then go to town.
// Of course, if you are adventurous, you can
// change your Visual Studio templates!
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Dynamic;
@jasoncable
jasoncable / dto-to-entity-comparison.cs
Created November 20, 2019 17:40
C# - DTO to Entity Comparison that outputs items to add/delete/update to/from/in target collection
// Let's say you have a list of DTOs (data tranfer objects) that someone
// posted on the web or anywhere. Items have been removed and added to it.
// You need to compare the input with what exists in the database
// and find out 1.) new items to add to the database,
// 2.) items to delete from the database, and
// 3.) items to update in the database.
// You don't want to continually rewrite that sort of thing over and over again, like I have.
// The problem with conventional methods is that the data types on either side of the
// equation are probably different types.
// The following will produce the items to add/delete/update by comparing them via
@jasoncable
jasoncable / sp_generate_merge.sql
Last active November 20, 2019 14:15
T-SQL generate merge statement sproc
-- SEE BELOW for Attribution... I have modified this sproc to incorporate additional data types
-- such as datetimeoffset, etc.
-- I have used it on MSSQL Server 2008R2 through 2017
CREATE PROC [dbo].[sp_generate_merge]
(
@table_name varchar(776), -- The table/view for which the MERGE statement will be generated using the existing data
@target_table varchar(776) = NULL, -- Use this parameter to specify a different table name into which the data will be inserted/updated/deleted
@from nvarchar(max) = NULL, -- Use this parameter to filter the rows based on a filter condition (using WHERE)
@include_timestamp bit = 0, -- Specify 1 for this parameter, if you want to include the TIMESTAMP/ROWVERSION column's data in the MERGE statement
@jasoncable
jasoncable / tsql-xml-comma-delimit.sql
Created November 20, 2019 14:04
T-SQL - Comma-seperated list from subselect (one to many)
select d.*,
stuff((select ', ' + f.Name
from FolderItem fi
join Folder f on fi.FolderId = f.FolderId
where d.DocumentId = fi.DocumentId
for xml path('')), 1, 2, '') as folders
from Document d