Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Last active November 22, 2023 03:33
Show Gist options
  • Save gistlyn/fe755746268be5611abcbfa1f997368c to your computer and use it in GitHub Desktop.
Save gistlyn/fe755746268be5611abcbfa1f997368c to your computer and use it in GitHub Desktop.
F# .NET 6 Console App
<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>
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