Skip to content

Instantly share code, notes, and snippets.


Cameron MacFarland distantcam

View GitHub Profile
mgravell / more
Last active Apr 20, 2017
More comparisons of async/await implementations
View more


For Task<T> and ValueTask<T> (T=int as a common non-trivial but inlineable case), compare async performance in the synchronous scenario (i.e. where data happens to be buffered - common in deserialization etc code) for 3 implementations:

  • using await throughout
  • using synchronous code until incompleteness detected (via IsCompleted); switch via local async Awaited if needed
  • using synchronous code until incompleteness detected (via IsCompletedSuccessfully); switch via local async Awaited if needed


View aa_init.ps1
Set-ExecutionPolicy Unrestricted -force
# fix Mouse scrolling
Get-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Enum\HID\*\*\Device` Parameters FlipFlopWheel -EA 0 | ForEach-Object { Set-ItemProperty $_.PSPath FlipFlopWheel 1 }
# Choco install
iex ((new-object net.webclient).DownloadString(''))
choco feature enable -n=allowGlobalConfirmation
cinst cmdermini
cinst GoogleChrome
choco install vscode
anaisbetts / AsyncReaderWriterLock.cs
Created Mar 12, 2014
Async reader/writer lock via abusing ConcurrentExclusiveSchedulerPair
View AsyncReaderWriterLock.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
kevin-smets /
Last active Feb 28, 2021
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)





SimonCropp / gist:8485964
Last active Apr 30, 2016
Roslyn weaver
View gist:8485964

Roslyn Weaver


As a nuget package the same as Fody

Injection into the pipeline

Optionally replace/add cs files to the build pipeline in a similar wat to GFV

mikeminutillo / AwesomeWeb.cs
Created Dec 11, 2013
Create a new Console App, Install all of the Packages (or enable package restore and hand-edit the packages.config file), Create a Web Folder and move your Scripts folder into it, Create Home.html in the root of /Web, mark all of the child files of /Web as Copy Always. Hit F5 and go to your browser for NancyFx, SignalR and static file hosting on…
View AwesomeWeb.cs
using Microsoft.AspNet.SignalR;
using Microsoft.Owin.Hosting;
using Nancy;
using Nancy.Owin;
using Owin;
using System;
using System.IO;
using System.Reflection;
public class Program
View RateLimit.cs
// Only let input Observable fire every 'n' seconds at most
// but unlike Throttle, items fire immediately when they aren't
// rate-limited.
public IObservable<T> RateLimit<T>(this IObservable<T> This, TimeSpan interval, IScheduler scheduler)
var slot = default(IObservable<Unit>);
var input = This.Publish().RefCount();
return input.Window(input, _ => {
if (slot != null) return slot;
piscisaureus /
Created Aug 13, 2012
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

shiftkey / gist:3337426
Created Aug 13, 2012
My Ideal MVVM Framework
View gist:3337426
Things you need:
- a base implementation of ICommand - for Win8 I'd recommend asynchronous support. For early frameworks I'd say no.
- an interface for messaging between components - current favourite interface is MvvmLight's Messenger
- a base implementation of this messenger
Things you don't need:
- a base implementation of INotifyPropertyChanged - just IL weave and [don't think too hard about it](
pawelpabich / LogModule.cs
Created Jul 7, 2012
Log4Net and NLog modules for Autofac
View LogModule.cs
using System;
using System.Linq;
using Autofac;
using Autofac.Core;
using NLog;
using log4net;
using LogManager = NLog.LogManager;
namespace AutofacIdea