Last active
October 28, 2022 09:38
-
-
Save vi/5b965253c869422a6bad32ad57f05790 to your computer and use it in GitHub Desktop.
Hacky workaround to track new stars of your repositoes (previously displayed on Github home page)
This file contains hidden or 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
#!/bin/bash | |
set -e | |
TOKEN=... | |
USERNAME=... | |
D=$(mktemp -d) | |
cd "$D" | |
P=1 | |
while true; do | |
curl -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $TOKEN" https://api.github.com/users/$USERNAME/repos?page=$P -o repos$P.json | |
N=$(gron repos$P.json | wc -l) | |
if [ $N -le 1 ]; then | |
break | |
fi | |
P=$((P+1)) | |
done | |
jq -rs 'flatten | map("\(.full_name),\(.stargazers_count),\(.forks_count)") | join("\n")' repos*.json | sed 's@^vi/@@' | sort | |
rm *.json | |
cd / | |
rmdir "$D" |
This file contains hidden or 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
#!/bin/bash | |
set -e | |
get_github_stars.sh > ~/b/github_stars2.csv | |
q -d, 'select "'$(date +'%Y-%m-%d')'" date, new.c1 name, new.c2 - old.c2 stars, new.c3 - old.c3 forks from /home/vi/b/github_stars2.csv new left join /home/vi/b/github_stars.csv old on new.c1 = old.c1 where new.c2 <> old.c2 or new.c3 <> old.c3' >> ~/b/new_github_stars.csv | |
N=$(($(wc -l < ~/b/new_github_stars.csv)-10)) | |
if [ $N -lt 1 ]; then | |
N=1 | |
fi | |
xsv slice -s "$N" ~/b/new_github_stars.csv | xsv table | |
mv ~/b/github_stars2.csv ~/b/github_stars.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment