Skip to content

Instantly share code, notes, and snippets.

@The-Running-Dev
The-Running-Dev / HookFx.cs
Created November 17, 2023 00:10 — forked from NaxAlpha/HookFx.cs
Windows API Hook with C#
using System;
using System.Runtime.InteropServices;
public class FxHook:IDisposable {
const int nBytes = 5;
IntPtr addr;
Protection old;
byte[] src = new byte[5];
@The-Running-Dev
The-Running-Dev / teamcity.psm1
Created June 29, 2023 14:28
TeamCity PowerShell module. Contains various functions for interacting with TeamCity.
if ($env:TEAMCITY_VERSION) {
# When PowerShell is started through TeamCity's Command Runner, the standard
# output will be wrapped at column 80 (a default). This has a negative impact
# on service messages, as TeamCity quite naturally fails parsing a wrapped
# message. The solution is to set a new, much wider output width. It will
# only be set if TEAMCITY_VERSION exists, i.e., if started by TeamCity.
$host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(8192,50)
}
function TeamCity-Message([string]$text, [string]$status = 'NORMAL', [string]$errorDetails) {
@The-Running-Dev
The-Running-Dev / Create Kavita Directory Structure
Last active February 10, 2024 14:32
Scans a directory of eBooks and creates a direcory and sub directories, with hard links to the actual eBooks.
<#
Save to: Create-Kavita-Structure.ps1
and run it with: .\Create-Kavita-Structure.ps1 -sourceDir 'DriveLetter:\PathToBooks' -kavitaDir 'DriveLetter:\PathToKavitaWatchedDir"
If sourceDir is not specified, assumes current directory (.)
If kavitaDir is not specified, assumes @Kavita under the current directory (.\@Kavita)
To test this without making any changes: Create-Kavita-Structure.ps1 -whatIf
#>
[CmdletBinding(SupportsShouldProcess = $true)]
Param(
@The-Running-Dev
The-Running-Dev / usersecrets.ps1
Created December 27, 2020 15:10 — forked from Zonciu/usersecrets.ps1
Manage User Secrets for .NET Core console application
<#
.NOTES
How to use: Open Visual Studio, go to Tools – External Tools to bring up the External Tools dialog, add a new tools menu with the following configuration:
Title: Manage User Secrets (Or whatever you want)
Command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (Path to powershell.exe)
Arguments: Path-to-this-script(e.g. D:\VisualStudioTools\usersecrets.ps1)
Initial Directory: $(ProjectDir)
.PARAMETER ProjectFilePath
The csproj file's path, or keep it empty to search *.csproj file in initial directory
@The-Running-Dev
The-Running-Dev / StringExtensions.cs
Created December 25, 2020 18:47
String Extensions
/// <summary>
/// Checks if string is empty, null or white space
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static bool IsEmpty(this string value)
{
return string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value);
}
@The-Running-Dev
The-Running-Dev / isPreview.yml
Last active December 14, 2020 14:32
Setting preview version based on source branch
# Set to preview version if the source branch is not the master branch
isPreviewVersion: ${{
ne(variables['Build.SourceBranch'], 'refs/heads/master')
}}
@The-Running-Dev
The-Running-Dev / generate-sas-task.yml
Created November 12, 2020 16:08
Azure YAML task for generating a SAS token
- task: AzureCLI@2
name: generateToken
displayName: Generating SAS Token
inputs:
azureSubscription: ${{variables.subscription}}
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
$sasToken = az storage blob generate-sas `
--account-name ${{variables.templateStorageAccount}} `
@The-Running-Dev
The-Running-Dev / Install-VsixExtension.ps1
Created October 17, 2019 15:24 — forked from lennybacon/Install-VsixExtension.ps1
Unattended install of Wix Toolset Visual Studio 2017 Extension
$extensionDisplayName = "Wix Toolset Visual Studio 2017 Extension";
$extensionApiVersion = "api-version=3.2-preview.1"
$marketplaceQueryUrl = "https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery";
$extensionQuery = "{`"flags`":`"262`"," +
"`"filters`":[" +
"{" +
"`"criteria`":" +
"[" +
"{`"filterType`":`"14`",`"value`":`"1033`"}," +
@The-Running-Dev
The-Running-Dev / Set-LnkToRunAsAdmin.ps1
Created October 17, 2019 15:22 — forked from lennybacon/Set-LnkToRunAsAdmin.ps1
Modify Link to run as admin
$linkFilePath = "C:\Users\$([Environment]::UserName)\Desktop\WindowsTerminal.lnk"
$bytes = [System.IO.File]::ReadAllBytes($linkFilePath)
$bytes[0x15] = $bytes[0x15] -bor 0x20 #set byte 21 (0x15) bit 6 (0x20) ON
[System.IO.File]::WriteAllBytes($linkFilePath, $bytes)
@The-Running-Dev
The-Running-Dev / update-visualstudio.ps1
Created October 17, 2019 15:21 — forked from lennybacon/update-visualstudio.ps1
Update all visual studio editions and instances equal or above 2017
$EventLogSourceName = "Visual Studio Updater"
if([System.Diagnostics.EventLog]::SourceExists($EventLogSourceName) -eq $false){
New-EventLog –LogName Application –Source $EventLogSourceName
}
$cacheDirs = @(
"C:\Program Files (x86)\Microsoft Visual Studio\Installer"
);
foreach($cacheDir in $cacheDirs){