Skip to content

Instantly share code, notes, and snippets.

Avatar

Rick Strahl RickStrahl

View GitHub Profile
View file.xml
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
We couldn’t find that file to show.
View CreateGistFile.cs
public static JObject CreateGistPostJson(GistItem gist)
{
dynamic obj = new JObject();
obj.Add("description", new JValue(gist.description));
obj.Add("public", gist.isPublic);
obj.Add("files", new JObject());
obj.files.Add(gist.filename, new JObject());
@RickStrahl
RickStrahl / SimpleHttpServer.cs
Created Jan 11, 2022
A simple .NET HttpListener implementation of a basic static Web Server on Windows
View SimpleHttpServer.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Sockets;
using System.Net;
using System.IO;
using System.Threading;
namespace Westwind.Http.Server
{
@RickStrahl
RickStrahl / ApplicationInsightsUIIssues.md
Last active Nov 14, 2021
Application Insights Query Portal Issues
View ApplicationInsightsUIIssues.md

For ApplicationInsights in particular the UI is absolutely, horrendously terrible. I'm not a fan of Azure portal in general, but the ApplicationInsights portal in particular has a ton of UI issues that are not just cosmetic but functionally broken.

  • Startup shows a getting started video even on direct links to my query list or a specific query.

  • Can't jump directly to a query - always extra steps.

  • Creation of queries in the UI is confusing as hell
    Edit and Save are conflated in meaning. Save creates a new Snippet? WTF? But Ctrl-S saves? WTF?

@RickStrahl
RickStrahl / program.cs
Last active Nov 7, 2021
ASP.NET Core Live Reload not working with this basic startup
View program.cs
using LicensingService.Configuration;
using Microsoft.AspNetCore.Authentication.Cookies;
using Newtonsoft.Json.Serialization;
using Westwind.AspNetCore.LiveReload;
using Westwind.Licensing;
using Westwind.Utilities.Data;
var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;
var configuration = builder.Configuration;
@RickStrahl
RickStrahl / HttpClientPerfTestMinimal.cs
Created Oct 12, 2021
Simple test of HTTP Client under load with many simultaneous requests. For me this produces about 15000 requests in 20 seconds which is nearly on par with what the old HttpWebRequest client I used produced.
View HttpClientPerfTestMinimal.cs
[TestClass]
public class HttpClientPerfTests
{
private string testUrl = "https://localhost:5001/api/artist/33";
private int counter = 0;
private bool cancel = false;
private HttpClient GetHttpClient(bool force = false)
{
if (!force && _httpClient != null) return _httpClient;
@RickStrahl
RickStrahl / MinimalApiAspNetStartup.cs
Last active Oct 11, 2021
Minimal API Startup in 6.0 for ASP.NET Core application - Auto-Refresh not working for Razor
View MinimalApiAspNetStartup.cs
using LicensingService.Configuration;
using Microsoft.AspNetCore.Authentication.Cookies;
using Newtonsoft.Json.Serialization;
using Westwind.Licensing;
using Westwind.Utilities.Data;
var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;
var configuration = builder.Configuration;
var host = builder.Host;
@RickStrahl
RickStrahl / RunVsCodeFromDotnet.cs
Last active Oct 11, 2021
Demonstrates different ways to launch VS Code from C# code on Windows
View RunVsCodeFromDotnet.cs
void Main()
{
string file = @"C:\temp\test.md";
OpenFileInTextEditorRegistry(file);
//OpenEditorWithShellExecute(file);
//OpenWithProcessStartFailed(file);
}
@RickStrahl
RickStrahl / BitmapSourceToBitmap.cs
Last active Oct 11, 2021
BitmapSource To Bitmap Conversion
View BitmapSourceToBitmap.cs
/// <summary>
/// Converts a bitmap source to a bitmap
/// Make sure to dispose the bitmap
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static Bitmap BitmapSourceToBitmap(BitmapSource source)
{
if (source == null)
return null;