Skip to content

Instantly share code, notes, and snippets.

@NickJosevski
NickJosevski / FSharpOptionConverter.cs
Last active March 5, 2016 20:26
FSharpOptionConverter : JsonConverter
public class FSharpOptionConverter : JsonConverter
{
private static MethodInfo _getInnerValue = typeof (FSharpOptionConverter).GetMethod("GetInnerValue",
BindingFlags.Instance |
BindingFlags.NonPublic);
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value != null)
{
var optionValueType = value.GetType().GetGenericArguments().Single();
@GeorgeHahn
GeorgeHahn / gist:914f2ebafff1ccd485b4
Last active September 12, 2018 19:34
Considering Rust + CLR interop

#Brainstorming Rust + C# interop

Use case A

  • Rust UI via WPF or Persperex
  • Make it feel like XAML is Rust-native
  • Put function name in WPF event handler, we stub out from that to Rust code
  • Rust event handlers written with a macro that we use to write interop stubs on each side
  • Can I do GUI nesting without XAML? Eg like the Zinc.rs config block, but for UI elements
  • Pros:
@robfe
robfe / Hubs.tt
Last active March 18, 2020 16:17
T4 template that creates Typescript type definitions for all your Signalr hubs. If you have C# interface named "I<hubName>Client", a TS interface will be generated for the hub's client too.If you turn on XML documentation in your build, XMLDoc comments will be picked up.Licensed with http://www.apache.org/licenses/LICENSE-2.0
<#@ template debug="true" hostspecific="true" language="C#" #>
<#@ output extension=".d.ts" #>
<# /* Update this line to match your version of SignalR */ #>
<#@ assembly name="$(SolutionDir)\packages\Microsoft.AspNet.SignalR.Core.2.2.0\lib\net45\Microsoft.AspNet.SignalR.Core.dll" #>
<# /* Load the current project's DLL to make sure the DefaultHubManager can find things */ #>
<#@ assembly name="$(TargetPath)" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Web" #>
<#@ assembly name="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #>
<#@ assembly name="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" #>
@johnnyreilly
johnnyreilly / GlobalizeUrls.cs
Last active October 10, 2015 06:58
A monkey patch for jquery.validate.js that allows validation to be internationalised
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Hosting;
using System.IO;
using System.Globalization;
namespace My.Helpers
{