This is my 100th blog post. I want to say thank you to all of you who reads my blog and follows me in twitter. Thanks to your interest new posts appear in this blog.
Author: Sergey Tihon 🦔🦀🦋
15 Principles for Data Scientists
I have developed 15 principles for my daily work as a data scientist. These are the principles  that I personally follow :
1- Do not lie with data and do not bullshit:Â Be honest and frank about empirical evidences. And most importantly do not lie to yourself with data
2- Build everlasting tools and share them with others: Spend a portion of your daily work building tools that makes someone’s life easier. We are freaking humans, we are supposed to be tool builders!
3- Educate yourself continuously: you are a scientist for Bhudda’s sake. Read hardcore math and stats from graduate level textbooks. Never settle down for shitty explanations of a method that you receive from a coworker in the hallway. Learn fundamentals and you can do magic. Read recent papers, go to conferences, publish, and review papers. There is no shortcut for this.
4- Sharpen your skills: learn one language well…
View original post 413 more words
F# Weekly #21 2013
![]() |
![]() |
Welcome to F# Weekly,
A roundup of F# content from this past week:
News
- Facebook social network analysis with Tsunami.
- FCell evaluation is now publicly available from Statfactory.
- An early prototype of a package / content search system based on Sliverlight PivotViewer.
- Matlab Type Provider now supports vararg in/out and matlab native functions.
- MS has fixed an F# bug: Now you can add F# projects to Azure web sites and deploy them from Git.
- Bunch of talks from flatMap 2013 Oslo were posted.
- It would be nice to have Nancy.FSharp as Nancy wrapper for F#.
Videos/Presentations
- “Developing a Windows 8 application with F#” by Gustavo Guerra.
- “F# Type Providers” by Jonas Folleso.
Blogs
- Mathias Brandewinder blogged “F# Coding Dojo in SF last week“.
- Phil Trelford shared “Modern Art“.
- Phil Trelford shared “.Net Developer – Opportunities to work with F#“.
- Matthew Adams wrote series of posts:
- Colin Bull posted “F# 3 and Raven DB“.
- Colin Bull posted “F# Actor: An Actor Library“.
- Faisal Waris wrote “Crypto in a few lines of F#“.
- Stuart Lodge shared “Awesome-F# + Awesome-Xamarin.iOS + Awesome-JMGomez“.
- Dave Fancher blogged “Replicating F#’s using Function in C#“.
- Natallie Baikevich posted “Z3 Mono Starter“.
- Lev Gorodinski wrote about “Domain-Driven Design (DDD) With F# – Validation“.
- The Nashville .NET User Group posted “May 16th Lab: Change of Plans – Intro to F#“.
- The Nashville .NET User Group posted “F# Lab Feedback“.
- Gene Belitski posted “If Google would be looking to hire F# programmers – part 6“.
- David Tchepak blogged “Why not try F#?“.
That’s all for now.  Have a great week.
Previous F# Weekly edition – #20
F# Weekly #20 2013
Welcome to F# Weekly,
This past week was full of interesting events and happenings. If you follow F#, you must read all of this carefully. The roundup of F# content:
News
- F# is now available on FreeBSD!
- Matlab Type Provider is available now.
- Does F# need a type-safe data-frame library? How should it look? (Discuss here)
- Ensure you have your say and vote or contribute to F# user voice.
- If you like F#, let MSR know about it.
- Just released a new beta of Tsunami IDE! Excel support back in as are 3rd party plugins.
- If you know any women interested in functional programming, let them know about lambdaladies.com.
- Updated F# Formatting is now on NuGet – with better line-number formatting, tables & Latex support.
- Functional Programming Using F#Â is available now.
- Record improvements were merged into MongoDB.FSharp.
- Time to vote for the sessions you want to see at DDD East Anglia in Cambridge on June 29th.
- Follow @FCellAddIn to get updates about FCell, integrating F# and C# with Excel.
- Cleaned-up version of LazyList was added to ExtCore.
- Free personal licenses for Alea.cuBase are available.
- The Manifesto for Not Only Object-Oriented Development now in Czech/Danish/French/German/Russian/Spanish.
Videos/Presentations
- “Functional DSLs for Biocomputation” by Colin Gravill.
- “Building a MMORPG with F#” by Yan Cui. (post)
Blogs
- Michael Bayne posted “F# Cheat Sheet“.
- Gustavo Guerra blogged “Building Type Providers – Part 1“.(!!!hot!!!)
- Don Syme posted “F# on FreeBSD“.
- Yossi Kreinin shared “Parallelism and concurrency need different tools“.
- Damir Arh published “Windows Phone 7.5 Application Development With F#“.
- John Liao wrote “Riak Links and Link Walking with F# and CorrugatedIron“.
- Nick Palladinos posted Clojure’s Reducers in F#.
- Tomas Petricek blogged “Power of mathematics: Reasoning about functional types“.
- Phil Trelford announced “F# UK ton of Meetups“.
- Richard Dalton wrote about “Learning to think Functionally: Memoization“.
- Juan M Gomez published “Reaching the Nirvana: MvvmCross + Xamarin.iOS + FSharp“.
-
Scott Wlaschin posted “How to design and code a complete program“.
- Scott Wlaschin posted “Railway oriented programming“.(!!!hot!!!)
- Scott Wlaschin posted “Why I won’t be writing a monad tutorial“.
- Sergey Tihon shared “Live tweets from Alea.cuBase F#-for-financial-GPU event in London.“
- Phil Trelford wrote about “F# Deep Dives“.
- Lincoln Atkinson blogged “A Twitter search client in 10 lines of code with F# and the JSON type provider“.
- Sergey Tihon blogged “Three easy ways to create simple Web Server with F#“.
- Gene Belitski posted “If Google would be looking to hire F# programmers – part 5“.
That’s all for now.  Have a great week.
Previous F# Weekly edition – #19

