Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Working on .NET 6

David Fowler davidfowl

:octocat:
Working on .NET 6
View GitHub Profile
@davidfowl
davidfowl / fastlinkedlist.cs
Created Mar 30, 2014
Specialized lock free linked list with 2 operations, Add and GetListAndClear. Useful for implementing batching.
View fastlinkedlist.cs
public class FastLinkedList<T>
{
private Node Head;
public void Add(T value)
{
var node = new Node();
node.Value = value;
while (true)
View NowinServerFactory.cs
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting.Server;
using Microsoft.AspNet.Owin;
using Microsoft.Framework.ConfigurationModel;
namespace Nowin.vNext
View FsharpLoader.cs
using System;
using System.Linq;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.Versioning;
using System.Text;
using Microsoft.Framework.Runtime;
using System.IO;
using NuGet;
View AzureStreamingLoggerProvider.cs
public class AzureStreamingLoggerProvider : ILoggerProvider
{
public ILogger Create(string name)
{
return new AzureLogger(name);
}
private class AzureLogger : ILogger
{
private readonly string _name;
@davidfowl
davidfowl / inferme.cs
Created Feb 9, 2015
C# type inference
View inferme.cs
public static class MyClass
{
public static void DoSomething<T>(Func<int, T, int> call)
{
}
public static void Example()
{
// This fails
View gist:2bf1c256e084ed2f9863
Warning: FindPackagesById: System.Runtime.Handles
Error getting response stream (ReadDone1): ReceiveFailure
GET https://nuget.org/api/v2/FindPackagesById()?Id='System.Runtime.Handles'.
Warning: FindPackagesById: System.Diagnostics.Process
Error getting response stream (ReadDone1): ReceiveFailure
GET https://nuget.org/api/v2/FindPackagesById()?Id='System.Diagnostics.Process '.
Warning: FindPackagesById: System.Reflection.Primitives
Error getting response stream (ReadDone1): ReceiveFailure
GET https://nuget.org/api/v2/FindPackagesById()?Id='System.Reflection.Primitiv es'.
Warning: FindPackagesById: System.IO.FileSystem.Primitives
@davidfowl
davidfowl / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@davidfowl
davidfowl / gist:0fc85f3215adf4eab294
Created May 19, 2015
project structure DSL in C# 6.0
View gist:0fc85f3215adf4eab294
public class Program
{
public void Main()
{
var solution = new Directory
{
["global.json"] = new JObject
{
["projects"] = new JArray { "src", "test" }
},
@davidfowl
davidfowl / UseMapMiddleware.cs
Created Aug 12, 2015
Middleware that rejoins the parent pipeline
View UseMapMiddleware.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
namespace WebApplication58
{
public class MapUseMiddleware
@davidfowl
davidfowl / loadcontextredux.txt
Last active Aug 29, 2015
LoadContext strikes again
View loadcontextredux.txt
A (project) -> B (package)
(build)-> CustomCompiler (project) (build)-> FSharpCompiler (project) -> System.Runtime (package)
public interface ILoadContextProvider {
IAssemblyLoadContext GetLoadContext(Project project, FrameworkName targetFramework);
}
var loadContextProvider = ...
Compile(A)