Skip to content

Instantly share code, notes, and snippets.

@denmerc
denmerc / exampleElastic.fsx
Created August 18, 2017 16:57 — forked from MartinBodocky/exampleElastic.fsx
ElasticSearch and F#
#r "../packages/Elasticsearch.Net.2.0.4/lib/net46/Elasticsearch.Net.dll"
#r "../packages/NEST.2.0.4/lib/net46/Nest.dll"
#r "../packages/Newtonsoft.Json.8.0.2/lib/net45/Newtonsoft.Json.dll"
open System
open System.Linq
open Nest
module Utils =
open Microsoft.FSharp.Quotations
@denmerc
denmerc / elasticsearch.fsx
Created August 17, 2017 05:19 — forked from mjul/elasticsearch.fsx
Elasticsearch in F# example
// paket add nuget NEST
#I "../../packages"
#r "Elasticsearch.Net/lib/net46/Elasticsearch.Net.dll"
#r "NEST/lib/net46/Nest.dll"
open System
//open Elasticsearch.Net
open Nest
@denmerc
denmerc / Dapper.fs
Created July 16, 2017 00:32 — forked from vbfox/Dapper.fs
Minimal dapper in F#
module DapperFSharp =
open System.Data.SqlClient
open System.Dynamic
open System.Collections.Generic
open Dapper
let dapperQuery<'Result> (query:string) (connection:SqlConnection) =
connection.Query<'Result>(query)
let dapperParametrizedQuery<'Result> (query:string) (param:obj) (connection:SqlConnection) : 'Result seq =
@denmerc
denmerc / redis-complete.fs
Created July 15, 2017 21:55 — forked from mlusiak/redis-complete.fs
Putting it all together - get data, save to redis, read back, chart
#if INTERACTIVE
#r "bin/Debug/FSharp.Data.dll"
#r "bin/Debug/FSharp.Charting.dll"
#r "bin/Debug/ServiceStack.Common.dll"
#r "bin/Debug/ServiceStack.Interfaces.dll"
#r "bin/Debug/ServiceStack.Text.dll"
#r "bin/Debug/ServiceStack.Redis.dll"
#load "../packages/FSharp.Charting.0.90.5/FSharp.Charting.fsx"
#endif
open System.IO
open Suave
open Suave.Http
open Suave.Operators
open Suave.Filters
open Suave.Successful
open Suave.Files
open Suave.RequestErrors
open Suave.Logging
open Suave.Utils
// include Fake lib
#r "packages/FAKE/tools/FakeLib.dll"
#r "System.Xml.Linq"
open Fake
open System.Xml.Linq
RestorePackages()
// Properties
let artifactsNuGetDir = @"./artifacts/nuget/"
@denmerc
denmerc / WebSocketServer.fs
Created January 9, 2017 18:58 — forked from AndrewNewcomb/WebSocketServer.fs
OLD from 2010 ... Updated example of using F# MailboxProcessor against an HTML5 WebSocket (in Google Chrome)
// Example of using F# MailboxProcessor against an HTML5 WebSocket (in Google Chrome)
// taken from http://v2matveev.blogspot.com/2010/04/mailboxprocessors-practical-application.html
// and then modified to work with the revised WebSocket protocol that includes a set of challenge bytes.
// The main changes are in the handshake function.
// Have a look at the http://nugget.codeplex.com for example WebSocket code in C#, on which I based the
// challenge processing code.
open System
open System.IO
open System.Linq
@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