Created
April 19, 2023 19:23
-
-
Save maxandersen/3547399c4853cdef95563bd9c7fee964 to your computer and use it in GitHub Desktop.
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
///usr/bin/env jbang "$0" "$@" ; exit $? | |
//DEPS org.kohsuke:github-api:1.125 | |
import org.kohsuke.github.*; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
public class myapp { | |
public static void main(String[] args) throws IOException { | |
// Provide your GitHub API token here | |
String gitHubToken = "<YOUR_GITHUB_API_TOKEN>"; | |
GitHub github = new GitHubBuilder().withOAuthToken(gitHubToken).build(); | |
List<GHRepository> repositories = github.getMyself().listRepositories(100).asList(); | |
List<Integer> listOfStars = new ArrayList<>(); | |
for (GHRepository repo : repositories) { | |
System.out.println("Repository Name: " + repo.getName() + " Star Count: " + repo.getStargazersCount()); | |
listOfStars.add(repo.getStargazersCount()); | |
} | |
int sum = 0; | |
for (int starCount : listOfStars) { | |
sum += starCount; | |
} | |
double average = ((double) sum) / listOfStars.size(); | |
System.out.println("Average Stars: " + average); | |
double variance = 0; | |
for (int starCount : listOfStars) { | |
double diff = starCount - average; | |
variance += diff * diff; | |
} | |
variance /= listOfStars.size(); | |
double standardDeviation = Math.sqrt(variance); | |
System.out.println("Standard Deviation: " + standardDeviation); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment