Skip to content

Instantly share code, notes, and snippets.

View joelverhagen's full-sized avatar

Joel Verhagen joelverhagen

View GitHub Profile
@joelverhagen
joelverhagen / Program.cs
Created April 5, 2024 16:22
Managed identities or user impersonation with WindowsAzure.Storage
using System;
using System.Linq;
using Azure.Core;
using Azure.Identity;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
internal class Program
{
private static void Main(string[] args)
@joelverhagen
joelverhagen / clean_py.sh
Created October 8, 2012 16:48
Recursively removes all .pyc files and __pycache__ directories in the current directory
#!/bin/sh
# recursively removes all .pyc files and __pycache__ directories in the current
# directory
find . | \
grep -E "(__pycache__|\.pyc$)" | \
xargs rm -rf
# or, for copy-pasting:
@joelverhagen
joelverhagen / RedirectingHandler.cs
Last active January 16, 2024 05:04
RedirectingHandler
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace Knapcode.Http.Handlers
{
----------------------------------------
at Knapcode.FactorioTools.OilField.LocationIntSet..ctor(Int32 width, Int32 height)
at Knapcode.FactorioTools.OilField.Context.GetLocationSet()
at Knapcode.FactorioTools.SetHandling.ToSet(IEnumerable`1 items, Context context)
at Knapcode.FactorioTools.OilField.AddElectricPoles.GetElectricPoleGroups(Context context, Dictionary`2 electricPoles)
at Knapcode.FactorioTools.OilField.AddElectricPoles.ConnectElectricPoles(Context context, Dictionary`2 electricPoles)
at Knapcode.FactorioTools.OilField.AddElectricPoles.Execute(Context context, LocationIntSet avoid, Boolean allowRetries)
at Knapcode.FactorioTools.OilField.Planner.Execute(OilFieldOptions options, Blueprint blueprint, LocationIntSet electricPolesAvoid, EletricPolesMode electricPolesMode)
at Knapcode.FactorioTools.OilField.Planner.Execute(OilFieldOptions options, Blueprint inputBlueprint)
Total: 6775
@joelverhagen
joelverhagen / Program.cs
Created December 1, 2023 15:56
Validate consistency of NuGet.org catalog page items and pages
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Serialization;
using Xunit;
Console.WriteLine("Starting...");
var indexUrl = "https://api.nuget.org/v3/catalog0/index.json";
@joelverhagen
joelverhagen / Program.cs
Last active October 26, 2023 19:53
Retry conflicts with Azure SDK
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Text.Json;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.Data.Tables;
var messageHandler = new TestHandler { InnerHandler = new SocketsHttpHandler() };
var serviceClient = new TableServiceClient(
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
@joelverhagen
joelverhagen / Program.cs
Last active October 26, 2023 16:11
Missing x-ms-client-request-id in Azurite
using System.Net.Http.Headers;
using Azure.Core.Pipeline;
using Azure.Data.Tables;
using Azure.Storage.Blobs;
using Azure.Storage.Queues;
var connectionString = "UseDevelopmentStorage=true";
// var connectionString = "DefaultEndpointsProtocol=https;AccountName=REDACTED;AccountKey=REDACTED;EndpointSuffix=core.windows.net";
var pipeline = new HttpClientTransport(new TestHandler { InnerHandler = new HttpClientHandler() });
@joelverhagen
joelverhagen / Program.cs
Last active October 17, 2023 17:18
Performance test for in-memory Azurite
using Azure.Data.Tables;
using Azure.Storage.Blobs;
using Azure.Storage.Queues;
using Azure.Storage.Queues.Models;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Extensions;
using System.Diagnostics;
using System.Net;
using System.Text;
@joelverhagen
joelverhagen / README.md
Created February 12, 2012 02:14
Jekyll YouTube Embed Plugin

This is a plugin meant for Jekyll.

Example use:

Easily embed a YouTube video. Just drop this file in your _plugins directory.

{% youtube oHg5SJYRHA0 %}