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
(* | |
* To get started, `dotnet new --lang f#` | |
* Add these to the 'dependencies' section in project.json: | |
"System.Threading.Tasks": "4.0.11-rc2-*", | |
"Microsoft.AspNetCore.Hosting":"1.0.0-rc2-final", | |
"Microsoft.Extensions.Logging.Console":"1.0.0-rc2-final", | |
"Microsoft.AspNetCore.Server.Kestrel":"1.0.0-rc2-final" | |
* And then edit Program.fs with reqHandler for the RequestDelegate, | |
* wrapping an async workflow. | |
*) |
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
let calcObjHash (objData:byte array) = | |
use sha1 = new System.Security.Cryptography.SHA1Managed () | |
let pre = | |
sprintf "blob %d\000" objData.Length | |
|> System.Text.Encoding.UTF8.GetBytes | |
use ms = new System.IO.MemoryStream () | |
ms.Write (pre, 0, pre.Length) | |
ms.Write (objData, 0, objData.Length) | |
ms.Position <- 0L | |
sha1.ComputeHash (ms) |
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.Drawing | |
[<EntryPoint>] | |
let main argv = | |
let text = argv.[0] | |
use font = new Font("Courier New", 72.0f * 5.0f, FontStyle.Bold) | |
let getTextSize str = | |
use b = new Bitmap (1, 1) | |
use g = b |> Graphics.FromImage | |
g.MeasureString (str, font) |
NewerOlder