Skip to content

Instantly share code, notes, and snippets.

@dazinator
dazinator / #emulate-managed-identity.md
Created April 8, 2024 17:49 — forked from maskati/#emulate-managed-identity.md
Emulate Azure managed identity locally
@dazinator
dazinator / docker-compose.yaml
Created July 18, 2023 12:18 — forked from lucj/docker-compose.yaml
fluent-bit / loki / grafana on Docker Swarm
version: '3.8'
configs:
loki-conf:
file: ./loki.conf
fluent-bit-conf:
file: ./fluent-bit.conf
networks:
monitoring:
@dazinator
dazinator / GLUSTER_SETUP.sh
Created December 1, 2022 17:28 — forked from smola/GLUSTER_SETUP.sh
Quick and dirty single-node GlusterFS setup
#
# Instructions for quick gluster server (1 node) setup with a volume on LVM.
# No replication, just using localhost.
#
# See https://docs.gluster.org/en/latest/Administrator%20Guide/Brick%20Naming%20Conventions/
#
# Install GlusterFS
add-apt-repository ppa:gluster/glusterfs-4.0
apt-get install glusterfs-server
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'windows-latest'
@dazinator
dazinator / unlist-packages.ps1
Last active June 10, 2020 13:37 — forked from dstockhammer/unlist-packages.ps1
Unlist all versions of a NuGet package
choco install nuget.commandline
$PackageId = "xxx"
$ApiKey = "yyy"
$json = Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/$PackageId/index.json" | ConvertFrom-Json
foreach($version in $json.versions)
{
Write-Host "Unlisting $PackageId, Ver $version"
@dazinator
dazinator / runtests.ps1
Created October 24, 2018 22:17
dotnet watch and run tests
Get-ChildItem -recurse *tests.csproj | % { Start-Process -FilePath 'dotnet' -NoNewWindow -ArgumentList "watch", "--project="$($_.FullName)"", "test";if($? -ne $TRUE) {throw 'Unit Test Failure.'} }
@dazinator
dazinator / gist:98b2cf4c99e7182b1e11fc4695cadaed
Last active January 31, 2018 15:18
Serilog Middleware - with log on dispose
class SerilogMiddleware
{
const string MessageTemplate =
"HTTP {RequestMethod} {RequestPath} {InterimStatusCode} status code {StatusCode} in {Elapsed:0.0000} ms";
private readonly ILogger Log; // global::Serilog.Log.ForContext<SerilogMiddleware>();
readonly RequestDelegate _next;
public SerilogMiddleware(RequestDelegate next, ILogger logger)
@dazinator
dazinator / FormsAuthenticationTicketHelper.cs
Last active December 27, 2023 09:46
Decrypt a Legacy ASP.NET Forms Authentication Cookie (that uses SHA1 validation, and AES encryption) - without horrendous dependencies on system.web.. This allows you to decrypt a forms authentication cookie that was created in ASP.NET 3.5, from an ASP.NET 5 application.
internal static class FormsAuthenticationTicketHelper
{
private const byte CURRENT_TICKET_SERIALIZED_VERSION = 0x01;
private const int MAX_TICKET_LENGTH = 4096;
// Resurrects a FormsAuthenticationTicket from its serialized blob representation.
// The input blob must be unsigned and unencrypted. This function returns null if
// the serialized ticket format is invalid. The caller must also verify that the
// ticket is still valid, as this method doesn't check expiration.
@dazinator
dazinator / UnlockIISHandlers.ps1
Last active June 25, 2020 16:11
Powershell to unlock IIS config section system.webServer/handlers
$assembly = [System.Reflection.Assembly]::LoadFrom("$env:systemroot\system32\inetsrv\Microsoft.Web.Administration.dll")
$manager = new-object Microsoft.Web.Administration.ServerManager
# load appHost config
$config = $manager.GetApplicationHostConfiguration()
Write-Host "Unlocking system.webServer/handlers"
$section = $config.GetSection('system.webServer/handlers')
$section.OverrideMode = 'Allow'
$manager.CommitChanges()
Write-Host "Unlocked system.webServer/handlers"
@dazinator
dazinator / ParseSemVerString.sql
Last active October 1, 2015 14:27
T-SQL function that takes a Semantic Version number string (see semver.org) and returns its component parts - Major, Minor, Patch, PreReleaseLabel and BuildMetadata
create function dbo.ParseSemVerString
(
-- a semantic version number string that meets specification described here: http://semver.org/
@versionString NVARCHAR(300)
)
returns @T table(Major int, Minor int, Patch int, PreReleaseLabel nvarchar(200), BuildLabel nvarchar(200))
as
begin
declare @segmentDelimiter char(1)