Skip to content

Instantly share code, notes, and snippets.

@miso-soup
miso-soup / App.config
Last active March 7, 2020 02:39
Importing a CSV file into Azure Table Storage
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
<appSettings>
<add key="AzureStorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=*****;AccountKey=*****" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
@cloudRoutine
cloudRoutine / 01_folds.fs
Last active December 12, 2022 13:01
F# Transducers - they work for the most part
open System.Collections.Generic
open Microsoft.FSharp.Collections
[<RequireQualifiedAccess>]
module Folds =
// These are the fast implementations we actually want to use
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
(*
CapabilityBasedSecurity_ConfigExample.fsx
An example of a simple capability-based design.
Related blog post: http://fsharpforfunandprofit.com/posts/capability-based-security/
*)
/// Configuration system
module Config =
@mattpodwysocki
mattpodwysocki / transducer.js
Created October 20, 2014 03:34
Transducer support coming in 2.3.14
/**
* Executes a transducer to transform the observable sequence
* @param {Transducer} transducer A transducer to execute
* @returns {Observable} An Observable sequence containing the results from the transducer.
*/
observableProto.transduce = function(transducer) {
var source = this;
function transformForObserver(observer) {
return {
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
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()
@gusty
gusty / trampoline.fsx
Last active February 27, 2024 08:04
Trampolines in F#
let trampoline f c n =
let rec loop = function
| Choice1Of2 x -> x
| Choice2Of2 x -> loop (f x)
loop (Choice2Of2 (c,n))
// Test
let factorial n =
let rec factorialT (current, n) =
if n = bigint 0 then Choice1Of2 current
(*
Towards verifying message-passing protocols.
Protocol typically involves two parties, let us call Client and Server,
a number of states and state transitions involving passing of messages.
Client has agency - non-deterministic process in process calculi.
Server is deterministic, but it should handle all possible clients.
Ideally, we would take a DSL for the protocol, and spit out F# code that