cheat.sh
cheat.sh copied to clipboard
Python module usages?
Does it make sense for cheat to start storing code snippets? (is it an overkill?)
I was thinking particularly about python - the official docs usually have code snippets for most of the modules. For eg. see difflib: https://docs.python.org/3/library/difflib.html
I was thinking querying curl cht.sh/python/difflib would give me these snippets.
If you don't have a problem with storing these snippets as "cheat sheets", I'll be up to create them!
It is a good idea, but it would be better to not extract them manually, because in this case they must be manually synchronized each time when the upstream changes, but write a so called adapter instead.
The idea of the adapter is that it sits between some repository,
or some website (though repository is better, because in this case
it could be used for offline queries also), and translates the cheat.sh queries
(like difflib) into queries to the repository.
Depending on the upstream, it maybe grep+awk+sed, or just raw python code, or BeautifulSoup to extract data from HTML, etc.
See some existing adapters for example: (python based)
- Learn X in Y
- Rosetta Code
or some recent ones, shell-based:
- chmod.sh (#197, by @ErezBinyamin )
- rfc.sh (#167, by @ErezBinyamin )
Please say if you need any help or some additional details.
Happy to help out and answer any questions I know the answers to :)