View Emojis.fs
// In Windows you can press WindowsKey+"." to open Emoji menu. | |
let ``🍕`` = "🥓" + "🍍" | |
//val ( 🍕 ) : string = "🥓🍍" |
View myvisitor.fs
// A simple expression tree visitor, to inject a lambda inside another lambda parameters. | |
open Microsoft.FSharp.Linq.RuntimeHelpers | |
open System | |
open System.Linq.Expressions | |
//F#-helper method for Linq.Expressions: fssnip.net/ts/title/F-lambda-to-C-LINQ-Expression | |
module Lambda = | |
let toExpression (``f# lambda`` : Quotations.Expr<'a>) = | |
``f# lambda`` | |
|> LeafExpressionConverter.QuotationToExpression |
View Program.fs
module GraphVizSample | |
open GraphVizWrapper | |
open GraphVizWrapper.Commands | |
open GraphVizWrapper.Queries | |
open System | |
open System.Configuration | |
open System.Drawing | |
open System.IO |
View uaparse.fs
open System | |
open System.IO | |
open System.Net | |
open System.Text.RegularExpressions | |
let req = HttpWebRequest.Create "https://raw.githubusercontent.com/ua-parser/uap-core/master/regexes.yaml" | |
let resp = (new StreamReader(req.GetResponse().GetResponseStream())).ReadToEnd() | |
let lines = resp.Split( [| Environment.NewLine; "\r"; "\n"; "\r\n" |], StringSplitOptions.RemoveEmptyEntries) | |
/// Minimal YAML-file parsing | |
let yamlParse = |
View bitbucket-pipelines.yml
# Take FSharp docker image and run Fake build script using Paket FSharp and Gulp. | |
image: fsharp:latest | |
pipelines: | |
default: | |
- step: | |
script: | |
- echo "Runs on branches that don't have specific pipeline." | |
# Install general utilities for building | |
- apt-get -qq update |
View ftps.fs
// FTPS = SSL encrypted FTP. | |
// SFTP = FTP over SSH. | |
// Set this as config, as the server may change the certificate. | |
let ``trusted server certificate hash`` = "603780E732DB12D0F6BA434BA8E04D141904A165" | |
open System | |
open System.IO | |
open System.Net | |
open System.Net.Security |
View sftp.fs
// #r "../packages/SSH.NET/lib/net40/Renci.SshNet.dll" | |
open Renci.SshNet | |
open System.IO | |
/// FSharp Async wrapper for SSH.NET SFTP | |
type SftpClient with | |
member x.ListDirectoryAsync path = | |
Async.FromBeginEnd((fun(iar,state) -> |
View DecisionTree.fs
(* | |
Install-Package FSharp.Data | |
Install-Package Accord | |
Install-Package Accord.MachineLearning | |
Install-Package Accord.Math | |
Install-Package Accord.Statistics | |
*) | |
#if INTERACTIVE |
View extension.fs
// Example follows this, translated to FSharp: | |
// https://msdn.microsoft.com/en-us/library/dn903708.aspx | |
// Just instead of copy&pasting C#, add a new F# class library and paste this code to there, | |
// then add that to reference to your C#-project. | |
// If you want to deploy without C# project, see e.g. this: | |
// You need to use some VSIX-package to deploy the code: | |
// https://github.com/fsharp-vsix/FsVSIX |
View ml.fs
// This example uses the same data and methods as | |
// http://accord-framework.net/docs/html/T_Accord_Statistics_Models_Regression_LogisticRegression.htm | |
#I @"./packages" | |
#r @"FSharp.Data.2.3.2/lib/net40/FSharp.Data.dll" | |
#r @"Accord.3.4.0/lib/net45/Accord.dll" | |
#r @"Accord.MachineLearning.3.4.0/lib/net45/Accord.MachineLearning.dll" | |
#r @"Accord.Math.3.4.0/lib/net45/Accord.Math.Core.dll" | |
#r @"Accord.Math.3.4.0/lib/net45/Accord.Math.dll" | |
#r @"Accord.Statistics.3.4.0/lib/net45/Accord.Statistics.dll" |
NewerOlder