A modern programmer, and even more so a beginner at a level lower than junior, hell, needs the ability to use a search engine. It seems there is nothing difficult in this, but nevertheless questions often pop up on questionnaires, which have long been answered in the first tab of the search engine output. Why is that? Inexperience, laziness - a lot of reasons. We are interested in laziness, let's simplify a little and automate the process of “googling”.
So, I present to you the service " cheat.sh ". It is written in Python, so that Pythonists may be interested. There are several implementations of it:
Here you need to have the utility "curl". On Linux distributions, it already exists; for Windows, it needs to be installed separately. I had no problems with Windows.
Go to the console and send a request of this type:curl cht.sh/[]/[----]
We get the answer:
$ curl cht.sh/python/how-to-read-text-file # How to read a text file into a list or an array with Python ... # # You will have to split your string into a list of values using split() # # So, lines = text_file.read().split(',') # [Achrome] [so/q/14676265] [cc by-sa 3.0]
Initially, the utility was conceived as a cheat sheet for commands for the Linux terminal, so you can look for help on them:
$ curl cheat.sh/tar $ curl cht.sh/curl $ curl https://cheat.sh/rsync $ curl https://cht.sh/tr
You can also install the console utility:
$ curl https://cht.sh/:cht.sh > ~/bin/cht.sh $ chmod +x ~/bin/cht.sh
Use example here .
There are no such commands for Windows, so there is an option to use Cygwin, Git bash and so on.
At your peril.
Just go to the desired link in the browser.
Using the example www.cht.sh/python/how-to-read-text-file
A link can be sent as a response to Stackoverflow, for example.
What for? In order not to leave the editor get a copy-paste solution code.
Plugin for emacs ,
Plugin for Sublime Text ,
Plugin for vim ,
Plugin for VSCode .
Installation for bash:
$ curl https://cheat.sh/:bash_completion > ~/.bash.d/cht.sh $ . ~/.bash.d/cht.sh $ # and add . ~/.bash.d/cht.sh to ~/.bashrc
Installation for ZSH:
$ curl https://cheat.sh/:zsh > ~/.zsh.d/_cht $ echo 'fpath=(~/.zsh.d/ $fpath)' >> ~/.zshrc $ # Open a new shell to load the plugin
If you do not need syntax highlighting in the answer:curl cht.sh/python/open-file?T
If you need only code without comments:curl cht.sh/python/open-file?Q
You can combine this:curl cht.sh/python/open-file?QT
Open the client version with the parameter "--shell" and use:$ cht.sh --shell [ ]
$ stealth []
What for? To quickly get an answer. The author proposes to use this in remote interviews. It's just a matter of your own conscience.
curl cht.sh/[]/1line
There is even for Python. Yes, for a language where the separation of blocks of code is a newline.
curl cht.sh/[]/weirdness
If you are not satisfied with the current response to your request, you can see another:curl cht.sh/[]/[]/[ ]
$ curl cht.sh/[]/:learn
In general, everything. Maybe someone already knows about “cht.sh” and uses it, but I did not find any normal materials about it in Russian. On GitHub there is a table of completeness “cht.sh” by languages, links to plugins for editors and a complete guide if someone doesn’t like mine. Thanks for reading.
Source: https://habr.com/ru/post/420741/
All Articles