Skip to content

Instantly share code, notes, and snippets.

@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 / bdd.fsx
Last active March 16, 2016 18:12
f# bdd testing without framework
open NUnit.Framework
type Calculator() =
member __.Add x y = x + y
let ``Given I have entered`` firstNumber continuation =
let calculator = Calculator()
continuation (firstNumber, calculator)
let ``into the calculator`` (state,calculator) continuation =
@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 / gist:4994c67c03ffea04eee0
Created March 10, 2016 08:23
fake build script model
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#r "System.Xml.Linq"
#if MONO
#else
#r "Microsoft.VisualBasic"
#endif
#r @"packages/FAKE/tools/FakeLib.dll"
#I @"../../../bin"
#r @"../../../bin/FSharp.Data.SqlProvider.dll"
open System
open FSharp.Data.Sql
open System.Data
[<Literal>]
let connStr = "User ID=colinbull;Host=localhost;Port=5432;Database=sqlprovider;"
namespace ViewModels
open System
open System.Threading
open System.Collections.ObjectModel
open System.Windows
open System.Windows.Input
open FsXaml
@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 ->