aboutsummaryrefslogtreecommitdiff
path: root/run
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-05-06 14:30:32 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-05-06 14:30:32 +0200
commitd514585bbb54482ee62070bc86a7447a657afaee (patch)
tree9e8b46af9df7dfafa3fd66f111d48f9653bac52f /run
downloadperlisdead-d514585bbb54482ee62070bc86a7447a657afaee.tar.gz
First commit
Diffstat (limited to 'run')
-rw-r--r--run/benchmark20
l---------run/blogs1
l---------run/cpan1
-rw-r--r--run/p5p31
l---------run/reddit1
-rw-r--r--run/rss34
6 files changed, 88 insertions, 0 deletions
diff --git a/run/benchmark b/run/benchmark
new file mode 100644
index 0000000..4c20e0e
--- /dev/null
+++ b/run/benchmark
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my @cmd = (
+ q{date},
+ q{perl5.32.0 -le 'print "Hello world!"'},
+ q{python3.7 -c 'print("Hello world!")'},
+ q{ruby26 -e 'puts "Hello world!"'},
+);
+my @res;
+for (1..3) {
+ @res = ();
+ for (reverse @cmd) {
+ (my $q = $_) =~ s/'/'"'"'/g;
+ push @res, "\$ time $_\n" . `bash -c 'time $q' 2>&1`;
+ }
+}
+print join("\n", reverse @res);
diff --git a/run/blogs b/run/blogs
new file mode 120000
index 0000000..81cf1df
--- /dev/null
+++ b/run/blogs
@@ -0,0 +1 @@
+rss \ No newline at end of file
diff --git a/run/cpan b/run/cpan
new file mode 120000
index 0000000..81cf1df
--- /dev/null
+++ b/run/cpan
@@ -0,0 +1 @@
+rss \ No newline at end of file
diff --git a/run/p5p b/run/p5p
new file mode 100644
index 0000000..ebb0c62
--- /dev/null
+++ b/run/p5p
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Net::NNTP;
+use HTML::Entities;
+
+my $nntp = Net::NNTP->new('nntp.perl.org') or die "Cannot contact nntp.perl.org: $!";
+my ($count, $first, $last) = $nntp->group('perl.perl5.porters');
+
+my %d = %{$nntp->xhdr('Date', [$last-10, $last])};
+my %f = %{$nntp->xhdr('From', [$last-10, $last])};
+my %s = %{$nntp->xhdr('Subject', [$last-10, $last])};
+
+# TODO: Escape potential HTML characters
+
+for ((reverse sort keys %d)[0..4]) {
+ $_ = encode_entities($_) for ($d{$_}, $f{$_}, $s{_});
+ $f{$_} =~ s,@[^.]*\.,@<i>hidden</i>.,;
+ print <<HTML;
+<p>
+<div style="font-size: 80%; margin: 0;">
+<span class="date" style="line-height: 1;">Date: $d{$_}</span>
+<br/><span class="from">From: $f{$_}</span>
+</div>
+<span class="subject">Subject: <a href="https://www.nntp.perl.org/group/perl.perl5.porters/0/0/msg$_.html">$s{$_}</a></span>
+</p>
+HTML
+}
+
+$nntp->quit;
diff --git a/run/reddit b/run/reddit
new file mode 120000
index 0000000..81cf1df
--- /dev/null
+++ b/run/reddit
@@ -0,0 +1 @@
+rss \ No newline at end of file
diff --git a/run/rss b/run/rss
new file mode 100644
index 0000000..2dfb60f
--- /dev/null
+++ b/run/rss
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use HTML::Entities;
+use XML::Feed;
+use Encode qw(decode encode);
+
+my %feeds = (
+ blogs => 'http://blogs.perl.org/atom.xml',
+ reddit => 'https://www.reddit.com/r/perl/.rss',
+ cpan => 'https://metacpan.org/feed/recent',
+);
+(my $name = $0) =~ s,.*/,,;
+
+my $feed = XML::Feed->parse(URI->new($feeds{$name}))
+ or die XML::Feed->errstr;
+my @entries = $feed->entries;
+
+# Print summary of five latest entries
+for my $entry (@entries[0..4]) {
+ my $d = encode_entities $entry->issued->ymd;
+ my $f = encode_entities decode('utf8', $entry->author);
+ my $s = encode_entities decode('utf8', $entry->title);
+ my $l = encode_entities $entry->link;
+ print <<HTML
+<div class="entry">
+<div class="date">$d</div>
+<div class="from">$f</div>
+<div class="subject"><a href="$l">$s</a></div>
+</div>
+HTML
+}