<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Joel Jucá on Medium]]></title>
        <description><![CDATA[Stories by Joel Jucá on Medium]]></description>
        <link>https://medium.com/@joeljuca?source=rss-9775fca901de------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*s_I9hpoaYmhLifGAFZ4cgQ.jpeg</url>
            <title>Stories by Joel Jucá on Medium</title>
            <link>https://medium.com/@joeljuca?source=rss-9775fca901de------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 13:27:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@joeljuca/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Search and destroy node_modules]]></title>
            <link>https://medium.com/@joeljuca/search-and-destroy-node-modules-136ba53d28c6?source=rss-9775fca901de------2</link>
            <guid isPermaLink="false">https://medium.com/p/136ba53d28c6</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[unix]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Joel Jucá]]></dc:creator>
            <pubDate>Thu, 14 Mar 2019 20:56:45 GMT</pubDate>
            <atom:updated>2023-02-26T14:18:27.628Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Edit: recently, find seem to have got a new option to do exactly what this post is about. Now, one could seek-and-destroy node_modules folders by just:</blockquote><blockquote>find . -name node_modules -delete</blockquote><p>This article is all about a bit of command-line <em>wizardry</em>. where I show how to recursively delete non-essential node_modules directories to recover storage capacity.</p><blockquote>DISCLAIMER: the following UNIX commands are destructive and should not be executed in case you don’t fully understand the implications.</blockquote><h3>TL;DR</h3><p>Below is the most quick-and-dirty way to perform a search-and-destroy operation against node_modules directories:</p><pre>find . -type d -name node_modules -exec rm -fR {} \;</pre><h3>WTF?</h3><p>I recently noticed a huge amount of disk usage on my MacBook Pro (240GB-powered SSD). It was a surprising issue, so I decided to look for non-essential data that could be safely deleted. Well, since I’m always working on JavaScript projects (browser-related, Node.js-related, and even Electron-related ones), my projects directory is full of node_modules directories of projects I’m not working anymore (they are still in disk for future eventual tweakings). After a quick command crafting, I was able to recover some additional gigabytes of storage space.</p><p>If I need to work on a project that doesn’t have a node_modules anymore, it’ll be just a matter of running npm install again, and it will be rebuilt as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=136ba53d28c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An introduction to environment variables]]></title>
            <link>https://medium.com/@joeljuca/an-introduction-to-environment-variables-8b7f7739902a?source=rss-9775fca901de------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b7f7739902a</guid>
            <category><![CDATA[unix]]></category>
            <category><![CDATA[command-line]]></category>
            <dc:creator><![CDATA[Joel Jucá]]></dc:creator>
            <pubDate>Sun, 20 Jan 2019 17:42:15 GMT</pubDate>
            <atom:updated>2019-01-20T17:42:15.061Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I introduce you to environment variables, what they are and why they are important. In the end, you’ll be able to take advantage of environment variables for its multiple use cases — with a special attenton for injecting configuration in programs without having to touch their source code.</p><h3>What are they?</h3><p>Environment variables are a simple way to store information that can be used by programs. They are simple variables that exist in your terminal, and it’s very easy to create and use them.</p><p>Technically speaking, they are just variables in your shell, the language you use when you’re using your terminal. If you’re using Linux or macOS and didn’t change your default shell, it’s probably <a href="https://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>. So in this case, environment variables would be Bash variables.</p><h3>Why should I care about it?</h3><p>Environment variables are frequently used by programs — both command-line and graphical ones, to allow its users to configure the way it should work. Also, cloud platforms like Heroku and AWS let users inject configurations this way. A frequent use case is the injection of secrets, such as API keys and database credentials in your app, so you could avoid committing sensitive information in your codebase.</p><p>A wise developer would write programs in such way that all needed configuration would be stored in the environment where the program would run (a good practice described in the book <a href="https://12factor.net/">The Twelve-Factor App</a>), and environment variables are good for this kind of job.</p><p>In the next section, you’ll learn the very basics of environment variables: how to create one, and read their value.</p><h3>Using environment variables</h3><p>Creating an environment variable is pretty simple. In the example below, I’m creating a variable called TWITTER_USERNAME that holds the value &quot;joelwallis1&quot;, directly from the command-line:</p><pre>TWITTER_USERNAME=&quot;joelwallis1&quot;</pre><p><em>Note: there must be no spaces between the variable name (</em>TWITTER_USERNAME<em>), the equal sign (</em><em>=) character, and the variable value (</em><em>&quot;joelwallis1&quot;).</em></p><p>Then, to use its value you just need to type the variable name, prepended with the dollar-sign character ($):</p><pre>echo $TWITTER_USERNAME</pre><p>Environment variables are just normal strings, and they are subjected to <a href="https://en.wikipedia.org/wiki/String_interpolation#Bash">string interpolation</a>. It means that you can create variables with contents of other variables. You could, for instance, produce the URL for my Twitter profile using the environment variable TWITTER_USERNAME:</p><pre>TWITTER_URL=&quot;https://twitter.com/$TWITTER_USERNAME&quot;</pre><p>Just like that. No rocket science, just basic code. See how I used $TWITTER_USERNAME when declaring $TWITTER_URL. It makes the content of $TWITTER_USERNAME to be used on $TWITTER_URL.</p><p>Running echo $TWITTER_URL outputs the following content:</p><pre>https://twitter.com/joelwallis1</pre><p>Try running these commands in your terminal to see it working.</p><p>Also, you might have noticed that I used upper case characters for variable names. It’s a good practice to name environment variables with upper case characters, and there’s an interesting <a href="https://stackoverflow.com/questions/673055/correct-bash-and-shell-script-variable-capitalization">discussion on Stack Overflow</a> covering the matter.</p><p>I’ll be writing articles focusing on using environment variables on real world software projects — including techniques like .env (dot-env) files. If you have feedback I would be happy hear it. Feel free to <a href="https://twitter.com/joelwallis1">contact me on Twitter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b7f7739902a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing backward-compatible packages with modern JavaScript]]></title>
            <link>https://medium.com/@joeljuca/writing-backward-compatible-packages-with-modern-javascript-21cb272458c7?source=rss-9775fca901de------2</link>
            <guid isPermaLink="false">https://medium.com/p/21cb272458c7</guid>
            <category><![CDATA[healthz]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Joel Jucá]]></dc:creator>
            <pubDate>Thu, 26 Jul 2018 14:28:16 GMT</pubDate>
            <atom:updated>2018-07-26T14:37:15.821Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently wrote a new Node.js package to publish on npm. <a href="https://npmjs.com/express-healthz">express-healthz</a> is a very small helper middleware that responds with 200 OK on a /health endpoint. Simple like that, but I wrote it using ES2015 modules, and the Node.js ecosystem still struggles to support it. I wanted to write modern JavaScript, but this package should be compatible with as many Node.js versions as possible.</p><h3>Publishing compiled code to npm</h3><p>After one second or two of deep critical thinking about the issue, I decided that it would be written in modern JavaScript, it’s 2018 and we all deserve to maintain modern code. And after all, since it’s just a simple helper, there’s a good opportunity to test different publishing strategies. 😃</p><p>Node.js package creators/maintainers benefit from an interesting npm feature: <a href="https://docs.npmjs.com/misc/scripts">the </a><a href="https://docs.npmjs.com/misc/scripts">scripts feld</a>. Specially, the prepublishOnly, and the postpublish were useful for me since I could automate the compiling process directly in the publishing process. Here’s how I could benefit from it to automate the compilation process:</p><p>Since it allows raw Bash as an npm script, my prepublishOnly script became a for loop that runs the linter against my code, tests it, and finally compiles a CommonJS version of my package. If any of these commands fail the publication process is cancelled automatically, since npm publish does not process if prepublishOnly returns an exit code different than zero. And, since it’s in the project’s package.json file, any future maintainer would benefit from this safety check since the configuration resides in the project’s repository. The compiled file became the unique JavaScript file being published to npm (my files is set to a single entry: index.js).</p><p>I thought this setup could be interesting to other maintainers. <a href="https://github.com/joelwallis/express-healthz/blob/master/package.json">You can check the </a><a href="https://github.com/joelwallis/express-healthz/blob/master/package.json">package.json of my express-healthz package here.</a> Next time you write a Node.js package, think about keeping a modern codebase. It’s quite easy to publish a backward-compatible compiled version of your code using a compiler like Babel nowadays.</p><p>If you have interesting Node.js/npm automation setups too, I would love to know! I’m on Twitter as <a href="https://twitter.com/joelwallis1">@joelwallis1</a>, and Mastodon fediverse as <a href="https://mastodon.social/@joelwallis">joelwallis@mastodon.social</a>. Ping me, lets discuss!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21cb272458c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Backing up Atom configs, keymaps, plugins, etc., for great good!]]></title>
            <link>https://medium.com/@joeljuca/backing-up-atom-configs-keymaps-plugins-etc-for-great-good-f172023a8fce?source=rss-9775fca901de------2</link>
            <guid isPermaLink="false">https://medium.com/p/f172023a8fce</guid>
            <category><![CDATA[atom-text-editor]]></category>
            <dc:creator><![CDATA[Joel Jucá]]></dc:creator>
            <pubDate>Wed, 10 Jan 2018 23:58:40 GMT</pubDate>
            <atom:updated>2018-02-25T03:12:10.501Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UWkL4QRmHnvLiIoXPoU2qA.jpeg" /></figure><p><a href="https://atom.io/">Atom</a> is my code editor. I love it, but I hate to do configuration every time I reinstall it on a new computer — or after formatting. So, I figured out a way to avoid this boring task: I’m now storing configurations and packages into Dropbox.</p><p>It’s quite easy to do! Atom stuff is stored into <strong>~/.atom</strong>: configurations are stored in <strong>config.cson</strong>, custom keyboard shortcuts in <strong>keymap.cson</strong>, custom snippets <strong>snippets.cson</strong>, and plugins/themes in the <strong>packages</strong> folder. So, if you control these files you control pretty much everything in Atom. 🙂</p><p>You can easily do this by running the following commands:</p><pre>mkdir ~/Dropbox/.atom<br>cd ~/.atom</pre><pre>for file in config.cson keymap.cson packages snippets.cson<br>do<br>  mv -R $file ~/Dropbox/.atom<br>  ln -fs &quot;~/Dropbox/.atom/${file}&quot;<br>done</pre><p>I hope this post can save you some time in the same way it saved for me.</p><p><em>Photo by </em><a href="https://unsplash.com/photos/OqtafYT5kTw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"><em>Ilya Pavlov</em></a><em> on </em><a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"><em>Unsplash</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f172023a8fce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Meet tmux, my preferred terminal multiplexer]]></title>
            <link>https://medium.com/@joeljuca/meet-tmux-my-preferred-terminal-multiplexer-f8df72380598?source=rss-9775fca901de------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8df72380598</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[tmux]]></category>
            <dc:creator><![CDATA[Joel Jucá]]></dc:creator>
            <pubDate>Mon, 13 Nov 2017 21:25:36 GMT</pubDate>
            <atom:updated>2017-12-01T12:40:11.987Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>If terminal multiplexers are awesome, <a href="https://tmux.github.io/">tmux</a> is even more! If you’re not using a terminal multiplexer like tmux, iTerm, Terminator, etc., chances are you’ve not achieved the full productivity of command-line interfaces yet.</p><p>Resuming: it allows you to have multiple terminals into one screen (and eventually much more). Check out the screenshot below (from the <a href="https://en.wikipedia.org/wiki/Tmux">tmux page on Wikipedia</a>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*DAcDqrdYOkb1EB_m53BNQg.png" /><figcaption>A tmux session with a window containing three panes.</figcaption></figure><p>This post will introduce you to tmux, teach some tricks and suggest some usage patterns to make you even more hacker then you already are.</p><h3>OK, but why should I use a terminal multiplexer?</h3><p>When working with command line interfaces you frequently need to multitask. For example, when coding a website you need to run <a href="http://gruntjs.com/">Grunt</a> or <a href="http://gulpjs.com/">gulp</a> tasks. You can use tmux to code your JavaScript using Vim on the left pane (left side), and keep the automated tasks running in the right pane (right side). That way you save yourself from cycling programs and/or tabs with Cmd+Tab or Ctrl+Tab.</p><p>This is just an example. After you start using it you’ll find lots of new ways to tmux. ;-)</p><h3>How to install tmux</h3><p>If you use <a href="https://www.debian.org/">Debian</a>, <a href="https://www.ubuntu.com/">Ubuntu</a>, <a href="https://elementary.io/">elementary OS</a> any other Linux distribution that uses APT to manage software packages:</p><pre>sudo apt-get update<br>sudo apt-get install tmux</pre><p>Using macOS? Install it using <a href="http://brew.sh/">Homebrew</a>:</p><pre>brew install tmux</pre><p>tmux is now installed in your computer. Yay!</p><h3>tmux: the basic concepts</h3><p>To start tmux, just run:</p><pre>tmux</pre><p>This command will start a new tmux session. You should see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*W51JGAypl7AdrEHGR1PHew.png" /><figcaption>My customized iTerm running tmux — and yeah, I use iTerm AND tmux</figcaption></figure><p>After starting tmux, it will take your entire terminal screen space. At this point you already have a tmux session, one window and one pane, right in front of you. Let’s take a minute and understand what are these things:</p><ul><li><strong>Session</strong><br>It’s just a collection of pseudo terminals controlled by tmux. A tmux session have one or more windows.</li><li><strong>Windows</strong><br>They are like workspaces that occupies the entire screen (think about it like the multiple desktop functionality present in OS X and also many Linux desktop environments like GNOME and Unity). A window can have one or more panes.</li><li><strong>Panes</strong><br>It’s where you’ll run commands and work on. A pane can occupy the entire screen (since you just started tmux that’s your case) or only a portion of it, like the left or right side, etc.</li></ul><p>If you look at the tmux screenshot at the beginning of this post you’ll see an usage example of tmux with three panes: the top left one running nano, the top right one showing the tmux’s clock and the bottom one running a program to chat at some IRC channel. All these panes are in the current window (remember, a window occupy all the available screen space of your terminal), and this window is inside a tmux session.</p><p>Check this other example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*nemOtj2XuejXDQaAEa8w4w.png" /></figure><p>Here I’m using a slightly more complex setup of tmux with five panes: one at the top, listing the source code of this blog, two at the left bottom showing some infos and two at the right bottom showing the clock and htop, respectively.</p><p>As you can see, your own workflow needs and creativity will tell you how to use it. So, now let’s learn how to take control of tmux.</p><h3>Working with panes</h3><p>tmux is controlled by keyboard shortcuts. They’re combinations of a prefixed key (Ctrl+B by default) followed by a command key. So, to split the current pane vertically, you hit:</p><pre>Ctrl+B, %</pre><p>That’s it. You hit Ctrl+B and then you hit %. After entering the key combination you should see two panes: the left one and the right one.</p><p>Now, to split the current pane horizontally, hit:</p><pre>Ctrl+B, &quot;</pre><p>See? It’s easy! Now check my list of my favorite pane commands:</p><ul><li>Ctrl+B, %<br>Split the current pane vertically.</li><li>Ctrl+B, &quot;<br>Split the current pane horizontally.</li><li>Ctrl+B, &lt;Up&gt;, Ctrl+B, &lt;Down&gt;, Ctrl+B, &lt;Left&gt;, Ctrl+B, &lt;Right&gt;<br>Go to the pane on the top/bottom/left/right side of the current pane, respectively.</li><li>Ctrl+B, t<br>Show the time - a digital clock that takes the entire pane space.</li><li>Ctrl+B, z<br>Toggle the zoom of the current pane.</li><li>Ctrl+B, x<br>Destroy the current pane.</li></ul><h3>Working with windows</h3><p>tmux windows are as useful as workspaces of destop environments like OS X, GNOME, etc. To create a new window, enter:</p><pre>Ctrl+B, c</pre><p>After entering the key combination you’ll get a brand new window with one pane occuping the entire screen. You can go back to the previous window by entering:</p><pre>Ctrl+B, p</pre><p>You can also go to the next window by entering:</p><pre>Ctrl+B, n</pre><p>Below is my list of my favorite window commands:</p><ul><li>Ctrl+B, c<br>Creates a new window.</li><li>Ctrl+B, n<br>Goes to the next window.</li><li>Ctrl+B, p<br>Goes the previous window.</li><li>Ctrl+B, c<br>Creates a new window.</li><li>Ctrl+B, ,<br>Rename the current window.</li></ul><h3>Working with sessions</h3><p>If you still are inside tmux, enter the following combination key: Ctrl+B, d. This command detaches you from the current tmux session. Let’s understand a bit more about it.</p><p>tmux sessions are persistent, which means that you if you’re using tmux to work in your blog you can just detach from the tmux session, do something else and then get back to work by attaching to the tmux session again. So, to check which tmux sessions are currently being running in your computer, run:</p><pre>tmux list-sessions</pre><p>You should see something like this:</p><pre>0: 1 window (created Sun Jan  3 22:13:35 2016) [88x43] (attached)</pre><p>Each line represents a different tmux session. In this case, I have only one session with ID 0 which has only one window. If I wanted to attach to this tmux session I would run:</p><pre>tmux attach-session -t 0</pre><p>You’ve just attached back to the session you were working before. Now you know what to do when you get connection issues while connected to your server. If you were using tmux that’s not a problem anymore. \o/</p><p>Well, tmux sessions are a lot more difficult to understand than windows and panes, so I’ll limit the scope of this post to just teaching you how to attach and detach from a tmux session. If you would like to go serious on it you can just read the tmux manual by running $ man tmux.</p><h3>Additional readings</h3><ul><li><a href="https://robots.thoughtbot.com/a-tmux-crash-course">A tmux Crash Course</a>: great tmux article by Josh Clayton (thoughtbot)</li></ul><h3>Useful links</h3><ul><li><a href="http://tmux.github.io/">The tmux website</a></li><li><a href="https://groups.google.com/forum/#!forum/tmux-users">tmux on Google Groups</a></li><li><a href="https://github.com/tmux/tmux">tmux on GitHub</a></li><li><a href="https://github.com/tmux/tmux/blob/master/CHANGES">tmux’s CHANGELOG file</a></li></ul><p>Now you can start using tmux in front of your friends:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FsQH363sTod0%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DsQH363sTod0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FsQH363sTod0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca25bb2e37a3dd065b424d3c3e37180a/href">https://medium.com/media/ca25bb2e37a3dd065b424d3c3e37180a/href</a></iframe><p>This article ended up being a quite big one but I hope you’ve enjoyed learning tmux. Feel free to <a href="https://twitter.com/joelwallis1">reach me on Twitter</a> to chat about cool things related to command-line interfaces. ;-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8df72380598" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>