<?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: Jaga santagostino</title>
    <description>The latest articles on DEV Community by Jaga santagostino (@jaga).</description>
    <link>https://dev.to/jaga</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%2F12804%2F9b5d9379-bc73-4c32-8d59-84b9530241ce.jpeg</url>
      <title>DEV Community: Jaga santagostino</title>
      <link>https://dev.to/jaga</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jaga"/>
    <language>en</language>
    <item>
      <title>How I Start New Go Projects in Seconds</title>
      <dc:creator>Jaga santagostino</dc:creator>
      <pubDate>Mon, 09 Mar 2020 00:00:00 +0000</pubDate>
      <link>https://dev.to/jaga/how-i-start-new-go-projects-in-seconds-2c1l</link>
      <guid>https://dev.to/jaga/how-i-start-new-go-projects-in-seconds-2c1l</guid>
      <description>

&lt;p&gt;For the past years, I’ve started using more and more golang as a scripting language, and since in the past we were forced to put code in the GOPATH it became a little cumbersome compared to just write a bash file in the current folder&lt;/p&gt;

&lt;h2&gt;
  
  
  Project goinit
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VrUKyb5A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://jagascript.com/8d81fbd6c936747da1a506d27fa98f99/goinit.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VrUKyb5A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://jagascript.com/8d81fbd6c936747da1a506d27fa98f99/goinit.gif" alt="goinit"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I created a go program called &lt;code&gt;goinit&lt;/code&gt; to generate a new project in my &lt;code&gt;GOPATH&lt;/code&gt; at &lt;code&gt;~/go/src/github.com/kandros/[project-name]&lt;/code&gt; and open it in my editor, so far it server me very well, every new experiment is just a couple keystroke away &lt;code&gt;goinit my-app&lt;/code&gt;, I literally can see something in the console in less than 15 seconds&lt;/p&gt;

&lt;h2&gt;
  
  
  Using go mod
&lt;/h2&gt;

&lt;p&gt;Since go 1.11 I’ve started using go modules and stopped using &lt;code&gt;goinit&lt;/code&gt;, a couple days ago I decided to refactor it to handle creating projects outside &lt;code&gt;GOPATH&lt;/code&gt; and decided to use an even simpler solution, a custom shell function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;goinit() {
 mkdir -p ~/coding/$1
 cd ~/coding/$1
 cat &amp;lt;&amp;lt;-EOF &amp;gt; main.go
 package main

 import "fmt"

 func main() {
    fmt.Println("hello")
    }
 EOF

 go mod init github.com/kandros/$1
 code-insiders --new-window . --goto main.go
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It works the same way as my previous script by running &lt;code&gt;goinit new-project&lt;/code&gt; in the terminal it will create the folder &lt;code&gt;~/coding/new-project&lt;/code&gt; open the project in VScode and the file main.go&lt;/p&gt;

&lt;h2&gt;
  
  
  Make the function accessible globally
&lt;/h2&gt;

&lt;p&gt;This function is stored in my &lt;code&gt;~/.zshrc&lt;/code&gt; file to be available in the terminal, Bash users can put it in their &lt;code&gt;~/.bash_profile&lt;/code&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>terminal</category>
      <category>cli</category>
    </item>
    <item>
      <title>How to Build a Textual Progress Bar for Node.js CLI and Terminal Apps </title>
      <dc:creator>Jaga santagostino</dc:creator>
      <pubDate>Fri, 06 Mar 2020 00:00:00 +0000</pubDate>
      <link>https://dev.to/jaga/how-to-build-a-textual-progress-bar-for-node-js-cli-and-terminal-apps-4ij9</link>
      <guid>https://dev.to/jaga/how-to-build-a-textual-progress-bar-for-node-js-cli-and-terminal-apps-4ij9</guid>
      <description>&lt;p&gt;I find textual interfaces extremely interesting and I’m trying to figure out how some common components can be creates&lt;/p&gt;

&lt;p&gt;this is the time of a progress bar&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uc970y2P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://user-images.githubusercontent.com/4562878/76140679-35db2200-605d-11ea-8258-d73dbcb8263c.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uc970y2P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://user-images.githubusercontent.com/4562878/76140679-35db2200-605d-11ea-8258-d73dbcb8263c.gif" alt="gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;to create a textual progress bar we need to understand two simple concepts&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you can control where the cursor Is programmatically&lt;/li&gt;
&lt;li&gt;There are ANSI escapes code to cancel the entire screen or the current line (\r)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One way to achieve this is to start a loop and on every iteration print the special escape code &lt;code&gt;\r&lt;/code&gt; that will clear the line at the cursor position and then print one of the following to simulate a progress&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[.]
[..]
[...]
[....]
[.....]
[......]
[.......]
[........]
[.........]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In this example, I’ll be using Node.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function main() {
  /* using 20 to make the progress bar length 20 charactes, multiplying by 5 below to arrive to 100 */

  for (let i = 0; i &amp;lt;= 20; i++) {
    const dots = ".".repeat(i)
    const left = 20 - i
    const empty = " ".repeat(left)

    /* need to use `process.stdout.write` becuase console.log print a newline character */
    /* \r clear the current line and then print the other characters making it looks like it refresh*/
    process.stdout.write(`\r[${dots}${empty}] ${i * 5}%`)
    await wait(80)
  }
}

main()

function wait(ms) {
  return new Promise(res =&amp;gt; setTimeout(res, ms))
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This was relatively simple but with some &lt;a href="https://dev.to/jaga/how-to-show-colored-text-in-terminal-4bbg"&gt;custom colors&lt;/a&gt; can have a huge impact in the UX of a tool, especially it takes some time to complete and there is no other feedback for the user that everything is going ok&lt;/p&gt;




&lt;p&gt;full code available on the repo on &lt;a href="https://github.com/kandros/textual-progress-bar"&gt;github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cli</category>
      <category>node</category>
      <category>terminal</category>
    </item>
    <item>
      <title>How to Show Colored Text in Terminal?</title>
      <dc:creator>Jaga santagostino</dc:creator>
      <pubDate>Tue, 03 Mar 2020 00:00:00 +0000</pubDate>
      <link>https://dev.to/jaga/how-to-show-colored-text-in-terminal-4bbg</link>
      <guid>https://dev.to/jaga/how-to-show-colored-text-in-terminal-4bbg</guid>
      <description>

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8K6nlgd---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/00ca0ef17e3778df5ff28eecec8f619c/chalk.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8K6nlgd---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/00ca0ef17e3778df5ff28eecec8f619c/chalk.svg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are many things that we see and use every day but rarely we stop and think “how does it work?”, other times we ask ourselves that question but dismiss it because we suppose that the answer is probably super complicated.&lt;/p&gt;

&lt;p&gt;This was the case for me about wondering how terminals show different colors, in my mind, it has always been something extremely complicated until I realized it’s quite simple and easy.&lt;/p&gt;

&lt;p&gt;For years I’ve been using tools that show colored output and from time to time I used them too, always relying on libraries such a &lt;a href="https://www.npmjs.com/package/chalk"&gt;chalk&lt;/a&gt; in Node.js&lt;/p&gt;

&lt;p&gt;This until one day, I wanted to print some errors messages in red in a simple script and wanted to avoid using a library for such a simple case, that day I understand the basics of colors and another formatting in terminal output&lt;/p&gt;

&lt;p&gt;all required is to print some special sequence of characters called &lt;em&gt;ANSI escape&lt;/em&gt; and the text after that will have the specific color or background or text style&lt;/p&gt;

&lt;p&gt;these are standardized and interpreted by almost any terminal emulator&lt;/p&gt;

&lt;p&gt;for example the Espace code &lt;code&gt;\x1b[32m&lt;/code&gt; will start printing in &lt;em&gt;green&lt;/em&gt; while &lt;code&gt;\x1b[0m&lt;/code&gt; is the reset Espace and will reset the next text to normal&lt;/p&gt;

&lt;p&gt;try to print this in you terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo "I'm normal \x1b[32m I will be green \x1b[47m I will have white background \x1b[4m I will be underscored \x1b[0m, not I'm back to normal"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;this will be the result&lt;a href="///static/87b093efde9b37390d450251f1e3a496/d9ed5/echo.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OLy7SzaK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/static/87b093efde9b37390d450251f1e3a496/fcda8/echo.png" alt="echo" title="echo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How can I do it in my programming language?
&lt;/h3&gt;

&lt;p&gt;as long the output is interpreted by an ANSI compatible terminal you only have to print the escape code, for example, the above command can be used as a string in &lt;code&gt;console.log&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log("I'm normal \x1b[32m I will be gre
en \x1b[47m I will have white background \x1b[4m
I will be undescored \x1b[0m not I'm back to norm
al")
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;These are some other cool escape codes you can try&lt;/p&gt;

&lt;p&gt;Have fun!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Reset = "\x1b[0m"
Bright = "\x1b[1m"
Dim = "\x1b[2m"
Underscore = "\x1b[4m"
Blink = "\x1b[5m"
Reverse = "\x1b[7m"
Hidden = "\x1b[8m"

FgBlack = "\x1b[30m"
FgRed = "\x1b[31m"
FgGreen = "\x1b[32m"
FgYellow = "\x1b[33m"
FgBlue = "\x1b[34m"
FgMagenta = "\x1b[35m"
FgCyan = "\x1b[36m"
FgWhite = "\x1b[37m"

BgBlack = "\x1b[40m"
BgRed = "\x1b[41m"
BgGreen = "\x1b[42m"
BgYellow = "\x1b[43m"
BgBlue = "\x1b[44m"
BgMagenta = "\x1b[45m"
BgCyan = "\x1b[46m"
BgWhite = "\x1b[47m"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;h3&gt;
  
  
  Some other cool colored and formatted text
&lt;/h3&gt;

&lt;p&gt;&lt;a href="///static/581cac2699ffcf4238315ad752aa7bdf/07a9c/man.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YTYZEMlU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/static/581cac2699ffcf4238315ad752aa7bdf/fcda8/man.png" alt="man" title="man"&gt;&lt;/a&gt;output of &lt;code&gt;man&lt;/code&gt; command&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Avqa2WdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/static/e40ffe31c1e4a5ff36c236beb26472b9/fcda8/gatsby.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Avqa2WdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/static/e40ffe31c1e4a5ff36c236beb26472b9/fcda8/gatsby.png" alt="gatsby" title="gatsby"&gt;&lt;/a&gt;part of &lt;a href="https://www.gatsbyjs.org/"&gt;GatsbyJS&lt;/a&gt; build script&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why I Created a Playlist on Spotify every month for the past 5 years</title>
      <dc:creator>Jaga santagostino</dc:creator>
      <pubDate>Sun, 10 Nov 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/jaga/why-i-created-a-playlist-on-spotify-every-month-for-the-past-5-years-1ojb</link>
      <guid>https://dev.to/jaga/why-i-created-a-playlist-on-spotify-every-month-for-the-past-5-years-1ojb</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X_9GwEsi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/static/4a657db7c9e5567edc4ef5190777cfeb/c739e/image.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X_9GwEsi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/static/4a657db7c9e5567edc4ef5190777cfeb/c739e/image.jpg" alt="image" title="image"&gt;&lt;/a&gt;image credit: &lt;a href="https://unsplash.com/photos/1oKxSKSOowE"&gt;Mohammad Metri&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some people love to carefully craft playlists, I’m by no means one of them.&lt;/p&gt;

&lt;p&gt;I listen in mostly shuffle-mode from a collection of thousands of songs, so for me is not uncommon to listen Iron Maiden followed by Be Gees, Mozart up next and then again Katy perry.&lt;/p&gt;

&lt;p&gt;In March 2015 I started creating a new playlist at the beginning of every month where I save songs I enjoyed to listen that month and continued since.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ok cool, but why?
&lt;/h2&gt;

&lt;p&gt;I find it fascinating to be able to check what I was listening to in some specific periods of my life and see how different styles of music I listen to&lt;/p&gt;

&lt;p&gt;At the start of every month, I listen to the previous years’ playlists for the corresponding month, (this has the interesting side effect that I’m more likely to add songs from prev year to the current month)&lt;/p&gt;

&lt;p&gt;What is amazing is that these songs triggers some kind of memories and being in the same time-frame make them revive memories associated with them&lt;/p&gt;

&lt;p&gt;Another amazing thing is that listening to songs from Films and Tv Shows I’m able to tell what I watched (or rewatched) that month&lt;/p&gt;

&lt;h2&gt;
  
  
  Automating the process
&lt;/h2&gt;

&lt;p&gt;Using &lt;a href="https://ifttt.com/"&gt;IFTTT&lt;/a&gt; I was able to create a new voice command for google assistant that would pick the phrase "save this song on my monthly playlist" and call an AWS lambda using &lt;a href="https://ifttt.com/maker_webhooks"&gt;IFTTT webhooks&lt;/a&gt; to save the current song in the appropriate folder using Spotify API&lt;/p&gt;




&lt;p&gt;If you are curious these are my lists from previous years in November&lt;/p&gt;

&lt;p&gt;Please don’t judge me :D&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://open.spotify.com/playlist/412yhxxfZ9dSq17E0x514c?si=4XW6Y9NvS0ibNVmaMyc7yw"&gt;November 2015&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://open.spotify.com/playlist/3WBqCQAcrxrZdzj5s3N830?si=Gx0Atp4-SPWHpHQ6Ebbt_w"&gt;November 2016&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://open.spotify.com/playlist/1Azo3uWXi3Arl65UiSMt75?si=miATZ3muQXCs5aE9bhMAdw"&gt;November 2017&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://open.spotify.com/playlist/4PTlhsW7XgchvCuIr5AVQF?si=4KAddqeJQfSYv7Q4l7X_QQ"&gt;November 2018&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://open.spotify.com/playlist/2hKiY5CPHTwze68Q7dZBBB?si=I7vRQe-XTCGLjcFh9yIJPw"&gt;November 2019&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Func fact: I hide link of songs I listen to while coding in commit messages and code comments&lt;/p&gt;

</description>
      <category>music</category>
      <category>habits</category>
      <category>spotify</category>
      <category>automation</category>
    </item>
    <item>
      <title>Opening a Folder and File in Vscode from Terminal</title>
      <dc:creator>Jaga santagostino</dc:creator>
      <pubDate>Fri, 08 Nov 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/jaga/opening-a-folder-and-file-in-vscode-from-terminal-1m19</link>
      <guid>https://dev.to/jaga/opening-a-folder-and-file-in-vscode-from-terminal-1m19</guid>
      <description>&lt;p&gt;&lt;a href="///static/075e78694a72146a7509186570137664/c35de/vscode.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qHYfnalM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/static/075e78694a72146a7509186570137664/c739e/vscode.jpg" alt="vscode" title="vscode"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;VSCode offers the &lt;code&gt;code&lt;/code&gt; command (&lt;code&gt;code-insiders&lt;/code&gt; for the beta channel) to open files and folders from terminal&lt;/p&gt;

&lt;p&gt;these are some possible usage:&lt;code&gt;code myfile&lt;/code&gt;&lt;code&gt;code a/b/c/d/text.sh&lt;/code&gt;&lt;code&gt;code myFolder&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;what if we want to open a folder and also a file within?&lt;/p&gt;

&lt;p&gt;use &lt;code&gt;code path_to_foder --goto path_to_file&lt;/code&gt;&lt;/p&gt;

</description>
      <category>vscode</category>
    </item>
    <item>
      <title>Daily random knowledge from Wikipedia</title>
      <dc:creator>Jaga santagostino</dc:creator>
      <pubDate>Wed, 16 Oct 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/jaga/daily-random-knowledge-from-wikipedia-4mn2</link>
      <guid>https://dev.to/jaga/daily-random-knowledge-from-wikipedia-4mn2</guid>
      <description>&lt;p&gt;In the past few weeks, I’ve added an interesting new “todo” to my morning routine: to read &lt;a href="https://en.wikipedia.org/wiki/Main_Page"&gt;Wikipedia’s Main page&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This page is updated every day to show a Featured article, facts happened the same day in the past, some &lt;em&gt;Did you know&lt;/em&gt; interesting events and a Featured Image with a detailed caption.&lt;/p&gt;

&lt;p&gt;This allows me to know a lot of interesting information every day with little to no effort, the best part is that I get to know facts I would probably never search for otherwise.&lt;/p&gt;

&lt;p&gt;A couple of days ago I started reading a fact about &lt;a href="https://en.wikipedia.org/wiki/Abraham_Lincoln"&gt;Lincoln&lt;/a&gt; and link after link I read very interesting stuff related to the &lt;a href="https://en.wikipedia.org/wiki/White_House"&gt;White House&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Did you know every new US president have a budget of $100.000 to changes things in the White House?&lt;/p&gt;

&lt;p&gt;President Obama built a basketball court for example.&lt;/p&gt;

&lt;p&gt;Did you know the President’s &lt;a href="https://en.wikipedia.org/wiki/Resolute_desk"&gt;desk&lt;/a&gt; in the Oval Office was a gift from Queen Victoria and was built from the timbers coming from a British Ship that the USA helped recover in the Artic?&lt;/p&gt;

&lt;h2&gt;
  
  
  fun fact
&lt;/h2&gt;

&lt;p&gt;Italian’s main page is different from the English one.&lt;/p&gt;

&lt;p&gt;we have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;born and dead anniversaries&lt;/li&gt;
&lt;li&gt;holidays&lt;/li&gt;
&lt;li&gt;no detailed description for the image of the day&lt;/li&gt;
&lt;li&gt;a single &lt;em&gt;Did you know&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;a call to action to translate a page not yet available in Italian&lt;/li&gt;
&lt;li&gt;a book of the Month from Wikisource&lt;/li&gt;
&lt;li&gt;a destination of the Month from Wikivoyage&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Most of these are far from being &lt;em&gt;must know&lt;/em&gt; pieces of information but I really enjoy getting to know more about the world I live in&lt;/p&gt;

&lt;p&gt;Especially if It’s one click away.&lt;/p&gt;

</description>
      <category>routines</category>
    </item>
    <item>
      <title>Disable VScode TypeScript alias in rename refactoring</title>
      <dc:creator>Jaga santagostino</dc:creator>
      <pubDate>Mon, 27 May 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/jaga/disable-vscode-typescript-alias-in-rename-refactoring-27kh</link>
      <guid>https://dev.to/jaga/disable-vscode-typescript-alias-in-rename-refactoring-27kh</guid>
      <description>&lt;p&gt;Since TypeScript 3.4 a setting has been implemented into tsserver that makes &lt;em&gt;refactoring &amp;gt; rename&lt;/em&gt; create an alias in the local scope insted of change the original name&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3fPjfQpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://jagascript.com/rename-27218f90fe8175b126c9b51345d0de35.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3fPjfQpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://jagascript.com/rename-27218f90fe8175b126c9b51345d0de35.gif" alt="rename"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;this abomination was enabled by default on VScode and after months of pain I found a way to disable it.&lt;/p&gt;

&lt;p&gt;🎉🎉🎉🎉🎉🎉🎉&lt;/p&gt;

&lt;p&gt;The configuration is called &lt;code&gt;typescript.preferences.renameShorthandProperties&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="///static/266dd9c7562743db1e99b13bef49a94a/8cbec/rename-alias-ts-vscode-setting.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--niJZUhxr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/static/266dd9c7562743db1e99b13bef49a94a/8cbec/rename-alias-ts-vscode-setting.png" alt="rename-alias-ts-vscode-setting.png"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tips</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Counting Visits and adblockers</title>
      <dc:creator>Jaga santagostino</dc:creator>
      <pubDate>Sun, 05 May 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/jaga/counting-visits-and-adblocker-4fb</link>
      <guid>https://dev.to/jaga/counting-visits-and-adblocker-4fb</guid>
      <description>&lt;p&gt;Nowadays a lot of users use some kind of adblocker, personally, I use &lt;a href="https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm?hl=it"&gt;uBlock origin&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  It this just for ads right?
&lt;/h2&gt;

&lt;p&gt;Well, no, most adblocker also blocks tracking events including the most famous tracking system which is the dead-simple to setup and goto tool for most companies &lt;a href="https://analytics.google.com/analytics/web/"&gt;google analytics&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How does a blocker work?
&lt;/h2&gt;

&lt;p&gt;Being a browser extension, a blocker sits between the internet and the browser, this can stop requests from a website you are navigating to another URL matching, for example, the domains from a blacklist.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SUM_avDE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/static/f87b71417a61ff8d45afdd18174347f7/a792c/request-blocked.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SUM_avDE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://jagascript.com/static/f87b71417a61ff8d45afdd18174347f7/a792c/request-blocked.png" alt="request-blocked"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This look familiar?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is the problem
&lt;/h2&gt;

&lt;p&gt;The obvious problem is that visits statistics such as numbers of pageview for an article or most used devices will no longer match the reality, given it only shows devices that don't have an adblocker, and based on your audience it can be a huge part, if not the most part.&lt;/p&gt;

&lt;p&gt;Having data you cannot trust or make decisions upon is just useless data.&lt;/p&gt;

&lt;p&gt;all I want for my personal projects is to know the visit count divided by page and the origin of the visit (slack, twitter, google, etc), from which country the visitor is requesting the page is a nice to have but not required.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Use something else, something that is not in a blacklist&lt;/p&gt;

&lt;h3&gt;
  
  
  First Try
&lt;/h3&gt;

&lt;p&gt;(This works and I'm using it now, it was my fault for not making it work in the end, details later)&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--9sB3OkRC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1026847078545346561/VK1bWEuW_normal.jpg" alt="Jaga santagostino profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Jaga santagostino
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @kandros5591
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      what is the goto tool for easy website analytics that is not blocked by adblockers? a dashboard with viewcount total and trend is enough, location nice to have
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      00:48 AM - 04 May 2019
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1124475843881861121" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1124475843881861121" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      0
      &lt;a href="https://twitter.com/intent/like?tweet_id=1124475843881861121" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      0
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;Suggested by a friend of mine on twitter, I tried to use &lt;a href="https://simpleanalytics.io/"&gt;simpleanalytics.io&lt;/a&gt; which offer an HTML script tag to insert in your pages and a dashboard to see the requests, it shows device type, country, origin.&lt;/p&gt;

&lt;p&gt;Enough for my case!&lt;/p&gt;

&lt;p&gt;The pricing is very good 9 dollars per month with unlimited websites, so I could use it for all my domains which is great.&lt;/p&gt;

&lt;p&gt;Unfortunately, I tried it and my adblocker blocked it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QTLUJ5eP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://media2.giphy.com/media/3ornjUrHrU17Cb1JFS/giphy.gif%3Fcid%3D790b76115cceb187393370332e89dd7e%26rid%3Dgiphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QTLUJ5eP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://media2.giphy.com/media/3ornjUrHrU17Cb1JFS/giphy.gif%3Fcid%3D790b76115cceb187393370332e89dd7e%26rid%3Dgiphy.gif" alt="booo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, it' a tracking service, no wonder it eventually entered in the huge blacklist.&lt;/p&gt;

&lt;h3&gt;
  
  
  Second Try
&lt;/h3&gt;

&lt;p&gt;So I went ahead and built my poor-man-edition visit counter in &lt;em&gt;go&lt;/em&gt; on &lt;em&gt;aws-lambda&lt;/em&gt; using &lt;em&gt;dynamodb&lt;/em&gt; that uses a great feature of lambdas being server by api-gateway receives the headers from CloudFront which have some amazing information inside&lt;/p&gt;

&lt;p&gt;here the repo of the visit tracker &lt;a href="https://github.com/kandros/go-visits-cloudfront"&gt;go-visits-cloudfront&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It works, have no frontend not dashboard at the moment but It's surprisingly useful for a 2-hour Saturday project built in a bar.&lt;/p&gt;

&lt;h3&gt;
  
  
  Third try
&lt;/h3&gt;

&lt;p&gt;In the meantime, the twitter thread continued and the author of simpleanalytics.io step-by, to add a much-appreciated information&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--mwKTSxAq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/905957622989324289/ZOOVIaqM_normal.jpg" alt="Adriaan van Rossum profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Adriaan van Rossum
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @adriaanvrossum
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      &lt;a href="https://twitter.com/kandros5591"&gt;@kandros5591&lt;/a&gt; &lt;a href="https://twitter.com/siscia_"&gt;@siscia_&lt;/a&gt; &lt;a href="https://twitter.com/Cloudflare"&gt;@Cloudflare&lt;/a&gt; &lt;a href="https://twitter.com/SimpleAnalytic"&gt;@SimpleAnalytic&lt;/a&gt; We have a feature called subdomain adblocker bypass, you just link a CNAME to our server and you're done. We setup SSL and do the rest. Bye bye adblockers ;-)
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      12:54 PM - 04 May 2019
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1124658593146519553" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1124658593146519553" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      2
      &lt;a href="https://twitter.com/intent/like?tweet_id=1124658593146519553" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      2
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;p&gt;adding a &lt;em&gt;cname&lt;/em&gt; redirect from one of your subdomains to simpleanalytics' api we can bypass the adblocker, given the fact that simpleanalitycs is based on privacy and "being a good internet citizen" at its core, I have no problem doing that.&lt;/p&gt;

&lt;p&gt;The solution is as simple as it is smart.&lt;/p&gt;

&lt;h3&gt;
  
  
  what about SSL?
&lt;/h3&gt;

&lt;p&gt;In case you wonder how it works with https, you set the subdomain you choose into the simpleanalytics dashboard and it does SSL certificates magic to enable secure data communication for you. Using domains from different registars (Godaddy, Google, Amazon Route 53, Zeit, Netlify via their domain servers) I had to do nothing else.&lt;/p&gt;

&lt;h3&gt;
  
  
  What about single page applications and gatsby?
&lt;/h3&gt;

&lt;p&gt;For SPA it just works, for details there is a page in their documentation &lt;a href="https://docs.simpleanalytics.com/trigger-custom-page-views"&gt;doc&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For &lt;a href="https://gatsbyjs.org"&gt;Gatsby&lt;/a&gt; I just had to add the script to the page "the gatsby way" using the SSR api&lt;br&gt;
Here's how&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


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

&lt;p&gt;I moved different sites to use &lt;a href="https://simpleanalytics.io"&gt;simpleanalytics.io&lt;/a&gt; because the pricing is small enough that it's worth buying it instead of maintaining an in-house solution even if very small, which means the greater experience for my visitors, greater experience for me because I can now have meaningful data to make decisions upon to create more content.&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>gatsby</category>
    </item>
    <item>
      <title>fix chrome flexbox layouts in chrome 72, 73+</title>
      <dc:creator>Jaga santagostino</dc:creator>
      <pubDate>Wed, 10 Apr 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/jaga/fix-chrome-flexbox-layouts-in-chrome-72-73-165a</link>
      <guid>https://dev.to/jaga/fix-chrome-flexbox-layouts-in-chrome-72-73-165a</guid>
      <description>&lt;p&gt;Chrome 72 introduced a change in how flexbox element with &lt;code&gt;height: 100%&lt;/code&gt; renders, that caused some strange product breakage from one day to another without any code change.&lt;/p&gt;

&lt;p&gt;&lt;a href="/static/fc02cb35b46762ccb2e475c40e37bf2d/7f393/chrome-before-fix.png"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjagascript.com%2Fstatic%2Ffc02cb35b46762ccb2e475c40e37bf2d%2F7f393%2Fchrome-before-fix.png" alt="chrome-before-fix"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The fix was simple but hard to find.flexbox elements with &lt;code&gt;height: 100%&lt;/code&gt; now need to have &lt;code&gt;min-height&lt;/code&gt; set, even 0 value is ok.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.list {
  display: flex;
}

.item {
  height: 100%;
  min-height: 0; /* add this */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="/static/15b2702193a9e6066cee1dfbc315be15/7c949/chrome-after-fix.png"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjagascript.com%2Fstatic%2F15b2702193a9e6066cee1dfbc315be15%2F7c949%2Fchrome-after-fix.png" alt="chrome-after-fix"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;more info: &lt;a href="https://developers.google.com/web/updates/2019/01/devtools" rel="noopener noreferrer"&gt;https://developers.google.com/web/updates/2019/01/devtools&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tips</category>
      <category>chrome</category>
    </item>
    <item>
      <title>don't use git stash pop</title>
      <dc:creator>Jaga santagostino</dc:creator>
      <pubDate>Tue, 09 Apr 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/jaga/don-t-use-git-stash-pop-4m3p</link>
      <guid>https://dev.to/jaga/don-t-use-git-stash-pop-4m3p</guid>
      <description>&lt;p&gt;&lt;a href="/static/27d7ec9074e09ad28289a938649ffbc4/36da7/room-of-requirement.jpg"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fjagascript.com%2Fstatic%2F27d7ec9074e09ad28289a938649ffbc4%2F44e84%2Froom-of-requirement.jpg" alt="room-of-requirement"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why?
&lt;/h2&gt;

&lt;p&gt;A git &lt;code&gt;stash&lt;/code&gt; is a very powerful concept, it’s like Harry Potter’s &lt;em&gt;Room of Requirement&lt;/em&gt; for your code, you throw it in here and you can get it back when you need it again in the future.&lt;/p&gt;

&lt;p&gt;But dealing with it can be dangerous.&lt;/p&gt;

&lt;p&gt;Running &lt;code&gt;git stash pop&lt;/code&gt; throws away the stash after applying it.&lt;code&gt;git stash apply&lt;/code&gt; leaves it in the stash list and can be reused later (or dropped using &lt;code&gt;git stash drop&lt;/code&gt;)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;note: If during a &lt;code&gt;pop&lt;/code&gt; there are conflicts it behave exactly like git stash apply and the stash will not be lost&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5&gt;
  
  
  Worth notice
&lt;/h5&gt;

&lt;p&gt;&lt;code&gt;git stash pop&lt;/code&gt; is equivalent to &lt;code&gt;git stash apply &amp;amp;&amp;amp; git stash drop&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;code&gt;git stash apply&lt;/code&gt; can be a life-saver somethimes when you mess up with taking something from the stash&lt;/p&gt;

&lt;p&gt;&lt;span&gt;&lt;br&gt;
image credit: &lt;a href="https://www.deviantart.com/ancientking" rel="noopener noreferrer"&gt;ancientking&lt;/a&gt;&lt;br&gt;
&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>tips</category>
    </item>
    <item>
      <title>Using Custom Terminal Functions</title>
      <dc:creator>Jaga santagostino</dc:creator>
      <pubDate>Wed, 27 Feb 2019 00:00:00 +0000</pubDate>
      <link>https://dev.to/jaga/using-custom-terminal-functions-1p3o</link>
      <guid>https://dev.to/jaga/using-custom-terminal-functions-1p3o</guid>
      <description>&lt;h2&gt;
  
  
  Did you know you can declare a custom function to use in your terminal?
&lt;/h2&gt;

&lt;p&gt;There’s dozens of operations you perform daily in your terminal that can be automated with very little effort, one way is using a custom function.&lt;/p&gt;

&lt;p&gt;How do functions in bash/zsh work? Here’s a little example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sayCiaone() {
    echo "ciaone from a shell function"
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;copy this in your terminal and then call &lt;code&gt;sayCiaone&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Here’s some functions that I use daily
&lt;/h2&gt;

&lt;h3&gt;
  
  
  create folder and cd into it
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function mkcd() {
    mkdir -p "$1" &amp;amp;&amp;amp; cd "$1"
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;$1&lt;/code&gt; is the first parameter after &lt;code&gt;mkcd&lt;/code&gt; for calling &lt;code&gt;mkcd my-new-folder&lt;/code&gt; is essentially like typing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir my-new-folder
cd my-new-folder
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;h3&gt;
  
  
  pasting clipboard content in a file
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function pastefile() {
    pbpaste &amp;gt; "$1"
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;pbpaste&lt;/code&gt; is a builtin utility on macOS that print the clipboard content&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;&lt;/code&gt; means to write the input from the left (the output of the command pbpaste)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$1&lt;/code&gt; is the argument, in this case, the filename I want to paste to.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;pastefile myFile&lt;/code&gt; will create a new file named &lt;em&gt;myFile&lt;/em&gt; with my current clipboard content&lt;/p&gt;




&lt;h3&gt;
  
  
  print package.json scripts
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function scripts() {
     cat package.json | jq -r '.scripts'
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hFWeB5N8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://jagascript.com/scripts-0cad385767a37dbef1d6729f44f50539.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hFWeB5N8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://jagascript.com/scripts-0cad385767a37dbef1d6729f44f50539.gif" alt="scripts"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;|&lt;/code&gt; is the pipe operator in shell scripting, it means the output of the command on his left will be the input of the command on his right, in this case, the content of the &lt;code&gt;package.json&lt;/code&gt; file&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;jq&lt;/code&gt; is a utility for formatting and pretty printing JSON, in this case we only read the field &lt;em&gt;scripts&lt;/em&gt; of the received object&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  commit everything with a wip commit message
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function wip() {
    git add --all
    git commit -m "wip"
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;this is pretty self-explanatory :D&lt;/p&gt;

&lt;h2&gt;
  
  
  tips
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;in &lt;em&gt;zsh&lt;/em&gt; you can set the function as a oneline&lt;/li&gt;
&lt;li&gt;in &lt;em&gt;zsh&lt;/em&gt; function keyword is optional&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;the snippet below is valid in &lt;em&gt;zsh&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkcd() { mkdir -p "$1" &amp;amp;&amp;amp; cd "$1" }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Saving in a dotfile for reuse
&lt;/h2&gt;

&lt;p&gt;declaring a function only makes it available in the current terminal session, if you want it to be persisted and accessible from any terminal you can declare them inside your .zshrc or .bashrc&lt;/p&gt;

&lt;h2&gt;
  
  
  UPDATE
&lt;/h2&gt;

&lt;p&gt;Looks like the &lt;code&gt;function&lt;/code&gt; keyword is optional&lt;/p&gt;

&lt;p&gt;this code is actually valid in both zsh and bash&lt;/p&gt;

&lt;p&gt;sayCiaone() {&lt;br&gt;
    echo "ciaone from a shell function"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;thanks to &lt;a class="comment-mentioned-user" href="https://dev.to/moopet"&gt;@moopet&lt;/a&gt;
 &lt;/p&gt;

</description>
      <category>terminal</category>
      <category>tips</category>
    </item>
  </channel>
</rss>
