community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rbo...@apache.org
Subject svn commit: r1774092 - /comdev/tools/birthday.pl
Date Tue, 13 Dec 2016 19:48:01 GMT
Author: rbowen
Date: Tue Dec 13 19:48:01 2016
New Revision: 1774092

URL: http://svn.apache.org/viewvc?rev=1774092&view=rev
Log:
Script to generate birthday tweets

Added:
    comdev/tools/birthday.pl   (with props)

Added: comdev/tools/birthday.pl
URL: http://svn.apache.org/viewvc/comdev/tools/birthday.pl?rev=1774092&view=auto
==============================================================================
--- comdev/tools/birthday.pl (added)
+++ comdev/tools/birthday.pl Tue Dec 13 19:48:01 2016
@@ -0,0 +1,52 @@
+#!/usr/bin/perl
+
+# Generates the csv file that I import into Hootsuite each month to do
+# the #ApacheBirthday tweets.
+# Note that as per https://s.apache.org/C3K7 this output isn't actually
+# correct, which hopefully I can fix before I need to use this script
+# the next time.
+
+use strict;
+use warnings;
+use JSON::Parse qw(parse_json);
+use LWP::UserAgent;
+use HTTP::Request;
+use Data::Dumper;
+
+my $month = $ARGV[0];
+usage() unless $month;
+
+my $thisyear = (localtime(time))[5] + 1900;
+
+my $where = 'https://projects.apache.org/json/foundation/projects.json';
+
+# Fetch the json
+my $ua = LWP::UserAgent->new(timeout=>30, agent=>"Twitter4Ponies/0.1 ");
+my $res = $ua->request(HTTP::Request->new(GET => $where)); 
+my $projects = parse_json( $res->content );
+
+foreach my $proj ( keys %$projects ) {
+    my $d = $projects->{$proj}->{created};
+    next unless $d;
+    next unless $d =~ m/-$month-/;
+
+    my $y = ( $d =~ m/(\d\d\d\d)/ )[0];
+    my $age = $thisyear - $y;
+
+    print '"01/' . "$month/$thisyear 09:00:00" . '",';
+    print '"';
+    print "Happy birthday to " .
+            $projects->{$proj}->{name} .
+            " celebrating " . $age;
+    print ( ($age > 1) ? ' years ' : ' year ' );
+    print "this month. #ApacheBirthday";
+    print '","';
+    print "http://$proj.apache.org/";
+    print '"' . "\n";
+
+}
+
+sub usage {
+    print "Usage: ./birthday.pl MONTH - eg, ./birthday.pl 07\n";
+    exit();
+}

Propchange: comdev/tools/birthday.pl
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message