<?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: Emili Parreno</title>
    <description>The latest articles on DEV Community by Emili Parreno (@eparreno).</description>
    <link>https://dev.to/eparreno</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%2F437175%2F925da94e-ef70-4380-bf8b-faf195f52ccc.jpeg</url>
      <title>DEV Community: Emili Parreno</title>
      <link>https://dev.to/eparreno</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/eparreno"/>
    <language>en</language>
    <item>
      <title>Smoother Fonts for Alacritty on macOS</title>
      <dc:creator>Emili Parreno</dc:creator>
      <pubDate>Sat, 23 Nov 2024 21:51:26 +0000</pubDate>
      <link>https://dev.to/eparreno/smoother-fonts-for-alacritty-on-macos-3b4f</link>
      <guid>https://dev.to/eparreno/smoother-fonts-for-alacritty-on-macos-3b4f</guid>
      <description>&lt;p&gt;The font rendering in Alacritty is not as smooth as it is in iTerm. If your OCD is getting the best of you, just run this command to get smooth fonts in Alacritty.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;defaults write org.alacritty AppleFontSmoothing -int 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Voilà!&lt;/p&gt;

&lt;p&gt;You can revert this change just deleting the default.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;defaults delete org.alacritty AppleFontSmoothing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>A curated list of shell commands and tools specific to macOS</title>
      <dc:creator>Emili Parreno</dc:creator>
      <pubDate>Tue, 08 Mar 2022 12:42:23 +0000</pubDate>
      <link>https://dev.to/eparreno/a-curated-list-of-shell-commands-and-tools-specific-to-macos-349g</link>
      <guid>https://dev.to/eparreno/a-curated-list-of-shell-commands-and-tools-specific-to-macos-349g</guid>
      <description>&lt;p&gt;&lt;a href="https://git.herrbischoff.com/awesome-macos-command-line/about/" rel="noopener noreferrer"&gt;https://git.herrbischoff.com/awesome-macos-command-line/about/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>macos</category>
    </item>
    <item>
      <title>Development in Apple M1</title>
      <dc:creator>Emili Parreno</dc:creator>
      <pubDate>Wed, 15 Dec 2021 12:03:36 +0000</pubDate>
      <link>https://dev.to/eparreno/development-in-apple-m1-4d4l</link>
      <guid>https://dev.to/eparreno/development-in-apple-m1-4d4l</guid>
      <description>&lt;p&gt;I got a new laptop one week ago and I've been investigating different ways of setting up our dev environment. Here are my findings&lt;/p&gt;

&lt;h2&gt;
  
  
  Virtual Machines
&lt;/h2&gt;

&lt;p&gt;There are different options&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Virtual Box doesn't work as of today in Apple M1&lt;/li&gt;
&lt;li&gt;Parallels, nice but you have to buy a license&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://mac.getutm.app" rel="noopener noreferrer"&gt;UTM&lt;/a&gt;, very nice UI on top of QEMU. My preferred choice&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you run ARM virtual machines, it's fast as hell, feels like a native app, probably having a M1 Max with 10 cores and 64Gb of RAM helps bit :) but I wanted to use mainly x86 VMs and they are not so fast. I'll definitely use UTM in the future for running ARM based VMs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker
&lt;/h2&gt;

&lt;p&gt;If you run everything inside Docker, it works out of the box. I didn't experience any issues.&lt;/p&gt;

&lt;h2&gt;
  
  
  Apple's Rosetta
&lt;/h2&gt;

&lt;p&gt;It turns out that the best virtualisation software comes already with you default MacOS installation and it's called Rosetta!&lt;/p&gt;

&lt;p&gt;Here's how I set up my dev laptop &lt;/p&gt;

&lt;p&gt;Duplicate your Terminal or iTerm app and give it a different name&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv7jtbbgix3s19gh75ehv.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv7jtbbgix3s19gh75ehv.png" alt="Image description" width="320" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I ended up with&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F76gkem72xxsukti1lx03.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F76gkem72xxsukti1lx03.png" alt="Image description" width="318" height="219"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the x86 terminal, get info details (CMD + i) and check "Open using Rosetta"&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrebp6gu8wvrguznjfjt.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsrebp6gu8wvrguznjfjt.png" alt="Image description" width="388" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it. Yes, really, that's all you need. Open your x86 terminal and you have an emulated x86 environment that just works.&lt;/p&gt;

&lt;p&gt;If you install Hombrew in both envs it will be installed in different folders, the traditional &lt;code&gt;/usr/local/Cellar&lt;/code&gt; for Intel based and the new one &lt;code&gt;opt/hombrew/Cellar&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I have a check in my &lt;code&gt;.zshrc&lt;/code&gt; to load paths based on the arch. With that approach you need to be mindful about the arch you are running and loading the proper paths or executing the right code after login.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if [ $(arch) = 'arm64' ]; then
  ...
else
  ...
fi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also added &lt;code&gt;$(arch)&lt;/code&gt; to my prompt to know in which environment I am&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20taxcgaexwavzu4koay.png" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20taxcgaexwavzu4koay.png" alt="Image description" width="289" height="81"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Caveats
&lt;/h2&gt;

&lt;p&gt;If you install the same app or library in both environments they may clash. Let's say you install MySQL in both ARM and x86 using Homebrew and you want to link the binary, you should choose on what env you do it. Just be careful about that.&lt;br&gt;
For me hasn't been a problem because I mainly use x86 so I didn't install anything in the ARM env. Just avoid installing the same stuff in both envs.&lt;br&gt;
If you really need to use both arches, an alternative could be using Rosetta to emulate x86 and UTM to run ARM based VMs so you don't risk messing with duplicated libraries or apps.&lt;/p&gt;

</description>
      <category>apple</category>
      <category>m1</category>
      <category>silicon</category>
      <category>arm</category>
    </item>
    <item>
      <title>Calling system commands from within Ruby</title>
      <dc:creator>Emili Parreno</dc:creator>
      <pubDate>Thu, 23 Sep 2021 16:41:22 +0000</pubDate>
      <link>https://dev.to/eparreno/calling-system-commands-from-within-ruby-483</link>
      <guid>https://dev.to/eparreno/calling-system-commands-from-within-ruby-483</guid>
      <description>&lt;p&gt;Sometimes we need to execute system commands from within a Ruby app or script. You can find some methods in the Kernel module to accomplish this, but they behave slightly different. Let's take a look at all those methods and see what are their main differences.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;exec("command")&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This is the least common and least useful method for running external commands. &lt;code&gt;exec&lt;/code&gt; replaces the current process (your Ruby script) by running the external command.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; exec('ls')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We rarely want this behaviour so let's see different ways to run system commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;command&lt;/code&gt; or &lt;code&gt;%x{ command }&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Backticks are the easiest and quickest way to run a command. Simply enclose the command you want to run in backticks like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; `ls`
=&amp;gt; "bin\ncode\n"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you prefer, you can get the same exact result using &lt;code&gt;%x&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; %x{ ls }
=&amp;gt; "bin\ncode\n"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Both return the standard output of running the command in a subshell.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;system("command")&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to explicitly check if the command was found and ran successfully, you can use the &lt;code&gt;system&lt;/code&gt; command. Unlike the backtick or &lt;code&gt;%x&lt;/code&gt; method, &lt;code&gt;system&lt;/code&gt; will execute the command and return &lt;code&gt;true&lt;/code&gt; if the command was successful (exit status 0), false if it was unsuccessful (exit status 1) or nil if the command execution failed.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; system('ls')
bin          code
=&amp;gt; true

&amp;gt; system('ls x')
ls: x: No such file or directory
=&amp;gt; false

&amp;gt; system('foo')
=&amp;gt; nil
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Special variables
&lt;/h2&gt;

&lt;p&gt;For all of those methods mentioned above, you can access the PID and exit status of the unix process via the &lt;code&gt;$?&lt;/code&gt; variable:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; system('ls')
bin       code
=&amp;gt; true

&amp;gt; $?.pid
=&amp;gt; 123

&amp;gt; $?.exitstatus
=&amp;gt; 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  &lt;code&gt;IO#popen&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;This method executes the specified command as a subprocess, as a result it will return an IO object containing both input and output, allowing you to use some convenient methods to access the output and the PID.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; command = IO.popen("ls -l")
&amp;gt; command.pid
=&amp;gt; 123
&amp;gt; command.readlines
=&amp;gt; ["total 8\n",
 "-rwxr-xr-x  1 emili  staff   40 Feb 11 20:25 hello.rb\n",
 "drwxr-xr-x  4 emili  staff  136 Jan 30 13:16 foo.rb\n"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>ruby</category>
    </item>
  </channel>
</rss>
