Skip to content

Instantly share code, notes, and snippets.

View MisinformedDNA's full-sized avatar

Dan Friedman MisinformedDNA

View GitHub Profile
@BenjaminAbt
BenjaminAbt / ApplicationInsightsBehavior.cs
Last active January 25, 2023 16:16
Application Insights MediatR Operation Behavior
using System;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
namespace BenjaminAbt.ApplicationInsights.MediatR
{
@chamindac
chamindac / BranchPolicyCopy.ps1
Created April 7, 2020 06:02
Copy Branch policies from a Azure DevOps Git branch to another branch
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string] $AzureDevOpsPAT,
[Parameter(Mandatory=$true)]
[string] $OrganizationName,
[Parameter(Mandatory=$true)]
[string] $teamProjectName,
[Parameter(Mandatory=$true)]
@haacked
haacked / ModelBuilderExtensions.cs
Last active March 29, 2024 14:16
Example of applying an EF Core global query filter on all entity types that implement an interface
/*
Copyright Phil Haack
Licensed under the MIT license - https://github.com/haacked/CodeHaacks/blob/main/LICENSE.
*/
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@attilah
attilah / X.Y.Z.Sources.csproj
Last active April 18, 2024 08:52
X.Y.Z.Sources nuget package
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<IsPackable>true</IsPackable>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>contentFiles</ContentTargetFolders>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
@jamesfdickinson
jamesfdickinson / Convert-Encoding.ps1
Last active June 20, 2023 11:45
Convert all files to UTF-8 using powershell
Param (
[Parameter(Mandatory=$True)][String]$SourcePath
)
Get-ChildItem $SourcePath\* -recurse -Include *.json,*.html,*.xml,*.js,*.txt,*.css | ForEach-Object {
$content = $_ | Get-Content
Set-Content -PassThru $_.Fullname $content -Encoding UTF8 -Force}
### Boxstarter options - not needed if using the No Reboot (/nr/) URL option
#$Boxstarter.RebootOk=$true # Allow reboots?
#$Boxstarter.NoPassword=$false # Is this a machine with no login password?
#$Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot?
### Windows components: IIS - not needed
#cinst -source windowsfeatures IIS-WebServerRole
#cinst -source windowsfeatures IIS-WebServer
#cinst -source windowsfeatures IIS-Security
#cinst -source windowsfeatures IIS-WindowsAuthentication
@bmoore-msft
bmoore-msft / New-KeyVaultForTemplateDeployment.ps1
Created February 22, 2016 21:40
Create an Azure KeyVault Enabled for Template Deployment (sh and ps)
#Requires -Module AzureRM.Profile
#Requires -Module AzureRM.KeyVault
#Login and Select the default subscription if needed
#Login-AzureRmAccount
#Select-AzureRmSubscription -SubscriptionName 'subscription name'
#Change the values below before running the script
$VaultName = 'myvault' #Globally Unique Name of the KeyVault
$VaultLocation = 'East US' #Location of the KeyVault