This file contains hidden or 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
//Using Azure Table Storage with WindowsAzure.Storage | |
open Microsoft.WindowsAzure.Storage | |
open Microsoft.WindowsAzure.Storage.Table | |
open Microsoft.WindowsAzure.ServiceRuntime | |
type Person(partitionKey, rowKey, name) = | |
inherit TableEntity(partitionKey, rowKey) | |
new(name) = Person("defaultPartition", System.Guid.NewGuid().ToString(), name) | |
new() = Person("") |
This file contains hidden or 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
module BtcTesting | |
open System | |
open System.Security.Cryptography | |
/// https://en.bitcoin.it/wiki/Base58Check_encoding | |
let base58encode (hash:byte[]) = | |
let code_string = ['1'..'9']@['A'..'H']@['J'..'N']@['P'..'Z']@['a'..'k']@['m'..'z'] |> List.toArray | |
let data = hash |> Array.toList | |
This file contains hidden or 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.Threading | |
/// Async timer to perform actions | |
let timer interval scheduledAction = async { | |
do! interval |> Async.Sleep | |
scheduledAction() | |
} | |
/// Add action to timer, return cancellation-token to cancel the action |
This file contains hidden or 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
module String = let notNullOrEmpty = not << System.String.IsNullOrEmpty |
This file contains hidden or 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
#if INTERACTIVE | |
#else | |
module LogReader | |
#endif | |
//Log file parser for log4Net files. | |
open System | |
open System.IO | |
type CollectData = |
This file contains hidden or 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.Threading | |
open System.IO | |
open Microsoft.FSharp.Control.WebExtensions | |
type Agent<'T> = MailboxProcessor<'T> | |
type SingleAgent<'T> = | |
| Set of 'T | |
| Get of AsyncReplyChannel<List<'T>> |
This file contains hidden or 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
== MyItem 1 == | |
...some content... | |
Total: 10 | |
Success | |
== MyItem 2 == | |
...some content... | |
Total: 2 | |
Failed |
This file contains hidden or 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 | |
open System.Drawing | |
let ImageSize = 300 | |
let fetchImage (url : Uri) = | |
let req = WebRequest.Create (url) :?> HttpWebRequest | |
use stream = req.GetResponse().GetResponseStream() |
This file contains hidden or 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
// Erlang-style message-passing: | |
// Agent that can upgrade its functionality on the fly. | |
// Note: static typing, this agent can't upgrade its state data type (so better to use obj or custom interface)... | |
// Also this runs only in localhost... | |
// So this is more a technical demo than something useful | |
open System | |
type Methods<'state, 'x, 'reply> = | |
| Upgrade of |
This file contains hidden or 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
// This shows how you can: | |
// 1) Code from top-down, give high level picture first and then go to details | |
// 2) Define LINQ outside EF-context and still convert it to SQL: | |
// - Don't hammer the database! | |
// 3) Have small independend classes (/parts) | |
// 4) Have state-less code with no global/class-variables outside entities | |
// 5) Easy to test: | |
// - Integration test with EF-DbContext. | |
// - LINQ logics unit tests without DbContext (with unit tests InternalsVisibleToAttribute). |