I was bored, looking for something to read, then I have:


I wrote a script rndeat.py, using python-recipes for accessing ActiveState Code and Pygments (optional) for syntax highlighting, to randomly pick one recipe:


You can query with one programming language and/or tags to get a random recipe. Here is the help of this simple script:
$ ./rndeat.py -h
usage: rndeat.py [-h] [-l LANG] [-t [TAG [TAG ...]]] [-s STYLE]

Random eats.

optional arguments:
  -h, --help            show this help message and exit
  -l LANG, --lang LANG  show recipe in the language (default: python)
  -t [TAG [TAG ...]], --tags [TAG [TAG ...]]
                        show recipe with tags
  -s STYLE, --style STYLE
                        highlighting style, "list" to get a list of styles
                        (default: default)
It ridiculously uses 3 API calls in order to get a random recipe, although it could possibly reduce to 1 API in a long run if adding caching in this script. The Python recipes only have a few thousands, there might be somewhere you can download entire recipe database. But, it might just like the API, I can't find any documentation about it except this python-recipes, basically it's been two years without new commits.

If you don't have Pygments, you can use sed to extract the code by looking for code +: and use your favorite highlighter, even load into Vim. Well, or just hack the script, that would be quicker.

Some are really fun to read, some are bored and too long, some are even older than your son or daughter (dated back to 2001, as far as I can see).

I am thinking a -i for interactive mode, so it can cache data in memory and allows you to bring up Python interpreter with the script if possible. It might be easier and fun to play with the recipe.

Disclaimer: This code is licensed under the MIT License, I am not responsible to anything that this code can cause, including, but not limited to, any health issues, such as obesity, food poisoning, etc.