<?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: Roberto Dip</title>
    <description>The latest articles on DEV Community by Roberto Dip (@roperzh).</description>
    <link>https://dev.to/roperzh</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%2F1369%2F8c8052ce-404e-4dac-876c-800fce72de2b.jpeg</url>
      <title>DEV Community: Roberto Dip</title>
      <link>https://dev.to/roperzh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/roperzh"/>
    <language>en</language>
    <item>
      <title>Weekly Command: comparing files line by line with diff</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Tue, 29 May 2018 18:33:26 +0000</pubDate>
      <link>https://dev.to/roperzh/weekly-command-comparing-files-line-by-line-with-diff-2081</link>
      <guid>https://dev.to/roperzh/weekly-command-comparing-files-line-by-line-with-diff-2081</guid>
      <description>

&lt;h2&gt;
  
  
  The basics
&lt;/h2&gt;


&lt;pre&gt;&lt;strong&gt;diff&lt;/strong&gt; [&lt;i&gt;option&lt;/i&gt;] [&lt;i&gt;files&lt;/i&gt;]&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;diff&lt;/code&gt; outputs the differences between two files, line by line. For files that are identical it produces no output, for binary files only reports if they are different or not.&lt;/p&gt;

&lt;p&gt;The set of differences produced by &lt;code&gt;diff&lt;/code&gt; is often called a &lt;em&gt;diff&lt;/em&gt; or &lt;em&gt;patch&lt;/em&gt;, and this output can be used later on by the &lt;a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/patch.html"&gt;&lt;code&gt;patch&lt;/code&gt;&lt;/a&gt; command to change other files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Play by play
&lt;/h2&gt;

&lt;p&gt;Before digging into the examples, let's define two files that will help us to illustrate some concepts.&lt;/p&gt;

&lt;p&gt;To keep the conceptual overhead as low as possible, the files are &lt;code&gt;with-text.js&lt;/code&gt; and &lt;code&gt;without-text.js&lt;/code&gt; to represent if the &lt;code&gt;text&lt;/code&gt; variable is present or not.&lt;/p&gt;

&lt;p&gt;File &lt;code&gt;with-text.js&lt;/code&gt;:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;example&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"===="&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;File &lt;code&gt;without-text.js&lt;/code&gt;:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;something&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"===="&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Default output
&lt;/h3&gt;

