What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

Do the data dumps have breadcrumbs other than posts and comments?

#! /usr/bin/perl

use warnings;
use strict;

use Time::Local;

Count daily activity in $seen{$date}:

my %seen;

Count comments and posts or edits:

sub comments {
  my($id) = @_;
  open my $fh, "<", "comments.xml" or die "$0: open: $!";
  while (<$fh>) {
    next unless /UserId="$id"/;
    die "$0: $.: no CreationDate"
      unless /CreationDate="(\d{4}-\d{2}-\d{2})T.*?"/;
    ++$seen{$1};
  }
}

sub posts {
  my($id) = @_;
  open my $fh, "<", "posts.xml" or die "$0: open: $!";
  while (<$fh>) {
    if (/OwnerUserId="$id"/) {
      die "$0: $.: no CreationDate"
        unless /CreationDate="(\d{4}-\d{2}-\d{2})T.*?"/;
      ++$seen{$1};
    }
    elsif (/LastEditorUserId="$id"/) {
      die "$0: $.: no LastEditDate"
        unless /LastEditDate="(\d{4}-\d{2}-\d{2})T.*?"/;
      ++$seen{$1};
    }
  }
}

Finally the tally:

sub as_time_t {
  my($date) = @_;
  die "$0: bad date '$date'"
    unless /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
  timegm 0, 0, 0, $3, $2-1, $1-1900;
}

die "Usage: $0 id-num\n" unless @ARGV == 1;
my $id = qr/\Q$ARGV[0]/;
comments $id;
posts    $id;

my($start,$end) = map as_time_t($_), (sort keys %seen)[0,-1];
for (my $t = $start; $t < $end; $t += 86_400) {
  my($mday,$mon,$year) = (gmtime $t)[3,4,5];
  $seen{ sprintf "%04d-%02d-%02d" => $year+1900, $mon+1, $mday } += 0;
}

my $streak = 0;
foreach my $date (sort keys %seen) {
  if ($seen{$date}) {
    ++$streak;
    printf "%4d - $date - $seen{$date}\n", $streak;
  }
  else {
    $streak = 0;
  }
}

Example usage:

$ cd "Stack Overflow Data Dump - Feb 10/Content/022010 SO"
$ streak 22656
[...]
 149 - 2010-01-27 - 38
 150 - 2010-01-28 - 17
 151 - 2010-01-29 - 25
 152 - 2010-01-30 - 17
 153 - 2010-01-31 - 7
share|improve this question
2  
How does someone who isn't even sure what language this is, could use your scripts? Care to add a little explanation? –  jmfsg Feb 12 '10 at 15:06
    
@Downvoter It's a single Perl program broken up with commentary to avoid scrolling. Run it in, for example, .../Stack Overflow Data Dump - Feb 10/Content/022010 SO. –  Greg Bacon Feb 12 '10 at 15:18
1  
To clarify, since this wasn't at all obvious to me: You need to run this Perl script from within the data dump directory. It takes your user id as a command-line argument. It identifies days where you made 1 or more comments, posts or edits. It prints 'streak' - date - number of contributions. 'streak' is a number which increments for each consecutive day you've made a contribution without a break. –  ire_and_curses Feb 12 '10 at 17:39
    
is it possible to run that script on some online service which allows running perl script? –  Sarfraz Mar 4 '10 at 7:52
1  
Ewww... Perl! Just kidding. –  uɐɯsO uɐɥʇɐN Sep 21 '10 at 20:18

4 Answers 4

This used to be a great question — I installed perl just to run that script — but it's past its expiration date.

The answer: to estimate your progress towards the Fanatic badge, go to your profile and look at the "consecutive days" count; you just need to visit for the next 100 - currentConsecutiveDays days in a row.

share|improve this answer

I wonder why someone hasn't set up a webservice that "visits" SO daily on behalf of users that sign up for it.

/classy

share|improve this answer
2  
It's called "Safari Top Sites" -- open browser, visit SO and Meta, voilà! –  tvanfosson Feb 12 '10 at 18:13
    
@tvanfosson: That's actually quite annoying. By automatically visiting SO it might hide the notification that I've got new rep or comments. –  Georg Schölly Feb 12 '10 at 20:25
    
Those don't typically disappear until you click the close button or do the action they've suggested. Anyway, I'm not suggesting that it should be done, just commenting that it works that way for me without even trying. –  tvanfosson Feb 12 '10 at 20:30

You're missing November 15th, so work it out from there ;-p

share|improve this answer
    
Hey, while you're on the topic, what day did I miss between September 7 and December 17? –  mmyers Feb 12 '10 at 16:59
    
@mmyers Sep 27th –  Marc Gravell Feb 12 '10 at 17:44
    
Thanks. And I know I missed a day in December when Jeff had the database down for a few hours (I forgot to try again later that day), so I'm not due for another month or so. –  mmyers Feb 12 '10 at 17:48

Has your spouse left you or complained about the amount of time spent on SO? Been reprimanded for using SO at work? If so, you're well on your way to the Fanatic badge.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .