shlomif-email-signature / gen-shlomif-at-iglu-sig

#!/usr/bin/perl

use strict;
use warnings;

use IO::All;

use File::Spec::Functions qw( catpath splitpath rel2abs );

my $script_dir = catpath( ( splitpath( rel2abs $0 ) )[ 0, 1 ] );

my $sig = io()->file($ENV{HOME}."/.signature")->slurp();

# my ($quote) = ($sig =~ m{(([^\n]*\w[^\n]*\n)+)\z}ms);

my @resource_lines =
(
    qq{Apple Inc. is Evil - http://www.shlomifish.org/open-source/anti/apple/},
    qq{Best Introductory Programming Language - http://shlom.in/intro-lang},
    qq{Escape from GNU Autohell - http://www.shlomifish.org/open-source/anti/autohell/},
    qq{First stop for Perl beginners - http://perl-begin.org/},
    qq{Free (Creative Commons) Music Downloads, Reviews and more - http://jamendo.com/},
    qq{Freecell Solver - http://fc-solve.shlomifish.org/},
    qq{Chuck Norris/etc. Facts - http://www.shlomifish.org/humour/bits/facts/},
    qq{Funny Anti-Terrorism Story - http://shlom.in/enemy}, # The Enemy and How I Helped to Fight it.
    qq{http://www.shlomifish.org/humour/ways_to_do_it.html},
    qq{"Humanity" - Parody of Modern Life - http://shlom.in/humanity},
    qq{Interview with Ben Collins-Sussman - http://shlom.in/sussman},
    qq{List of Portability Libraries - http://shlom.in/port-libs},
    qq{List of Text Editors and IDEs - http://shlom.in/IDEs},
    qq{List of Text Processing Tools - http://shlom.in/text-proc},
    qq{List of Networking Clients - http://shlom.in/net-clients},
    qq{My Aphorisms - http://www.shlomifish.org/humour.html},
    qq{My Public Domain Photos - http://www.flickr.com/photos/shlomif/},
    qq{My Favourite FOSS - http://www.shlomifish.org/open-source/favourite/},
    qq{Original Riddles - http://www.shlomifish.org/puzzles/},
    qq{Optimising Code for Speed - http://shlom.in/optimise},
    qq{Parody of "The Fountainhead" - http://shlom.in/towtf},
    qq{Perl Humour - http://perl-begin.org/humour/},
    qq{Rethinking CPAN - http://shlom.in/rethinking-cpan},
    qq{Stop Using MSIE - http://www.shlomifish.org/no-ie/},
    qq{Selina Mandrake - The Slayer (Buffy parody) - http://shlom.in/selina},
    qq{"Star Trek: We, the Living Dead" - http://shlom.in/st-wtld},
    qq{The Case for File Swapping - http://shlom.in/file-swap},
    qq{"The Human Hacking Field Guide" - http://shlom.in/hhfg},
    qq{Understand what Open Source is - http://shlom.in/oss-fs},
    qq{UNIX Fortune Cookies - http://www.shlomifish.org/humour/fortunes/},
    qq{Beginners Site for the Vim text editor - http://vim.begin-site.org/},
    qq{What does "Zionism" mean? - http://shlom.in/def-zionism},
    qq{What Makes Software Apps High Quality -  http://shlom.in/sw-quality},
    qq{Why I Love Perl - http://shlom.in/joy-of-perl},
);

my $line = $resource_lines[rand(@resource_lines)];

my $quotes_text = io()->encoding('utf-8')->file("$script_dir/shlomif-sig-quotes")->slurp;

my @quotes = grep { /\S/ } split(/^\n*%\n*$/ms, $quotes_text);

my $quote = $quotes[rand(scalar(@quotes))];

$quote =~ s{\n+\z}{}ms;
$quote =~ s{\A\n+}{}ms;

my $text = <<"EOF";
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
$line

$quote

Please reply to list if it's a mailing list post - http://shlom.in/reply .
EOF

binmode STDOUT, ":utf8";
print $text;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.