Skip to content

Instantly share code, notes, and snippets.

View fredeil's full-sized avatar
🤔

Fredrik Eilertsen fredeil

🤔
View GitHub Profile
@davidfowl
davidfowl / Example.cs
Last active June 6, 2023 08:10
An implementation of MessagePipe. Something like a channel but with buffer management so you can peek and advance the message that was read.
using System.Buffers;
using System.Net.WebSockets;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/ws", async (HttpContext context) =>
{
const int MaxMessageSize = 1024 * 1024;
[StructLayout(LayoutKind.Sequential, Size = 256)]
public unsafe struct Bitset
{
public void Set(int bitIndex) => ((int*) Unsafe.AsPointer(ref Unsafe.AsRef(this)))[(bitIndex & ~7) >> 5] |= 1 << (bitIndex & 7);
public void Unset(int bitIndex) => ((int*)Unsafe.AsPointer(ref Unsafe.AsRef(this)))[(bitIndex & ~7) >> 5] ^= 1 << (bitIndex & 7);
public void SetAll() => Unsafe.InitBlock(Unsafe.AsPointer(ref Unsafe.AsRef(this)), 0xff, (uint) Unsafe.SizeOf<Bitset>());
public void UnsetAll() => Unsafe.InitBlock(Unsafe.AsPointer(ref Unsafe.AsRef(this)), 0x00, (uint) Unsafe.SizeOf<Bitset>());
}
@arthurrump
arthurrump / FakeGitVersioning.fsx
Last active August 14, 2019 10:35
How to use FAKE to automatically set version numbers based on your Git history. https://www.arthurrump.com/2019/07/19/git-based-versioning-using-fake
#r "paket:
nuget Fake.Core.SemVer
nuget Fake.Core.Target
nuget Fake.DotNet.Cli
nuget Fake.Tools.Git //"
#load "./.fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.Tools
@unitycoder
unitycoder / teams-ux-notes.md
Last active June 19, 2024 11:48
Whats Wrong With Microsoft Teams - UX

Whats Wrong With Microsoft Teams

*(not in any order, and i know few of these have been fixed, like having conference in separate window) **These are mostly from Classic version, will collect New Teams specific in the gist below

Chat

  • If you typed message in some chat, then alt tab and go to another chat, that message is still in the chatbox (wrong room)
  • if there is many single messages, with link on each, tooltip emoji menu popups and blocks your view to previews item (and you can accidentally click it if tried to click the previous link)
  • if paste image to messagebox, messagebox stays very small 2 rows.. so cannot see anything (or wait, it expands after you alt tab away..)
  • channel mention doesnt show alerts for people by default
  • replies minimize automatically if leave chat open for a while (so context is lost where you left it)
@praeclarum
praeclarum / CSharpPredictor.fs
Created July 19, 2018 17:48
Predicts then next C# tokens given a history of previous tokens using CoreML on iOS with F#
// Given previous tokens, predict the next token (and runners up)
let predictNextToken (previousKinds : SyntaxKind[]) : Prediction[] =
if ios11 then
let model : MLModel = model.Value // Load the cached model
let mutable predictions : Prediction[] = [| |]
// RNNs require external memory
let mutable lstm_1_h : MLMultiArray = null
let mutable lstm_1_c : MLMultiArray = null
@igogrek
igogrek / How I stopped loving Angular.md
Last active April 2, 2024 03:00
How I stopped loving Angular

I've worked with AngularJS for many years now and still use it in production today. Even though you can't call it ideal, given its historically-formed architecture, nobody would argue that it became quite a milestone not only for evolution of JS frameworks, but for the whole web.

It's 2017 and every new product/project has to choose a framework for development. For a long time I was sure that new Angular 2/4 (just Angular below) will become the main trend for enterprise development for years to come. I wasn't even thinking of working with something else.

Today I refuse to use it in my next project myself.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.WebMVC.Services
{
/// <summary>
/// When working with cloud services and Docker containers, it's very important to always catch
@joepie91
joepie91 / vpn.md
Last active July 29, 2024 07:41
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.