Skip to content

Instantly share code, notes, and snippets.

@gromnitsky
gromnitsky / twitter-stats
Created January 6, 2021 08:58
Twitter stats using gnuplot, json & gnu make
#!/usr/bin/make -sf
$(if $(i),,$(error Usage: twitter-stats i=twitter-YYYY-MM-DD-sha256.zip [lang|users|1.png|1.svg]))
n=5
top: tweets.json
json -e 'this.tweet.permalink = `https://twitter.com/i/web/status/$${this.tweet.id}`; this.tweet.rating = Number(this.tweet.favorite_count) + Number(this.tweet.retweet_count)' -c 'this.tweet.rating > 0' < $< | json -Ae 'this.sort((a,b)=> a.tweet.rating-b.tweet.rating)' | json -Ae 'this.q = this.slice(-$(n))' q | json -e 'this.q = {rating: this.tweet.rating, date: this.tweet.created_at, text: this.tweet.full_text, permalink: this.tweet.permalink}' -a q
lang: tweets.json; json -a tweet.lang < $< | $(aggregate) | $(sort)