![]() |
![]() |
![]() |
Three easy ways to create simple Web Server with F#
I have tried to find easiest ways to create a simple web server with F#. There are three most simple ways to do it.
The goal is to create a simple web service that maps web request urls to the files in the site folder. If file with such name exists then return its content as html. Assume that all html files located in ‘D:\mySite\‘.
HttpListener
First and probably the most promising option was created by Julian Kay and described in his post “Creating a simple HTTP Server with F#“. I slightly modified source code to satisfy my initial goal. You can find detailed description of how it works in Julian’s post. (Works from FSI)
open System
open System.Net
open System.Text
open System.IO
let siteRoot = @"D:\mySite\"
let host = "http://localhost:8080/"
let listener (handler:(HttpListenerRequest->HttpListenerResponse->Async<unit>)) =
let hl = new HttpListener()
hl.Prefixes.Add host
hl.Start()
let task = Async.FromBeginEnd(hl.BeginGetContext, hl.EndGetContext)
async {
while true do
let! context = task
Async.Start(handler context.Request context.Response)
}Â |>Â Async.Start
let output (req:HttpListenerRequest) =
let file = Path.Combine(siteRoot,
Uri(host).MakeRelativeUri(req.Url).OriginalString)
printfn "Requested : '%s'" file
if (File.Exists file)
then File.ReadAllText(file)
else "File does not exist!"
listener (fun req resp ->
async {
let txt = Encoding.ASCII.GetBytes(output req)
resp.ContentType <- "text/html"
resp.OutputStream.Write(txt, 0, txt.Length)
resp.OutputStream.Close()
})
// TODO: add your code here
Self-hosted WCF service
The second option is a tuned self-hosted WCF service. This approach was proposed by  Brian McNamara as an answer to the StackOverflow question “F# web server library“. (Works from FSI)
#r "System.ServiceModel.dll"
#r "System.ServiceModel.Web.dll"
open System
open System.IO
open System.ServiceModel
open System.ServiceModel.Web
let siteRoot = @"D:\mySite\"
[<ServiceContract>]
type MyContract() =
[<OperationContract>]
[<WebGet(UriTemplate="{file}")>]
member this.Get(file:string) : Stream =
printfn "Requested : '%s'" file
WebOperationContext.Current.OutgoingResponse.ContentType <- "text/html"
let bytes = File.ReadAllBytes(Path.Combine(siteRoot, file))
upcast new MemoryStream(bytes)
let startAt address =
let host = new WebServiceHost(typeof<MyContract>, new Uri(address))
host.AddServiceEndpoint(typeof<MyContract>, new WebHttpBinding(), "")
|>Â ignore
host.Open()
host
let server = startAt "http://localhost:8080/"
// TODO: add your code here
server.Close()
NancyFx
The third one is based on NancyFx. It is lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono. Nancy is a popular framework in C# world, but does not have a natural support of F#. The F# code looks not so easy and simple as it could be. If you want to make it work, you need to create console application and install the Nancy and Nancy.Hosting.Self NuGet packages.
module WebServers
open System
open System.IO
open Nancy
open Nancy.Hosting.Self
open Nancy.Conventions
let (?) (this : obj) (prop : string) : obj =
(this :?> DynamicDictionary).[prop]
let siteRoot = @"d:\mySite\"
type WebServerModule() as this =
inherit NancyModule()
do this.Get.["{file}"] <-
fun parameters ->
new Nancy.Responses.HtmlResponse(
HttpStatusCode.OK,
(fun (s:Stream) ->
let file = (parameters?file).ToString()
printfn "Requested : '%s'" file
let bytes = File.ReadAllBytes(Path.Combine(siteRoot, file))
s.Write(bytes,0,bytes.Length)
))Â |>Â box
let startAt host =
let nancyHost = new NancyHost(new Uri(host))
nancyHost.Start()
nancyHost
let server = startAt "http://localhost:8080/"
printfn "Press [Enter] to exit."
Console.ReadKey()Â |>Â ignore
server.Stop()
Further reading
- “Writing an Agent-Based Web Server” by Tomas Petricek and Jon Skeet.
- “An F# Web Server From Sockets and Up” by Anton Tayanovskyy.
- “A Simple Web Server in F#” by Maxim Moiseev
- “Working with WebSharper Sitelets” by IntelliFactory.
- “Frank” – a resource-oriented wrapper library for working with the Web API and is developed in F#.
- “Frack” – an implementation of the Open Web Interface for .NET (OWIN), a .NET Web Server Gateway Interface, written in F#.
- “Suave” – a simple web development F# library providing a lightweight web server and a set of combinators to manipulate route flow and task composition.
- “Kayak” – an event-driven networking library for .NET. It allows you to easily create TCP clients and servers. Kayak contains an HTTP/1.1 server implementation.
- “Building Web, Cloud, and Mobile Solutions with F#” by Daniel Mohl.
A Twitter search client in 10 lines of code with F# and the JSON type provider
Live tweets from Alea.cuBase F#-for-financial-GPU event in London.
Yesterday, there was Alea.cuBase live coding session. Don Syme led live tweets from inside. This post is dedicated to those who missed it.
I’ll be live tweeting from the .NET in the City event where Daniel Egloff presents F# for GPGPU quantalea.net/news/29/
— Don Syme (@dsyme) May 16, 2013
Continue reading ➞ Live tweets from Alea.cuBase F#-for-financial-GPU event in London.
F# Weekly #19, 2013
Welcome to F# Weekly,
Tiny weekly this time, a short roundup of F# content from this past week:
News
- Node.js + C# + F# + Python + PowerShell interop ===
#edgejs - Enjoying interactive data visualization with Tsunami by Taha Hachana
- F#-based quantum algorithms simulator was presented at Niels Bohr Institute last week.
- Call F# async workflows from node.js.
- New FSharpx version was released with fixes in the Excel type provider.
- R Type Provider is on Nuget now.
- GestIT is a C# library for gestures (ready for F#). (Here is a video of using LeapMotion sensor for playing Jetpack)
Videos/Presentations
- The first wave of Evolve sessions videos were posted.
- “Slackless gears with licorice video” by Semasiographologist.
- “Debugging CUDA Written in F#! (First Try)” by Xiang Zhang.
- “F# for Trading” by Phil Trelford.
Blogs
- Vatro published “Ping your boss“.
- Faisal Waris posted “Sample Mobile Web App Presented at #mobidevday“.
- Phil Trelford wrote about “Fixed Width Data Files“.
- Alex Young shared “VimSpeak: Control Vim with Speech Recognition“.
- Experiences using F# for developing analysis scripts and tools over search engine query log data.
- Don Syme blogged “F# for Machine Learning – a Gentle Introduction and Coding Dojo“.
- Marko Apfel posted “Productive work environments for F# development (under windows)“.
P.S. The top 20 data visualisation tools
That’s all for now.  Have a great week.
Previous F# Weekly edition – #18
@sergey_tihon Lastest results for json.net using the most recent versions off NuGet twitter.com/JamesNK/status…
— James Newton-King â™” (@JamesNK) May 12, 2013
Json.Net vs ServiceStack.Text
I can not understand why JSON.NET so popular (http://www.servicestack.net/mythz_blog/?p=344)
Or maybe I am wrong and picture have changed ?
@sergey_tihon Lastest results for json.net using the most recent versions off NuGet twitter.com/JamesNK/status…
— James Newton-King ♔ (@JamesNK) May 12, 2013
Need to test it!






