Skip to content

Instantly share code, notes, and snippets.

View tcartwright's full-sized avatar

Tim Cartwright tcartwright

  • Houston, Texas
View GitHub Profile
@tcartwright
tcartwright / PullMainBranchesForAllRepos.ps1
Created November 26, 2024 22:44
POWERSHELL: Pull all the main branches for a set of repo folders
Clear-Host
$folders = [IO.Directory]::EnumerateDirectories("**PATH**")
$branches = "dev", "qa", "staging", "master"
foreach ($folder in $folders) {
Set-Location $folder
if (!(Get-ChildItem -Path ".git" -Directory -ErrorAction SilentlyContinue)) {
continue
}
@tcartwright
tcartwright / FixGitFileCasing.md
Last active November 26, 2024 22:37
GIT: Rename file with bad casing that cant be changes cannot be undone on

If you've changed the case of a file name in Git and can't undo the changes, it's likely that Git isn't recognizing the change as a rename. Here's how to fix it:

  • Method 1: Using git mv

    • Rename the file back to the original case:
      • Code git mv NewFileName.txt oldfilename.txt
    • Commit the change.
      • Code git commit -m "Fix case sensitivity issue"
  • Method 2: Force a rename

  • Rename the file to a temporary name:

@tcartwright
tcartwright / ConvertFilesToUTF8.ps1
Created November 26, 2024 22:12
POWERSHELL: Convert files to UTF-8 NO BOM
$Utf8NoBomEncoding = [System.Text.UTF8Encoding]::new($false);
Get-ChildItem -Path "." -Recurse -File |
Where-Object { $_.FullName -inotmatch "\\bin\\|\\obj\\"} |
ForEach-Object {
Write-Output $_.FullName;
$content = [IO.File]::ReadAllLines($_.FullName);
[IO.File]::WriteAllLines($_.FullName, $content, $Utf8NoBomEncoding);
}
@tcartwright
tcartwright / CleanRsaMachineKeys.ps1
Created November 14, 2024 17:52
POWERSHELL: Cleans machine keys out that may get out of control
#Requires -RunAsAdministrator
Clear-Host
$deleteDate = (Get-Date).AddMonths(-2)
$counter = 0
# https://port135.com/remove-older-files-machinekeys/
# Back up the three files below. These files are used by IIS. It’s important to back them up before removing any files from MachinkeKeys folder.
#
# 6de9cb26d2b98c01ec4e9e8b34824aa2_GUID iisConfigurationKey
@tcartwright
tcartwright / InstallP4Merge.bat
Last active October 12, 2024 13:40
WINDOWS: Install p4 merge
@REM Just save this file in the same directory as the p4vinst64.msi file and run it as administrator, or just copy the msiexec line minus the %~dp0
@%~d0
@cd "%~dp0"
@echo INSTALLING: %~dp0p4vinst64.msi
@rem install p4 with minimal ui
msiexec.exe /i "%~dp0p4vinst64.msi" /qb
@tcartwright
tcartwright / ExternalMenuItems.vssettings.xml
Last active October 14, 2024 20:06
Visual Studio: My external tools menu items
<UserSettings>
<ApplicationIdentity version="17.0"/>
<ToolsOptions/>
<Category name="Environment_Group" RegisteredName="Environment_Group">
<Category name="Environment_ExternalTools" Category="{E8FAE9E8-FBA2-4474-B134-AB0FFCFB291D}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_ExternalTools" PackageName="Visual Studio Environment Package">
<ExternalTools>
<UserCreatedTool>
<Arguments>locals all -clear</Arguments>
<CloseOnExit>true</CloseOnExit>
<Command>nuget.exe</Command>
<# download and install Solarwinds SentryOne Plan Explorer #>
$filenamePlanExplorerInstall = "$env:USERPROFILE\downloads\" + ([string](Get-Date -format "yyyy-MM-dd")) + "_SolarWinds-PlanExplorer.exe"
Start-BitsTransfer -Source 'https://downloads.solarwinds.com/solarwinds/Release/FreeTool/SolarWinds-PlanExplorer.exe' -Destination $filenamePlanExplorerInstall
& $filenamePlanExplorerInstall /install /passive /norestart
@tcartwright
tcartwright / AlterDateTimeColumnsToDateTimeOffset.ps1
Last active September 25, 2024 13:30
SQL SERVER: Converts sql server datetime and datetime2 columns to datetimeoffset
Clear-Host
$module = Get-Module tcdbtools
if (!$module) {
Install-Module tcdbtools -Force
}
Import-Module tcdbtools
$module = Get-Module SqlServer
if (!$module) {
@tcartwright
tcartwright / GetWebSiteProcessId.ps1
Last active August 29, 2024 18:13
POWERSHELL: Get W3WP ProcessId for specific app pool name
Get-WmiObject Win32_Process -Filter "name = 'w3wp.exe'" |
Where-Object {$_.CommandLine -imatch "appPoolName"} |
Select-Object ProcessId, Name, CommandLine
@tcartwright
tcartwright / Directory.Build.props
Created August 12, 2024 14:03
VISUAL STUDIO: MY Standard Directory.Build.props file
<Project>
<PropertyGroup>
<!--ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally-->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <!-- True for new projects, false for existing ones with lots of warnings -->
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PublishReadyToRun>true</PublishReadyToRun>
<SelfContained>true</SelfContained>
<SatelliteResourceLanguages>en-US</SatelliteResourceLanguages>