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 / GetPostmanUserInfo.js
Last active January 3, 2025 14:56
POSTMAN: Get User Information from script
utils = {
GetUserInfoPromise: function() {
return new Promise((resolve, reject) => {
// have to use a promise as sendrequest is async if we want to use the response
const postman_api_key = pm.globals.get('postman_api_key');
pm.sendRequest({
url: 'https://api.getpostman.com/me',
method: 'GET',
header: {
'X-API-Key': postman_api_key,
@tcartwright
tcartwright / ListWebSites.bat
Last active December 5, 2024 15:43
BAT: Get list of IIS web sites, listing IDs, and bindings with state
C:\Windows\System32\inetsrv\appcmd.exe list site
@tcartwright
tcartwright / 0.Directory.Build.props-Directory.Build.targets-Directory.Packages.props.MD
Last active November 28, 2024 16:25
VISUAL STUDIO: Directory packages, build, and targets files.
@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