Skip to content

Instantly share code, notes, and snippets.

@slavingia
Created October 14, 2024 15:19
Show Gist options
  • Save slavingia/dbb18741e82d4d57579910491e05c47b to your computer and use it in GitHub Desktop.
Save slavingia/dbb18741e82d4d57579910491e05c47b to your computer and use it in GitHub Desktop.
import datetime
# https://x.com/shl/status/926024538
# Found via https://x.com/search?q=from%3Ashl%20until%3A2008-09-19&src=typed_query&f=live
# Define dates
first_tweet_date = datetime.date(2008, 9, 18)
today = datetime.date.today()
birth_date = datetime.date(1992, 8, 25)
# Calculate total days lived and days since first tweet
total_days_lived = (today - birth_date).days
days_since_first_tweet = (today - first_tweet_date).days
days_not_tweeting = total_days_lived - days_since_first_tweet
# Calculate percentage
percentage = (days_since_first_tweet / total_days_lived) * 100
print(f"Days alive: {total_days_lived}")
print(f"Days tweeting: {days_since_first_tweet}")
print(f"Days not tweeting: {days_not_tweeting}")
print(f"Percentage of life spent tweeting: {percentage:.2f}%")
@Mohamed3nan
Copy link

Javascript version to run it in Browser's console quickly:

// Define dates
const firstTweetDate = new Date(2008, 8, 18); // Note: Months are 0-indexed in JavaScript
const today = new Date();
const birthDate = new Date(1992, 7, 25);

// Calculate total days lived and days since first tweet
const totalDaysLived = Math.floor((today - birthDate) / (1000 * 60 * 60 * 24));
const daysSinceFirstTweet = Math.floor((today - firstTweetDate) / (1000 * 60 * 60 * 24));
const daysNotTweeting = totalDaysLived - daysSinceFirstTweet;

// Calculate percentage of life spent tweeting
const percentage = (daysSinceFirstTweet / totalDaysLived) * 100;

// Display results
console.log(`Days alive: ${totalDaysLived}`);
console.log(`Days tweeting: ${daysSinceFirstTweet}`);
console.log(`Days not tweeting: ${daysNotTweeting}`);
console.log(`Percentage of life spent tweeting: ${percentage.toFixed(2)}%`);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment