Skip to content

Instantly share code, notes, and snippets.

@catdevnull
Created August 20, 2024 23:35
Show Gist options
  • Save catdevnull/4b06cbc914cc0c339a0f72c3878948b7 to your computer and use it in GitHub Desktop.
Save catdevnull/4b06cbc914cc0c339a0f72c3878948b7 to your computer and use it in GitHub Desktop.
analisis tonyaracre
// @ts-check
import { readFileSync } from "fs";
import z from "zod";
import { isSameDay, startOfDay, sub, format } from "date-fns";
const zTweet = z.object({
text: z.string(),
timeParsed: z.coerce.date(),
});
const file = readFileSync(
// https://drive.google.com/file/d/1q5Yq4urLS-Ne9U-oVF60TLFjGVJdnB_g/view?usp=sharing
"./tonyaracre.allTweetsEver.2024-08-20.jsonl",
"utf8",
);
const lines = file
.split("\n")
.filter((l) => l.trim().length > 0)
.map((line) => JSON.parse(line));
const tweets = lines.map((tweet) => zTweet.parse(tweet));
console.log("total tweets:", tweets.length);
console.log(
"total mentions to @jmilei:",
tweets.filter((tweet) => tweet.text.toLowerCase().includes("@jmilei")).length,
);
const today = startOfDay(new Date());
for (
let day = startOfDay(today);
day > sub(today, { months: 2 });
day = sub(day, { days: 1 })
) {
const tweetsInDay = tweets.filter((tweet) =>
isSameDay(tweet.timeParsed, day),
);
console.log(
`${format(day, "yyyy-MM-dd")}: ${
tweetsInDay.filter((tweet) =>
tweet.text.toLowerCase().includes("@jmilei"),
).length
} mentions out of ${tweetsInDay.length}`,
);
}
$ bun run analisis-tonyaracre.js
total tweets: 7022
total mentions to @jmilei: 948
2024-08-20: 5 mentions out of 11
2024-08-19: 3 mentions out of 7
2024-08-18: 2 mentions out of 4
2024-08-17: 3 mentions out of 5
2024-08-16: 5 mentions out of 10
2024-08-15: 15 mentions out of 23
2024-08-14: 3 mentions out of 26
2024-08-13: 3 mentions out of 13
2024-08-12: 4 mentions out of 7
2024-08-11: 5 mentions out of 9
2024-08-10: 3 mentions out of 13
2024-08-09: 2 mentions out of 4
2024-08-08: 1 mentions out of 10
2024-08-07: 4 mentions out of 15
2024-08-06: 4 mentions out of 15
2024-08-05: 3 mentions out of 10
2024-08-04: 3 mentions out of 10
2024-08-03: 2 mentions out of 15
2024-08-02: 4 mentions out of 18
2024-08-01: 19 mentions out of 31
2024-07-31: 15 mentions out of 27
2024-07-30: 9 mentions out of 23
2024-07-29: 8 mentions out of 16
2024-07-28: 15 mentions out of 24
2024-07-27: 4 mentions out of 9
2024-07-26: 8 mentions out of 15
2024-07-25: 12 mentions out of 22
2024-07-24: 6 mentions out of 13
2024-07-23: 1 mentions out of 6
2024-07-22: 5 mentions out of 9
2024-07-21: 11 mentions out of 31
2024-07-20: 3 mentions out of 15
2024-07-19: 2 mentions out of 5
2024-07-18: 8 mentions out of 20
2024-07-17: 13 mentions out of 21
2024-07-16: 8 mentions out of 22
2024-07-15: 5 mentions out of 18
2024-07-14: 5 mentions out of 12
2024-07-13: 14 mentions out of 27
2024-07-12: 11 mentions out of 18
2024-07-11: 2 mentions out of 5
2024-07-10: 2 mentions out of 21
2024-07-09: 9 mentions out of 15
2024-07-08: 5 mentions out of 26
2024-07-07: 2 mentions out of 16
2024-07-06: 7 mentions out of 14
2024-07-05: 2 mentions out of 13
2024-07-04: 2 mentions out of 10
2024-07-03: 2 mentions out of 12
2024-07-02: 10 mentions out of 24
2024-07-01: 9 mentions out of 29
2024-06-30: 11 mentions out of 20
2024-06-29: 21 mentions out of 25
2024-06-28: 12 mentions out of 25
2024-06-27: 11 mentions out of 37
2024-06-26: 9 mentions out of 17
2024-06-25: 10 mentions out of 22
2024-06-24: 3 mentions out of 9
2024-06-23: 7 mentions out of 15
2024-06-22: 1 mentions out of 1
2024-06-21: 11 mentions out of 17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment