<?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>Forem: Mattia Orfano</title>
    <description>The latest articles on Forem by Mattia Orfano (@mattiaorfano).</description>
    <link>https://forem.com/mattiaorfano</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%2F876004%2F6e7114f3-1ea8-4728-9ffc-7049fec534f2.JPG</url>
      <title>Forem: Mattia Orfano</title>
      <link>https://forem.com/mattiaorfano</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mattiaorfano"/>
    <language>en</language>
    <item>
      <title>MacOS Sonoma: libmysqlclient.21.dylib (no such file, not in dyld cache)</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Fri, 20 Oct 2023 09:22:21 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/macos-sonoma-libmysqlclient21dylib-no-such-file-not-in-dyld-cache-1ijg</link>
      <guid>https://forem.com/mattiaorfano/macos-sonoma-libmysqlclient21dylib-no-such-file-not-in-dyld-cache-1ijg</guid>
      <description>&lt;p&gt;I was happy when I received a call from one of my customers: "&lt;em&gt;Hello Mattia, how are you? We'd like to add a new feature to our Rails Web App to let users pay for an annual subscription. Are you available to discuss the details?&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;You can guess my answer.. "&lt;em&gt;Of course! Let's do that&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;2 weeks later I sat down on my computer to start the implementation.&lt;/p&gt;

&lt;p&gt;I had already worked on that project - so everything was already set up - and I just needed to launch: &lt;code&gt;rails s&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then I saw this error message on the console:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✗ rails s

/Users/mattiaorfano/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': dlopen(/Users/mattiaorfano/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle, 0x0009): Library not loaded: /opt/homebrew/opt/mysql/lib/libmysqlclient.21.dylib
  Referenced from: &amp;lt;E748A2AA-20C9-3078-8838-91C4C0607EB7&amp;gt; /Users/mattiaorfano/.asdf/installs/ruby/2.7.8/lib/ruby/gems/2.7.0/gems/mysql2-0.5.2/lib/mysql2/mysql2.bundle
  Reason: tried: '/opt/homebrew/opt/mysql/lib/libmysqlclient.21.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/mysql/lib/libmysqlclient.21.dylib' (no such file), '/opt/homebrew/opt/mysql/lib/libmysqlclient.21.dylib' (no such file), '/usr/local/lib/libmysqlclient.21.dylib' (no such file), '/usr/lib/libmysqlclient.21.dylib' (no such file, not in dyld cache),
....
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;WTF?! 😭&lt;/p&gt;

&lt;p&gt;Couple of days before I had upgraded to MacOS Sonoma 14 and maybe something with mysql installation went wrong. I checked everything and it seemed to work correctly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql -V                                        
mysql  Ver 8.1.0 for macos14.0 on arm64 (Homebrew)

mysql -u root -p
mysql&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I could even use a GUI such as SequelPro.&lt;/p&gt;

&lt;p&gt;Yet, my rails app couldn't connect to mysql database.&lt;/p&gt;

&lt;p&gt;Mhh. It was that time.&lt;/p&gt;

&lt;p&gt;As an experienced software developer, I decided to use my super power: a google search! If you click &lt;a href="https://letmegooglethat.com/?q=%2Fusr%2Flib%2Flibmysqlclient.21.dylib%27+(no+such+file%2C+not+in+dyld+cache)"&gt;here&lt;/a&gt;, you'll see exactly what I did.&lt;/p&gt;

&lt;p&gt;Beyond a variety of nerdy explanations of the possible reasons, the solutions were funny to say the least. Things like: reinstall mysql, create symbolic links in remote folders of your MacOs, copy&amp;amp;run python scripts, etc.&lt;/p&gt;

&lt;p&gt;My mom always told me "never take candies from strangers".&lt;/p&gt;

&lt;p&gt;So, I read carefully the error message...&lt;/p&gt;

&lt;h2&gt;
  
  
  Something with mysql2 adapter was not working, and maybe...
&lt;/h2&gt;

&lt;p&gt;I thought "&lt;em&gt;What if the solution is as simple as &lt;code&gt;gem pristine mysql2&lt;/code&gt;?&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;Boom! My rails app started working again.&lt;/p&gt;

&lt;p&gt;gem pristine basically takes a gem and restores it. It’s like uninstalling and reinstalling the gem, using the new system libraries and configurations of MacOS Sonoma.&lt;/p&gt;

&lt;p&gt;Now it's your turn. Do you want to take the direct approach, or waste 2 hours googleing around? Let me know in the comments ;)&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>rails</category>
      <category>macos</category>
    </item>
    <item>
      <title>Coding Is Social Activity.</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Tue, 18 Jul 2023 15:17:49 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/coding-is-social-activity-29ee</link>
      <guid>https://forem.com/mattiaorfano/coding-is-social-activity-29ee</guid>
      <description>&lt;p&gt;There's a pletora of principles, patterns, practises and heuristics that a craftsman should know in order to be defined a software engineer. But...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To become a good, trusted and admired programmer you need more than a bunch of engineering theories.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Typically, we measure one's greatness by its intelligence, gut knowledge, and years of practice. But, almost 20 years in software development, taught me that &lt;strong&gt;bad programmers are everywhere, despite their "expertise".&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have all worked on projects where WTFs/minute were insane.&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%2Fm3ifp6088v1a1tcjytym.jpeg" 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%2Fm3ifp6088v1a1tcjytym.jpeg" alt="code quality"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why there's so much shit around? Who's to blame? Project managers? Business owners? Customers always demanding more, asap and with fewer resources?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Coding requires hard work.&lt;/strong&gt; But knowing the underlying mechanisms, building complex applications, and sweating over this job for years, does not guarantee code quality.&lt;/p&gt;

