A new Swiss Army Knife

A new Swiss Army Knife

Mario Pinkster

As a backend developer I use a lot of different tools in the course of my daily work. Apart from the IDE and git, I need a universal REST client to fire requests at my server code under development to see what it does, I’ll occasionally need to write technical documentation of some sorts, write scripts to do useful things of a various nature, dab around in frontend code, do stuff with Docker containers - the list is long and diverse.

Specialized tools exist for each of these tasks, but they are not always free and may require quite a bit of setup, knob-turning, threats, and intimidation, before they do what I want. So I am always on the lookout for tools that do less and deliver more. In this article I will present some light weight and free tools that are available as extensions for Microsofts Visual Studio Code editor (vscode).

Why Visual Studio Code ?

As a long time user of the linux desktop on all my computers both at home and at work, I have no particular affinity for the products offered by Microsoft. But one day, while searching for an editor that would easily let me create a PDF document out of Markdown source code, I stumbled upon vscode and as it looked promising I decided to give it a whirl. Installation on my linux development machine went smooth enough and after some initial disorientation the interface seemed at least understandable, if not quite what I was used to.

So I tried the PDF plugin for vscode and it worked exactly as advertized. No hassle, just PDF. It even seamlessly picked up the HTML <table> that I had sneaked into my Markdown text. I was pleasantly surprised and the rest, as they say, is history.

Markdown PDF

Markdown is my weapon of choice when I have to write technical documentation (even this article is initially written in Markdown and then copypasted into the blog application). Mostly because it is a lightweight format that requires no proprietary editor, it plays nice with version control tools and offers enough flexibility in expressing my thoughts without bogging me down with all kinds of stuff that I don’t really need. Oh, and I like using the keyboard for input without having to stop every other word to manipulate the mouse in order to access some function or other.

As noted, the Markdown PDF extention adds easy conversion of Markdown text to a PDF document. Install the plugin, use the context menu and that is all there is to it. It writes out a pdf file in the same directory where your markdown document lives. No additional configuration needed, no endless series of questions in modal dialog boxes, just a magical *poof! and there is my crisp, clean and tidy PDF. It even understands and converts embedded HTML. Yes, even image tags.

In addition to converting to PDF this plugin is able to convert Markdown to HTML, and it can also produce UML and other diagrams when provided with special syntax input. And in case you were wondering, yes, it also has a live preview window that shows what your Markdown source code looks like when it’s rendered.

vscode-markdown

REST client

The REST client extension is a nifty tool for submitting requests to any url and inspecting the response. It is driven by a simple file that contains the requests in text form. You can use variable substitution in an intuitive syntax, like so:

@protocol = http
@hostname = localhost
@port = 9200
@host = {{protocol}}://{{hostname}}:{{port}}

POST {{host}}/philosophers/2
Content-Type: application/json

{
    "name":  "Smurf",
    "color": "blue"
}

###
PUT {{host}}/philosophers
Content-Type: application/json

Save your file with the extention .http or .rest and it will automatically be associated with the REST client when you open it in vscode.

You can send a request by placing the cursor anywhere in the text between two ### separators. A small send request link appears. Press it and the response will be shown as plain text in a separate window.

According to documentation it is also capable of various forms of authentication support, though I haven’t had occasion to try that out as yet.

In the past, I have used both Postman and Soap UI and while these specialized tools obviously offer a far more complete set of functions, they also come with a learning curve and need some setting up before you can start firing off requests. What I like about the vscode REST client plugin is that it is simple and easy to use, it lets me collect all my favourite test requests in a single text file (managed and edited by me, not by the tooling) and keep that in my project’s code base, and it is flexible enough to let me quickly change the recipient of my requests to a test or production server.
vscode-restclient

Other handy tools

  • The Live Server extension takes whatever code is currently in your editor in vscode and serves it at http://localhost:5500.
  • The Python extension turns your vscode editor into a fully equipped IDE for working with the Python language. Code completion, formatting, debugging, managing environments, Jupyter Notebook, it’s all there.
  • The Docker extension is another great tool. In addition to enhancing the editing of Dockerfile and docker-compose.yaml files through code completion and syntax highlights, it adds functions to simplify the care and feeding of the Docker containers and images that you work with.

Links

If you would like to read what other people have to say about vscode, here are some links for your perusal:

https://www.vscodecandothat.com

https://stackify.com/top-visual-studio-code-extensions/

https://calebporzio.com/my-vs-code-setup-2

https://dev.to/hannahgooding/vs-code-shortcuts-and-tricks-that-i-wish-i-knew-sooner-3mcj