Last active
September 30, 2019 20:26
-
-
Save bgalvao/f59d10229693a3a2a4cb1b7cad7a9d2b to your computer and use it in GitHub Desktop.
Fetch random quote from indiehackers.com, as a kickstart to your terminal session (add it to your .bashrc or similar), as if you're loading they're page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import numpy as np | |
| import requests | |
| from colored import fg, bg, attr | |
| # after probing, I found out that these are the possible values | |
| # [0, 140[ | |
| url = "https://indie-hackers.firebaseio.com/loadingQuotes/{}.json".format( | |
| np.random.choice(140) | |
| ) | |
| r = requests.get(url) | |
| data = r.json() | |
| quote = data['quote'] | |
| founder, company = data['byline'].split('of') | |
| print('\n%s"%s"%s%s\n' % (fg(221), quote, attr(7), attr(0))) | |
| print('%s- %sof%s%s\n' % (fg('dark_green_sea'), founder, company, attr(0))) | |
| #print(fg('dark_green_sea') + '(www.indiehackers.com)' + attr(0) + '\n') |
Author
Doesn't have color output (got lazy and didn't want to look up the color escape sequences ๐
) but here's a bash (+ jq) version:
#!/bin/sh
quote_num=$(($RANDOM%140))
url=https://indie-hackers.firebaseio.com/loadingQuotes/${quote_num}.json
data=$(curl -s $url)
quote=$(echo $data | jq .quote)
byline=$(echo $data | jq -r .byline)
echo $quote
echo "- " $byline
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So uh, three dependencies, all pip installable to your system python.