&lt;p&gt;In fact, contrary to the popular belief, &lt;strong&gt;programming is a social activity.&lt;/strong&gt; Why? Because we type words, all day long. Words that are then read and processed by other human beings.&lt;/p&gt;

&lt;p&gt;And guess what... The human brain has evolved to deal with spoken language and words, through which we are able to communicate, organize and build some amazing things such as historical monuments, tall buildings and world-wide companies.&lt;/p&gt;

&lt;p&gt;If we weren't able to understand words and communicate effectively, we wouldn't be at this stage of development. We would be still hanging off the trees, eating bananas.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So our goal is to be understood, even if our job is mostly done alone, in darkness (and despair).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I fuc***g hate to see misleading variable names, terribly organized directories, missing documentation and other hell related horrors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code should be written so others can understand it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And we should take the proper amount of time to do it right, no matter the external pressure to clear up the backlog.&lt;/p&gt;

&lt;p&gt;It's horrific and discouraging when the onboarding process into a new project requires days or months just because someone else didn't put the effort to write clean code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Software developers proudly state their intelligence, their ability to understand complex ideas and algorithms. But they often lack wisdom, the capacity to identify and protect the identity of their code so others can enjoy it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And this is the major problem with today's software industry.&lt;/p&gt;

&lt;p&gt;Our value system focuses more on outward appearance than on the substance of what we deliver. We obsess about the schedule and deadlines. We never defend code quality.&lt;/p&gt;

&lt;p&gt;Let me write it again...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It's only when your code can be immediately understood by others, that you can define yourself a good programmer.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Coding is a social skill, it's a communication act. It produces art that people will look at and be either fascinated or terrified from.&lt;/p&gt;

&lt;p&gt;So, next time you open up your codebase, look for ways to make things clearer and better:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;improve readability&lt;/li&gt;
&lt;li&gt;refactor code&lt;/li&gt;
&lt;li&gt;avoid duplication&lt;/li&gt;
&lt;li&gt;make it efficient&lt;/li&gt;
&lt;li&gt;make it effective&lt;/li&gt;
&lt;li&gt;re-organize files and classes&lt;/li&gt;
&lt;li&gt;assign proper names&lt;/li&gt;
&lt;li&gt;avoid misinformation, misleading names, messy directories..&lt;/li&gt;
&lt;li&gt;...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We are not monkeys. We are humans, we think in words and write code. Make it good, make it right.&lt;/p&gt;

&lt;p&gt;Let's discuss in the comment section, what do you think?&lt;/p&gt;

</description>
      <category>programming</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Dealing with "git-lfs" was not found on your path</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Wed, 17 May 2023 16:08:32 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/dealing-with-git-lfs-was-not-found-on-your-path-1j8</link>
      <guid>https://forem.com/mattiaorfano/dealing-with-git-lfs-was-not-found-on-your-path-1j8</guid>
      <description>&lt;p&gt;After 2 weeks of sweat and tears, today I was ready to release a few changes I've made to one of my client's GITHUB repositories.&lt;/p&gt;

&lt;p&gt;I cracked my fingers with a smile on my face, and typed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rebase main
... solved a bunch of conflicts
git push -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And.... fuck!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.

error: failed to push some refs to 'github.com:....git'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The typical reaction of a junior developer would be to do exactly what the error message says: delete the file.&lt;/p&gt;

&lt;p&gt;But my parents told me long ago not to trust strangers (or random messages from the internet), and since this is a legacy project where several other developers work on a daily basis, I took a different approach.&lt;/p&gt;

&lt;p&gt;The solution was pretty simple. On MacOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install git-lfs
git lfs install
git push -f
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thank me later! Bye ;)&lt;br&gt;
Read my other &lt;a href="https://dev.to/t/10stips"&gt;#10stips&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>development</category>
      <category>programming</category>
    </item>
    <item>
      <title>RSA host key changed for github.com</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Tue, 11 Apr 2023 13:35:27 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/rsa-host-key-changed-for-githubcom-228p</link>
      <guid>https://forem.com/mattiaorfano/rsa-host-key-changed-for-githubcom-228p</guid>
      <description>&lt;p&gt;As recently &lt;a href="https://github.blog/2023-03-23-we-updated-our-rsa-ssh-host-key/"&gt;announced&lt;/a&gt;, Github replaced their RSA SSH host key used to secure Git operations for GitHub.com as a security measure.&lt;/p&gt;

&lt;p&gt;This "small" change will affect all your future deploys and you might encounter errors like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s.
Please contact your system administrator.
Add correct host key in /home/project/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/project/.ssh/known_hosts:1
remove with:
ssh-keygen -f "/home/project/.ssh/known_hosts" -R "github.com"
RSA host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even following Github's advice I wasn't able to fix the error and I had to tweak a little bit...&lt;/p&gt;

&lt;p&gt;First, &lt;strong&gt;ensure you have an updated SSH key&lt;/strong&gt; in your project's "deploy keys". Go to Github.com, enter your repository, go to Settings&amp;gt;Deploy Keys and create/update the existing ones.&lt;/p&gt;

&lt;p&gt;Then, on your local machine (as well as your remote server that serves your web application) run the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen -R github.com
ssh-keyscan github.com &amp;gt; ~/.ssh/known_hosts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, try again to deploy your code.&lt;/p&gt;

