Last active
November 22, 2023 03:33
-
-
Save gistlyn/fe755746268be5611abcbfa1f997368c to your computer and use it in GitHub Desktop.
F# .NET 6 Console App
This file contains 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>net8.0</TargetFramework> | |
<NoWarn>1591</NoWarn> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="ServiceStack.Common" Version="8.*" /> | |
</ItemGroup> | |
<ItemGroup> | |
<Compile Include="Program.fs" /> | |
</ItemGroup> | |
</Project> |
This file contains 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 c -> c.With(fun x -> x.UserAgent <- "gist.cafe") |> ignore) | |
.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