&lt;p&gt;By default, &lt;code&gt;diff&lt;/code&gt; outputs a list of all the lines that are different between the files, one after the other, alongside with useful information about what changed. A change can be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An addition, represented by the letter &lt;code&gt;a&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A deletion, represented by the letter &lt;code&gt;d&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A change, represented by the letter &lt;code&gt;c&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For every line in which &lt;code&gt;diff&lt;/code&gt; finds a change, it outputs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What type of change is (&lt;code&gt;a/c/d&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;What is the line number affected in each file&lt;/li&gt;
&lt;li&gt;The content of the lines affected&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In a more concrete example, if you run:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ diff with-text.js without-text.js

1c1
&amp;lt; function example (text) {
---
&amp;gt; function something () {
3d2
&amp;lt;   console.log(text)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You get:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;1c1&lt;/code&gt; indicating that there's a &lt;code&gt;c&lt;/code&gt;hange in line &lt;code&gt;1&lt;/code&gt; of both files.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt; function example (text) {&lt;/code&gt; indicating how the line looks in &lt;code&gt;with-text.js&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt; function something () {&lt;/code&gt; indicating how the line looks in &lt;code&gt;without-text.js&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Are you able to deduce what the rest of the lines are expressing in the output?&lt;/p&gt;

&lt;h3&gt;
  
  
  Side by side comparison
&lt;/h3&gt;

&lt;p&gt;Apart from the default output format, you can specify the &lt;code&gt;--side-by-side&lt;/code&gt; (short &lt;code&gt;-y&lt;/code&gt;) to produce a side-by-side view of what changed.&lt;/p&gt;

&lt;p&gt;This format is more visual and can be easier to understand at first sight, for example:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ diff with-text.js without-text.js --side-by-side

function example (text) {             | function something () {
  console.log("====")                     console.log("====")
  console.log(text)                   &amp;lt;
}                                       }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Working with directories
&lt;/h3&gt;

&lt;p&gt;A very powerful feature of &lt;code&gt;diff&lt;/code&gt; is the ability to work with directories. It's important to note that actual contents of directories are never compared as if they were a file, instead &lt;code&gt;diff&lt;/code&gt; uses the following rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If one file is a directory and the other is not, &lt;code&gt;diff&lt;/code&gt; compares the file in the directory whose name is that of the non-directory.&lt;/li&gt;
&lt;li&gt;If two file names are given and both are directories, &lt;code&gt;diff&lt;/code&gt; compares corresponding files in both directories, in alphabetical order.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Colorised output
&lt;/h3&gt;

&lt;p&gt;Since version 3.4 (&lt;a href="https://savannah.gnu.org/forum/forum.php?forum_id=8639"&gt;launched&lt;/a&gt; around August of 2016), &lt;code&gt;diff&lt;/code&gt; supports the &lt;code&gt;--color&lt;/code&gt; flag print colorised output in the terminal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reading standard input
&lt;/h3&gt;

&lt;p&gt;If you provide &lt;code&gt;-&lt;/code&gt; as a file name, &lt;code&gt;diff&lt;/code&gt; will use it for text read from the standard input. As a special case, &lt;code&gt;diff - -&lt;/code&gt; compares a copy of standard input to itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Omitting differences
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;diff&lt;/code&gt; also provides ways to suppress differences between files that may not be important to you, common examples of this are changes in the amount of white space between words or lines.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Flag&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;-i --ignore-case&lt;/td&gt;
&lt;td&gt;Ignore case differences in file contents.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--ignore-file-name-case&lt;/td&gt;
&lt;td&gt;Ignore case when comparing file names.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;--no-ignore-file-name-case&lt;/td&gt;
&lt;td&gt;Consider case when comparing file names.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-E --ignore-tab-expansion&lt;/td&gt;
&lt;td&gt;Ignore changes due to tab expansion.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-b --ignore-space-change&lt;/td&gt;
&lt;td&gt;Ignore changes in the amount of white space.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-w --ignore-all-space&lt;/td&gt;
&lt;td&gt;Ignore all white space.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-B --ignore-blank-lines&lt;/td&gt;
&lt;td&gt;Ignore changes whose lines are all blank.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-I RE --ignore-matching-lines=RE&lt;/td&gt;
&lt;td&gt;Ignore changes whose lines all match RE.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Using the right tool for the job
&lt;/h2&gt;

&lt;p&gt;While &lt;code&gt;diff&lt;/code&gt; awesome, it's not always the right tool for the job, here are some better fits for different scenarios:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;diff3&lt;/code&gt; command can be useful to show differences among &lt;em&gt;three&lt;/em&gt; files.&lt;/li&gt;
&lt;li&gt;For binary files, &lt;code&gt;cmp&lt;/code&gt; reports the differences between two files byte by byte, instead of line by line.&lt;/li&gt;
&lt;li&gt;If you are looking only for visual diffing without the patching, &lt;code&gt;vim -d&lt;/code&gt; and &lt;code&gt;git diff&lt;/code&gt; do a good job.&lt;/li&gt;
&lt;/ul&gt;


</description>
      <category>weeklycommand</category>
      <category>xnix</category>
    </item>
    <item>
      <title>Weekly Command: inspecting network usage with iftop</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Mon, 21 May 2018 19:42:55 +0000</pubDate>
      <link>https://dev.to/roperzh/weekly-command-inspecting-network-usage-with-iftop-3pk7</link>
      <guid>https://dev.to/roperzh/weekly-command-inspecting-network-usage-with-iftop-3pk7</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F40357344-412b927c-5d92-11e8-9ca6-8588bcdf009b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F40357344-412b927c-5d92-11e8-9ca6-8588bcdf009b.jpg" alt="iftop-overview"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you need a tool to inspect your network usage, without having to wire a proxy or install a more complex tool like Wireshark, &lt;code&gt;iftop&lt;/code&gt; may be what are you looking for.&lt;/p&gt;

&lt;h2&gt;
  
  
  The basics
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iftop | [-nNpblBP] [-i interface] [-f filter] [-F net/mask] [-G net6/mask6]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When running, &lt;code&gt;iftop&lt;/code&gt; uses the whole screen to display network usage. At the top there’s is a logarithmic scale which gives a visual indication of traffic, and at the bottom a summary with information of all packages captured.&lt;/p&gt;

&lt;p&gt;By default, the program shows for each pair of hosts, the rate at which data has been sent and received over the preceding 2, 10 and 40-second intervals. The arrows (&lt;code&gt;&amp;lt;=&lt;/code&gt; and &lt;code&gt;=&amp;gt;&lt;/code&gt;) indicates the direction of data flow. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;foo.example.com =&amp;gt; bar.example.com 1Kb 500b 100b
                 &amp;lt;= 2Mb 2Mb 2Mb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If invoked without arguments, &lt;code&gt;iftop&lt;/code&gt; displays information for the first interface it can find which looks like an external interface, most of the time you may want to provide a specific interface with the &lt;code&gt;-i&lt;/code&gt; flag.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;note: to find interfaces, you can use &lt;code&gt;ifconfig&lt;/code&gt; in *nix systems, or &lt;code&gt;networksetup -listallhardwareports&lt;/code&gt; in macOS.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The system needs special privileges to execute &lt;code&gt;iftop&lt;/code&gt;, which in most cases implies running it as a root.&lt;/p&gt;

&lt;p&gt;The program is very versatile, you can filter, sort, and even use it in text-mode if you don’t need the interactive interface.&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Screen filters
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;l&lt;/code&gt; allows you to enter a POSIX extended regular expression that will be used to filter hostnames shown in the display.&lt;/p&gt;

&lt;p&gt;It’s important to note that this happens at a much later stage than filter codes and does not affect what is actually captured, therefore, display filters DO NOT affect the totals at the bottom of the screen.&lt;/p&gt;

&lt;h3&gt;
  
  
  Filter codes
&lt;/h3&gt;

&lt;p&gt;Screen filters are good to do a quick, visual filter, but if you only need to track packets transmitted under certain conditions, you can use a filter code to select the packets to count.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;iftop&lt;/code&gt; uses &lt;a href="http://www.manpagez.com/man/7/pcap-filter/" rel="noopener noreferrer"&gt;pcap formatted filters&lt;/a&gt; as input, and you can provide them with the &lt;code&gt;-f&lt;/code&gt; flag, or in the app by pressing &lt;code&gt;f&lt;/code&gt;. As a general rule, I will always recommend using the flag to prevent unexpected behavior.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;note: because only IP packets are ever counted, the specified code is evaluated as “(filter code) &lt;strong&gt;and ip&lt;/strong&gt; ”.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Sorting
&lt;/h3&gt;

&lt;p&gt;You can also use a set of pre-defined sort methods to order the data presented in the view by pressing one of these keys:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;1/2/3&lt;/code&gt; - sort by 1st/2nd/3rd column (2, 10 and 40-second intervals)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;&lt;/code&gt; - sort by source name&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;&lt;/code&gt; - sort by dest name&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;o&lt;/code&gt; - freeze current order&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Text mode
&lt;/h3&gt;

&lt;p&gt;You can enable text-mode with the &lt;code&gt;-t&lt;/code&gt; flag, in text-mode the output is printed to STDOUT in intervals.&lt;/p&gt;

</description>
      <category>weeklycommand</category>
      <category>xnix</category>
    </item>
    <item>
      <title>Weekly Command: managing processes with htop</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Thu, 10 May 2018 13:08:43 +0000</pubDate>
      <link>https://dev.to/roperzh/weekly-command-managing-processes-with-htop-bm5</link>
      <guid>https://dev.to/roperzh/weekly-command-managing-processes-with-htop-bm5</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F40049134-474ba27e-580a-11e8-9068-bc5951933f9e.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F40049134-474ba27e-580a-11e8-9068-bc5951933f9e.jpg" alt="overview"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The basics
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;htop [-dChustv]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;htop&lt;/code&gt; is an interactive command-line process manager that allows you to visualize, sort and manage processes running in your system.&lt;/p&gt;

&lt;p&gt;As with many other great command-line utilities, &lt;code&gt;htop&lt;/code&gt; is built with &lt;code&gt;ncurses&lt;/code&gt;, so the interface may look familiar to you.&lt;/p&gt;

&lt;p&gt;You can run the command without any flags and start interacting with your running processes immediately.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;fun fact: the community has a &lt;a href="https://hisham.hm/htop/index.php?page=sightings" rel="noopener noreferrer"&gt;list of TV shows and films&lt;/a&gt; where &lt;code&gt;htop&lt;/code&gt; has appeared.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;htop&lt;/code&gt; is very well designed, and your great ally is the help bar at the bottom, which makes the program very intuitive to use, nonetheless here are some examples.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sending different signals
&lt;/h3&gt;

&lt;p&gt;While the bottom-bar menu presents an option to kill the selected process with &lt;code&gt;F9&lt;/code&gt;, you can send any signal to them by pressing the &lt;code&gt;k&lt;/code&gt; key and selecting the desired signal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tagging multiple processes
&lt;/h3&gt;

&lt;p&gt;Multiple processes can be marked and then signaled at the same time by using the tagging functionality. You can tag a process with the spacebar &lt;code&gt;␣&lt;/code&gt; or a process with all its children with &lt;code&gt;c&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To untag all processes at once you can use &lt;code&gt;U&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Searching and filtering
&lt;/h3&gt;

&lt;p&gt;You can search and filter processes incrementally by name by using &lt;code&gt;F3&lt;/code&gt; or &lt;code&gt;/&lt;/code&gt; to search and &lt;code&gt;F4&lt;/code&gt; or &lt;code&gt;\&lt;/code&gt; to filter.&lt;/p&gt;

&lt;h3&gt;
  
  
  Leveraging arguments
&lt;/h3&gt;

&lt;p&gt;Besides all the goodness of the user interface, you can also manage some of the features of &lt;code&gt;htop&lt;/code&gt; when launching it via custom flags, here are some of my favorites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--no-color&lt;/code&gt; starts the program in monochrome mode, personally, I find it very pleasant to use.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--pid=PID1,PID2...&lt;/code&gt; only shows the given comma-separated list of PIDs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--tree&lt;/code&gt; shows the processes in the tree view.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Configuring
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F40049133-471ec18c-580a-11e8-94ba-04ec5cf3370a.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F40049133-471ec18c-580a-11e8-94ba-04ec5cf3370a.jpg" alt="config"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;htop&lt;/code&gt; provides a nice interface to configure the UI: from the meters at the top to the number of columns displayed for every process, almost everything can be changed. This interface lives in the setup menu, which can be opened with &lt;code&gt;F2&lt;/code&gt;, once there you will be presented with several menus to configure.&lt;/p&gt;

&lt;p&gt;Your configurations are stored in &lt;code&gt;~/.config/htop/htoprc&lt;/code&gt; by default, and this file is automatically managed by &lt;code&gt;htop&lt;/code&gt; so you shouldn’t have to manually change it. The path to the config file can be set with the &lt;code&gt;$HTOPRC&lt;/code&gt; environment variable, allowing you to have different config files for different scenarios.&lt;/p&gt;

</description>
      <category>weeklycommand</category>
      <category>xnix</category>
      <category>monades</category>
    </item>
    <item>
      <title>Getting better at team communication</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Mon, 30 Apr 2018 16:51:10 +0000</pubDate>
      <link>https://dev.to/roperzh/getting-better-at-team-communication-aig</link>
      <guid>https://dev.to/roperzh/getting-better-at-team-communication-aig</guid>
      <description>&lt;p&gt;Communication is frequently mentioned as one of the fundamental skills of a good software developer, but finding simple and actionable ways to get better it’s hard.&lt;/p&gt;

&lt;p&gt;A couple of months ago I came into the realization that I needed to improve my communication skills, which was exacerbated by the fact that I work in a remote team. This is my intent to write down what gave me good results over the last six months; the conclusions I came after making an active effort to change my communication habits. Please take them with a grain of salt, this a work in progress and nothing is backed with more data than my own—probably very biased—experience.&lt;/p&gt;

&lt;p&gt;For the sake of organizing things, I’ve grouped the bullets into three categories: the other, the group and the self.&lt;/p&gt;

&lt;h2&gt;
  
  
  The other
&lt;/h2&gt;

&lt;p&gt;The other alludes to 1:1 communication with other teammates, it’s partially different from group communications because the dynamics and the constraints are different, but almost everything in this section can be extrapolated to the group section.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It may sound cliché, but communication is a two-way street, don’t expect others to hear you if you don’t pay attention them.&lt;/li&gt;
&lt;li&gt;Always make sure you understand 100% of what the other is trying to manifest, and ask until it’s cristal clear to you. Making “progress” based on wrong assumptions wastes way more time and adds frustration to both parts.&lt;/li&gt;
&lt;li&gt;Try to find the balance between not asking questions and asking too much. It’s easier said than done, but at the end of the day is a muscle that has to be exercised.&lt;/li&gt;
&lt;li&gt;If you are having a 1:1 conversation with somebody that needs your help, try to stay in the convo until the issue is sorted, async communication is great, but if you can unblock your teammate by giving exclusive attention to the chat for 10 minutes it’s worth it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The group
&lt;/h2&gt;

&lt;p&gt;The group alludes to 1:many communication, this includes chat groups, mails with several recipients, pull requests, issue trackers, etc.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you are using pull requests or a similar way to deal with team collaboration, treat them as documentation, put as much info as you can so other members in the team can read and understand what is going on.&lt;/li&gt;
&lt;li&gt;If you are not posting in groups of people because you don’t want to disturb the whole team, think about that twice: you don’t need to mention &lt;code&gt;@everyone&lt;/code&gt; every time you post, if you are working on something and you think that could be beneficial for other people of the team to know about that go ahead and post.&lt;/li&gt;
&lt;li&gt;If you find anything interesting, whether is a tool or something related to the product that you are building, don’t keep it for yourself.&lt;/li&gt;
&lt;li&gt;Tools don’t matter that much: don’t be attached to them, communication is always possible when goodwill is present.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The self
&lt;/h2&gt;

&lt;p&gt;While the previous two sections are clearly self-actionable, I think there’s room for a third group: the self, here are some points that make your personal communication skills that are worth paying attention:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Commit yourself to make an active effort to communicate better, communicating is hard.&lt;/li&gt;
&lt;li&gt;Take the time to re-read a long message before sending it, sometimes a brain dump is not clear for people that are not in your head!&lt;/li&gt;
&lt;li&gt;Try to be clean in regards to formatting, it helps to process the information.&lt;/li&gt;
&lt;li&gt;Find ways to express yourself and your work better, an image, a GIF or a video can show in a few seconds what could take a lot of text.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final words
&lt;/h2&gt;

&lt;p&gt;Communication is a complex and difficult topic, I plan to expand and revisit this list as the time goes on. If you have any tips or resources, &lt;em&gt;please&lt;/em&gt; ping me at &lt;a href="https://twitter.com/roperzh"&gt;@roperzh&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>general</category>
      <category>remote</category>
      <category>communication</category>
    </item>
    <item>
      <title>Weekly Command: Fuzzy finding everything with fzf</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Thu, 26 Apr 2018 14:08:35 +0000</pubDate>
      <link>https://dev.to/roperzh/weekly-command-fuzzy-finding-everything-with-fzf-3i0k</link>
      <guid>https://dev.to/roperzh/weekly-command-fuzzy-finding-everything-with-fzf-3i0k</guid>
      <description>&lt;h2&gt;
  
  
  The Basics
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fzf [--options]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;fzf&lt;/code&gt; is an interactive fuzzy finder, it reads a list of items from STDIN, and writes the selected item to STDOUT.&lt;/p&gt;

&lt;p&gt;If no input is provided via STDIN, &lt;code&gt;fzf&lt;/code&gt; by default will use the &lt;a href="http://man7.org/linux/man-pages/man1/find.1.html" rel="noopener noreferrer"&gt;&lt;code&gt;find&lt;/code&gt;&lt;/a&gt; command to fetch the list of files excluding hidden ones.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fzf&lt;/code&gt; fits very well into to the *nix philosophy, which gives it a lot of flexibility, including a lot of built-in goodness for bash and zsh shells (head to the [examples][#examples] for more).&lt;/p&gt;

&lt;p&gt;The program is portable, has no dependencies and can be installed easily following the &lt;a href="https://github.com/junegunn/fzf#installation" rel="noopener noreferrer"&gt;instructions in the README&lt;/a&gt; of the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;p&gt;Without further introduction, here are some examples of &lt;code&gt;fzf&lt;/code&gt; in action.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bare
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F39314537-d868a596-494a-11e8-9adf-aa6043912510.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F39314537-d868a596-494a-11e8-9adf-aa6043912510.jpg" alt="fzf-bare"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As stated earlier, &lt;code&gt;fzf&lt;/code&gt; can be invoked on its own, and it will provide fuzzy completion for the items found in the current directory and subdirectories.&lt;/p&gt;

&lt;h3&gt;
  
  
  Previewing
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F39314540-d8d3e73e-494a-11e8-937e-85e8396b95f8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F39314540-d8d3e73e-494a-11e8-937e-85e8396b95f8.jpg" alt="fzf-preview"&gt;&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;$ fzf --preview="head -$LINES {}"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In addition, you can provide a &lt;code&gt;--preview&lt;/code&gt; flag with a command to execute when a file is selected. The command string accepts placeholders to be replaced by &lt;code&gt;fzf&lt;/code&gt; during file selection:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;{}&lt;/code&gt; single-quoted string of the current line.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;{+}&lt;/code&gt; space-separated list of the selected lines (or the current line if no selection was made) individually quoted.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;{q}&lt;/code&gt; current query string.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Fuzzy completion for commands
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F39314536-d83dd348-494a-11e8-8b7c-0e4af0186114.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F39314536-d83dd348-494a-11e8-8b7c-0e4af0186114.jpg" alt="fzf-asterisk"&gt;&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;# Files under current directory
$ cat **&amp;lt;TAB&amp;gt;
# Processes
$ kill -9 &amp;lt;TAB&amp;gt;
# Host names
$ ssh **&amp;lt;TAB&amp;gt;
# Environment variables / Aliases
$ export **&amp;lt;TAB&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A great feature which comes bundled-in for bash and zsh is fuzzy completion for different commands, in most cases just typing &lt;code&gt;**&lt;/code&gt; and pressing &lt;code&gt;↹&lt;/code&gt; (TAB) will give you the fuzzy completion interface to feed the command with the selected items.&lt;/p&gt;

&lt;p&gt;On bash, fuzzy completion is enabled only for a predefined set of commands via the &lt;a href="https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html#Programmable-Completion-Builtins" rel="noopener noreferrer"&gt;&lt;code&gt;complete&lt;/code&gt;&lt;/a&gt; built in, but you can enable it for other commands with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;complete -F _fzf_path_completion -o default -o bashdefault &amp;lt;COMMAND_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Searching history
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F39314538-d898951c-494a-11e8-8032-22a84a449106.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F39314538-d898951c-494a-11e8-8032-22a84a449106.jpg" alt="fzf-history"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also by default in bash and zsh, there’s built-in support for the reverse incremental history search.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further configuration
&lt;/h2&gt;

&lt;p&gt;You can provide additional configuration options via environment variables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;FZF_COMPLETION_TRIGGER&lt;/code&gt; helps you to define a custom trigger sequence instead of the default &lt;code&gt;**&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FZF_COMPLETION_OPTS&lt;/code&gt; allows you to define and provide custom default flags&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FZF_DEFAULT_COMMAND&lt;/code&gt; default command to use when the input is tty&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/junegunn/fzf" rel="noopener noreferrer"&gt;&lt;code&gt;fzf&lt;/code&gt; repo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/junegunn/fzf.vim" rel="noopener noreferrer"&gt;vim plugin&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>weeklycommand</category>
      <category>xnix</category>
    </item>
    <item>
      <title>Weekly Command: going over Git history with tig</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Thu, 19 Apr 2018 02:41:39 +0000</pubDate>
      <link>https://dev.to/roperzh/weekly-command-going-over-git-history-with-tig-4ajp</link>
      <guid>https://dev.to/roperzh/weekly-command-going-over-git-history-with-tig-4ajp</guid>
      <description>&lt;p&gt;There are many UI utilities that allow you to explore a Git repository, but for me, nothing beats &lt;code&gt;tig&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F38970312-139b8b28-436b-11e8-82d7-019f5397e7c8.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F38970312-139b8b28-436b-11e8-82d7-019f5397e7c8.gif" alt="A GIF showing examples of the usage of the tig command"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Basics
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tig [view] [-options] [revs]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;tig&lt;/code&gt; is a text-based user interface for Git that can be used directly from your terminal to explore the repository in the current working directory. It can be invoked directly or by piping Git output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Views
&lt;/h3&gt;

&lt;p&gt;The program exposes different &lt;em&gt;views&lt;/em&gt;, each view displays different data from the repository. You can tell &lt;code&gt;tig&lt;/code&gt; to use a view with the optional &lt;em&gt;view&lt;/em&gt; argument or you can switch views once &lt;code&gt;tig&lt;/code&gt; is open with the default keybindings:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;View&lt;/th&gt;
&lt;th&gt;Argument&lt;/th&gt;
&lt;th&gt;Keybinding&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;main view&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;m&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;diff view&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;td&gt;d&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;log view&lt;/td&gt;
&lt;td&gt;log&lt;/td&gt;
&lt;td&gt;l&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;show view&lt;/td&gt;
&lt;td&gt;show&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;blame view&lt;/td&gt;
&lt;td&gt;blame **&lt;/td&gt;
&lt;td&gt;b *&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;grep view&lt;/td&gt;
&lt;td&gt;grep **&lt;/td&gt;
&lt;td&gt;g&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;refs view&lt;/td&gt;
&lt;td&gt;refs&lt;/td&gt;
&lt;td&gt;r&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;status view&lt;/td&gt;
&lt;td&gt;status&lt;/td&gt;
&lt;td&gt;s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;help&lt;/td&gt;
&lt;td&gt;--help&lt;/td&gt;
&lt;td&gt;h&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;small&gt;&lt;br&gt;
  &lt;/small&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need to have a file selected in the UI 
** You neeed to supply an argument

&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are familiar with Git commands, view names are almost self-explanatory, I strongly encourage you to download &lt;code&gt;tig&lt;/code&gt; and try the different views by yourself, they are very intuitive to navigate.&lt;/p&gt;
&lt;h3&gt;
  
  
  Pager mode
&lt;/h3&gt;

&lt;p&gt;You can also pipe regular Git commands via stdin to &lt;code&gt;tig&lt;/code&gt;, for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git show | tig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F39009773-f496ca08-43e2-11e8-9c42-adc35b57b4b1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F39009773-f496ca08-43e2-11e8-9c42-adc35b57b4b1.jpg" alt="output of the git show command piped into tig"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://jonas.github.io/tig/doc/manual.html" rel="noopener noreferrer"&gt;tig manual&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/jonas/tig" rel="noopener noreferrer"&gt;tig repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>unix</category>
      <category>git</category>
    </item>
    <item>
      <title>SCUMM internals and syntax for the sake of nostalgia</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Tue, 17 Apr 2018 17:20:20 +0000</pubDate>
      <link>https://dev.to/roperzh/scumm-internals-and-syntax-for-the-sake-of-nostalgia-384j</link>
      <guid>https://dev.to/roperzh/scumm-internals-and-syntax-for-the-sake-of-nostalgia-384j</guid>
      <description>&lt;p&gt;I spent an unbelievable amount of time playing games from the LucasArts franchise circa 1999 in an &lt;a href="https://en.wikipedia.org/wiki/Intel_80486" rel="noopener noreferrer"&gt;Intel 486&lt;/a&gt;. It was already an old computer at the time, but it was more than enough to play games like Maniac Mansion and Monkey Island.&lt;/p&gt;

&lt;p&gt;As I grew up and learned more about computers, I found that “SCUMM” wasn’t just the name of a bar in Monkey Island, it was the platform on which all my favorite childhood games were programmed on.&lt;/p&gt;

&lt;p&gt;This post explores the SCUMM scripting language based on a list of sources, from talks to interviews and various posts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Brief History
&lt;/h2&gt;

&lt;p&gt;SCUMM stands for “Script Creation Utility for Maniac Mansion”, and as the name implies, it was created as to serve as a toolset to develop Maniac Mansion.&lt;/p&gt;

&lt;p&gt;The game had to work in a &lt;a href="https://en.wikipedia.org/wiki/Commodore_64" rel="noopener noreferrer"&gt;Commodore 64&lt;/a&gt;, so as it was done with other games at the time, the game was developed at first in Assembly, but in order to deal with the complexity of the game (it had seven different characters and a huge amount of combinations), Ron Gilbert decided to create a higher level syntax.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I started kind of hand-coding it all in assembly language, […] and it was just obvious this was going to be a very difficult task without some kind of a language to be able to abstract the gameplay.&lt;/p&gt;

&lt;p&gt;— &lt;em&gt;Ron Gilbert, &lt;a href="http://www.ign.com/articles/2007/04/26/interview-scumm-of-the-earth" rel="noopener noreferrer"&gt;interview for IGN&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once Maniac Mansion was finished, they realized that SCUMM could be used as a general purpose tool to create adventure games.&lt;/p&gt;

&lt;p&gt;It’s worth noting that SCUMM wasn’t only a scripting language, it also included other utilities named after body fluids like SPIT (a font editor) and FLEM (a graphical interface.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Concepts and Syntax
&lt;/h2&gt;

&lt;p&gt;The syntax of SCUMM scripts is really high level and strongly related to the characteristic graphics interface of the adventure games that were built with it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F38932439-8d028ea0-42ec-11e8-9512-b8736cafa401.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F38932439-8d028ea0-42ec-11e8-9512-b8736cafa401.jpg" alt="Screenshot of a scene of Maniac Mansion gameplay."&gt;&lt;/a&gt;&lt;br&gt;
    &lt;br&gt;
      Screenshot of a scene of Maniac Mansion gameplay portraying a typical SCUMM interface: a character, objects to interact with and actions.&lt;br&gt;
    &lt;br&gt;
  &lt;/p&gt;

&lt;p&gt;If you haven’t played any of the old school LucasArts adventure games (and I really encourage you &lt;a href="https://en.wikipedia.org/wiki/Commodore_64" rel="noopener noreferrer"&gt;to do it&lt;/a&gt;), they consist of a story/puzzle that you must solve: you are in control of a character, which is able to interact with objects via a set of predefined actions placed at the bottom of the screen.&lt;/p&gt;

&lt;p&gt;The scripting language itself is a very well done abstraction: it has almost a 1:1 mapping regarding what you see in the screen to what you code, and is based upon simple concepts/keywords like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;room&lt;/code&gt;: each screen that the user sees is a &lt;code&gt;room&lt;/code&gt;, which is no more than a group of &lt;code&gt;object&lt;/code&gt; definitions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;actor&lt;/code&gt;: the characters in the game, actors can wear &lt;code&gt;costumes&lt;/code&gt; and interact with &lt;code&gt;object&lt;/code&gt;s.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;object&lt;/code&gt;: elements in the &lt;code&gt;room&lt;/code&gt;, objects can have &lt;code&gt;verbs&lt;/code&gt;, which are related to actions you can apply to them.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;costumes&lt;/code&gt;: definitions of a player costume.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sounds&lt;/code&gt;: definitions of sounds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Doing a more detailed summary of the syntax would be pointless, but if you are interested, the &lt;a href="https://web.archive.org/web/20160721004826/http://www.wilmunder.com/Arics_World/Games_files/SCUMM%20Tutorial%200.1.pdf" rel="noopener noreferrer"&gt;SCUMM Tutorial&lt;/a&gt; is an in-depth resource. You can even write your own games using compilers like &lt;a href="https://github.com/AlbanBedel/scummc" rel="noopener noreferrer"&gt;SCUMMC&lt;/a&gt; and &lt;a href="https://github.com/Liquidream/scumm-8" rel="noopener noreferrer"&gt;SCUMM-8&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To give you a taste of what a bit of code may look like, let’s try to code the scene in the image above (Dave in the doorstep)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;room "doorstep" doorstep {
  sounds {
    "SFX/doorclos" door-close
    "SFX/dooropen" door-open
  }

  costumes {
    "costumes\dave" dave-skin
  }

  enter {
    ; Code to set up the room lives here,
    ; you can trigger sounds, animations, etc.
  }

  exit {
    ; Things to do when exiting the room,
    ; cleaning states, stopping sounds, etc
  }

  object Key {
    name is "key"

    verb look-at {
      say-line "it is a key"
    }

    verb pick-up {
      pick-up-object key
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Multitasking
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Probably the most distinctive part of SCUMM was that it was multi-tasking. This meant that multiple scripts could effectively run simultaneously. You might create a clock on the wall in Zak McKracken’s office and have it animate. There would be a single, very simple script just for the clock that would tell the animation engine to change from one image of the clock to the next, tell the sound engine to play the “tick” sound, and then tell the script to “sleep-for 1 second” and then repeat.&lt;/p&gt;

&lt;p&gt;— &lt;em&gt;Aric Wilmunder, &lt;a href="https://www.gamasutra.com/view/feature/196009/the_scumm_diary_stories_behind_.php?print=1" rel="noopener noreferrer"&gt;Gamasutra interview&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Another of the outstanding points of SCUMM is how easy it made for the developer to add cooperative multitasking into the system. You could trigger a task with the &lt;code&gt;do&lt;/code&gt; keyword and the task will keep running &lt;em&gt;once per frame&lt;/em&gt; until it hits a &lt;code&gt;break-here&lt;/code&gt;, then it runs the next task.&lt;/p&gt;

&lt;p&gt;For example, in the next image, we can think that every ghost pirate and the shadow moving in the background is a separate script running on its own:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F38961725-39f60436-4340-11e8-856f-0c0f0f0e91bc.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F38961725-39f60436-4340-11e8-856f-0c0f0f0e91bc.gif" alt="5ad7c8f06a421525259541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s a script transcripted from &lt;a href="https://www.youtube.com/watch?v=wNpjGvJwyL8" rel="noopener noreferrer"&gt;Gilbert’s talk&lt;/a&gt; which details how you would make a clock tick:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;script clock-tick {
  do {
    clock-state = not clock-state
    object living-room-clock state clock-state
    play-sound clock-tick
    break-here 60
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Other interesting bits
&lt;/h2&gt;

&lt;p&gt;To wrap up, here are some bits that may be interesting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The SCUMM compiler was written in Yacc and Lex.&lt;/li&gt;
&lt;li&gt;SCUMM requires carriage returns at the end of lines but how things are tabbed does not matter. It is not possible to put open brace, an instruction and a closing brace on the same line.&lt;/li&gt;
&lt;li&gt;The SCUMM system has global and local variables. A global variable can be used throughout the game. A local variable is specific to a script.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://web.archive.org/web/20160721004826/http://www.wilmunder.com/Arics_World/Games_files/SCUMM%20Tutorial%200.1.pdf" rel="noopener noreferrer"&gt;SCUMM tutorial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ign.com/articles/2007/04/26/interview-scumm-of-the-earth" rel="noopener noreferrer"&gt;Interview: SCUMM of the Earth&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.thimbleweedpark.com/scripting_test" rel="noopener noreferrer"&gt;Scripting Test&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.filfre.net/2015/07/a-new-force-in-games-part-3-scumm/" rel="noopener noreferrer"&gt;A New Force in Games, Part 3: SCUMM&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gamasutra.com/view/feature/196009/the_scumm_diary_stories_behind_.php?print=1" rel="noopener noreferrer"&gt;The SCUMM Diary&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/1SLVyjUCOIo" rel="noopener noreferrer"&gt;David Fox Talk&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.pagetable.com/?p=614" rel="noopener noreferrer"&gt;Ron Gilbert comment on SCUMM&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=wNpjGvJwyL8" rel="noopener noreferrer"&gt;Ron Gilbert - Maniac Mansion postmortem talk&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gamedev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Weekly Command: jumping directories with z</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Thu, 12 Apr 2018 21:58:14 +0000</pubDate>
      <link>https://dev.to/roperzh/weekly-command-jumping-directories-with-z-j0d</link>
      <guid>https://dev.to/roperzh/weekly-command-jumping-directories-with-z-j0d</guid>
      <description>&lt;p&gt;This week we are going to review one of my favorite and most used commands. If you move around the command line, you may have experienced the pain of recalling directory structures and typing them over and over to access directories that are distant from each other.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;z&lt;/code&gt; is specifically designed to fix this pain by allowing you to &lt;em&gt;jump&lt;/em&gt; trough directories.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;h/t to &lt;a href="https://twitter.com/luislavena/" rel="noopener noreferrer"&gt;@luislavena&lt;/a&gt; for sharing the existence of &lt;code&gt;z&lt;/code&gt; with me.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The basics
&lt;/h2&gt;


&lt;pre&gt;&lt;strong&gt;z&lt;/strong&gt; [-chlrtx] [regex1 regex2 ... regexn]&lt;/pre&gt;

&lt;p&gt;As simple as it sounds, &lt;code&gt;z&lt;/code&gt; will take you directly to a directory that matches the regexes you provide, no matter where you are.&lt;/p&gt;

&lt;p&gt;It’s worth emphasizing that the argument is a regex, which is especially useful if you are lazy: I usually type the first two or three letters of the directory that I want to access and it’s enough.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;z&lt;/code&gt; is very easy to install, if you are anxious to try it by yourself head to the &lt;a href="https://github.com/rupa/z" rel="noopener noreferrer"&gt;install instructions in the README&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;An important gotcha: &lt;code&gt;z&lt;/code&gt; is only able to take you to directories that you already visited before: it needs a learning phase because of how it works.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;z&lt;/code&gt; does its magic by storing the directories you visit in a flat file database and matching your query against this list. This file is located by default in &lt;code&gt;$HOME/.z&lt;/code&gt;, but the directory can be changed via the &lt;code&gt;$_Z_DATA&lt;/code&gt; variable.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;z&lt;/code&gt; works so well because this list of directories is ordered based on what the author refers as “frecency” (a term apparently coined by Firefox developers, if you have more info please let me know!) which combines &lt;em&gt;frequency&lt;/em&gt;: the amount of time you spend in a directory with &lt;em&gt;recentness&lt;/em&gt;: how recently you were in a directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F38288175-64e10660-37a5-11e8-83b4-665b657adfc8.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F38288175-64e10660-37a5-11e8-83b4-665b657adfc8.gif" alt="A bash session using  raw `z` endraw  on the left, the flat file database on the right, notice how it gets updated everytime a directory is visited."&gt;&lt;/a&gt;&lt;br&gt;
    &lt;br&gt;
      Session using z on the left, flat file database on the right: notice how it gets updated every time a directory is visited.&lt;br&gt;
    &lt;br&gt;
  &lt;/p&gt;

&lt;p&gt;As you keep navigating directories, the rank maintained by &lt;code&gt;z&lt;/code&gt; undergoes aging based on a simple formula:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The rank of each entry is incremented every time it is accessed. When the sum of ranks is over 9000, all ranks are multiplied by 0.99. Entries with a rank lower than 1 are forgotten.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Functionality&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;z foo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;cd to most frecent dir matching foo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;z foo bar&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;cd to most frecent dir matching foo, then bar&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;z -r foo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;cd to highest ranked dir matching foo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;z -t foo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;cd to most recently accessed dir matching foo&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;z -l foo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;list all dirs matching foo (by frecency)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/rupa/z" rel="noopener noreferrer"&gt;z Repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>xnix</category>
      <category>commandline</category>
      <category>monades</category>
    </item>
    <item>
      <title>Weekly Command: processing JSON with jq</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Thu, 29 Mar 2018 23:30:46 +0000</pubDate>
      <link>https://dev.to/roperzh/weekly-command-processing-json-with-jq-39g5</link>
      <guid>https://dev.to/roperzh/weekly-command-processing-json-with-jq-39g5</guid>
      <description>&lt;p&gt;The command of this week is &lt;code&gt;jq&lt;/code&gt;, a flexible tool to process and manipulate JSON input.&lt;/p&gt;

&lt;p&gt;Before we start, let me say that a blog post can’t do justice to &lt;code&gt;jq&lt;/code&gt; without turning into a full manual. If you are eager to learn more, head to the resources section.&lt;/p&gt;

&lt;h2&gt;
  
  
  The basics
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**jq** [_options_...] _filter_ [_files_...]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While &lt;code&gt;jq&lt;/code&gt; can take a wide variety of &lt;em&gt;options&lt;/em&gt; they mostly concern input and output formatting, the real magic happens in the &lt;code&gt;filter&lt;/code&gt; argument.&lt;/p&gt;

&lt;p&gt;The key point to understand how &lt;code&gt;jq&lt;/code&gt; works is to think about it as a processor: receives an input, processes the input based on the defined &lt;code&gt;filter&lt;/code&gt; and generates an output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;p&gt;Most of the examples below will use the &lt;code&gt;/feed&lt;/code&gt; endpoint of the &lt;a href="https://api.nasa.gov/api.html#NeoWS"&gt;NASA NeoWs API&lt;/a&gt;, which retrieves a list of &lt;a href="https://en.wikipedia.org/wiki/Asteroid"&gt;asteroids&lt;/a&gt; near Earth in a date range.&lt;/p&gt;

&lt;p&gt;For the sake of simplicity, let’s assume that in every example, the following &lt;code&gt;curl&lt;/code&gt; command is used to retrieve and pipe JSON into &lt;code&gt;jq&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl "https://api.nasa.gov/neo/rest/v1/feed?\
start_date=$(date +%Y-%m-%d)\
&amp;amp;api_key=DEMO_KEY"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The endpoint retrieves a response that roughly looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "links" : { /* pagination info here */ },
  "element_count" : 70,
  "near_earth_objects" : {
    "2018-03-30" : [/* Asteroids around this date */],
    "2018-04-01" : [/* Asteroids around this date */]
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to follow along and don’t have a terminal at hand, there’s an &lt;a href="https://jqplay.org"&gt;online playground&lt;/a&gt; that you can use.&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic filter
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ jq '.'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The basic filter produces the input unchanged. You can think of the dot as the “current context” which in this case is the whole JSON input.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;tip: since &lt;code&gt;jq&lt;/code&gt; formats its output by default, you can use this to pretty print JSON in the console.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Accessing fields
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ jq '.element_count'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fields can be accessed in the JSON data with a dot (&lt;code&gt;.&lt;/code&gt;) followed by the field name. You can think of this as accessing a property from the current context.&lt;/p&gt;

&lt;p&gt;In this case, we are retrieving the &lt;code&gt;element_count&lt;/code&gt; field to know how many asteroids around the Earth are. At the time I ran it, there were 70!&lt;/p&gt;

&lt;h3&gt;
  
  
  Collections
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ jq '.[]'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The family of &lt;code&gt;.[]&lt;/code&gt; filters is very versatile:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the input is an array, &lt;code&gt;.[]&lt;/code&gt; will iterate through the elements.&lt;/li&gt;
&lt;li&gt;If the input is an object &lt;code&gt;.[]&lt;/code&gt; will iterate through the object values.&lt;/li&gt;
&lt;li&gt;If you provide an index, &lt;code&gt;.[0]&lt;/code&gt; will access elements in arrays by their position.&lt;/li&gt;
&lt;li&gt;If you provide a string, &lt;code&gt;.["foo"]&lt;/code&gt; will access elements in objects by their keys.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Pipes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ jq '.near_earth_objects | .[] | .[].name'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Filters can be chained with pipes as you would normally do with commands in the terminal. In this example, we are looping through the fields of the &lt;code&gt;.near_earth_objects&lt;/code&gt;, which are arrays, and retrieving the names of all asteroids.&lt;/p&gt;

&lt;p&gt;Result (click to expand)&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"(2015 FN120)"
  "(1999 FP19)"
  "(2017 FW90)"
  "(2018 FH5)"
  "(2018 FM4)"
  "(2018 FF1)"
  "348306 (2005 AY28)"
  "(2008 GB110)"
  "(2012 QG42)"
  "(2016 CC194)"
  "(2017 GO4)"
  "(2018 CZ13)"
  "(2018 FV3)"
  "(2005 GR33)"
  "(2007 GS3)"
  "(2007 RX8)"
  "(2011 HN5)"
  "(2014 OE338)"
  "(2016 GA3)"
  "489486 (2007 GS3)"
  "(2018 FV1)"
  "(2018 EM4)"
  "(2007 DB61)"
  "17511 (1992 QN)"
  "(2001 OT)"
  "(2004 FG29)"
  "(2018 ER1)"
  "(2004 FG1)"
  "(2008 GH110)"
  "(2015 XE261)"
  "474574 (2004 FG1)"
  "(2017 RO17)"
  "498548 (2008 GH110)"
  "(2018 FW4)"
  "(2011 EC7)"
  "85953 (1999 FK21)"
  "204232 (2004 DG2)"
  "225586 (2000 WS67)"
  "(2009 FF)"
  "(2015 TC25)"
  "(2017 GX6)"
  "(2017 UD1)"
  "(2018 FW2)"
  "(2007 WB)"
  "(2008 GE)"
  "(2011 HJ)"
  "(2013 HM11)"
  "(2016 AG9)"
  "(2015 XT168)"
  "(2008 VR4)"
  "(2013 OW2)"
  "509520 (2007 WB)"
  "(2013 GZ7)"
  "(2011 UH20)"
  "441304 (2008 AU26)"
  "(2004 FJ29)"
  "(2015 EL7)"
  "(2016 FF1)"
  "(2016 WB10)"
  "(2018 EB)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Object and Array construction
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ jq '{count: .element_count}'
$ jq '.near_earth_objects | [.[] | .[]]'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;jq&lt;/code&gt; also provides granular control over the formatting of the output by allowing you to explicitly define how it will look like.&lt;/p&gt;

&lt;p&gt;In the first example, we are returning an object with &lt;code&gt;element_cont&lt;/code&gt; as &lt;code&gt;count&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The second example is a bit more involved, we are arranging all &lt;code&gt;near_earth_objects&lt;/code&gt; of all dates in a single array. This can be done in a nicer way with the help of operators and functions (see below).&lt;/p&gt;

&lt;p&gt;Result 1 (click to expand)&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{count: 70}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result 2 (click to expand)&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
    {/* Asteroid data */},
    {/* Asteroid data */},
    {/* Asteroid data */},
    {/* Asteroid data */},
  ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Operators and functions
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ jq '.near_earth_objects | map(.[])'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;jq&lt;/code&gt; also comes with a group of built-in operators and functions: &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, &lt;code&gt;length&lt;/code&gt;, &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;add&lt;/code&gt;, &lt;code&gt;range&lt;/code&gt;, and the &lt;a href="https://stedolan.github.io/jq/manual/#Builtinoperatorsandfunctions"&gt;list goes on&lt;/a&gt;. In this case we are revisiting our previous example to arrange all &lt;code&gt;near_earth_objects&lt;/code&gt; of all dates in a single array using &lt;code&gt;map&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Result (click to expand)&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
    {/* Asteroid data */},
    {/* Asteroid data */},
    {/* Asteroid data */},
    {/* Asteroid data */},
  ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  All together now ♫
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ jq '.near_earth_objects | map(.[] | {name, is_potentially_hazardous_asteroid})'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To wrap up, let’s build a filter to freak out our family and friends. Every asteroid has a &lt;code&gt;name&lt;/code&gt; and a param called &lt;code&gt;is_potentially_hazardous_asteroid&lt;/code&gt; which, as the name implies, is currently defined based on parameters that measure the asteroid’s potential to make threatening close approaches to the Earth (&lt;a href="https://cneos.jpl.nasa.gov/faq/"&gt;source&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Let’s retrieve a list of all asteroids names indicating if they are hazardous or not:&lt;/p&gt;

&lt;p&gt;Result (click to expand)&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
    {
      "name": "(2018 FF1)",
      "is_potentially_hazardous_asteroid": false
    },
    {
      "name": "348306 (2005 AY28)",
      "is_potentially_hazardous_asteroid": true
    },
    {
      "name": "(2008 GB110)",
      "is_potentially_hazardous_asteroid": false
    },
    {
      "name": "(2012 QG42)",
      "is_potentially_hazardous_asteroid": true
    }
  ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://stedolan.github.io/jq/manual/"&gt;jq Manual&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stedolan.github.io/jq/tutorial/"&gt;jq Tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Memories of writing a parser for man pages</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Sat, 24 Mar 2018 18:30:13 +0000</pubDate>
      <link>https://dev.to/roperzh/memories-of-writing-a-parser-for-man-pages-4jap</link>
      <guid>https://dev.to/roperzh/memories-of-writing-a-parser-for-man-pages-4jap</guid>
      <description>&lt;p&gt;I generally enjoy being bored, but sometimes enough is enough—that was the case a Sunday afternoon of 2015 when I decided to start an open source project to overcome my boredom.&lt;/p&gt;

&lt;p&gt;In my quest for ideas, I stumbled upon a request to build a &lt;a href="https://github.com/h5bp/lazyweb-requests/issues/114" rel="noopener noreferrer"&gt;“Man page viewer built with web standards”&lt;/a&gt; by &lt;a href="https://mathiasbynens.be/" rel="noopener noreferrer"&gt;Mathias Bynens&lt;/a&gt; and without thinking too much, I started coding a man page parser in JavaScript, which after a lot of back and forths, ended up being &lt;a href="https://dev.tojroff"&gt;Jroff&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Back then, I was familiar with manual pages as a concept and used them a fair amount of times, but that was all I knew, I had no idea how they were generated or if there was a standard in place. Two years later, here are some thoughts on the matter.&lt;/p&gt;

&lt;h3&gt;
  
  
  How man pages are written
&lt;/h3&gt;

&lt;p&gt;The first thing that surprised me at the time, was the notion that manpages at their core are just plain text files stored somewhere in the system (you can check this directory using the &lt;code&gt;manpath&lt;/code&gt; command).&lt;/p&gt;

&lt;p&gt;This files not only contain the documentation, but also formatting information using a typesetting system from the 1970s called &lt;code&gt;troff&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;troff, and its GNU implementation groff, are programs that process a textual description of a document to produce typeset versions suitable for printing. &lt;strong&gt;It’s more ‘What you describe is what you get’ rather than WYSIWYG.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;— &lt;em&gt;extracted from &lt;a href="https://www.troff.org/" rel="noopener noreferrer"&gt;troff.org&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you are totally unfamiliar with typesetting formats, you can think of them as Markdown on steroids, but in exchange for the flexibility you have a more complex syntax:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F37868021-2e74027c-2f7f-11e8-894b-80829ce39435.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F37868021-2e74027c-2f7f-11e8-894b-80829ce39435.gif" alt="groff-compressor"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;groff&lt;/code&gt; file can be written manually, or generated from other formats such as Markdown, Latex, HTML, and so on with many different tools.&lt;/p&gt;

&lt;p&gt;Why &lt;code&gt;groff&lt;/code&gt; and man pages are tied together has to do with history, the format has &lt;a href="https://manpages.bsd.lv/history.html" rel="noopener noreferrer"&gt;mutated along time&lt;/a&gt;, and his lineage is composed of a chain of similarly-named programs: RUNOFF &amp;gt; roff &amp;gt; nroff &amp;gt; troff &amp;gt; groff.&lt;/p&gt;

&lt;p&gt;But this doesn’t necessarily mean that &lt;code&gt;groff&lt;/code&gt; is strictly related to man pages, it’s a general-purpose format that has been used to &lt;a href="https://rkrishnan.org/posts/2016-03-07-how-is-gopl-typeset.html" rel="noopener noreferrer"&gt;write books&lt;/a&gt; and even for &lt;a href="https://en.wikipedia.org/wiki/Phototypesetting" rel="noopener noreferrer"&gt;phototypesetting&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Moreover, It’s worth noting that &lt;code&gt;groff&lt;/code&gt; can also call a postprocessor to convert its intermediate output to a final format, which is not necessarily ascii for terminal display! some of the supported formats are: TeX DVI, HTML, Canon, HP LaserJet4 compatible, PostScript, utf8 and many more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Macros
&lt;/h3&gt;

&lt;p&gt;Other of the cool features of the format is its extensibility, you can write macros that enhance the basic functionalities.&lt;/p&gt;

&lt;p&gt;With the vast history of *nix systems, there are several macro packages that group useful macros together for specific functionalities according to the output that you want to generate, examples of macro packages are &lt;code&gt;man&lt;/code&gt;, &lt;code&gt;mdoc&lt;/code&gt;, &lt;code&gt;mom&lt;/code&gt;, &lt;code&gt;ms&lt;/code&gt;, &lt;code&gt;mm&lt;/code&gt;, and the list goes on.&lt;/p&gt;

&lt;p&gt;Manual pages are conventionally written using &lt;code&gt;man&lt;/code&gt; and &lt;code&gt;mdoc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can easily distinguish native &lt;code&gt;groff&lt;/code&gt; commands from macros by the way standard &lt;code&gt;groff&lt;/code&gt; packages capitalize their macro names. For &lt;code&gt;man&lt;/code&gt;, each macro’s name is uppercased, like .PP, .TH, .SH, etc. For &lt;code&gt;mdoc&lt;/code&gt;, only the first letter is uppercased: .Pp, .Dt, .Sh.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F37866838-e602ad78-2f6e-11e8-97a9-2a4494c766ae.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F37866838-e602ad78-2f6e-11e8-97a9-2a4494c766ae.jpg" alt="groff-example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenges
&lt;/h3&gt;

&lt;p&gt;Whether you are considering to write your own &lt;code&gt;groff&lt;/code&gt; parser, or just curious, these are some of the problems that I have found more challenging.&lt;/p&gt;

&lt;h4&gt;
  
  
  Context-sensitive grammar
&lt;/h4&gt;

&lt;p&gt;Formally, &lt;code&gt;groff&lt;/code&gt; has a context-free grammar, unfortunately, since macros describe opaque bodies of tokens, the set of macros in a package may not itself implement a context-free grammar.&lt;/p&gt;

&lt;p&gt;This kept me away (for good or bad) from the parser generators that were available at the time.&lt;/p&gt;

&lt;h4&gt;
  
  
  Nested macros
&lt;/h4&gt;

&lt;p&gt;Most of the macros in &lt;code&gt;mdoc&lt;/code&gt; are callable, this roughly means that macros can be used as arguments of other macros, for example, consider this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The macro &lt;code&gt;Fl&lt;/code&gt; (Flag) adds a dash to its argument, so &lt;code&gt;Fl s&lt;/code&gt; produces &lt;code&gt;-s&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The macro &lt;code&gt;Ar&lt;/code&gt; (Argument) provides facilities to define arguments&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Op&lt;/code&gt; (Optional) macro wraps its argument in brackets, as this is the standard idiom to define something as optional.&lt;/li&gt;
&lt;li&gt;The following combination &lt;code&gt;.Op Fl s Ar file&lt;/code&gt; produces &lt;code&gt;[-s file]&lt;/code&gt; because &lt;code&gt;Op&lt;/code&gt; macros can be nested.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Lack of beginner-friendly resources
&lt;/h4&gt;

&lt;p&gt;Something that really confused me was the lack of a canonical, well defined and clear source to look at, there’s a lot of information in the web which assumes a lot about the reader that it takes time to grasp.&lt;/p&gt;

&lt;h3&gt;
  
  
  Interesting macros
&lt;/h3&gt;

&lt;p&gt;To wrap up, I will offer to you a very short list of macros that I found interesting while developing jroff:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;man&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;TH:&lt;/em&gt; when writing manual pages with &lt;code&gt;man&lt;/code&gt; macros, your first line that is not a comment must be this macro, it accepts five parameters: title section date source manual&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;BI:&lt;/em&gt; bold alternating with italics (especially useful for function specifications)&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;BR:&lt;/em&gt; bold alternating with Roman (especially useful for referring to other manual pages)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;mdoc&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;.Dd, .Dt, .Os:&lt;/em&gt; similar to how &lt;code&gt;man&lt;/code&gt; macros require the &lt;code&gt;.TH&lt;/code&gt; the &lt;code&gt;mdoc&lt;/code&gt; macros require these three macros, in that particular order. Their initials stand for: Document date, Document title and Operating system.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;.Bl, .It, .El:&lt;/em&gt; these three macros are used to create list, their names are self-explanatory: Begin list, Item and End list.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Sources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.gnu.org/software/groff/manual/html_node/History.html#History" rel="noopener noreferrer"&gt;The GNU Troff Manual: History&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://manpages.bsd.lv/history.html" rel="noopener noreferrer"&gt;History of UNIX Manpages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://2009.asiabsdcon.org/papers/abc2009-P6B-paper.pdf" rel="noopener noreferrer"&gt;Deprecating groff for BSD manual display&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>xnix</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Concurrency != Parallelism</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Wed, 31 Jan 2018 02:11:56 +0000</pubDate>
      <link>https://dev.to/roperzh/concurrency--parallelism-55h5</link>
      <guid>https://dev.to/roperzh/concurrency--parallelism-55h5</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published on &lt;a href="https://monades.roperzh.com/concurrency-is-different-than-parallelism/?cm=devto"&gt;monades.roperzh.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I truly enjoy listening to &lt;a href="https://en.wikipedia.org/wiki/Carl_Hewitt"&gt;Carl Hewitt&lt;/a&gt; talk about computers, and something he repeats often is “concurrency is not parallelism”. For me, there was no real difference, and honestly, I’ve never bothered to dig into it.&lt;/p&gt;

&lt;p&gt;Last week, I’ve stumbled upon &lt;a href="https://blog.golang.org/concurrency-is-not-parallelism"&gt;Rob Pike’s talk&lt;/a&gt; on the subject, which leads me to finally do some research on the matter. Here are my findings.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;beware: as with most things in life, a lot of people consider that there’s no real difference between the two.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Concurrency
&lt;/h2&gt;

&lt;p&gt;Concurrency is all about doing tasks in the same &lt;em&gt;interval of time&lt;/em&gt;. The important detail here is that the tasks don’t necessarily execute &lt;em&gt;at the same time&lt;/em&gt;, but they can be divided into smaller tasks that can be interleaved.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5jo_D9Hp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/4419992/35572695-ee6275c8-05b3-11e8-8460-2c1ac7081574.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5jo_D9Hp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/4419992/35572695-ee6275c8-05b3-11e8-8460-2c1ac7081574.jpg" alt="concurrency"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A good place where concurrency takes place is in the kitchen, imagine a single chef cutting lettuce while is also checking from time to time something in the oven. He has to stop cutting, check the oven, stop checking the oven and then start cutting again, and repeat the process until is done.&lt;/p&gt;

&lt;p&gt;As you can see, concurrency is mostly related to the &lt;em&gt;logistics&lt;/em&gt;, without concurrency, the chef will have to wait until the meat in the oven is ready in order to cut the lettuce.&lt;/p&gt;

&lt;h2&gt;
  
  
  Parallelism
&lt;/h2&gt;

&lt;p&gt;Parallelism, on the other hand, is about doing tasks &lt;em&gt;literally at the same time&lt;/em&gt;, as the name implies they are executed in parallel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7LZI52RC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/4419992/35572701-f14520f6-05b3-11e8-9989-f4dcc7fc987e.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7LZI52RC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/4419992/35572701-f14520f6-05b3-11e8-9989-f4dcc7fc987e.jpg" alt="parallelism-bw"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Back in the kitchen again, now we have two chefs, one can take care of the oven, while the otter cuts the lettuce, we split the work at the expence of having another chef.&lt;/p&gt;

&lt;p&gt;Parallelism is a subclass of concurrency: before you execute multiple tasks simultaneously, you first have to manage multiple tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.braveclojure.com/concurrency/"&gt;Brave Clojure&lt;/a&gt;: The Sacred Art of Concurrent and Parallel Programming&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.haskell.org/Parallelism_vs._Concurrency"&gt;Haskell Wiki&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.golang.org/concurrency-is-not-parallelism"&gt;Rob Pike’s talk&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Bonus&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have time, take a look at &lt;a href="https://en.wikipedia.org/wiki/Talk%3AParallel_programming"&gt;this humorous exchange&lt;/a&gt; between Carl Hewitt and a Wikipedia moderator about concurrency vs parallelism.&lt;/p&gt;

</description>
      <category>concurrency</category>
      <category>parallelism</category>
      <category>multithreading</category>
    </item>
    <item>
      <title>Rediscovering make: automatic variables</title>
      <dc:creator>Roberto Dip</dc:creator>
      <pubDate>Tue, 23 Jan 2018 21:32:33 +0000</pubDate>
      <link>https://dev.to/roperzh/rediscovering-make-automatic-variables-58n5</link>
      <guid>https://dev.to/roperzh/rediscovering-make-automatic-variables-58n5</guid>
      <description>&lt;p&gt;Despite its simplicity, automatic variables are very convenient when writing non-trivial makefiles. This article covers what they are and how to use them.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;note: if you need a quick refresher on rules, check out &lt;a href="https://dev.to/roperzh/rediscovering-make-the-power-behind-rules-3367-temp-slug-6534817"&gt;the previous post&lt;/a&gt; on the make series.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Automatic variables
&lt;/h2&gt;

&lt;p&gt;As &lt;a href="https://monades.roperzh.com/rediscovering-make-power-behind-rules/#patterns" rel="noopener noreferrer"&gt;patterns&lt;/a&gt; can be really useful to define targets and prerequisites, they are also dynamic: every time the recipe is run the wildcard can be matching different files, which is a problem if you need to reference them in your recipe.&lt;/p&gt;

&lt;p&gt;You can deal with this using automatic variables. As the name implies, &lt;code&gt;make&lt;/code&gt; defines a set of variables for you &lt;em&gt;every time a rule is executed&lt;/em&gt;, based on the target and the prerequisites of the rule.&lt;/p&gt;

&lt;p&gt;While automatic variables are most useful with patterns, the following examples use static file names in order to simplify the concepts, but all of what’s described above works for patterns too.&lt;/p&gt;

&lt;p&gt;Suppose you have the following rule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;targetdir/targetfile.o : pre.c predir/pre.h | order-only.c
    # recipe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the recipe is run, the following variables are automatically assigned:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variable&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;$@&lt;/td&gt;
&lt;td&gt;file name of the target&lt;/td&gt;
&lt;td&gt;targetdir/targetfile.o&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$&amp;lt;&lt;/td&gt;
&lt;td&gt;name of the first prerequisite&lt;/td&gt;
&lt;td&gt;pre.c&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$?&lt;/td&gt;
&lt;td&gt;names of all prerequisites newer than the target&lt;/td&gt;
&lt;td&gt;depends on context&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$^&lt;/td&gt;
&lt;td&gt;names of all prerequisites&lt;/td&gt;
&lt;td&gt;pre.c predir/pre.h&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;names of all the order-only prerequisites&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$*&lt;/td&gt;
&lt;td&gt;stem with which an implicit rule matches&lt;/td&gt;
&lt;td&gt;targetdir/targetfile&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$%&lt;/td&gt;
&lt;td&gt;name of the archive member (&lt;a href="https://monades.roperzh.com/rediscovering-make-power-behind-rules/#archive-files" rel="noopener noreferrer"&gt;see archives&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Modifiers
&lt;/h4&gt;

&lt;p&gt;Sometimes, you may only need only the directory or the filename of the variable, for this scenario &lt;code&gt;make&lt;/code&gt; offers two modifiers you can add to your variables:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Modifier&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;the directory part&lt;/td&gt;
&lt;td&gt;&lt;code&gt;dir&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;td&gt;the file-within-directory part&lt;/td&gt;
&lt;td&gt;&lt;code&gt;simple.c&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Modifiers are added right next to the variable and need to be wrapped in parenthesis, for example if &lt;code&gt;$@&lt;/code&gt; is &lt;code&gt;targetdir/targetfile.o&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;$(@D)&lt;/code&gt; is &lt;code&gt;targetdir&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$(@F)&lt;/code&gt; is &lt;code&gt;targetfile.o&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Helpers
&lt;/h3&gt;

&lt;p&gt;As automatic variables can be difficult to remember, here are a couple of resources to help you:&lt;/p&gt;

&lt;h4&gt;
  
  
  Phony makefile
&lt;/h4&gt;

&lt;p&gt;A good way to learn is by experimentation: create a directory, place mock files in there, and define your targets and prerequisites, then, instead of doing something useful in the recipe, just print the variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;targetdir/targetfile.o : predir/pre.h | order-only.c
  @echo '@: $@'
  @echo '%: $%'
  @echo '&amp;lt;: $&amp;lt;'
  @echo '?: $?'
  @echo '^: $^'
  @echo '|: $|'
  @echo '*: $*'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Snippets
&lt;/h4&gt;

&lt;p&gt;I published snippet packs for &lt;a href="https://github.com/roperzh/vscode-make-auto-vars" rel="noopener noreferrer"&gt;Visual Studio Code&lt;/a&gt; and &lt;a href="https://github.com/roperzh/sublime-make-auto-vars" rel="noopener noreferrer"&gt;Sublime Text&lt;/a&gt; that may come in handy: they give you a list of the available variables, followed by a short explanation of their purpouse:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F35174851-a1af3c78-fd4f-11e7-9882-ff8f02523ffe.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fuser-images.githubusercontent.com%2F4419992%2F35174851-a1af3c78-fd4f-11e7-9882-ff8f02523ffe.jpg" alt="plugin-example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;note: If you are using another editor there are tools to convert between snippets formats.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>unix</category>
      <category>tooling</category>
    </item>
  </channel>
</rss>
