Skip to content

Instantly share code, notes, and snippets.

View smklancher's full-sized avatar

Stephen Klancher smklancher

View GitHub Profile
@RickStrahl
RickStrahl / VoiceDictation.cs
Last active March 30, 2025 18:46
Windows Media Speech Recognition/Dictation
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Windows.Media.SpeechRecognition;
using System.Windows.Controls;
using System.Windows.Input;
using Westwind.Utilities;
using MarkdownMonster.Windows;
using Windows.Globalization;
#Requires -RunAsAdministrator
# Disable telemetry in Visual Studio 2022 - https://learn.microsoft.com/en-us/visualstudio/ide/visual-studio-experience-improvement-program?view=vs-2022
New-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\VSCommon\17.0\SQM" -Name "OptIn" -Value "0" -PropertyType "DWORD" -Force
# Delete telemetry directories
Remove-Item -Path "$env:APPDATA\vstelemetry" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "$env:LOCALAPPDATA\Microsoft\VSApplicationInsights" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "$env:PROGRAMDATA\Microsoft\VSApplicationInsights" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "$env:TEMP\Microsoft\VSApplicationInsights" -Recurse -Force -ErrorAction SilentlyContinue
@massimopiccardo
massimopiccardo / #Effortless SQL Query Crafting: Unleashing GitHub Copilot's.txt
Last active June 11, 2025 00:26
These are the files used in "Effortless SQL Query Crafting: Unleashing GitHub Copilot's Power" Medium post
These are the files used in Effortless SQL Query Crafting: Unleashing GitHub Copilot's Power post. See here:
https://medium.com/@massimopiccardo/effortless-sql-query-crafting-unleashing-github-copilots-power-d09136e92de8
DatabaseContextCreation_base.sql --> A basic query to generate a list of comments to use as a context for copilot generated queries
DatabaseContextCreation_relations.sql --> An evolution of the base one, adding foreing keys information
DatabaseContextCreation_descriptions.sql --> Another evolution, adding table and column free text descriptions
sp_AddUpdateDescription.sql --> A stored procedure to simplify the definition of descriptions ofr tables and columns
@ygoe
ygoe / ps-csharp.cmd
Created January 29, 2022 23:20
Write your Windows batch files in C# (using PowerShell)
<# :
@echo off & setlocal & set __args=%* & %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -Command Invoke-Expression ('. { ' + (Get-Content -LiteralPath ""%~f0"" -Raw) + ' }' + $env:__args) & exit /b %ERRORLEVEL%
#> Add-Type @'
// ========== BEGIN C# CODE ==========
using System;
public class App
{
public static void Run(string[] args)
{
@richardszalay
richardszalay / IISAssemblyDebugging.psm1
Created June 14, 2019 02:56
Enable/Disable JIT optimizations for assemblies so they can be debugged with dnSpy
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
function Enable-IISAssemblyDebugging
{
param(
[string]$Path = ".",
[string]$Filter = "*.dll"
)
@olljanat
olljanat / Find-OrphanDockerLayers.ps1
Last active May 13, 2025 09:46
Find Windows containers orphan layers
param (
[switch]$RenameOrphanLayers
)
If ($RenameOrphanLayers) {
Write-Warning "$($env:COMPUTERNAME) -RenameOrphanLayers option enabled, will rename all orphan layers"
}
# Get known layers on Docker images
[array]$ImageDetails += docker images -q | ForEach { docker inspect $_ | ConvertFrom-Json }
@sverrirs
sverrirs / AutoCompleteExt.cs
Created November 2, 2018 09:54
AutoComplete in .NET through the Windows Shell (provides more options than default implementation)
using System;
using System.Runtime.InteropServices;
/// <summary>
/// From: https://www.codeproject.com/Articles/3792/C-does-Shell-Part-4
/// Note: The UCOMIEnumString interface is deprecated in .NET as of 2018!
/// </summary>
public class AutoCompleteExt {
public static Guid CLSID_AutoComplete = new Guid("{00BB2763-6A77-11D0-A535-00C04FD7D062}");
@mattifestation
mattifestation / CollectDotNetEvents.ps1
Created August 27, 2018 21:50
A PoC script to capture relevant .NET runtime artifacts for the purposes of potential detections
logman --% start dotNetTrace -p Microsoft-Windows-DotNETRuntime (JitKeyword,NGenKeyword,InteropKeyword,LoaderKeyword) win:Informational -o dotNetTrace.etl -ets
# Do your evil .NET thing now. In this example, I executed the Microsoft.Workflow.Compiler.exe bypass
# logman stop dotNetTrace -ets
# This is the process ID of the process I want to capture. In this case, Microsoft.Workflow.Compiler.exe
# I got the process ID by running a procmon trace
$TargetProcessId = 8256
@timabell
timabell / assoc.ps1
Last active December 6, 2022 15:22
set windows file associations
# https://gist.github.com/timabell/bc90e0808ec1cda173ca09225a16e194
# MIT license
$exts=@(
"csv",
"csproj",
"json",
"log",
"md",
"patch",
"sql",
@kitmenke
kitmenke / finderrors.ps1
Created August 1, 2016 02:45
Working in progress: powershell script to automatically fix DCOM errors which show up in the event log
# Get-EvengLog doesn't quite work I guess:
# https://stackoverflow.com/questions/31396903/get-eventlog-valid-message-missing-for-some-event-log-sources#
# Get-EventLog Application -EntryType Error -Source "DistributedCOM"
# The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID
#$logs = Get-EventLog -LogName "System" -EntryType Error -Source "DCOM" -Newest 1 -Message "The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID*"
# 2 is error
# 3 is warning
$EVT_MSG = "The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID"
# Search for System event log ERROR entries starting with the specified EVT_MSG
$logEntry = Get-WinEvent -FilterHashTable @{LogName='System'; Level=2} | Where-Object { $_.Message -like "$EVT_MSG*" } | Select-Object -First 1