F# Weekly #22, 2016

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos/Presentations

Blogs

F# vNext

Open source projects

  • ProtoTypes – F# type provider for Google Protocol Buffers
  • Fing – F# API Search
  • CafeApp – A Real World Business Application using F# and Suave
  • RabbitMqActors – RabbitMQ actors for Akka.NET F# API
  • bench-fsharp-template – A simple template for an F# benchmark using BenchmarkDotNet and Diagnostics.Windows

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #21Subscribe

F# Weekly #21, 2016

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos/Presentations

Blogs

F# vNext

Open source projects

  • genit – A cross-platform website generator and server using F#, Suave and PostgreSQL.
  • FSharp.Data.GraphQL – FSharp implementation of Facebook GraphQL query language
  • Atropos -machine learning models in F#
  • fable-hotload – Code from Getting-Started-with-Fable-and-Webpack by Krzysztof Cieslak (F# transpiled to JS with Fable compiler). Webpack devserver, hotload etc included

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #20Subscribe

F# Weekly #20, 2016

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos/Presentations

Blogs

F# vNext

Open source projects

  • FSharp.AspNetCore.Examples – Example of AspNetCore Running on Kestrel all inside a Windows Service
  • FSharp.Control.FusionTasks – F# Async computation <–> .NET Task an easy seamless interoperability library
  • quickjump – EasyMotion clone for MonoDevelop and Xamarin Studio 6.0 and higher
  • FsActorApp – Updated: Service fabric reliable actor app in F#
  • IfSharp – Jupiter notebook integration for F#

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #19Subscribe

F# Weekly #19, 2016

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos/Presentations

Blogs

F# vNext

Open source projects

  • hlsl.typeprovider – F# type provider for HLSL shaders
  • FsMap3 – A Function Library for Procedural 3-D Textures
  • Endorphin.Core – Infrastructure for scientific instrument control in F#
  • fsharp-data-processing-pipeline – Provides an extensible solution for creating Data Processing Pipelines in F#.
  • AIFAD – Automated Induction of Functions over Algebraic Data Types

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #17-#18Subscribe

Google Cloud Vision API from .NET\F# (OAuth2 with ServiceAccount.json)

Google Cloud Platform provides a wide range of APIs, one of which is Cloud Vision API that allows you to detect faces in images, extract sentiments, detect landmark, OCR and etc.

One of available annotators is “Logo Detection” that allows you to find company logo in your image and recognize it.

.NET is not the part of mainstream Google Cloud SDK. Google maintains google-api-dotnet-client that should allow you to authenticate to and call all available services. API design looks slightly not intuitive for .NET world (at least from my point of view).

I spent some time on Google/SO/Github trying to understand how to use OAuth2 in server-to-server authentication scenario with ServiceAccount.json file generated by Google API Manager.

s2s

You cannot use this API without billing account, so you have to put your credit card info, if you want to play with this API.

Also, note that you need to have two NuGet packages Google.Apis.Vision.v1Google.Apis.Oauth2.v2 (and a lot of their dependencies)

So, here is the full sample:

#I __SOURCE_DIRECTORY__
#load "Scripts/load-references-debug.fsx"

open System.IO
open Google.Apis.Auth.OAuth2
open Google.Apis.Services
open Google.Apis.Vision.v1
open Google.Apis.Vision.v1.Data

// OAuth2 authentication using service account JSON file
let credentials =
    let jsonServiceAccount = @"d:\ServiceAccount.json"
    use stream = new FileStream(jsonServiceAccount, 
                         FileMode.Open, FileAccess.Read)
    GoogleCredential.FromStream(stream)
        .CreateScoped(VisionService.Scope.CloudPlatform)

let visionService = // Google Cloud Vision Service
    BaseClientService.Initializer(
        ApplicationName = "my-cool-app",
        HttpClientInitializer = credentials)
    |> VisionService

// Logo detection request for one image
let createRequest content = 
  let wrap (xs:'a list) = System.Collections.Generic.List(xs)
  BatchAnnotateImagesRequest(
    Requests = wrap
      [AnnotateImageRequest(
        Features = wrap [Feature(Type = "LOGO_DETECTION")],
        Image = Image(Content = content))
      ])
  |> visionService.Images.Annotate


let call fileName = // Call and interpret results
    let request =
        File.ReadAllBytes fileName
        |> System.Convert.ToBase64String
        |> createRequest
    let response = request.Execute()

    [ for x in response.Responses do
        for y in x.LogoAnnotations do
          yield y.Description
    ] |> List.toArray


let x = call "D:\\fsharp256.png"
// val x : string [] = [|"F#"|]

F# Weekly #17-18, 2016

Welcome to F# Weekly,

A roundup of F# content from this past week:

News

Videos/Presentations

Blogs

F# vNext

Open source projects

  • higher – A lightweight library of abstractions for Higher-kinded programming in F#
  • LibAAS – Another sample project showing event sourcing in F#
  • fantomas – FSharp source code formatter
  • azure-fsharp-helpers – A set of files which help provide better support for Azure with a number of F# projects.
  • AkkaSftpWorkshop.Tasks – Tasks for workshop exploring use of Akka.NET and F# to implement FTP file distribution.
  • Kaggle.HomeDepot – F# datascience code from the Home Deport Kaggle competition
  • Imms – High Performance, Immutable Data Structures for .NET
  • JoinCML – A research project to create an extension of CML with a join combinator.
  • xlamx – Lambda calc stepper for mobile devices
  • FSharp.Data.GraphQL – FSharp implementation of Facebook GraphQL query language

New Releases

That’s all for now. Have a great week.

Previous F# Weekly edition – #16Subscribe