Skip to content

Instantly share code, notes, and snippets.

@denmerc
denmerc / gist:d2510ea5b370a45392c60d774d26a917
Created October 11, 2016 18:35 — forked from richardadalton/gist:61fd9e02a34398c78c217c4fd311fdf5
A simple generic Command/Query Agent in F# using MailboxProcessor
type Message<'S> =
| Query of ('S -> unit)
| Command of ('S -> 'S)
| Kill
type CQAgent<'S>(state: 'S) =
let innerModel =
MailboxProcessor<Message<'S>>.Start(fun inbox ->
let rec messageLoop (state: 'S) =
async {
@denmerc
denmerc / README.md
Created October 6, 2016 17:57 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@denmerc
denmerc / 01_SayHello.fsx
Created September 27, 2016 21:12 — forked from akimboyko/01_SayHello.fsx
Samples from "Actor-based Concurrency with F# and Akka.NET" http://bit.ly/FSharpAkkaNET
#time "on"
#load "Bootstrap.fsx"
open System
open Akka.Actor
open Akka.Configuration
open Akka.FSharp
open Akka.TestKit
// #Using Actor
@denmerc
denmerc / on-jsx.markdown
Created August 13, 2016 19:13 — forked from chantastic/on-jsx.markdown
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I lead the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can'

@denmerc
denmerc / gist:afead2939215888870d7
Created March 15, 2016 07:00 — forked from dsyme/gist:9b18608b78dccf92ba33
Working self-contained getting-started sample for Suave Web Scripting
//==========================================
// Working fully self-contained getting-started example for Suave Web Server scripting
//
// Note you don't need to have _anything_ installed before starting with this script. Nothing
// but F# Interactive and this script.
//
// This script fetches the Paket.exe component which is referenced later in the script.
// Initially the #r "paket.exe" reference is shown as unresolved. Once it has been
// downloaded by the user (by executing the first part of the script) the reference
// shows as resolved and can be used.
@denmerc
denmerc / AsyncSockets.fs
Created February 5, 2016 23:31 — forked from t0yv0/AsyncSockets.fs
Asynchronous socket programming with F# async.
open System.Net.Sockets
type A = System.Net.Sockets.SocketAsyncEventArgs
type B = System.ArraySegment<byte>
exception SocketIssue of SocketError with
override this.ToString() =
string this.Data0
/// Wraps the Socket.xxxAsync logic into F# async logic.
@denmerc
denmerc / ws.fsx
Created February 5, 2016 23:27 — forked from DanThiffault/ws.fsx
Simple F# Web Server
open System
open System.Net
open System.Text
open System.IO
// Modified from http://sergeytihon.wordpress.com/2013/05/18/three-easy-ways-to-create-simple-web-server-with-f/
// download this file to your root directory and name as ws.fsx
// run with `fsi --load:ws.fsx`
// visit http://localhost:8080
@denmerc
denmerc / BootstrapService.cs
Created February 5, 2016 00:02 — forked from KevM/BootstrapService.cs
Example configuration of Topshelf to turn an console application into a Windows service
public class BootstrapService : ServiceControl
{
private readonly HostSettings _settings;
private Container _container;
private CaseMonitor _monitor;
public BootstrapService(HostSettings settings)
{
_settings = settings;
}
@denmerc
denmerc / CloudAgent-3.fs
Created January 15, 2016 23:40 — forked from isaacabraham/CloudAgent-3.fs
Mailbox Processor in Cloud Agent with automatic dead lettering and at-least-once processing.
let CreateActor (ActorKey name) =
MailboxProcessor.Start(fun mailbox ->
let messageStore = GetMessageStore name
let rec loop data =
async {
// Wait asynchronously until we get a message + reply channel
let! message, replyWith = mailbox.Receive()
match message with
| Clear ->
@denmerc
denmerc / FilesystemWatchCache.cs
Created December 28, 2015 07:40 — forked from anaisbetts/FilesystemWatchCache.cs
An Rx-friendly Filesystem Watcher
using System;
using System.IO;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using ReactiveUI;
namespace SaveAllTheTime.Models
{
interface IFilesystemWatchCache
{