This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
// Basic data structures | |
[<Flags>] | |
type Day = | |
| None = 0 | |
| Mon = 1 | |
| Tue = 2 | |
| Wed = 4 | |
| Thu = 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Diagnostics | |
open System.Net | |
open System.Threading | |
let consolePrinter = | |
MailboxProcessor.Start(fun agent -> | |
async { | |
while true do | |
let! message = agent.Receive() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type account = Elastacloud.FSharp.AzureTypeProvider.AzureAccount< "accountName","accountKey" > | |
// Downloads LeagueTable.csv as an Async<string> | |
let textAsyncWorkflow = async { | |
let! text = account.Containers.container1.``LeagueTable.csv``.Download() | |
printfn "%s" (text.ToLower()) | |
return text | |
} | |
// Downloads binary.zip as an Async<Byte[]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Uses Unity to create Hubs - and ONLY Hubs. | |
/// </summary> | |
// Register with GlobalHost.DependencyResolver.Register(typeof(IHubActivator), () => unityHubActivator); | |
public class UnityHubActivator : IHubActivator | |
{ | |
private readonly IUnityContainer container; | |
public UnityHubActivator(IUnityContainer container) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A simple word-count mapper | |
let wordCountMapper (line : string) = | |
line.ToLower().Split(' ') | |
|> Seq.filter (not << System.String.IsNullOrEmpty) | |
|> Seq.map (fun word -> word, word) | |
// lets try to plug it into the Microsoft Hadoop API so we can call e.g. let mapper = createStreamingUnitExecutor wordCountMapper | |
let createStreamingUnitExecutor mapper = | |
// object expression to create a new implementation of the MapperBase based on the function provided | |
let mapperBase = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Foo(); | |
Console.ReadLine(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace AwaiterDemo | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Foo(); | |
Console.ReadLine(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
module Seq = | |
/// Evaluate a predicate over every item. If the predicate passes, return Some x, otherwise return None. | |
let toOptional predicate = | |
Seq.map(fun item -> if predicate item then Some item else None) | |
type Cell = | |
{ Index : int | |
X : int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open FSharp.Data | |
open System | |
type Outcome = | Win | Lose | Draw | |
type Location = | H | A | |
type Result = | |
{ Date : DateTime | |
Opponent : string | |
Location : Location | |
Score : int * int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
open System.Net | |
type FootballMail = | |
{ From : string * string | |
Subject : string | |
Date : string } | |
let emailWriter = |