Skip to content

Instantly share code, notes, and snippets.

View mhagrelius's full-sized avatar

Matthew Hagrelius mhagrelius

  • Rockford, MI, USA
  • 08:21 (UTC -04:00)
View GitHub Profile
@mhagrelius
mhagrelius / AuthHelpers.cs
Created October 2, 2019 20:57
Get Access Token from Azure AD for Integration Testing
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json.Linq;
namespace Api.Test
{
public static class AuthHelpers
{
@mhagrelius
mhagrelius / BitManipulation.cs
Created October 3, 2019 18:11
Useful bit manipulation functions
public static class BitManipulation
{
public static bool CheckBitSet(int num, int bit)
{
return ((num & (1 << bit)) != 0);
}
public static int SetBit(int num, int bit)
{
return num | (1 << bit);
@mhagrelius
mhagrelius / steps.md
Created October 4, 2019 13:04
Steps to encrypt web.config

For Single Box

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef connectionStrings "C:\Folder\Project"

To Share Across Environments

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pc "SiteRSAEncryptionKeys" -exp C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pa "SiteRSAEncryptionKeys" "COMPUTER\UserName"

Setup ConfigProtectedData section of web.config

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -pef connectionStrings "C:\Folder\Project" -prov "SiteRSAEncryptionProvider"

@mhagrelius
mhagrelius / DeadLetterDrain.csproj
Created April 28, 2021 22:24
Azure Service Bus Dead Letter Queue Drain
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Messaging.ServiceBus" Version="7.1.2"/>
<PackageReference Include="CsvHelper" Version="27.0.2"/>
</ItemGroup>
</Project>