Showing posts from July, 2016

Approximate your spending pattern using Gradient descent in FSharp

Approximate your spending pattern using Gradient descent in FSharp The advantage of tracking your expenses is that you can compare each month and check if you saved more or less money than the previous month. Another interesting information is to know how fast you are spending your money . Checking how fast you spend your money gives you a hint on whether you are likely to be out or within budget at the end of the month. The easiest way to check that is to plot the daily cumulated sum of your expenses and compare each month. I have been doing this for the past few months and it worked pretty well but I realised that the cumulated sum is not always nice to look at. It looks like incremental steps which is not so pleasing to the eye. As soon as you have more than three cumulated sum plotted on the same graph, it becomes messy and hard to see. The goal is to be able to be able to understand your financial situation in a glance, without having to spend more than one second a the plot.

How to setup a nice output folder for WebSharper projects

How to setup a nice output folder for WebSharper projects There are part of software development which aren’t very exciting. Setting up output directories is one of them. But we have to go through it because having a well defined output structure helps tremendously when time comes to deploy and publish an application. When using the default template from WebSharper, it could be confusing how and where binaries goes when build the application. In fact choosing between Debug and Release make no difference, it all goes under the \bin folder. Also, the files Scripts and Content generated by WebSharper all goes on a folder in the project directory Scripts and Content folders for site projects (client-server) and Content for bundle project (spa) regardless of whether Debug or Release is chosen. But it doesn’t have to be this way, it is possible to configure your own output folder. How do I set my own output folder for the WebSharper generated files and binaries? I will show

Manage mutable state using actors with F# Mailbox processor

Manage mutable state using actors with F# Mailbox processor Today I would like to share a technique that I use to maintain mutable shared state in my F# applications. This technique uses the MailboxProcesser , a simplified implementation of the actor model built into F#. Here’s the issue: I have a dataframe shared accross my whole application. The dataframe is constructed at bootup of the server which makes the application not scalable as to reconstruct the dataframe, a reboot is needed. The solution would be to provide a way to mutate the dataframe any time I need to. But mutable state involves concurrency issues and that’s where the MailboxProcesser comes to the rescue. This is what the MailboxProcesser gives a thread safe way to perform operations on a shared object. This post is composed by two parts: Introduction of the MailboxProcessor Usage in my scenario 1. Introduction of the MailboxProcessor MailboxProcessor can be seen a mailbox . It contains an inbox availab

From idea to product with WebSharper in FSharp

From idea to product with WebSharper in FSharp From time to time I get asked, Why do you use WebSharper? A legitimate question as from the abundance of libraries, tools and frameworks available, one might think that WebSharper + F# is just another hippie stack. My answer to this question is: What matters isn’t the tools that you use but the products that you build with those tools WebSharper allows me to take my F# logic and place it into a web application and give me a reactive framework - UI.Next - to write shorter and more understandable code. That is the reason why I use it. So today, in order to backup what I just said above, I would like to share with you a small tool that I built few days ago. In case you are interested in the tool, it is for Marvel Champions of Contest, the mobile game. To stay generic, here’s the problem: An alliance is composed of players. Each player has two characteristics: level and continent where the