Skip to content

Instantly share code, notes, and snippets.

View mwwhited's full-sized avatar

Matthew Whited mwwhited

View GitHub Profile
@mwwhited
mwwhited / [dbo].[LongestCommonPrefix].sql
Created December 3, 2024 18:21
Handy T-SQL Scripts
CREATE FUNCTION [dbo].[LongestCommonPrefix]
(
@word1 NVARCHAR(MAX)
,@word2 NVARCHAR(MAX)
)
RETURNS NVARCHAR(MAX)
WITH SCHEMABINDING
AS
BEGIN
RETURN (
@mwwhited
mwwhited / Gadgets.md
Last active November 28, 2024 14:38
List of Gadgets for Me
@mwwhited
mwwhited / VersionSqlProj.md
Last active November 1, 2024 02:12
Add versioning to SQL Server Projects

Add versioning to SQL Server Projects

Summary

This is a basic set of instructions on how to add version number support for SQL Server projects and databases. This will will add the version number as an extended property on the deployed database.

How to access version number

@mwwhited
mwwhited / run-sonar.bat
Last active February 2, 2024 22:57
Local SonarQube
SET SONARQUBE_KEY=XXX
SET SONARQUBE_TOKEN=YYY
dotnet tool restore
echo "Git fetch"
git fetch --prune
FOR /F "tokens=* USEBACKQ" %%g IN (`dotnet gitversion /output json /showvariable FullSemVer`) DO (SET BUILD_VERSION=%%g)
if "%BUILD_VERSION%"=="" GOTO error
@mwwhited
mwwhited / Directory.Build.props
Last active February 2, 2024 22:51
Custom build extensions for .Net
<Project>
<PropertyGroup Condition="'$(SolutionDir)' == ''">
<!-- Resolve solution dir if not set -->
<SolutionDir Condition="'$(SolutionDir)' == '' and $([System.IO.Directory]::GetFiles('../', '*.sln').get_Length()) != 0">../</SolutionDir>
<SolutionDir Condition="'$(SolutionDir)' == '' and $([System.IO.Directory]::GetFiles('../../', '*.sln').get_Length()) != 0">../../</SolutionDir>
<SolutionDir Condition="'$(SolutionDir)' == '' and $([System.IO.Directory]::GetFiles('../../../', '*.sln').get_Length()) != 0">../../../</SolutionDir>
<SolutionDir Condition="'$(SolutionDir)' == '' and $([System.IO.Directory]::GetFiles('../../../../', '*.sln').get_Length()) != 0">../../../../</SolutionDir>
<SolutionDir Condition="'$(SolutionDir)' == '' and $([System.IO.Directory]::GetFiles('../../../../../', '*.sln').get_Length()) != 0">../../../../../</SolutionDir>
<SolutionDir Condition="'$(SolutionDir)' != ''">$([System.IO.Path]::GetFullPath('$(SolutionDir)'))</SolutionDir>
@mwwhited
mwwhited / .gitconfig
Created February 1, 2024 18:12
.gitconfig for beyond compare 4
[credential "https://source.developers.google.com"]
useHttpPath = true
[user]
name = Matthew Whited
email = matt@whited.us
[core]
excludesfile =
[difftool "sourcetree"]
cmd = '' \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
@mwwhited
mwwhited / .wslconfig
Last active February 1, 2024 01:19
Preferred Settings for WSL2
# %USERPROFILE%\.wslconfig
# https://learn.microsoft.com/en-us/windows/wsl/wsl-config
[wsl2]
# If the value is mirrored then this turns on mirrored networking mode. Default or unrecognized strings result in NAT networking.
networkingMode=mirrored
# Only applicable when experimental.networkingMode is set to mirrored. When set to True, will allow the Container to connect to
# the Host, or the Host to connect to the Container, by an IP address that's assigned to the Host. Note that the 127.0.0.1
# loopback address can always be used - this option allows for all additionally assigned local IP addresses to be used as well.
@mwwhited
mwwhited / .editorconfig
Created January 28, 2024 03:31
My favorite csharp .editorconfig settings
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options
###############################
# Core EditorConfig Options #
###############################
root = true
# All files
[*]
indent_style = space