Skip to content

Instantly share code, notes, and snippets.

@michael-simons
Last active November 20, 2022 10:15
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 michael-simons/ef3043c02107496cb93c7ad108e6d995 to your computer and use it in GitHub Desktop.
Save michael-simons/ef3043c02107496cb93c7ad108e6d995 to your computer and use it in GitHub Desktop.
Some jq fun
# Most interactions / mentions, excluding myself.
{ sed -e '1s/.*/[/' -e '$d' tweets.js && sed '1s/.*/,/' tweets-part1.js; } | \
jq '
[.[].tweet.entities.user_mentions[] | select(.screen_name != "rotnroll666") | {handle: .screen_name}] |
group_by(.handle) | map(.[0] + {"count": length}) |
sort_by(-.count,.handle|=ascii_downcase) | limit(20;.[]) |
"@\(.handle) (\(.count))"
'
# "Best" tweets by RT (turns out, that retweets are in the archive, but prefixed only with RT @...
# and not a proper info
{ sed -e '1s/.*/[/' -e '$d' tweets.js && sed '1s/.*/,/' tweets-part1.js; } | \
jq -r '
[.[] | select(.tweet.full_text | startswith("RT @") | not)] |
sort_by(.tweet.retweet_count|tonumber) |reverse | limit(3;.[]) |
"\(.tweet.retweet_count|tonumber): https://twitter.com/rotnroll666/status/\(.tweet.id_str)"
'
# Same but by fav
{ sed -e '1s/.*/[/' -e '$d' tweets.js && sed '1s/.*/,/' tweets-part1.js; } | \
jq -r '
[.[] | select(.tweet.full_text | startswith("RT @") | not)] |
sort_by(.tweet.favorite_count|tonumber) |reverse | limit(3;.[]) |
"\(.tweet.favorite_count|tonumber): https://twitter.com/rotnroll666/status/\(.tweet.id_str)"
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment