Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Last active November 22, 2023 03:31
Show Gist options
  • Save gistlyn/c3bb227c31dd930ed1b274ff327f3eff to your computer and use it in GitHub Desktop.
Save gistlyn/c3bb227c31dd930ed1b274ff327f3eff to your computer and use it in GitHub Desktop.
C# .NET 6 Console App
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Exe</OutputType>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ServiceStack.Common" Version="8.*" />
</ItemGroup>
</Project>
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
var orgName = "dotnet";
var orgRepos = $"https://api.github.com/orgs/{orgName}/repos"
.GetJsonFromUrl(c => c.With(x => x.UserAgent = "gist.cafe"))
.FromJson<GithubRepo[]>()
.OrderByDescending(x => x.Watchers);
$"Top 3 '{orgName}' Github Repos:".Print();
orgRepos.Take(3).ToList().PrintDump();
$"\nTop 10 {orgName} Github Repos:\n".Print();
orgRepos.Take(10).Map(x => new {
x.Name, x.Language, x.Watchers, x.Forks }).PrintDumpTable();
Inspect.vars(new { orgRepos });
public class GithubRepo
{
public string? Name { get; set; }
public string? Description { get; set; }
public string? Url { get; set; }
public string? Homepage { get; set; }
public string? Language { get; set; }
public int Watchers { get; set; }
public int Forks { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment