Cht.sh search tool

Updated: August 11, 2024

What if an API client helped you find programming questions? It exists already: cht. Sh!!!!

Often, we have a rush deadline to deliver a feature; often, we need an answer so quickly that we open the browser and google it. Then, a bunch of wonderful people working on an [open-source project created a toll named cht. Sh](https://github.com/chubin/cheat.sh), which is an API client that retrieves answers to questions based on a list of sheets (Linux, Postgres, JS, and so many more). I've been using it for over three years and love it. There are numerous ways to use it. The simplest is to use a curl request, browser, Postman, or Insomnia. Okay, I know you get it. Let's see one example of that:

curl cht. sh/python/write+a+file
              

Let's look at the pieces: Cht. sh is just the hostname. Python stands for the sheet list. Write+a+file is the search string (try to be as strict as possible because not all strings can always match any results). Now, moving on with the answer:

#  python - What is the correct way to write a line to a file?
#
#  You should use the print() function which is available since Python
#  2.6+

from __future__ import print_function  # Only needed for Python 2
print("hi there", file=f)

#  For Python 3 you don't need the import since the  print() function is
#  the default.
#
#  The alternative would be to use:

f = open('myfile', 'w')
f.write('hi there\n')  # python will convert \n to os.linesep
f.close()  # you can omit in most cases as the destructor will call it

#  Quoting from Python documentation
#  (https://docs.python.org/2/tutorial/inputoutput.htmlreading-and-
#  writing-files) regarding newlines:
#  >On output, if newline is None, any '\n' characters written are
#  translated to the system default line separator, os.linesep. If
#  newline is '', no translation takes place. If newline is any of the
#  other legal values, any '\n' characters written are translated to the
#  given string.
#
#  [sorin] [so/q/6159900] [cc by-sa 3.0]
              

Let's analyse the parts. First: cht.sh is just the hostname. Second: python stands for the sheet list. Finally, write+a+file is the search string (try to be as strict as possible because not all strings can match any results). Now, moving on to the answer:

call plug#begin('~/.vim/plugged')
Plug 'dbeniamine/cheat.sh-vim'
" ...
call plug#end()

" Vim command used to open a new buffer
let g:CheatSheetReaderCmd='new"'

" Cheat sheet file type
let g:CheatSheetFt='markdown'

" Program used to retrieve cheat sheet with its arguments
let g:CheatSheetUrlGetter='curl --silent'

" Flag to add cookie file to the query.
let g:CheatSheetUrlGetterIdFlag='-b'

" cheat sheet base URL
let g:CheatSheetBaseUrl='https://cht.sh'

" cheat sheet settings do not include style settings neiter comments,
" see other options below
let g:CheatSheetUrlSettings='q'

" cheat sheet pager
let g:CheatPager='less -R'

" pygmentize theme used for pager output, see :CheatPager :styles-demo
" let g:CheatSheetPagerStyle=rrt

" Show comments in answers by default
" (setting this to 0 means giving ?Q to the server)
let g:CheatSheetShowCommentsByDefault=1

" Stay in origin buffer (set to 0 to keep the focus on the cheat sheet buffer)
let g:CheatSheetStayInOrigBuf=1

" cheat sheet buffer name
let g:CheatSheetBufferName="_cheat"

" Default selection in normal mode (line for whole line, word for word under cursor)
let g:CheatSheetDefaultSelection="line"

" Default query mode
" 0 => buffer
" 1 => replace (do not use or you might lose some lines of code)
" 2 => pager
" 3 => paste after query
" 4 => paste before query
let g:CheatSheetDefaultMode=0

"  let g:CheatSheetIdPath=expand('~/.cht.sh/id')

" Make plugin silent by  setting bellow variable to 1
let g:CheatSheetSilent=0
              

After that, you will be able to run in the world's most beloved code editor:

:HowIn python writes a file
              

And a new pane with the result (if it exists) is returned! It couldn't be more striking.

Portfolio

I selected a few projects I've worked on to show you. Some projects have contract constraints so that I won't be showing them. I played the role of Frontend and Backend developer in all of them, sometimes in time, sometimes on my own.

Lillio's Observations Project: 2024

Lillo's Observations

At Lillio, I served as both the tech lead and full-stack engineer for the Observations project, developing a comprehensive feature using Ruby on Rails, ReactJS, React Native, PostgreSQL, and AWS. I managed the integration of a robust backend with a dynamic frontend to enhance functionality and mobile integration. More info here.

Lune: 2023

Conserve Piso

Payment management system for Cappta getway. This project was done in dotnet core, MSSQL SERVER and VueJS.

Ideallang English: 2022

Ideallang

English Course website made in WordPress and using a MySQL database (in partnership with another engineer).

Posto7: 2021

Ideallang

Nutrition application made with ReactJS, Firestore DB, and Firebase. My main attribution was to build an admin portal for the back office team

PSMI: 2020

PSMI

(Work in maintenance) Education platform containing a bunch of curses in Brazil, written in Ruby on Rails, PostgreSQL, Express JS, Google Cloud Functions, and AWS. I was responsible for upgrading Ruby and Rails versions, as well as transitioning the cloud infrastructure from GCP to AWS.

Mangue Tecnologia: 2020

Mangue Tecnologia

(Work in maintenance) An educational platform offering a variety of courses in Brazil, developed using Ruby on Rails, PHP, JavaScript, and MySQL. I built several eCommerce websites, enhancing user experience and functionality.

Chefstrela': 2019

Ideallang

Gastronomy E-commerce made in WordPress and using a MySQL database (in a partnership with another engineer and a designer)

Casa Roberto Marinho: 2018

ICRM

Content management system with Ruby on Rails, MySQL, and JQuery. Cultural and educational business.

Kariri Sapuyá: 2018

Kariri Sapuyá

Digital archive combined with a content management system for storing and : was delivering historical documents about South American Native peoples in Northeast Brazil. It is made with Ruby, Ruby on Rails, ElasticSearch, JQuery, MySQL, and MongoDB.Link to the web app: Kariri Sapuyá.

Perceive: 2017

Perceive

Automated tool for extracting useful information about vulnerabilities from mailing lists. It includes a series of solutions, including Python Jupyter Notebooks, a Flask server, and a MySQL database. More info here.

Conserve Piso: 2017

Conserve Piso

A web system developed using PHP, MySQL, and jQuery, designed to streamline the management of flooring projects. This system replaces traditional methods with a digital platform that enhances efficiency and accuracy.

DPMS (Digital Management System): 2015-2017

DPMS

System constructed with Ruby on Rails, MySQL, JQuery, and Telerik Kendo. It aims to manage all steps of an industrial project, replacing common spreadsheets with sophisticated, customizable, and reliable resources. See more info: See more info: Oxeanbits.

Portuguese Atlantic (Portuguese Name: Atlântico Português): 2014

Portuguese Atlantic

Content management system made with Ruby on Rails, PostgreSQL, JQuery, and ElasticSearch. It is an application to manage and search content in a digital historical archive, which is also uploaded within the CMS. Link to the web app: Atlântico Português.

About me

Hey! I'm a senior full-stack software engineer, Vinicius L. Gesteira (aka Vini). Since 2014, I've worked with web development (mainly Ruby, Ruby on Rails, Rust, Solidity, Node JS, Docker, AWS, React, and Svelte), machine learning, web scraping, Python scripts and other related fields. If you are interested in more details, please check out my LinkedIn and GitHub.