<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bruno Baère</title>
    <description>The latest articles on DEV Community by Bruno Baère (@killerasus).</description>
    <link>https://dev.to/killerasus</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F778003%2F4091db7b-a620-438c-894c-78af3e78d7b9.png</url>
      <title>DEV Community: Bruno Baère</title>
      <link>https://dev.to/killerasus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/killerasus"/>
    <language>en</language>
    <item>
      <title>Configuring NeoVim plugins</title>
      <dc:creator>Bruno Baère</dc:creator>
      <pubDate>Thu, 04 Aug 2022 05:37:40 +0000</pubDate>
      <link>https://dev.to/killerasus/configuring-neovim-plugins-2kj0</link>
      <guid>https://dev.to/killerasus/configuring-neovim-plugins-2kj0</guid>
      <description>&lt;p&gt;&lt;a href="https://neovim.io/" rel="noopener noreferrer"&gt;NeoVim&lt;/a&gt; is a fork of vim that evolved into its own thing, but maybe you already knew that.&lt;/p&gt;

&lt;p&gt;In this very short post, I'm going to help you configure your NeoVim installation on Windows to use &lt;a href="https://github.com/preservim/nerdtree" rel="noopener noreferrer"&gt;NERDTree&lt;/a&gt; and &lt;a href="https://github.com/vim-airline/vim-airline" rel="noopener noreferrer"&gt;vim-airline&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Starting from ready-made &lt;code&gt;init.vim&lt;/code&gt; file
&lt;/h2&gt;

&lt;p&gt;Download Lefticus's &lt;a href="https://github.com/lefticus/nvim-config" rel="noopener noreferrer"&gt;vim-config&lt;/a&gt; files (including the &lt;code&gt;autoload&lt;/code&gt; directory) to your nvim configuration directory.&lt;/p&gt;

&lt;p&gt;On Windows 10 it will be located at &lt;code&gt;C:\Users\&amp;lt;USER&amp;gt;\AppData\Local\nvim&lt;/code&gt;, where &lt;code&gt;&amp;lt;USER&amp;gt;&lt;/code&gt; is your user handle. Maybe you'll need to create the nvim folder.&lt;/p&gt;

&lt;p&gt;Lefticus's config files already include vim-airline. Let's add NERDTree. Locate in the &lt;code&gt;init.vim&lt;/code&gt; file the section where plugins are added. Add the line &lt;code&gt;Plug 'preservim/nerdtree'&lt;/code&gt; to this section. You may end with something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feoqz9lnjyrtiow0b0jt7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feoqz9lnjyrtiow0b0jt7.png" alt="Section of the init.vim file with Plug commands" width="768" height="776"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing the plugins
&lt;/h2&gt;

&lt;p&gt;Launching neovim after adding the files may show some errors. These errors will be corrected after downloading the plugins.&lt;/p&gt;

&lt;p&gt;Enter command mode (press &lt;code&gt;:&lt;/code&gt;) and run the command &lt;code&gt;PlugInstall&lt;/code&gt;. Ex: &lt;code&gt;:PlugInstall&lt;/code&gt;. Another tab will open with the downloading and installation progress.&lt;/p&gt;

&lt;p&gt;If at any moment you need to update the plugins, run &lt;code&gt;:PlugUpdate&lt;/code&gt;. And if any plugin is broken (for example, when I changed the path to NERDTree), you may be prompted to run &lt;code&gt;:PlugClean&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Airline to use a Nerd Font with Powerlines
&lt;/h2&gt;

&lt;p&gt;Firstly, if you don't have a Nerd Font, you can install &lt;a href="https://github.com/microsoft/cascadia-code" rel="noopener noreferrer"&gt;Cascadia Code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Better yet, if you're using the &lt;a href="https://github.com/ryanoasis/vim-devicons" rel="noopener noreferrer"&gt;vim-devicons&lt;/a&gt; plugin, use the patched version at &lt;a href="https://github.com/ryanoasis/nerd-fonts" rel="noopener noreferrer"&gt;Nerd Fonts&lt;/a&gt; that include the icons. The rest of the post follows as equal.&lt;/p&gt;

&lt;p&gt;The next step is to add a line to your &lt;code&gt;init.vim&lt;/code&gt; file configuring GUI Font to a font with powerlines. See the example below, where I configure neovim to use Cascadia Mono PL with size 12:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set guifont=Cascadia\ Mono\ PL:h12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Mapping an shortcut for toggling NERDTree
&lt;/h2&gt;

&lt;p&gt;Add the following line to your &lt;code&gt;init.vim&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;map &amp;lt;C-o&amp;gt; :NERDTreeToggle&amp;lt;CR&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will set &lt;code&gt;Ctrl+o&lt;/code&gt; to run the command &lt;code&gt;:NERDTreeToggle&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adjusting tabs to spaces
&lt;/h2&gt;

&lt;p&gt;These lines will adjust tabs to 4 charactes wide. (Extracted from &lt;a href="https://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces" rel="noopener noreferrer"&gt;StackOverflow&lt;/a&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set tabstop=4
set softtabstop=0 noexpandtab
set shiftwidth=4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Being a heretic and using the mouse
&lt;/h2&gt;

&lt;p&gt;If you really want to use the mouse with neovim, add &lt;code&gt;set mouse=a&lt;/code&gt; to your &lt;code&gt;init.vim&lt;/code&gt;. &lt;code&gt;a&lt;/code&gt; stands for "all modes".&lt;/p&gt;

&lt;p&gt;Beware! You will attract strange looks from fellow workers using a mouse with neovim.&lt;/p&gt;

&lt;h2&gt;
  
  
  The final look
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2u7q53a8ln6fhclbbby0.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2u7q53a8ln6fhclbbby0.PNG" alt="NeoVim screen showing what you can achieve using the plugins and config files mentioned in the post" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/c/lefticus1" rel="noopener noreferrer"&gt;C++ Weekly with Jason Turner&lt;/a&gt; - From where I took the initial vim files. Jason is a well known figure in the C++ community, and his channel is a great place to learn.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.hanselman.com/blog/how-to-make-a-pretty-prompt-in-windows-terminal-with-powerline-nerd-fonts-cascadia-code-wsl-and-ohmyposh" rel="noopener noreferrer"&gt;How to make a pretty prompt in Windows Terminal with Powerline, Nerd Fonts, Cascadia Code, WSL, and oh-my-posh&lt;/a&gt; - Scott guides you through configuring Windows Terminal to show git status on your prompt. Still useful, and where I first heard about Nerd Fonts.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>neovim</category>
      <category>nvim</category>
    </item>
    <item>
      <title>The experience of writing a ray tracer in Go</title>
      <dc:creator>Bruno Baère</dc:creator>
      <pubDate>Fri, 08 Jul 2022 05:11:42 +0000</pubDate>
      <link>https://dev.to/killerasus/the-experience-of-writing-a-ray-tracer-in-go-24op</link>
      <guid>https://dev.to/killerasus/the-experience-of-writing-a-ray-tracer-in-go-24op</guid>
      <description>&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;There was a lazy day on an extended weekend when I was watching &lt;a href="https://www.youtube.com/watch?v=sb1FtMYAcYQ" rel="noopener noreferrer"&gt;The Cherno's Code Reviews&lt;/a&gt; series and came to meet (again) the &lt;a href="https://raytracing.github.io/" rel="noopener noreferrer"&gt;Ray Tracing in a Weekend&lt;/a&gt; book series. As the code was already in C++, I thought it wouldn't be much of a challenge to write it again in the same language. It would rather be best to identify and improve bottlenecks, or to use Modern C++ techniques.&lt;/p&gt;

&lt;p&gt;Alas, I had already written a ray tracer in C back in college as a classroom assignment and had worked on some improvements in a Computer Graphics class in my post-grad.&lt;/p&gt;

&lt;p&gt;But as I'm learning Go (and loving it) and I was searching for projects that would be nice to have a taste of what Go has to offer, it occurred to me that writing the ray tracer&lt;sup&gt;1&lt;/sup&gt; in Go would be fun and easy.&lt;/p&gt;

&lt;p&gt;And it was.&lt;/p&gt;

&lt;h2&gt;
  
  
  Go makes it a breeze
&lt;/h2&gt;

&lt;p&gt;Go already has image manipulation, profiling, and flag-parsing off the shelf. So, instead of following the book's suggestion of writing the result to a text file, I could output it directly to a png file.&lt;/p&gt;

&lt;p&gt;Go's syntax&lt;sup&gt;2&lt;/sup&gt; makes you write clean and easy-to-understand code. This project made me work with interfaces, whereas in C++ I'd probably resort to templates or inheritance.&lt;/p&gt;

&lt;p&gt;The only external library I had to resort to was a Go implementation of &lt;a href="https://github.com/engoengine/glm" rel="noopener noreferrer"&gt;glm&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next?
&lt;/h2&gt;

&lt;p&gt;Once I finished the first book, I knew some improvements could be made to run faster and better. For example, as ray tracing is extremely parallel, I could use goroutines to use more cores.&lt;/p&gt;

&lt;p&gt;Also, there are other two books in the series: "The next week", and "The rest of your life".&lt;/p&gt;

&lt;h2&gt;
  
  
  The path of others
&lt;/h2&gt;

&lt;p&gt;Surely, I wasn't the only one who thought about doing this project. If you're interested in how other developers handled implementing the ray tracer in Go, I'd recommend taking a look at these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://callistaenterprise.se/blogg/teknik/2020/07/04/a-go-ray-tracer/" rel="noopener noreferrer"&gt;Erik Lupander - Optimizing a simple ray-tracer written in Go, part 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/markphelps/go-trace" rel="noopener noreferrer"&gt;Mark Phelps - Writing a Ray Tracer in Go&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ypujante/ray-tracing" rel="noopener noreferrer"&gt;Yan Pujante - Ray-Tracing&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What do we take from it?
&lt;/h2&gt;

&lt;p&gt;Adapting "Ray Tracing in a Weekend - Part 1"'s code to Go was an entertaining experience. I certainly would recommend using it to get a hold of the basics of a new language you're learning. I'm just waiting for the opportunity to tackle the second and third books in the series, and going back to the start with &lt;a href="https://pragprog.com/titles/jbtracer/the-ray-tracer-challenge/" rel="noopener noreferrer"&gt;The Ray Tracer Challenge&lt;/a&gt;.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/killerasus" rel="noopener noreferrer"&gt;
        killerasus
      &lt;/a&gt; / &lt;a href="https://github.com/killerasus/GoRTIW" rel="noopener noreferrer"&gt;
        GoRTIW
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Implementation of the book series Ray Tracing in One Weekend in Go
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Go Raytracing in One Weekend&lt;/h1&gt;

&lt;/div&gt;
&lt;p&gt;This is an implementation of &lt;a href="https://raytracing.github.io/" rel="nofollow noopener noreferrer"&gt;Ray Tracing in One Weekend - The Book Series&lt;/a&gt; using Go and &lt;a href="https://github.com/engoengine/glm" rel="noopener noreferrer"&gt;go-glm&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As I am learning Go, I decided to translate the book's C++ implementation to Go. The objective is to compare both implementations, trying firstly to accomplish each chapter's objectives, and secondly trying to optimize the result.&lt;/p&gt;
&lt;p&gt;The current status of the code is shown below:&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Chapter&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Book 1 Complete&lt;/td&gt;
&lt;td&gt;&lt;a rel="noopener noreferrer" href="https://github.com/killerasus/GoRTIWoutput.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fkillerasus%2FGoRTIWoutput.png" alt="Result"&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;As stated in the book, Ray Tracing in One Weekend does not aim to create a complete ray tracer (more of a path tracer). The following books add more functionalities to the ray tracer, making it feature complete by the end of the series.&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/killerasus/GoRTIW" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;&lt;a&gt;1&lt;/a&gt;: Actually more of a path tracer than a ray tracer.&lt;br&gt;
&lt;a&gt;2&lt;/a&gt;: Sometimes I get myself thinking that Go is C and Python's child.&lt;/p&gt;

</description>
      <category>go</category>
      <category>raytracer</category>
      <category>computergraphics</category>
      <category>learning</category>
    </item>
    <item>
      <title>Using Hoppscotch to test REST APIs</title>
      <dc:creator>Bruno Baère</dc:creator>
      <pubDate>Tue, 05 Jul 2022 22:32:44 +0000</pubDate>
      <link>https://dev.to/killerasus/using-hoppscotch-to-test-rest-apis-gm5</link>
      <guid>https://dev.to/killerasus/using-hoppscotch-to-test-rest-apis-gm5</guid>
      <description>&lt;p&gt;Recently I've been involved in backend development writing an REST API to expose some data to other apps from our client's ecosystem.&lt;/p&gt;

&lt;p&gt;After messing with &lt;a href="https://curl.se/" rel="noopener noreferrer"&gt;curl&lt;/a&gt;, I felt the need to have some friendlier way to test the API, besides writing some shell scripts or Python code, so non-technical people could also test with ease. &lt;a href="https://hoppscotch.io" rel="noopener noreferrer"&gt;Hoppscotch&lt;/a&gt; came to the rescue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hoppscotch
&lt;/h2&gt;

&lt;p&gt;Hoppscotch is a free open source API development suite which runs in your browser. A commercial equivalent is Postman. Hoppscotch provides a workspace environment, where you can organize your work in request collections and environment variables.&lt;/p&gt;

&lt;p&gt;This post shows the basic usage of Hoppscotch services for testing requests to an API. For more details on how to setup testing and scripts, refer to the official documentation at &lt;a href="https://docs.hoppscotch.io/" rel="noopener noreferrer"&gt;https://docs.hoppscotch.io/&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sample code for the server
&lt;/h2&gt;

&lt;p&gt;For this article, I'm using the following GitHub repository for the server code (Go with Gin). It provides an API to retrieve and create drivers for an &lt;del&gt;not nearly secure or even close to&lt;/del&gt; hitchhiking-like app (you know which one).&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/killerasus" rel="noopener noreferrer"&gt;
        killerasus
      &lt;/a&gt; / &lt;a href="https://github.com/killerasus/GoRest" rel="noopener noreferrer"&gt;
        GoRest
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Implementing the REST API examples from APIs REST by Alexandre Saudate
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Go REST API&lt;/h1&gt;

&lt;/div&gt;
&lt;p&gt;This program simulates a driver-sharing app like many famous apps through a REST API using &lt;a href="https://golang.org" rel="nofollow noopener noreferrer"&gt;Go&lt;/a&gt; and &lt;a href="https://github.com/gin-gonic/gin" rel="noopener noreferrer"&gt;Gin&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;An adaptation of the examples from the book &lt;a href="https://www.casadocodigo.com.br/products/livro-apis-rest" rel="nofollow noopener noreferrer"&gt;APIs REST by Alexandre Saudate&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/killerasus/GoRest" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;The server (as of the time of writing this post) provides the following API:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/driver&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Recover drivers list&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/driver/:id&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Recover driver information&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/driver&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create a driver&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;We'll start by creating a collection to hold our requests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a collection
&lt;/h2&gt;

&lt;p&gt;Collections are a way to organize your work. So, for your workspace, you could create a collection for all driver-related requests, other collection for hitchhiker requests, and another for the rides requests.&lt;/p&gt;

&lt;p&gt;Let's start by clicking on the Collections icon and then clicking on &lt;code&gt;+ New&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkcdmcuzcjiyayu83xjoz.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkcdmcuzcjiyayu83xjoz.PNG" alt=" " width="400" height="189"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give your collection a name (if following the example API, I would recommend GoRestDrivers).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpw5tcqmi0rh56qnwehaw.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpw5tcqmi0rh56qnwehaw.PNG" alt=" " width="465" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, we'll create our first request. On the three dots icon on the right hand side of your collection, you can see other operations, such as exporting and renaming your collection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a request
&lt;/h2&gt;

&lt;p&gt;After creating a collection, we can use the New button to create a new request. Let's do that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjvcudxsj0c07pjhw9dy8.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjvcudxsj0c07pjhw9dy8.PNG" alt=" " width="464" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's name our request Create Driver. The main area is now representing this request. Let's customize the request. According to the documentation, to create a driver we must send a request usiung the method POST to the &lt;code&gt;/driver&lt;/code&gt; endpoint. The body of our request is a json object.&lt;/p&gt;

&lt;p&gt;There's a combo for choosing the method. On the left, click on &lt;code&gt;GET&lt;/code&gt; and change it to &lt;code&gt;POST&lt;/code&gt;. The URL should be &lt;code&gt;http://localhost:8080/driver&lt;/code&gt;, as I am running my server on the localhost using port 8080.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpvku3lnlz4vldkqmd98.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpvku3lnlz4vldkqmd98.PNG" alt=" " width="574" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To set the body of our request, click the Body tab. Set content-type to &lt;code&gt;application/json&lt;/code&gt;, and on the raw request body, we can insert the data to create our driver.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr2nwwh1h9p3r6rgkgkr2.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr2nwwh1h9p3r6rgkgkr2.PNG" alt=" " width="701" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the request and troubleshooting
&lt;/h2&gt;

&lt;p&gt;To test our request, we must first run the server. Then, we'll need to click on the button &lt;code&gt;Send&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If this is your first time running, you may receive an error that  the API endpoint couldn't be reached. This could mean the server isn't running, you need a proxy or you haven't installed the Hoppscotch browser extension. A message similar (because I already have installed the browser extension, but haven't started the server yet) to the following should appear.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqctb8zz2yptosoginghi.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqctb8zz2yptosoginghi.PNG" alt=" " width="492" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After installing the browser extension and making sure the server is running on the correct port, click &lt;code&gt;Send&lt;/code&gt; again. You should see the result.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fye5ge0sgs7kmk73letxc.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fye5ge0sgs7kmk73letxc.PNG" alt=" " width="488" height="227"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try modifying the body json to create new drivers. A following exercise should be creating the other request, like the &lt;code&gt;GET&lt;/code&gt; request to get the list of drivers to verify everything is working as it should.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating environment variables
&lt;/h2&gt;

&lt;p&gt;Until now, our requests used a hardcoded port (8080) to access our server. But if we are to modify the port, we would have to change every request created.&lt;/p&gt;

&lt;p&gt;We can use environment variables to avoid this issue. Let's change our &lt;code&gt;GET /driver&lt;/code&gt; request to use a variable named port instead of a hardcoded port. The URL will be written as follow:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flsjtlvay1muvyebpalfy.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flsjtlvay1muvyebpalfy.PNG" alt="http://localhost:&amp;lt;&amp;lt;port&amp;gt;&amp;gt;/driver" width="513" height="91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Variables are referenced by &lt;code&gt;&amp;lt;&amp;lt;variable&amp;gt;&amp;gt;&lt;/code&gt; and can be used everywhere. For example, you can define a &lt;code&gt;token&lt;/code&gt; variable and use it as the authorization token value. When a variable isn't defined yet, it will have a red shading. After defining the variable, it will assume a blue shading.&lt;/p&gt;

&lt;p&gt;Click the Environment icon, and the Global environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmbbd367945eb79k20yym.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmbbd367945eb79k20yym.PNG" alt="Environment creation/edition" width="791" height="213"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;A popup will open to Edit Environment. Click the + icon to create a new variable, name it port and assign the port value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhy8xu2tb3oh278hkplc.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhy8xu2tb3oh278hkplc.PNG" alt="Variable definition in an environment" width="645" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The port variable shading in the request will be changed, signifying it is defined.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqpf6jdyvnyfxkaorslq8.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqpf6jdyvnyfxkaorslq8.PNG" alt="Variable port correctly defined in the request" width="510" height="80"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Anytime you need to change the value of the port, you just need to change the variable value in the Environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This was a quick introduction to Hoppscotch. I hope this has driven your curiosity to experiment with Hoppscotch. It has made testing our APIs easier.&lt;/p&gt;

&lt;p&gt;For more information, check the current documentation on &lt;a href="https://docs.hoppscotch.io/" rel="noopener noreferrer"&gt;https://docs.hoppscotch.io/&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>testing</category>
      <category>hoppscotch</category>
    </item>
    <item>
      <title>Measuring program execution time in PowerShell</title>
      <dc:creator>Bruno Baère</dc:creator>
      <pubDate>Sat, 05 Mar 2022 00:32:33 +0000</pubDate>
      <link>https://dev.to/killerasus/measuring-program-execution-time-in-powershell-fdg</link>
      <guid>https://dev.to/killerasus/measuring-program-execution-time-in-powershell-fdg</guid>
      <description>&lt;p&gt;As I was nearing completion of implementing &lt;a href="https://raytracing.github.io/" rel="noopener noreferrer"&gt;Ray Tracing in One Weekend&lt;/a&gt; in &lt;a href="https://github.com/killerasus/GoRTIW" rel="noopener noreferrer"&gt;Go&lt;/a&gt;, I felt the need to measure the time it would take to render a scene&lt;sup&gt;1&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;My day-to-day work is in CentOS, so I was tempted to try &lt;code&gt;time gortiw&lt;/code&gt; in Windows Terminal, as it already had some improvements over &lt;code&gt;cmd&lt;/code&gt;, like &lt;code&gt;ssh&lt;/code&gt; and an alias for &lt;code&gt;ls&lt;/code&gt;. I was disappointed. There was no easily accessible &lt;a href="https://man7.org/linux/man-pages/man1/time.1.html" rel="noopener noreferrer"&gt;time&lt;/a&gt;-like command nor it was an alias.&lt;/p&gt;

&lt;p&gt;After searching a little, I got to a solution: using PowerShell's &lt;code&gt;Measure-Command&lt;/code&gt;. Then I just needed to create a function time in my PowerShell profile and it was done.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Edit your &lt;code&gt;Documents\PowerShell\Microsoft.PowerShell_profile.ps1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Add the line&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="kr"&gt;function&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$Command&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="bp"&gt;$args&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Measure-Command&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Invoke-Expression&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$Command&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;2&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;out-default&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open a new instance or tab of PowerShell to use the new time function.&lt;br&gt;
Ex: &lt;code&gt;time gortiw.exe&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Satisfied with the results, the next step will be using a &lt;a href="https://go.dev/blog/pprof" rel="noopener noreferrer"&gt;profiler&lt;/a&gt; to check where to improve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Notes
&lt;/h2&gt;

&lt;p id="note1"&gt;1. Yes, I could have used a timer in Go inside the ray tracer itself, but having a timer like `time` is still useful.&lt;/p&gt;

</description>
      <category>powershell</category>
      <category>windows</category>
    </item>
  </channel>
</rss>
