Skip to content

Instantly share code, notes, and snippets.

@tphummel
Last active February 12, 2017 06:50
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 tphummel/efdfc6737187e9927f72dac7465cadab to your computer and use it in GitHub Desktop.
Save tphummel/efdfc6737187e9927f72dac7465cadab to your computer and use it in GitHub Desktop.
run queries on a user's starred github repos

run queries on a user's starred github repos

download data

for i in {1..20}
do
  curl -H "Accept: application/vnd.github.v3.star+json" "https://api.github.com/users/tphummel/starred?page=$i" > "p$i.json"
done

answer questions

what languages did I star most frequently in 2016?

cat *.json \
  | jq --slurp '. | flatten | .[] | select((.starred_at >= "2016-01-01") and (.starred_at <= "2016-12-31"))' \
  | jq --slurp '.[] .repo.language' \
  | awk '{ FS="\n" count[$1]++}END{for(j in count) print j","count[j]}' \
  | sort -t "," -k2 -nr  
"JavaScript",63
"Python",34
"Go",34
"Shell",20
"Ruby",13
null,12
"C",7
"Java",5
"HCL",4
"PHP",3
"Objective-C",3
"HTML",3
"Perl",2
"CSS",2
"TeX",1
"Roff",1
"Jupyter Notebook",1
"Hack",1
"C++",1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment