Skip to content

Instantly share code, notes, and snippets.

@loisaidasam
Last active April 7, 2022 19:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loisaidasam/1486674 to your computer and use it in GitHub Desktop.
Save loisaidasam/1486674 to your computer and use it in GitHub Desktop.
Automatically set the latest AsciiArtFarts.com art to your MOTD!

So you want that super clever and funny AsciiArtFarts.com humor on your terminal's Message of the Day? Here's how!

STEP 1.

First put asciiartfarts-motd.php somewhere where you know where it is:

mv asciiartfarts-motd.php /Users/sam/bin/

STEP 2.

Modify your crontab ("crontab -e" on command line) to include something like this:

# motd
0 * * * * php /Users/sam/bin/asciiartfarts-motd.php > /etc/motd.tail 2>/dev/null

STEP 3.

Laugh your ass off on the regular

Brought to you by @LoisaidaSam

(I am in no way affiliated with asciiartfarts.com nor does its content represent my opinion on anything)

<?php
try {
$xml = new SimpleXMLElement('http://www.asciiartfarts.com/farts.rss', NULL, TRUE);
$title = $xml->channel[0]->item[0]->title;
$link = $xml->channel[0]->item[0]->link;
$ascii = $xml->channel[0]->item[0]->description;
$ascii = html_entity_decode(str_replace(array('<pre>', '</pre>'), array('', ''), $ascii)) . "\n\n";
$daily_ascii = "\n{$title}\n{$link}\n\n{$ascii}";
echo $daily_ascii;
}
catch (Exception $e) {
echo "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment