Skip to content

Instantly share code, notes, and snippets.

View lethek's full-sized avatar

Michael Monsour lethek

  • Workday
  • Brisbane, Australia
  • 12:21 (UTC +10:00)
  • X @lethek
View GitHub Profile
@jaredpar
jaredpar / buffalo.cs
Last active January 31, 2022 12:19
buffalo.cs
using System;
using System.Runtime.CompilerServices;
class await {
async async async(async async) => await async(async(async));
}
[AsyncMethodBuilder(typeof(builder))]
delegate async async(async async);
@pamolloy
pamolloy / README.md
Last active October 16, 2024 20:40
Ubiquiti USG configuration for Wireguard

Download the latest ugw3 package from https://github.com/Lochnair/vyatta-wireguard/releases and install it on your USG using dpkg -i wireguard-ugw3-<version>.deb.

cd /config/auth
umask 077
mkdir wireguard
cd wireguard
wg genkey > wg_private.key
wg pubkey < wg_private.key > wg_public.key
@GrabYourPitchforks
GrabYourPitchforks / memory_guidelines.md
Last active August 21, 2024 09:07
Memory usage guidelines

Memory<T> usage guidelines

This document describes the relationship between Memory<T> and its related classes (MemoryPool<T>, IMemoryOwner<T>, etc.). It also describes best practices when accepting Memory<T> instances in public API surface. Following these guidelines will help developers write clear, bug-free code.

First, a tour of the basic exchange types

  • Span<T> is the basic exchange type that represents contiguous buffers. These buffers may be backed by managed memory (such as T[] or System.String). They may also be backed by unmanaged memory (such as via stackalloc or a raw void*). The Span<T> type is not heapable, meaning that it cannot appear as a field in classes, and it cannot be used across yield or await boundaries.

  • Memory is a wrapper around an object that can generate a Span. For instance, Memory instances can be backed by T[], System.String (readonly), and even SafeHandle instances. Memory cannot be backed by "transient" unmanaged me

@janv8000
janv8000 / AsyncRunner.cs
Created January 12, 2015 13:32
Start background tasks from MVC actions using Autofac
public interface IAsyncRunner
{
void Run<T>(Action<T> action);
}
public class AsyncRunner : IAsyncRunner
{
public ILifetimeScope LifetimeScope { get; set; }
public AsyncRunner(ILifetimeScope lifetimeScope)
@patroza
patroza / BaseHub.cs
Last active September 4, 2015 07:08 — forked from lethek/AirtimeHub.cs
Using Mef to inject dependencies into SignalR hubs and manage dependency lifetimes. Currently makes assumptions based on using the request scoped container implementation from https://github.com/sickboy/Heliar-Web-Composition/tree/develop
public abstract class BaseHub : Hub
{
public EventHandler Disposing;
bool _disposed;
protected override void Dispose(bool disposing) {
if (_disposed)
return;
_disposed = true;