Skip to content

Instantly share code, notes, and snippets.

@maxandersen
Created April 19, 2023 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxandersen/3547399c4853cdef95563bd9c7fee964 to your computer and use it in GitHub Desktop.
Save maxandersen/3547399c4853cdef95563bd9c7fee964 to your computer and use it in GitHub Desktop.
///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