Skip to content

Instantly share code, notes, and snippets.

Avatar

Rick Strahl RickStrahl

View GitHub Profile
@RickStrahl
RickStrahl / ColorConsole.cs
Last active Nov 24, 2021
Color Console - a simple class to add color to .NET Console commands more easily.
View ColorConsole.cs
using System;
using System.Text;
using System.Text.RegularExpressions;
namespace MainColorConsole
{
class Program
{
static void Main(string[] args)
{
View New-Machine-Windows-Configuration-Notes.md

Windows Setup Notes

based on original document from Alan Stevens

Installation

IMPORTANT:

  • Install using Local Account first, attach Microsoft account later
@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 / Inno File Associations.txt
Created Jun 29, 2017
File Association Registry Settings
View Inno File Associations.txt
[Registry]
; File Association for .md and .markdown
Root: HKCR; Subkey: ".md"; ValueData: "{#MyAppName}"; Flags: uninsdeletevalue; ValueType: string; ValueName: ""
Root: HKCR; Subkey: ".markdown"; ValueData: "{#MyAppName}"; Flags: uninsdeletevalue; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}"; ValueData: "Program {#MyAppName}"; Flags: uninsdeletekey; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}\DefaultIcon"; ValueData: "{app}\{#MyAppExeName},0"; ValueType: string; ValueName: ""
Root: HKCR; Subkey: "{#MyAppName}\shell\open\command"; ValueData: """{app}\{#MyAppExeName}"" ""%1"""; ValueType: string; ValueName: ""
View ImageSharpClipboard
public void ImageSharpClipboardTest()
{
string of = "c:\\temp\\test_imagesharp.png";
Assert.IsTrue(Clipboard.ContainsImage(), "No image on clipboard");
var img = Clipboard.GetImage();
ImageConverter converter = new ImageConverter();
byte[] bytes = (byte[])converter.ConvertTo(img, typeof(byte[]));
@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;
@RickStrahl
RickStrahl / file.cs
Created Jan 22, 2017
Gist Addin OnExecute() code that fires off the Addin's UI.
View file.cs
public override void OnExecute(object sender)
{
var editor = GetMarkdownEditor();
if (editor == null)
return;
var gist = new GistItem()
{
code = editor.AceEditor.getselection(false),
language = "cs"