Skip to content

Instantly share code, notes, and snippets.

View bjorkstromm's full-sized avatar
:shipit:
My hovercraft is full of eels

Martin Björkström bjorkstromm

:shipit:
My hovercraft is full of eels
View GitHub Profile
@bjorkstromm
bjorkstromm / Sample.cs
Created October 9, 2024 11:01
Distributed Lock using Lease Blob
using Azure;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Specialized;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.DurableTask;
using Microsoft.DurableTask.Client;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@bjorkstromm
bjorkstromm / profile.ps1
Last active September 11, 2024 12:10
pwsh prompt
function prompt {
$ESC = [char]27
$time = "$ESC[93m$([System.DateTime]::Now.ToString("HH:mm:ss"))$ESC[0m"
$gitbranch = ""
$us = ""
$ts = ""
if (Test-Path "$($executionContext.SessionState.Path.CurrentLocation)/.git")
{
$gitbranch = " $ESC[92m$(git rev-parse --abbrev-ref HEAD)$ESC[0m"
@bjorkstromm
bjorkstromm / Program.cs
Last active October 18, 2024 11:32
Distributed Durable Semaphore using Durable Entities
using Microsoft.Extensions.Hosting;
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.Build();
host.Run();
@bjorkstromm
bjorkstromm / Microsoft.Extensions.DependencyInjection.Abstractions.cs.diff
Created April 27, 2021 09:58
Microsoft.Extensions.DependencyInjection.Abstractions.cs.diff
diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/ref/Microsoft.Extensions.DependencyInjection.Abstractions.cs b/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/ref/Microsoft.Extensions.DependencyInjection.Abstractions.cs
index 02ba0389eea..a3b9edc9fd2 100644
--- a/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/ref/Microsoft.Extensions.DependencyInjection.Abstractions.cs
+++ b/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/ref/Microsoft.Extensions.DependencyInjection.Abstractions.cs
@@ -8,22 +8,22 @@ namespace Microsoft.Extensions.DependencyInjection
{
public static partial class ActivatorUtilities
{
- public static Microsoft.Extensions.DependencyInjection.ObjectFactory CreateFactory([System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicConstructors)] System.Type instanceType, System.Type[] argumentTypes) { throw null
@bjorkstromm
bjorkstromm / keybase.md
Created February 10, 2021 11:46
keybase.md

Keybase proof

I hereby claim:

  • I am bjorkstromm on github.
  • I am mholo65 (https://keybase.io/mholo65) on keybase.
  • I have a public key ASAHd41ids9ag679TjHuWUAICRle1Cc_6c_UljEGdLD1SQo

To claim this, I am signing this object:

@bjorkstromm
bjorkstromm / list-appinsights.ps1
Last active August 12, 2020 11:36
List Application Insights configurations for Web Apps and Function Apps
$webApps = ConvertFrom-Json([string](& az webapp list --query "[*].{name: name, resourceGroup: resourceGroup}" -o json))
$webApps | ForEach-Object {
Write-Host $_.Name
$settings = ConvertFrom-Json([string](& az webapp config appsettings list -n $_.name -g $_.resourceGroup --query "{APPINSIGHTS_INSTRUMENTATIONKEY: [?name=='APPINSIGHTS_INSTRUMENTATIONKEY'].value | [0], APPLICATIONINSIGHTS_CONNECTION_STRING: [?name=='APPLICATIONINSIGHTS_CONNECTION_STRING'].value | [0]}"))
$_ | Add-Member -NotePropertyName APPINSIGHTS_INSTRUMENTATIONKEY -NotePropertyValue $settings.APPINSIGHTS_INSTRUMENTATIONKEY
$_ | Add-Member -NotePropertyName APPLICATIONINSIGHTS_CONNECTION_STRING -NotePropertyValue $settings.APPLICATIONINSIGHTS_CONNECTION_STRING
}
$funcApps = ConvertFrom-Json([string](& az functionapp list --query "[*].{name: name, resourceGroup: resourceGroup}" -o json))
$funcApps | ForEach-Object {
@bjorkstromm
bjorkstromm / frontdoor.ps1
Created June 1, 2020 10:05
Front Door - Access Restrictions
$ResourceGroup = "<your RG>"
$AppName = "<your App>"
az webapp config access-restriction add --priority 100 --action Allow -g $ResourceGroup -n $AppName --rule-name FrontDoor_13.73.248.16/29 --ip-address 13.73.248.16/29
az webapp config access-restriction add --priority 100 --action Allow -g $ResourceGroup -n $AppName --rule-name FrontDoor_20.36.120.104/29 --ip-address 20.36.120.104/29
az webapp config access-restriction add --priority 100 --action Allow -g $ResourceGroup -n $AppName --rule-name FrontDoor_20.37.64.104/29 --ip-address 20.37.64.104/29
az webapp config access-restriction add --priority 100 --action Allow -g $ResourceGroup -n $AppName --rule-name FrontDoor_20.37.156.120/29 --ip-address 20.37.156.120/29
az webapp config access-restriction add --priority 100 --action Allow -g $ResourceGroup -n $AppName --rule-name FrontDoor_20.37.195.0/29 --ip-address 20.37.195.0/29
az webapp config access-restriction add --priority 100 --action Allow -g $ResourceGroup -n $AppName --rule-name FrontDoor_20.37.224.1
#line 1 "B3437BF2-8AE3-4281-8726-B926BB9DF75D"
/// <summary>
/// Determines whether or not the specified argument exist.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="name">The argument name.</param>
/// <returns>Whether or not the specified argument exist.</returns>
/// <example>
/// This sample shows how to call the <see cref="M:Cake.Common.ArgumentAliases.HasArgument(Cake.Core.ICakeContext,System.String)" /> method.
/// <code>
@bjorkstromm
bjorkstromm / Xamarin.cshrml
Created August 8, 2019 20:14
Xamarin Gazorator
@inherits Gazorator.Scripting.RazorScriptHost<AndroidBinderator.BindingProjectModel>
@using System.Linq
@using System.Xml.Linq
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>MonoAndroid90</TargetFrameworks>
<IsBindingProject>true</IsBindingProject>
@if (!string.IsNullOrEmpty(Model.AssemblyName))
{
@bjorkstromm
bjorkstromm / program.cs
Created July 17, 2019 22:10
Catalog ids from Registration
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
namespace ConsoleApp3