cheat.sh icon indicating copy to clipboard operation
cheat.sh copied to clipboard

Python module usages?

Open dufferzafar opened this issue 5 years ago • 3 comments
trafficstars

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!

dufferzafar avatar May 23 '20 23:05 dufferzafar

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.

chubin avatar Jun 01 '20 11:06 chubin

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.

chubin avatar Jun 01 '20 11:06 chubin

Happy to help out and answer any questions I know the answers to :)

ErezBinyamin avatar Jun 01 '20 14:06 ErezBinyamin