Skip to content

Instantly share code, notes, and snippets.

@panesofglass
panesofglass / protocols-experiment-2.fsx
Last active August 29, 2015 14:12
Experimenting with a potential solution for implementing protocols in F#
#nowarn "0686"
[<AbstractClass>]
type ListLike<'T>() =
abstract Head : 'T with get
abstract Tail : ListLike<'T> with get
abstract Length : int
static member op_Implicit(list: 'T list) =
{ new ListLike<'T>() with
@panesofglass
panesofglass / Runtime exception
Last active August 29, 2015 14:06
Repro of failing Katana app in Xamarin Studio
System.MissingMethodException
Method not found: 'System.Web.HttpApplication.RegisterModule'.
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /Volumes/build-root-ramdisk/mono-3.8.0/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
namespace WebSocket
// Appache 2.0 license
// References:
// [1] Proposed WebSockets Spec December 2011 http://tools.ietf.org/html/rfc6455
// [2] John McCutchan (Google Dart Team Member) http://www.altdevblogaday.com/2012/01/23/writing-your-own-websocket-server/
// [3] A pretty good Python implemenation by mrrrgn https://github.com/mrrrgn/websocket-data-frame-encoder-decoder/blob/master/frame.py
// [4] WebSockets Organising body http://www.websocket.org/echo.html
// [5] AndrewNewcomb's Gist (starting point) https://gist.github.com/AndrewNewcomb/711664
namespace WebSocket
// Appache 2.0 license
// References:
// [1] Proposed WebSockets Spec December 2011 http://tools.ietf.org/html/rfc6455
// [2] John McCutchan (Google Dart Team Member) http://www.altdevblogaday.com/2012/01/23/writing-your-own-websocket-server/
// [3] A pretty good Python implemenation by mrrrgn https://github.com/mrrrgn/websocket-data-frame-encoder-decoder/blob/master/frame.py
// [4] WebSockets Organising body http://www.websocket.org/echo.html
// [5] AndrewNewcomb's Gist (starting point) https://gist.github.com/AndrewNewcomb/711664
namespace Tsunami.Server
open System
open System.IO
open System.Linq
open System.Net
open System.Net.Sockets
open System.Text
open System.Threading
open System.Runtime.Serialization
@panesofglass
panesofglass / Global.asax.fs
Created July 10, 2014 18:40
Taliesin Sample
namespace FSharpWeb4
open Owin
open Microsoft.Owin
open System
open System.Net
open System.Net.Http
open System.Web
open Dyfrig
open Taliesin
open System.Net
open Microsoft.FSharp.Control.WebExtensions
open System.Diagnostics
open System
let fetch name (url:string) =
printfn "fetching %s" name
let uri = new System.Uri(url)
use webClient = new WebClient()
let stopwatch = Stopwatch()
@panesofglass
panesofglass / AsyncCallableHandler.fs
Last active April 24, 2023 17:53
How to use base.SendAsync in F# DelegatingHandler
type internal AsyncCallableHandler(messageHandler) =
inherit DelegatingHandler(messageHandler)
member internal x.CallSendAsync(request, cancellationToken) =
base.SendAsync(request, cancellationToken)
@panesofglass
panesofglass / MidFuncAsClass.cs
Last active February 18, 2016 15:42
Quick hack to adapt the current HttpMessageHandlerAdapter to the OWIN signatures
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using AppFunc = Func<IDictionary<string, obj>, Task>;
using MidFunc = Func<AppFunc, AppFunc>;
public class MidFuncType
{
private readonly AppFunc next;
#if run_with_bin_sh
# See why this works at http://stackoverflow.com/a/21948918/637783
exec fsharpi --define:mono_posix --exec $0 $*
#endif
(*
* Crossplatform FSharp Makefile Bootstrapper
* Apache licensed - Copyright 2014 Jay Tuley <jay+code@tuley.name>
* v 2.0 https://gist.github.com/jbtule/9243729
*