<?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: Ángel Blanco</title>
    <description>The latest articles on DEV Community by Ángel Blanco (@angelbt91).</description>
    <link>https://dev.to/angelbt91</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%2F549999%2Ff40a2450-de56-4fff-bfb7-69aab727b533.png</url>
      <title>DEV Community: Ángel Blanco</title>
      <link>https://dev.to/angelbt91</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/angelbt91"/>
    <language>en</language>
    <item>
      <title>#AskDev - Using JS shorthand operators for side effects?</title>
      <dc:creator>Ángel Blanco</dc:creator>
      <pubDate>Mon, 03 Oct 2022 17:28:23 +0000</pubDate>
      <link>https://dev.to/angelbt91/askdev-using-js-shorthand-operators-for-side-effects-3h6k</link>
      <guid>https://dev.to/angelbt91/askdev-using-js-shorthand-operators-for-side-effects-3h6k</guid>
      <description>&lt;p&gt;JavaScript shorthand operators are helpful for making code more concise and readable. They let us convert code like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;dbName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;PROD&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;dbName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;users&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;dbName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;users-dev&lt;/span&gt;&lt;span class="dl"&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;p&gt;Into this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dbName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;PROD&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;users&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;users-dev&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, basically, you can use shorthand operators to evaluate an expression into a value in fewer lines of code.&lt;/p&gt;

&lt;p&gt;However, in some tutorials and blog posts scattered through the Internet, I saw shorthand operators being used to invoke functions. Not because they wanted to store the resulting value in a variable, but because they want to run the side effects contained in those functions. Something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;isUserAdmin&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;storeNewData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;sendErrorMessage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To me, this is a weird way of using shorthand operators, because, in my mind, shorthand operators are intented for resolving into a value, not for running side effects conditionally. That syntax works anyway, but somehow it feels wrong to me.&lt;/p&gt;

&lt;p&gt;And that's why I'm writing this post, to have a place where we can &lt;strong&gt;respectfully&lt;/strong&gt; share our opinion on this. What are your thoughts? Does invoking functions with side effects through shorthand operators makes sense for you? What is your advice on this topic?&lt;/p&gt;

&lt;p&gt;Thanks for reading / answering! 😁&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>javascript</category>
    </item>
    <item>
      <title>TISO #01 🤯 crontab -e != sudo crontab -e</title>
      <dc:creator>Ángel Blanco</dc:creator>
      <pubDate>Mon, 03 Oct 2022 16:40:24 +0000</pubDate>
      <link>https://dev.to/angelbt91/tiso-01-crontab-e-sudo-crontab-e-320f</link>
      <guid>https://dev.to/angelbt91/tiso-01-crontab-e-sudo-crontab-e-320f</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Welcome to &lt;strong&gt;TISO&lt;/strong&gt; (&lt;em&gt;Today I Stack-Overflow-ed&lt;/em&gt;)! This a post series where I share what I learnt after facing a weird bug on my code or an unexpected behavior on my machine, in hopes that you also learn from it. Feedback and comments are welcome!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Today I was trying to configure a Linux server to run a NodeJS service on every boot using Cron and Crontab. The shell command to edit the Crontab file where you schedule the tasks is &lt;code&gt;crontab -e&lt;/code&gt;. But then, while playing around with Crontab, I stumbled upon something unexpected:&lt;/p&gt;

&lt;p&gt;Running &lt;code&gt;crontab -e&lt;/code&gt; opens a different Crontab file than &lt;code&gt;sudo crontab -e&lt;/code&gt;! If you add some cron tasks on the first one, they won't appear in the latter, and vice versa.&lt;/p&gt;

&lt;p&gt;This is because when you run the command without &lt;code&gt;sudo&lt;/code&gt;, you will add tasks as the current logged in user. But if you add &lt;code&gt;sudo&lt;/code&gt; then you will add tasks to another Crontab that executes with root user's permissions. Quite dangerous!&lt;/p&gt;

&lt;p&gt;Did you know this already? Is there something else you want to add? Feel free to say it in the comments! ⬇&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Original source: &lt;a href="https://stackoverflow.com/questions/43237488/linux-difference-between-sudo-crontab-e-and-just-crontab-e"&gt;https://stackoverflow.com/questions/43237488/linux-difference-between-sudo-crontab-e-and-just-crontab-e&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>tiso</category>
      <category>crontab</category>
    </item>
  </channel>
</rss>
