Skip to content

Instantly share code, notes, and snippets.

View Lakerfield's full-sized avatar

Michael Lakerveld Lakerfield

View GitHub Profile
@Lakerfield
Lakerfield / RejectWebsocketOverHttp2WhileUnsupportedMiddleware.cs
Created December 27, 2022 18:36
Fix for YARP reverse proxy when using home assistant companion app. Untill https://github.com/microsoft/reverse-proxy/issues/1375 is fixed, this middleware will reject websocket CONNECT over HTTP/2.0
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
namespace Lakerfield.Net.ProxyApp.Middleware
{
/// <summary>
/// Fix to disable websockets over non http/1.1 connections
/// Implementation of comment https://github.com/microsoft/reverse-proxy/issues/1375#issuecomment-1312799130
@Lakerfield
Lakerfield / InExpression.MD
Created October 19, 2022 14:12 — forked from bartdesmet/InExpression.MD
Roslyn workshop (Techorama) - Add a new `in` expression to C#

Add a new in expression to C#

Goals

In this workshop, we'll add a new in expression to C#, with example use cases shown below:

x in 1..10     // x >= 1 && x < 10
'a' in "bar"   // "bar".IndexOf('a') >= 0   -or-   "bar".Contains('a')
x in xs // xs.Contains(x)
@Lakerfield
Lakerfield / cheat-sheet.md
Last active October 11, 2017 12:26
Lakerfields cheat sheets

Multiple cheatsheets

  • cron
  • ssh
  • ubuntu updates
  • docker on azure
@Lakerfield
Lakerfield / index.html
Last active January 11, 2024 15:36
Print ZPL from browser
<!doctype html>
<html lang="en">
<head>
<title>Print ZPL from browser</title>
</head>
<body>
<h1>Test page for print ZPL from browser!</h1>
<script type="text/javascript">
function printZpl(zpl) {
@Lakerfield
Lakerfield / keybase.md
Created January 6, 2016 12:21
keybase.md

Keybase proof

I hereby claim:

  • I am lakerfield on github.
  • I am lakerfield (https://keybase.io/lakerfield) on keybase.
  • I have a public key whose fingerprint is AD0F CB46 8D85 7583 D5F5 FC54 2CA5 C95F 67A9 2CE4

To claim this, I am signing this object:

@Lakerfield
Lakerfield / A_Wcf_SelfHost_Gzip.cs
Last active March 25, 2021 21:23
A WCF SelfHost GZip Content-Encoding implementation for .NET 4.5
// A WCF SelfHost GZip Content-Encoding implementation for .NET 4.5 based on:
// Work of Francesco De Vittori @ http://www.frenk.com/2009/12/gzip-compression-wcfsilverlight/
// and Microsoft’s Compression Encoder sample http://msdn.microsoft.com/en-us/library/ms751458.aspx
// Files of blog post: http://lakerfield.eu/post/2014/06/17/A-WCF-SelfHost-GZip-Content-Encoding-implementation-for-NET-45.aspx
_serviceHost = new ServiceHost(typeof(MyService), new Uri(Options.Url));
var encoding = new GZipMessageEncodingBindingElement(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8));