Last active
January 18, 2021 05:45
-
-
Save gistlyn/c33b525c276ec68df1c748dc2da7f497 to your computer and use it in GitHub Desktop.
Simple F# .NET 5 Console App
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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net5.0</TargetFramework> | |
<NoWarn>1591</NoWarn> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="ServiceStack.Common" Version="5.*" /> | |
</ItemGroup> | |
<ItemGroup> | |
<Compile Include="Program.fs" /> | |
</ItemGroup> | |
</Project> |
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 | |
open System.Linq | |
open ServiceStack | |
open ServiceStack.Text | |
module Program = | |
type GithubRepo() = | |
member val Name = "" with get, set | |
member val Description = "" with get, set | |
member val Url = "" with get, set | |
member val Homepage = "" with get, set | |
member val Language = "" with get, set | |
member val Watchers = 0 with get, set | |
member val Forks = 0 with get, set | |
type Table = { Name:string; Language:string; Watchers:int; Forks:int; } | |
[<EntryPoint>] | |
let main args = | |
let orgName = "dotnet" | |
let orgRepos = | |
$"https://api.github.com/orgs/{orgName}/repos" | |
.GetJsonFromUrl(fun httpReq -> httpReq.UserAgent <- "gist.cafe") | |
.FromJson<GithubRepo[]>() | |
.OrderByDescending(fun x -> x.Watchers) | |
$"Top 3 '{orgName}' Github Repos:".Print() | |
orgRepos.Take(3).ToList().PrintDump() | |
$"\nTop 10 {orgName} Github Repos:\n".Print(); | |
orgRepos.Take(10).Select(fun x -> | |
{| Name = x.Name; Language = x.Language; Watchers = x.Watchers; Forks = x.Forks |}) | |
.PrintDumpTable() | |
Inspect.vars({| orgRepos = orgRepos |}) | |
0 //exitCode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment