From d514585bbb54482ee62070bc86a7447a657afaee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20Ankarstr=C3=B6m?=
Date: Thu, 6 May 2021 14:30:32 +0200
Subject: First commit
---
run/benchmark | 20 ++++++++++++++++++++
run/blogs | 1 +
run/cpan | 1 +
run/p5p | 31 +++++++++++++++++++++++++++++++
run/reddit | 1 +
run/rss | 34 ++++++++++++++++++++++++++++++++++
6 files changed, 88 insertions(+)
create mode 100644 run/benchmark
create mode 120000 run/blogs
create mode 120000 run/cpan
create mode 100644 run/p5p
create mode 120000 run/reddit
create mode 100644 run/rss
(limited to 'run')
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,@[^.]*\.,@hidden.,;
+ print <
+
+Date: $d{$_}
+
From: $f{$_}
+
+Subject: $s{$_}
+
+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 <
+$d
+$f
+
+
+HTML
+}
--
cgit v1.2.3