&lt;p&gt;If you see another error like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The authenticity of host 'github.com (140.82.121.4)' can't be established.
       ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '140.82.121.4'
       Offending key for IP in /home/project/.ssh/known_hosts:1
       Matching host key in /home/project/.ssh/known_hosts:4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you have to remove the specified IP address from known_host. Run the following command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ssh-keygen -R "140.82.121.4"&lt;/code&gt;&lt;/p&gt;

</description>
      <category>github</category>
    </item>
    <item>
      <title>Postgresql not working on Mac M1 ARM: quick fix</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Sat, 17 Sep 2022 08:38:36 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/postgresql-not-working-on-mac-m1-arm-quick-fix-5a42</link>
      <guid>https://forem.com/mattiaorfano/postgresql-not-working-on-mac-m1-arm-quick-fix-5a42</guid>
      <description>&lt;p&gt;Sometimes, shit happens.&lt;/p&gt;

&lt;p&gt;Especially after a long work-day, when you have no energy left and decide to upgrade system libraries without understanding a dime... and boom! Everything breaks and stop working.&lt;/p&gt;

&lt;p&gt;This is exactly what happened to me few weeks ago.&lt;/p&gt;

&lt;p&gt;I launched a simple &lt;code&gt;brew upgrade&lt;/code&gt; to have all formulae updated and after that my postgresql stopped working. From &lt;code&gt;brew services list&lt;/code&gt; I saw:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;postgresql@14   error 256 mattia ~/Library/LaunchAgents/homebrew.mxcl.postgresql@14.plist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;mhh... wtf!??&lt;/p&gt;

&lt;p&gt;So I thought, "&lt;em&gt;maybe I have to start the service again...&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;&lt;code&gt;➜  ~ brew services start postgresql&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;Warning: Use postgresql@14 instead of deprecated postgresql
Bootstrap failed: 5: Input/output error
Try re-running the command as root for richer errors.
Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/mattiaorfano/Library/LaunchAgents/homebrew.mxcl.postgresql@14.plist` exited with 5.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It seems they changed path to stable postgresql version and there is some wrong configuration in my system. What do I do?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"I'm tired as shit and don't want to fix this at 8PM"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"Tomorrow I can't work"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"Worse... I can't read all the databases"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"I'm fucked!"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I looked around and found few suggestions that involved reinstalling the entire postgresql instance.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"Absolutely not! I don't want to uninstall it and lose the data. There must be another solution..."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I took a long breath, stretched my arms, and created another &lt;a href="https://dev.to/t/10stips"&gt;#10stips&lt;/a&gt; that you're about to read (what's 10stips? the column where you learn how to solve issues within 10 seconds, because I already tested it for you).&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix Postgresql installation on MAC M1 ARM
&lt;/h2&gt;

&lt;p&gt;Instead of deleting and reinstalling the entire postgresql installation (you might lose your data!) I just did this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew services stop postgresql

using Activity monitor check if there are active postgres processes and kill them

reboot the system

rm -rf /opt/homebrew/var/postgres/postmaster.pid

brew services start postgresql@14
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you might encounter another issue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Library not loaded: '/opt/homebrew/opt/postgresql/lib/libpq.5.dylib' (LoadError)
  Referenced from: '/Users/mattiaorfano/.rbenv/versions/2.4.10/lib/ruby/gems/2.4.0/gems/pg-0.20.0/lib/pg_ext.bundle'
  Reason: tried: '/opt/homebrew/opt/postgresql/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file), '/opt/homebrew/Cellar/postgresql@14/14.5_1/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file) - /Users/mattiaorfano/.rbenv/versions/2.4.10/lib/ruby/gems/2.4.0/gems/pg-0.20.0/lib/pg_ext.bundle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is an incorrect library pathing for postgresql@14, and all you have to do is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ln -s /opt/homebrew/opt/postgresql@14/lib/postgresql@14/libpq.5.dylib /usr/local/lib/libpq.5.dylib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Launch the service again with &lt;code&gt;brew services start postgresql@14&lt;/code&gt; and now you can turn off the computer and go to sleep.&lt;/p&gt;

&lt;p&gt;You're welcome ;-)&lt;/p&gt;

</description>
      <category>10stips</category>
      <category>postgres</category>
    </item>
    <item>
      <title>Cannot build iOS apps with Ionic/Capacitor and Vue.js</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Mon, 01 Aug 2022 13:21:30 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/cannot-build-ios-apps-with-ioniccapacitor-and-vuejs-8c8</link>
      <guid>https://forem.com/mattiaorfano/cannot-build-ios-apps-with-ioniccapacitor-and-vuejs-8c8</guid>
      <description>&lt;p&gt;Lately I've been experimenting with Ionic/Capacitor to build native apps using Vue.js. But I had problems building for iOS and configuring all the dependencies... so I wrote this short guide to help you with that.&lt;/p&gt;

&lt;h6&gt;
  
  
  This is part of &lt;a href="https://dev.to/t/10stips"&gt;#10stips&lt;/a&gt; (the column where you learn how to solve coding issues within 10 seconds or so, because I already tested it for you).
&lt;/h6&gt;

&lt;h2&gt;
  
  
   The tech stack
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Vue&lt;/strong&gt; is a Javascript framework meant to be easy yet powerful, and it allows the creation of powerful web apps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ionic&lt;/strong&gt; is a popular platform for building native-looking IOS/Android apps using HTML, CSS and Javascript. And adding native functionalities and Ios/Android support becomes super straightforward with &lt;strong&gt;Capacitor&lt;/strong&gt;, that integrates perfectly with an Ionic project.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;After creating a sample app, that I tested on the browser with &lt;code&gt;ionic serve&lt;/code&gt;, I felt ready to deploy it on my iPhone.&lt;/p&gt;

&lt;p&gt;I plugged in the phone to my Mac Mini M1 via USB-cable, made sure it has been recognised, and in Visual Studio Code I launched a new terminal and typed...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ionic build
ionic cap add ios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and boom! command failed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;zsh: command not found: pod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I quickly recognised there were unmet dependencies and after checking the documentation (&lt;a href="https://ionicframework.com/docs/intro/environment"&gt;here&lt;/a&gt; and &lt;a href="https://capacitorjs.com/docs/getting-started/environment-setup"&gt;here&lt;/a&gt;) and following some online tutorials, I launched again and boom.... another error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Invalid Podfile file: cannot load such file -- /Users/admin/CapProject/node_modules/@capacitor/ios/scripts/pods_helpers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;WTF! It took me a while to make it work, so I created these steps for you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# First, update your OS (at least MacOS 12+)
# this is to ensure the greatest compatibility between Apple Silicon and other libraries

# you will need NodeJS 14 or higher
node --version

# make sure to have the javascript package manager
npm --version

# ionic/cli should be present at this stage because you already built your amazing app
npm install -g @ionic/cli

# install Xcode
# just open the App store and search for it

# make sure you have Xcode Command Line Tools
xcode-select --install

# check the installation with
xcode-select -p
# should appear this /Applications/Xcode.app/Contents/Developer

# Install Cocoapods with Homebrew (do not install it manually using ruby gems as sometimes suggested)
brew install cocoapods

# Now, restart your computer (seriously, this is important!)
restart

# check the installation with
pod --version

# build your project to create a dist folder
ionic build

# add Capacitor IOS support
# this time it should work and it creates an ios folder
ionic cap add ios

# open up your IOS build in Xcode
ionic cap open ios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Few, you're done! Make your clients happy ;)&lt;/p&gt;

&lt;p&gt;Matt&lt;/p&gt;

</description>
      <category>vue</category>
      <category>ionic</category>
    </item>
    <item>
      <title>Quick fix to empty page and noscript serving a Vue App</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Thu, 21 Jul 2022 14:58:22 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/quick-fix-to-empty-page-and-noscript-serving-a-vue-app-13ee</link>
      <guid>https://forem.com/mattiaorfano/quick-fix-to-empty-page-and-noscript-serving-a-vue-app-13ee</guid>
      <description>&lt;p&gt;Hey everyone, another &lt;code&gt;#10stips&lt;/code&gt; today.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;What is #10stips?&lt;/em&gt; The column where you solve coding issues within 10 seconds and prevent your mental health.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Basic stuff here, so if you're an advanced javascript/Vue developer, and don't want to laugh out loud, just skip this.&lt;/p&gt;

&lt;p&gt;I decided to publish it anyway because the answers on StackOverflow to the same issue wasted my time.&lt;/p&gt;

&lt;p&gt;The solution was way easier that I felt like an idiot.&lt;/p&gt;

&lt;p&gt;In fact, it was my fault... but it seems it happens a lot since there are many similar requests on the internet.&lt;/p&gt;

&lt;p&gt;So, this might be helpful.&lt;/p&gt;

&lt;h2&gt;
  
  
  The issue with App.vue
&lt;/h2&gt;

&lt;p&gt;Look at this basic Component:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;nav&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;router-link&lt;/span&gt; &lt;span class="na"&gt;to=&lt;/span&gt;&lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Home&lt;span class="nt"&gt;&amp;lt;/router-link&amp;gt;&lt;/span&gt; |
    &lt;span class="nt"&gt;&amp;lt;router-link&lt;/span&gt; &lt;span class="na"&gt;to=&lt;/span&gt;&lt;span class="s"&gt;"/about"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;About&lt;span class="nt"&gt;&amp;lt;/router-link&amp;gt;&lt;/span&gt; |

    &lt;span class="c"&gt;&amp;lt;!-- same as previous because router-link always look for a name attribute inside the routes object --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;router-link&lt;/span&gt; &lt;span class="na"&gt;:to=&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;{ name: 'About' }"&amp;gt;About&lt;span class="nt"&gt;&amp;lt;/router-link&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/nav&amp;gt;&lt;/span&gt;

  &lt;span class="c"&gt;&amp;lt;!-- a component from the route will be injected here (eg /about) --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;router-view&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We have 3 router-links. The second and third loads the same About view... but &lt;strong&gt;instead of a string I am passing an object with a name attribute.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is possible because Vue looks for a name attribute inside each route object. These are the routes:&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;routes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;home&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;component&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;HomeView&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/about&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;about&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;component&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AboutView&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;If you run the app with &lt;code&gt;npm run serve&lt;/code&gt; you end up with a blank page (wtf!!).&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%2Fxx4ad82thx66q8sepsi1.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%2Fxx4ad82thx66q8sepsi1.png" alt="Vue blank page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inspecting the code you see this:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&lt;p&gt;&amp;lt;noscript&amp;gt;&lt;br&gt;
   &amp;lt;strong&amp;gt;We're sorry but demo-jobs doesn't work properly without JavaScript enabled. Please enable it to continue.&amp;lt;/strong&amp;gt;&lt;br&gt;
&amp;lt;/noscript&amp;gt;&lt;br&gt;
&amp;lt;div id="app"&amp;gt;&amp;lt;/div&amp;gt;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Quick fix with explanation&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;Did you spot the difference?&lt;/p&gt;

&lt;p&gt;In the routes I have&lt;br&gt;
&lt;code&gt;name: 'about'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;while in router-link I wrote&lt;br&gt;
&lt;code&gt;{ name: 'About' }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;yes ;) a typo. the string doesn't match. must be lowercase.&lt;/p&gt;

&lt;p&gt;But the behavior of Vue interpreter is strange and you don't have clear errors on console. An headache will arise.&lt;/p&gt;

&lt;p&gt;Now that I saved your life, leave a thumbs up :) &lt;/p&gt;

&lt;p&gt;See ya next time,&lt;br&gt;
Matt&lt;/p&gt;

</description>
      <category>10stips</category>
      <category>vue</category>
      <category>javascript</category>
    </item>
    <item>
      <title>The end of a love story, after 11 years together. Atom :-(</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Tue, 19 Jul 2022 09:26:41 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/the-end-of-a-love-story-after-11-years-together-atom--45p4</link>
      <guid>https://forem.com/mattiaorfano/the-end-of-a-love-story-after-11-years-together-atom--45p4</guid>
      <description>&lt;p&gt;It's been 11 amazing years with ups and downs, where we enjoyed each other's company and had a lot of fun facing together new experiences.&lt;/p&gt;

&lt;p&gt;And now, it's (almost) over.&lt;/p&gt;

&lt;p&gt;On December 15, we will say goodbye.&lt;/p&gt;

&lt;p&gt;You know.. It's hard to leave behind a love story :-(&lt;/p&gt;

&lt;p&gt;Especially, when it involves a trustworthy "partner" that doesn't cheat on you and is always there to make you happy whenever you need it.&lt;/p&gt;

&lt;p&gt;On December 15, &lt;strong&gt;GitHub plans to turn out the lights on Atom.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;EOL.&lt;/p&gt;

&lt;p&gt;I started using Atom in 2011, the year it came out.&lt;/p&gt;

&lt;p&gt;It was released as a free and open-source, deeply customizable, yet easy-to-use code editor. And I loved 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fveh3089n6hnela7o1d2c.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%2Fveh3089n6hnela7o1d2c.png" alt="Atom text editor"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Back then there wasn't much wiggle room to handle code written in multiple languages within the same interface.&lt;/p&gt;

&lt;p&gt;Atom was designed by Github to accommodate the needs of every developer thanks to its built-in package manager that lets you install different language interpreters and plugins like autocompletion features and so on.&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%2Fr84zw1pt7ibw3ewsc12p.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%2Fr84zw1pt7ibw3ewsc12p.png" alt="Atom package manager"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Moreover, you could directly tweak the UI and features to your liking with HTML, CSS, and JavaScript.&lt;/p&gt;

&lt;p&gt;It quickly gained popularity, but &lt;strong&gt;hasn’t had any significant feature updates&lt;/strong&gt;, except for maintenance and security patches. This is why &lt;strong&gt;its popularity dropped&lt;/strong&gt;, as you can see from the Google searches from 2011 until now:&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%2F2liz2l40cut1d0rrgp6i.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%2F2liz2l40cut1d0rrgp6i.png" alt="Atom Google searches"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, here I am, flirting around with yet another code editor (hoping this time it will last forever). Before revealing its name, let me explain one thing...&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites before choosing a text editor
&lt;/h2&gt;

&lt;p&gt;As you might know, I am a &lt;strong&gt;professional backend developer&lt;/strong&gt; and I'm also &lt;strong&gt;learning Vue.js&lt;/strong&gt;. I write production code daily and I have very little patience towards slowliness of my working tools.&lt;/p&gt;

&lt;p&gt;So I had a list of prerequisites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There must be shortcuts to language-specific syntax&lt;/li&gt;
&lt;li&gt;Good integration with git flow&lt;/li&gt;
&lt;li&gt;A precise linter that flags stylistic errors and suspicious constructs while typing the code&lt;/li&gt;
&lt;li&gt;A near-perfect syntax highlighting with .erb, HTML, Javascript, CSS files&lt;/li&gt;
&lt;li&gt;Easy navigation between files&lt;/li&gt;
&lt;li&gt;Go to Definition through a simple click/key-binding&lt;/li&gt;
&lt;li&gt;Should be an actively maintained code editor&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What code editor did I choose?
&lt;/h2&gt;

&lt;p&gt;The story went like this...&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%2Fxfkoe3re98m81c5kbay8.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%2Fxfkoe3re98m81c5kbay8.png" alt="code editor"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Well, Atom was developed by Github, and Github was acquired by Microsoft in 2018. By transitivity, I realized that if GitHub turns out the lights on Atom, it will focus on Microsoft's proprietary software (Visual Studio Code).&lt;/p&gt;

&lt;p&gt;So, I did a little research.&lt;/p&gt;

&lt;p&gt;How is Visual Studio Code adopted by the community?&lt;/p&gt;

&lt;p&gt;By 2016, VsCode ranked 13th among the top popular development tools on Stackoverflow. It reached the #1 spot according to the &lt;a href="https://insights.stackoverflow.com/survey/2019" rel="noopener noreferrer"&gt;2019 Developers Survey&lt;/a&gt;, with 50% of 87,317 respondents using 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fszznem8p4ns63c1d9q6j.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%2Fszznem8p4ns63c1d9q6j.png" alt="2019 Developers survey"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I was almost convinced.&lt;/p&gt;

&lt;p&gt;After an internal battle between my mind and my computer (a 2021 Mac Mini) that lasted several weeks, I decided to give it a try...&lt;/p&gt;

&lt;p&gt;And fuckity fuck.. there we go!&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%2Ff4bfl87ji42ccfll2027.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%2Ff4bfl87ji42ccfll2027.png" alt="My computer with Vscode"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Am I liking it? Yes.&lt;br&gt;
Is it fast and reliable? Yes.&lt;br&gt;
Does it meet all the prerequisites? Yes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, Visual Studio Code has become my official editor as Ruby backend developer on a Mac computer.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Our kids will be amazing :-)&lt;/p&gt;

&lt;p&gt;Now, I'd like to give you a few suggestions.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to set up Vscode for maximum productivity
&lt;/h2&gt;

&lt;p&gt;The extensions I'm using are...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Material Icon Theme&lt;/code&gt;: shows icons near each file in the tree indicating the type of source code (html5, js, ...)&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%2F795iq2c9bdeliymo354l.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%2F795iq2c9bdeliymo354l.png" alt="Material Icon Theme"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Live Server&lt;/code&gt;: easy to start local webserver that reloads automatically when you update the code (particularly helpful when coding frontend)&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%2Fbs9fa1lwobu198ta9clm.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%2Fbs9fa1lwobu198ta9clm.png" alt="Live Server"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Vetur&lt;/code&gt;: Vue syntax highliting&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%2Fqsdpc7pj9nb5jo9myg91.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%2Fqsdpc7pj9nb5jo9myg91.png" alt="Vetur"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Rails and Ruby&lt;/code&gt;: Ruby on Rails support for Visual Studio Code&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Fcekpb5cs1fzl4z3ctvdi.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%2Fcekpb5cs1fzl4z3ctvdi.png" alt="rails support on vscode"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What's your favourite IDE? Let me know in the comments.&lt;/p&gt;

&lt;p&gt;Bye,&lt;br&gt;
Matt&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Rails, add_reference with null constraint on existing table</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Thu, 23 Jun 2022 11:04:28 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/rails-addreference-with-null-constraint-on-existing-table-4n6n</link>
      <guid>https://forem.com/mattiaorfano/rails-addreference-with-null-constraint-on-existing-table-4n6n</guid>
      <description>&lt;h6&gt;
  
  
  &lt;strong&gt;This is &lt;a href="https://dev.to/t/10stips"&gt;#10stips&lt;/a&gt; (where you learn to solve coding problems and prevent your mental health with &lt;em&gt;10 seconds tips&lt;/em&gt;).&lt;/strong&gt;
&lt;/h6&gt;

&lt;p&gt;Good morning engineers!&lt;/p&gt;

&lt;p&gt;How do you add a column with &lt;code&gt;null:false&lt;/code&gt;, &lt;strong&gt;setting a default value to existing records&lt;/strong&gt;, but making sure that &lt;strong&gt;new records are validated against nil&lt;/strong&gt; (instead to be assigned a default value)?&lt;/p&gt;

&lt;p&gt;This sounds tricky and I'm here to save your life.&lt;/p&gt;

&lt;p&gt;Ready?&lt;/p&gt;

&lt;h2&gt;
  
  
  Add reference with constraint &lt;code&gt;null:false&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Today I wanted to add a validated reference column (aka, foreign key) to an existing table with data. Easy, peasy...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_reference :application_users, :company, index: true, foreign_key: true, null: false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Setting &lt;code&gt;null: false&lt;/code&gt; on company_id column creates a constraint where records MUST always have a default value.&lt;/p&gt;

&lt;p&gt;This is exactly what I wanted. And if table is empty, there are no problems.&lt;/p&gt;

&lt;p&gt;But, what about the default value on existing records?&lt;/p&gt;

&lt;p&gt;The migration shown above will fail without providing one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-- add_reference(:application_users, :company, {:null=&amp;gt;false, :foreign_key=&amp;gt;true, :index=&amp;gt;true})
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::NotNullViolation: ERROR:  column "company_id" contains null values

Caused by:
ActiveRecord::NotNullViolation: PG::NotNullViolation: ERROR:  column "company_id" contains null values

Caused by:
PG::NotNullViolation: ERROR:  column "company_id" contains null values
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If null is not allowed by the constraint, and no other default value is offered, the database has no other way to decide.&lt;/p&gt;

&lt;p&gt;And here comes the interesting part!&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding a default value, the proper way
&lt;/h2&gt;

&lt;p&gt;If you know for sure that you have a company with id: 1, you could add &lt;code&gt;default: 1&lt;/code&gt; to set all existing records to belong to that company by default.&lt;/p&gt;

&lt;p&gt;But, having multiple environments such as development, staging and production, forces you to use the &lt;code&gt;Company&lt;/code&gt; model and retrieve a value from it.&lt;/p&gt;

&lt;p&gt;So, I decided to do something like this...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;default_company_id = Company.first.try(:id) || Company.create(name: 'Default company').id
add_reference :application_users, :company, index: true, foreign_key: true, null: false, default: default_company_id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But I knew it wasn't over, yet!&lt;/p&gt;

&lt;p&gt;I don't want new records to be assigned to &lt;code&gt;default: default_company_id&lt;/code&gt;. Instead, I want the database to validate the transaction and gracefully fail if no company is provided.&lt;/p&gt;

&lt;p&gt;So, I added a line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;default_company_id = Company.first.try(:id) || Company.create(name: 'Default company').id
add_reference :application_users, :company, index: true, foreign_key: true, null: false, default: default_company_id

# set default back to nil
change_column_default :application_users, :company_id, nil
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sets the default value back to nil... and the constraint is still there, so creating an ApplicationUser without a company_id will raise an exception as expected.&lt;/p&gt;

&lt;p&gt;Great! We're done!&lt;/p&gt;

&lt;h2&gt;
  
  
  An important sidenote
&lt;/h2&gt;

&lt;p&gt;In general, using the model classes in migrations is considered to be an anti-pattern.&lt;/p&gt;

&lt;p&gt;I'm using Rails 4 here and with newer versions of Rails you could create an anonymous class which inherits from the ApplicationRecord and then explicitly set the table name to groups, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;default_company_id = Class.new(ApplicationRecord)
                            .tap { |c| c.table_name = :companies }
                            .find_or_create_by(name: 'Default company')
                            .id
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Was it helpful?&lt;/p&gt;

&lt;p&gt;Share it with your friends/colleagues/brothers and sisters.&lt;/p&gt;

&lt;p&gt;Bye,&lt;br&gt;
M.&lt;/p&gt;

</description>
      <category>10stips</category>
      <category>rails</category>
    </item>
    <item>
      <title>Being a programmer sucks, most of the time.</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Wed, 15 Jun 2022 10:00:19 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/being-a-programmer-sucks-most-of-the-time-j4d</link>
      <guid>https://forem.com/mattiaorfano/being-a-programmer-sucks-most-of-the-time-j4d</guid>
      <description>&lt;p&gt;Let's be honest, folks.&lt;/p&gt;

&lt;p&gt;Coding is brutally, punishingly frustrating.&lt;/p&gt;

&lt;p&gt;Nothing has ever made me feel like an idiot so regularly than computer programming. In fact, I took 3 years off this job, thinking "&lt;em&gt;I'm done. no more!&lt;/em&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwphr8970tiw06gftv4il.jpeg" 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%2Fwphr8970tiw06gftv4il.jpeg" alt="computer programming"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It means going through failure after failure, spending hours-sometimes days- on a problem only to reveal a tiny typo, a missing colon.&lt;/p&gt;

&lt;p&gt;Sometimes you write a few lines of code, something fairly simple, then you run a test and… it doesn’t work. Sometimes everything works and your mind goes, "&lt;em&gt;what about that improvement?&lt;/em&gt;" (so you change code and &lt;em&gt;tada!!!&lt;/em&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9nmdkx8p7u0iwlrr2nma.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%2F9nmdkx8p7u0iwlrr2nma.png" alt="Code refactoring"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But, there's something interesting about it. Isn't it?&lt;/p&gt;

&lt;p&gt;When you finally open your pull-request, tests run smoothly and you tick off items from the development todo list, you experience an absolute sense of mastery and joy.&lt;/p&gt;

&lt;p&gt;I remember when I started studying computer science back in high-school.&lt;/p&gt;

&lt;p&gt;I've always been a logical and systematic human being. The one who crosses the street stepping on or avoiding particular floor tiles.&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%2Fw9942xh7oaf8knszbddp.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw9942xh7oaf8knszbddp.jpg" alt="perfectionist"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And I immediately fell in love working with machines that do whatever you say — but only if you are perfectly, utterly precise in your instructions.&lt;/p&gt;

&lt;p&gt;Sure, in the beginning is hard. One small mistake, one misplaced bracket, and the whole thing stops working. But...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Programming is like martial arts.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The more you train, the more able you become to handle crushing and incessant failures and roadblocks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Software engineering helps you approach problems methodically, break big tasks down into tiny steps and develop sound solutions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a prerequisite in many modern jobs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not only programmers, but researchers, entrepreneurs and white-collars of any kind benefit from this mindset.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you're able to tackle with the psychological storm and endure such a grind of this job, you'll:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;develop a strong &lt;strong&gt;ability&lt;/strong&gt; to deal with pain (a "painability")&lt;/li&gt;
&lt;li&gt;become &lt;strong&gt;fearless&lt;/strong&gt; of new challenges&lt;/li&gt;
&lt;li&gt;work on &lt;strong&gt;interesting&lt;/strong&gt; stuff that will make you proud&lt;/li&gt;
&lt;li&gt;have lots of &lt;strong&gt;digital friends&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;break production code and make customers go crazy before fixing the bug and pretending &lt;strong&gt;you just saved their life&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Trust me, this one of the most rewarding jobs out there. I've sold my successful real estate company, just to come back and work again as a programmer. I really like it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Mattia, what's the real secret of a programmer?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To succeed in life, you must be great at analyzing details, facing challenges and automating tasks.&lt;/p&gt;

&lt;p&gt;Programmers are really good at it.&lt;/p&gt;

&lt;p&gt;And programming can also improve your relationships, because you know... women appreciate attention to details and men, well, they're men (they're cute dogs). &lt;em&gt;Marry a programmer!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let me know what you think, in the comments ;-)&lt;br&gt;
See ya!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>devjournal</category>
      <category>beginners</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Solve network errors with PDFKit and wkhtmltopdf</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Tue, 14 Jun 2022 11:24:43 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/solve-network-errors-with-pdfkit-and-wkhtmltopdf-4gm</link>
      <guid>https://forem.com/mattiaorfano/solve-network-errors-with-pdfkit-and-wkhtmltopdf-4gm</guid>
      <description>&lt;p&gt;In today's &lt;em&gt;#10stips&lt;/em&gt; (where you learn how to solve coding issues within 10 seconds) we talk about the lovely &lt;a href="https://github.com/pdfkit/pdfkit" rel="noopener noreferrer"&gt;PDFKit gem&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I've been using it since I was a child (ehm no.. since the gem was born around 12 years ago). It creates PDFs using plain old HTML+CSS.&lt;/p&gt;

&lt;p&gt;PDFKit requires &lt;code&gt;wkhtmltopdf&lt;/code&gt; library which renders HTML using Webkit.&lt;/p&gt;

&lt;p&gt;Now, Webkit is a rendering engine and depending on your system configuration you may stumble upon compatibility issues loading resources or &lt;strong&gt;unsolicited network errors that might drive you crazy&lt;/strong&gt;, especially when you have HTML pages with lots of images.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

PDFKit::ImproperWkhtmltopdfExitStatus UnknownNetworkError
Exit with code 1 due to network error: UnknownNetworkError
Exit with code 1 due to network error: ContentNotFoundError
Warning Failed to load


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Basically, wkhtmltopdf fails to load CSS, JS or IMG files.&lt;/p&gt;

&lt;p&gt;There are several factors playing a role...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PDFkit 0.13 seems to work, while 0.12.5 does not.&lt;/li&gt;
&lt;li&gt;loading images from a web server with TLSv1, it works.&lt;/li&gt;
&lt;li&gt;on a modern server with TLS 1.2, it breaks but not for all resources.&lt;/li&gt;
&lt;li&gt;better to use absolute paths instead of relative ones&lt;/li&gt;
&lt;li&gt;&lt;em&gt;who knows, who cares!?!?!?!&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, I give you a quick and final solution.&lt;/p&gt;

&lt;p&gt;Ready?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Turn off the computer and go on a hike. Seriously, it helps your mental and physical health.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But if you're still interested to solve the problem, this is what I suggest...&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If possible, update your wkhtmltopdf to the latest version&lt;/li&gt;
&lt;li&gt;Check wether external resources in your HTML comes from a TLSv1 or TLSv2 server (newer versions of wkhtmltopdf work best with TLSv2).&lt;/li&gt;
&lt;li&gt;Try to switch URLs from HTTPS to HTTP (and viceversa)&lt;/li&gt;
&lt;li&gt;Set &lt;code&gt;config.default_options[:ignore_load_errors] = true&lt;/code&gt; in your PDFKit.configure block&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Obviously, using HTTP versus HTTPS presents a security concern. Unfortunately, we have very few options and I'm a guy who prioritize sanity over bugfixing.&lt;/p&gt;

&lt;p&gt;And remember, sometimes it's OK to pretend bugs are features.&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%2Foy6u9i3tm01c6h3ml7qt.jpeg" 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%2Foy6u9i3tm01c6h3ml7qt.jpeg" alt="Bugfixing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Leave a thumbs up and comment if you wish.&lt;/p&gt;

</description>
      <category>10stips</category>
      <category>rails</category>
      <category>wkhtmltopdf</category>
    </item>
    <item>
      <title>.gitignore all .DS_Store files, even if already committed</title>
      <dc:creator>Mattia Orfano</dc:creator>
      <pubDate>Sun, 12 Jun 2022 10:40:37 +0000</pubDate>
      <link>https://forem.com/mattiaorfano/gitignore-mac-dsstore-files-even-if-already-committed-14dm</link>
      <guid>https://forem.com/mattiaorfano/gitignore-mac-dsstore-files-even-if-already-committed-14dm</guid>
      <description>&lt;p&gt;Hello everyone, and welcome to &lt;em&gt;#10stips&lt;/em&gt;! The column where you learn how to solve coding issues within 10 seconds.&lt;/p&gt;

&lt;p&gt;In today's episode I show you &lt;strong&gt;how to .gitignore MacOS .DS_Store files in every folder and subfolder of your project.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A little bit of background
&lt;/h2&gt;

&lt;p&gt;I recently jumped onboard onto an existing Rails 4 project.&lt;/p&gt;

&lt;p&gt;Yes, Rails 4 is still widely used in production and oftentimes is particularly challenging to upgrade an application with newer Rails versions without creating breaking changes.&lt;/p&gt;

&lt;p&gt;As soon as I cloned the repository, and opened up the code with Atom, I noticed all those magical .DS_Store files.&lt;/p&gt;

&lt;p&gt;"&lt;em&gt;Fuck! Back up little bastards!&lt;/em&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw82lrbwnnf6jtofiexok.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw82lrbwnnf6jtofiexok.gif" alt="shooting at the computer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to .gitignore .DS_Store files
&lt;/h2&gt;

&lt;p&gt;First, unmatch previously committed files:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Then, add &lt;code&gt;**/.DS_Store&lt;/code&gt; into .gitignore&lt;/p&gt;

&lt;p&gt;Finally, commit and push the changes:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

git commit -m "Remove .DS_Store from everywhere"
git push


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You're welcome!&lt;/p&gt;

&lt;p&gt;Now, your Mac will still create .DS_Store files in every folder. If you become frustrated, you can turn them off.&lt;/p&gt;

&lt;h2&gt;
  
  
  (bonus) How to turn off the creation of .DS_Store files
&lt;/h2&gt;

&lt;p&gt;Mac creates the .DS_Store files to retain settings configured for each folder such as the size and orientation of icons, sort settings, and so on.&lt;/p&gt;

&lt;p&gt;If you become frustrated, you can turn off the creation of .DS_Store files - just execute the following command in Terminal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;defaults write com.apple.desktopservices DSDontWriteNetworkStores true&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Reboot your Mac, and you’ll be good to go.&lt;/p&gt;

</description>
      <category>git</category>
      <category>10stips</category>
    </item>
  </channel>
</rss>
