NaNoGenMo / 2019

National Novel Generation Month, 2019 edition.
97 stars 5 forks source link

Litany: a prayer book in 255 bytes #NNNGM #100

Open kevincolyer opened 4 years ago

kevincolyer commented 4 years ago

(EDITED to fix bug noted by hugovk below) Nick Monfort's post about Nano-NaNoGenMo #NNNGM inspired my to write this little prayer book generator in 255 bytes of Perl.

It uses correct pairings of 3 bidding and responses from the Church of England's common worship.

A reading of the Litany would be:

  1. Always bang up to date!
  2. Abiding by Canon law
  3. A comprehensive intercession
  4. An exhausting and rather boring addition to a church service ;-p

Enjoy,

Rev Kevin Colyer Pioneer Curate, Church of England

Run with perl -CS -e 'use Mojo::Feed;print"Litany\n";$e=hear;$h="$e our prayer";$l=Lord;map{Mojo::Feed->new(url=>$_)->items->each(sub{$a=rand 3;print$_->title."\n ".("God of love","$l, in your mercy","$l, $e us")[$a]."\nALL ".($h,$h,"$l graciously $e us")[$a]."\n\n"})}@ARGV' RSS-URL [RSS-URL...]

Requires Mojo::Feed module from Mojolicious.

Sample book litany.txt compiled with the following code:

perl -CS litany256.pl http://feeds.bbci.co.uk/news/world/rss.xml http://feeds.bbci.co.uk/news/uk/rss.xml http://feeds.bbci.co.uk/news/business/rss.xml http://feeds.bbci.co.uk/news/politics/rss.xml http://feeds.bbci.co.uk/news/health/rss.xml http://feeds.bbci.co.uk/news/education/rss.xml http://feeds.bbci.co.uk/news/science_and_environment/rss.xml http://feeds.bbci.co.uk/news/technology/rss.xml http://feeds.bbci.co.uk/news/entertainment_and_arts/rss.xml http://feeds.bbci.co.uk/news/world/africa/rss.xml http://feeds.bbci.co.uk/news/world/asia/rss.xml http://feeds.bbci.co.uk/news/world/europe/rss.xml http://feeds.bbci.co.uk/news/world/latin_america/rss.xml http://feeds.bbci.co.uk/news/world/middle_east/rss.xml http://feeds.bbci.co.uk/news/world/us_and_canada/rss.xml http://feeds.bbci.co.uk/news/england/rss.xml http://feeds.bbci.co.uk/news/northern_ireland/rss.xml http://feeds.bbci.co.uk/news/scotland/rss.xml http://feeds.bbci.co.uk/news/wales/rss.xml http://feeds.bbci.co.uk/news/also_in_the_news/rss.xml http://feeds.bbci.co.uk/news/special_reports/rss.xml https://www.independent.co.uk/news/uk/rss https://www.independent.co.uk/news/world/rss https://www.independent.co.uk/news/business/rss https://www.independent.co.uk/news/people/rss https://www.independent.co.uk/news/science/rss https://www.independent.co.uk/news/education/rss https://www.independent.co.uk/environment/climate-change/rss https://www.theguardian.com/uk-news/rss https://www.theguardian.com/education/rss https://www.theguardian.com/uk/media/rss https://www.theguardian.com/society/rss https://www.theguardian.com/law/rss https://www.theguardian.com/uk/scotland/rss https://www.theguardian.com/uk/wales/rss https://www.theguardian.com/uk/northernireland/rss https://www.theguardian.com/uk/environment/rss https://www.theguardian.com/world/rss > litany.txt

hugovk commented 4 years ago
Which chancellor would you prefer to ruin your life? Sajid Javid or John McDonnell?
    God of love
ALL hear our prayer
hugovk commented 4 years ago

Hmm, I don't see any in your mercy or graciously in the sample.

kevincolyer commented 4 years ago

Hmm, I don't see any in your mercy or graciously in the sample.

Fixed bug - was overzealous in pruning spaces. Needs a space between rand and 3! Ran it a few times till I got: Which chancellor would you prefer to ruin your life? Sajid Javid or John McDonnell? Lord, in your mercy ALL hear our prayer Much better!

kevincolyer commented 4 years ago

I liked this bit: line 5450 onwards

Decriminalising drug possession could save lives, say MPs
    Lord, hear us
ALL Lord graciously hear us

Mystery of Cornish island strewn with rubber bands solved by seabird experts
    God of love
ALL hear our prayer

For seventeen spectacular minutes, the House of Commons actually had an opinion on Brexit
    Lord, in your mercy
ALL hear our prayer