<?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: Monica </title>
    <description>The latest articles on DEV Community by Monica  (@nirnaeth).</description>
    <link>https://dev.to/nirnaeth</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%2F9812%2F1135197.jpeg</url>
      <title>DEV Community: Monica </title>
      <link>https://dev.to/nirnaeth</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nirnaeth"/>
    <language>en</language>
    <item>
      <title>TIL about testing commands</title>
      <dc:creator>Monica </dc:creator>
      <pubDate>Mon, 18 May 2020 20:35:09 +0000</pubDate>
      <link>https://dev.to/nirnaeth/til-about-testing-command-line-227p</link>
      <guid>https://dev.to/nirnaeth/til-about-testing-command-line-227p</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a walk-with-me-while-I-do-things series, I'm going to tell you what I learned while I'm learning&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If this was our program&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# my_tool.rb&lt;/span&gt;

&lt;span class="c1"&gt;# Removes and returns the first item from the command-line arguments&lt;/span&gt;
&lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;ARGV&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shift&lt;/span&gt;

&lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;command&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;you can test this code using RSpec with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# specs/my_tool_spec.rb&lt;/span&gt;

&lt;span class="no"&gt;RSpec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;describe&lt;/span&gt; &lt;span class="s2"&gt;"my_tool"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s2"&gt;"says hello"&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;system&lt;/span&gt; &lt;span class="s2"&gt;"ruby my_tool.rb hello"&lt;/span&gt; &lt;span class="p"&gt;}.&lt;/span&gt;
      &lt;span class="nf"&gt;to&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hello&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
      &lt;span class="nf"&gt;to_stdout_from_any_process&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here we have three fundamental pieces:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;the method &lt;code&gt;Kernel#system&lt;/code&gt; that invokes a command as if we were on the command line itself. The argument passed as a string will be the command being executed;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the RSpec matcher &lt;code&gt;output&lt;/code&gt; that checks against the expectation and passes if the expectation block on which it is invoked outputs &lt;code&gt;to_stdout&lt;/code&gt; or &lt;code&gt;to_stderr&lt;/code&gt; the string passed as an argument;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;the &lt;code&gt;to_stdout_from_any_process&lt;/code&gt; that we have to use instead of &lt;code&gt;to_sdtdout&lt;/code&gt; because the &lt;code&gt;system&lt;/code&gt; call is actually spawning a subprocess, and RSpec wouldn't be able to access &lt;code&gt;$stdout&lt;/code&gt; otherwise. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If we weren't testing a command line invocation, we could have written&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;expect&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;"Same process"&lt;/span&gt; &lt;span class="p"&gt;}.&lt;/span&gt;
  &lt;span class="nf"&gt;to&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Same process"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;
  &lt;span class="nf"&gt;to_stdout&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;More sources are &lt;a href="https://medium.com/@joejamesio/testing-command-line-tool-output-with-rspec-8960bedeb1ce"&gt;here&lt;/a&gt;. To use RSpec for capturing the output and where you can go to &lt;a href="https://www.rubydoc.info/gems/rspec-expectations/RSpec%2FMatchers:output"&gt;the official doc&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>commandline</category>
      <category>todayilearned</category>
      <category>microlearning</category>
    </item>
    <item>
      <title>TIL about Ruby command line execution</title>
      <dc:creator>Monica </dc:creator>
      <pubDate>Tue, 05 May 2020 20:01:22 +0000</pubDate>
      <link>https://dev.to/nirnaeth/til-about-ruby-command-line-execution-395j</link>
      <guid>https://dev.to/nirnaeth/til-about-ruby-command-line-execution-395j</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a walk-with-me-while-I-do-things series, I'm going to tell you what I learned while I'm learning&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can execute a Ruby file by passing it on as an argument to the &lt;code&gt;ruby&lt;/code&gt;. What if I told you you can require a library and give executable code directly to the command on the terminal? &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;ruby&lt;/code&gt; command supports two options among others:&lt;br&gt;
&lt;code&gt;-r&lt;/code&gt; stands for &lt;code&gt;require&lt;/code&gt; and receives as an argument the name of the Ruby file you want to load&lt;br&gt;
&lt;code&gt;-e&lt;/code&gt; stands for &lt;code&gt;execute&lt;/code&gt; and receives as an argument a script&lt;/p&gt;

&lt;p&gt;Let's have a file in the current directory called &lt;code&gt;hello.rb&lt;/code&gt; that defines the Hello class like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Hello&lt;/span&gt;
  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;"Hello there!"&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;By running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ruby &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"./hello"&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"h = Hello.new; h.greet"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;the prompt will present you with the following output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello there!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can even write a multiline script as if you were writing in a file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;➜  first-repo git:&lt;span class="o"&gt;(&lt;/span&gt;master&lt;span class="o"&gt;)&lt;/span&gt; ✗ ruby &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s2"&gt;"./hello"&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"
dquote&amp;gt; h = Hello.new
dquote&amp;gt; h.greet
dquote&amp;gt; "&lt;/span&gt;
Hello there!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here is &lt;a href="https://ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/options.html"&gt;the documentation&lt;/a&gt; for all the options you can feed to the &lt;code&gt;ruby&lt;/code&gt; command&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>commandline</category>
      <category>todayilearned</category>
      <category>microlearning</category>
    </item>
    <item>
      <title>TIL about zshell startup</title>
      <dc:creator>Monica </dc:creator>
      <pubDate>Mon, 04 May 2020 20:40:23 +0000</pubDate>
      <link>https://dev.to/nirnaeth/til-about-zshell-startup-4ne</link>
      <guid>https://dev.to/nirnaeth/til-about-zshell-startup-4ne</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a walk-with-me-while-I-do-things series, I'm going to tell you what I learned while I'm learning&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You might remember about &lt;a href="https://dev.to/nirnaeth/yak-shaving-my-way-to-hacktoberfest-day-2-2b5m"&gt;my ordeal&lt;/a&gt; with &lt;em&gt;bash&lt;/em&gt; and &lt;em&gt;Catalina&lt;/em&gt; and &lt;em&gt;zshell&lt;/em&gt; and &lt;em&gt;iTerm&lt;/em&gt;. I bit the bullet and switched to &lt;em&gt;zshell&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;I have an alias for starting the &lt;em&gt;postgres&lt;/em&gt; server that on &lt;em&gt;bash&lt;/em&gt; resides on &lt;code&gt;.bashrc&lt;/code&gt; (by the way, did you know that &lt;code&gt;rc&lt;/code&gt; stands for &lt;code&gt;run commands&lt;/code&gt;?). With &lt;em&gt;zshell&lt;/em&gt;, you can use &lt;code&gt;.zshrc&lt;/code&gt; for the same purpose. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;zshell&lt;/em&gt; at startup reads these files for the user in the following order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;.zshenv&lt;/code&gt;&lt;/strong&gt; - 
always read when launching the shell, no matter from where. you want the important stuff here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;.zshprofile&lt;/code&gt;&lt;/strong&gt; - 
read at login. don't use, use &lt;code&gt;.zshlogin&lt;/code&gt; instead. the purpose is the same.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;.zshrc&lt;/code&gt;&lt;/strong&gt; - 
read when interactive. this is where you should put aliases, key bindings, coloring, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;.zshlogin&lt;/code&gt;&lt;/strong&gt; - 
read at login, use it for things needed once the shell is set up, to execute external commands.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;.zshlogout&lt;/code&gt;&lt;/strong&gt; - 
read when the login shell exits, it should be used to release resources acquired during login.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Before each of these, &lt;em&gt;zshell&lt;/em&gt; runs the matching files that can be found in &lt;code&gt;/etc/&lt;/code&gt; for &lt;strong&gt;all&lt;/strong&gt; users on the machine.&lt;/p&gt;

&lt;p&gt;More info &lt;a href="http://zsh.sourceforge.net/Intro/intro_3.html"&gt;here&lt;/a&gt; (official documentation), &lt;a href="https://unix.stackexchange.com/a/487889"&gt;here&lt;/a&gt; on StackOverflow, and &lt;a href="https://scriptingosx.com/2019/06/moving-to-zsh-part-2-configuration-files/"&gt;here&lt;/a&gt; (switching to zshell because of Catalina).&lt;/p&gt;

</description>
      <category>zshell</category>
      <category>microlearning</category>
      <category>commandline</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>TIL about tree</title>
      <dc:creator>Monica </dc:creator>
      <pubDate>Sat, 02 May 2020 08:02:43 +0000</pubDate>
      <link>https://dev.to/nirnaeth/til-about-tree-b59</link>
      <guid>https://dev.to/nirnaeth/til-about-tree-b59</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a walk-with-me-while-I-do-things series, I'm going to tell you what I learned while I'm learning&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Yesterday I purchased &lt;a href="https://shop.jcoglan.com/building-git/"&gt;Rebuilding Git&lt;/a&gt; by &lt;a href="http://jcoglan.com/"&gt;James Coglan&lt;/a&gt; and today I set up for Chapter 1. I already learned something new on page 4 📖&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tree&lt;/code&gt; is a command originated in MS-DOS (apparently) that has been ported to *nix systems. &lt;br&gt;
By running it in the terminal, it draws for you a graphical recursive representation of the content of the current folder and its children (files and directories), and prints the number of files and/or directories listed.&lt;/p&gt;

&lt;p&gt;It might not come with your OS, it is a program on its own. If you are on a Mac and using &lt;a href="https://brew.sh/"&gt;homebrew&lt;/a&gt; like me, just type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install tree
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;More info &lt;a href="https://linux.die.net/man/1/tree"&gt;here&lt;/a&gt; and &lt;a href="https://vitux.com/linux-tree-command/"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tree</category>
      <category>microlearning</category>
      <category>commandline</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>Yak Shaving My Way To Hacktoberfest - Day 2</title>
      <dc:creator>Monica </dc:creator>
      <pubDate>Sat, 19 Oct 2019 09:56:05 +0000</pubDate>
      <link>https://dev.to/nirnaeth/yak-shaving-my-way-to-hacktoberfest-day-2-2b5m</link>
      <guid>https://dev.to/nirnaeth/yak-shaving-my-way-to-hacktoberfest-day-2-2b5m</guid>
      <description>&lt;h4&gt;
  
  
  &lt;em&gt;On how an OS upgrade can kill your Terminal&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;I woke up to the upgrade to Catalina being completed. I had a couple of hours after work I could use to fix the setup.&lt;/p&gt;

&lt;p&gt;I launched &lt;a href="https://www.iterm2.com/features.html"&gt;iTerm&lt;/a&gt; that with a very graceful popup tells me something-something command profile. As soon as I acknowledged the popup, the window closed. I tried another couple of times (monkey monkey), decided to close permanently the popup because brainfart. Probably I was hoping to be able to see the content of the iTerm window underneath. Unable to revert the behavior, I realized I have two profiles on iTerm. I opened the default profile and there it was, the popup in its splendor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A session ended very soon after starting. Check that the command in profile “molli” is correct.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Looking for the message online &lt;a href="https://apple.stackexchange.com/questions/344971/two-red-lines-bars-in-iterm2-window-and-error-message-about-session-ending-what"&gt;told me&lt;/a&gt; that something was wrong with the command that iTerm launches at start and that I should look at what the window behind the popup says. I couldn't move the popup around so I had to revert to reopen the window a few times and be reading very fast 🙄&lt;/p&gt;

&lt;p&gt;It seemed that bash was causing the problem. I went to my &lt;code&gt;bash_profile&lt;/code&gt; and commented out everything bash-related. Relaunching iTerm showed the same issue. I suddenly remembered that, with the last version of MacOS, Apple &lt;a href="https://insights.dice.com/2019/06/12/macos-catalina-zsh-bash-xcode-11/"&gt;started suggesting&lt;/a&gt; devs to &lt;a href="https://www.theverge.com/2019/6/4/18651872/apple-macos-catalina-zsh-bash-shell-replacement-features"&gt;switch to &lt;code&gt;zsh&lt;/code&gt;&lt;/a&gt;. I fired the OS terminal app that presented the same problem: I cannot use it because it's still looking for bash.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Id2L1aco--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://2.bp.blogspot.com/-3xtPQ5Mc88c/VTiUiYJspSI/AAAAAAAAS-c/rF-0oHwlb4A/s1600/but-why.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Id2L1aco--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://2.bp.blogspot.com/-3xtPQ5Mc88c/VTiUiYJspSI/AAAAAAAAS-c/rF-0oHwlb4A/s1600/but-why.gif" alt="but-why.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In my skimming through internet pages and iTerm settings, I realized there was a &lt;em&gt;Command&lt;/em&gt; setting under Profiles &amp;gt; General that was set to &lt;em&gt;Login Shell&lt;/em&gt;. Finally a stable iTerm with, &lt;a href="http://osxdaily.com/2018/12/29/use-zsh-default-terminal-mac-os-x/"&gt;guess what&lt;/a&gt;?&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Of course it wasn't enough, because to my subsequent &lt;code&gt;brew doctor&lt;/code&gt;, the terminal replied with the equivalent of "I have no clue what you are talking about". But I knew the little rascal (...) was there. FINE. Maybe it was something in the path that zsh doesn't pick up. I tried to configure it properly, but this meant understanding the &lt;a href="https://superuser.com/a/187673"&gt;difference&lt;/a&gt; between &lt;code&gt;.zprofile&lt;/code&gt;, &lt;code&gt;.profile&lt;/code&gt; and &lt;code&gt;.zshrc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I ended up with a &lt;code&gt;.zprofile&lt;/code&gt; that looks 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;emulate sh
. ~/.profile
emulate zsh
export PATH="/usr/local/sbin:$PATH"
export PATH=/usr/local/bin:$PATH
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;but still no joy for my brewing.&lt;/p&gt;

&lt;p&gt;I checked Terminal and lo and behold, it did indeed recognize homebrew. So I used it to launch &lt;code&gt;homebrew&lt;/code&gt; and installed &lt;code&gt;bash&lt;/code&gt; (sorry, zsh, we'll meet again soon).&lt;/p&gt;

&lt;p&gt;I reverted iTerm to use bash too, but it would still close. I made sure I had the latest version of batch available on homebrew, but &lt;a href="http://osxdaily.com/2009/09/25/what-shell-am-i-using/"&gt;when I issue &lt;code&gt;echo $SHELL&lt;/code&gt;&lt;/a&gt;, what I get is still bash 4.3.0. I couldn't figure out where it'd pick this up, because I was 100% sure at this point I had no version named anywhere.&lt;/p&gt;

&lt;p&gt;Apparently, on Mac, &lt;a href="https://www.pegaxchange.com/2017/06/17/mac-os-x-path-variable/"&gt;you can set your &lt;code&gt;PATH&lt;/code&gt; variable in multiple places&lt;/a&gt;, one of them will add an entry &lt;em&gt;permanently for all users on the machine&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I dug my &lt;code&gt;/etc/shell&lt;/code&gt;, changed the config, iTerm doesn't close anymore.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source ~/.bash_profile
-bash: __git_ps1: command not found
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kJgwJu_p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://rlv.zcache.com/rage_guy_angry_fuu_fuuu_rage_face_meme_poster-r2505f4c7185e472c9b975195048c681d_a21y_8byvr_307.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kJgwJu_p--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://rlv.zcache.com/rage_guy_angry_fuu_fuuu_rage_face_meme_poster-r2505f4c7185e472c9b975195048c681d_a21y_8byvr_307.jpg" alt="FFUU.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It was 9.15AM. I had a meeting at 10. I was still in my pijiama. &lt;/p&gt;

&lt;p&gt;Well...&lt;/p&gt;

&lt;p&gt;On my way to the subway, I realized I should save this knowledge somewhere. I was learning stuff. I should have a blog. I should actually have a self-hosted blog, because I would be sure that then the content would belong to me 100%. &lt;/p&gt;

&lt;p&gt;I stopped. That would have added a WHOLE new yak to shave. What is the mantra of the agile ~daleks~ software engineers? Iterate! ITERATE!&lt;br&gt;
So I went for the fastest thing I could get my hands on and I opened my DEV.TO profile. On my phone, I hacked the first lines of the first post of this series. &lt;/p&gt;

&lt;p&gt;Fast forward to 7PM. I was finally home and decided to finish the first post. I had to search for all the sources and reconstruct in my memory what happened the day before. I also decided to note down what happened on that day (you don't want to see those notes, but as you can see, it was a good call, after a week I would have ZERO recollection of any of this).&lt;/p&gt;

&lt;p&gt;Now back to my last problem of the day, &lt;code&gt;__git_ps1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I have my prompt configured in such a way that, when I am in a folder that is a git repository, it shows me the status of the files and the branch I am in. Since I had an old version of git and an old version of OSX, the former configuration wouldn't work. I updated &lt;code&gt;.bash_profile&lt;/code&gt; to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;33m\]\$(__git_ps1)\[\033[01;34m\] \$\[\033[00m\] "
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;as &lt;a href="https://stackoverflow.com/a/15253752,%20update%20bash_profile"&gt;described here&lt;/a&gt; and I had my git status on my prompt again, all cool.&lt;/p&gt;

&lt;p&gt;I ran &lt;code&gt;rake db:setup&lt;/code&gt; only to be told that - of course - the database server wasn't running. Because I'm lazy, I have an alias for that too&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias pgstart='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;so I added it to &lt;code&gt;.bash_profile&lt;/code&gt; and, when sourcing it, bash very nicely told me&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;I launched and initialized the Postgres app, same outcome. RTFM, Monica: on &lt;a href="https://postgresapp.com/"&gt;https://postgresapp.com/&lt;/a&gt; they clearly say to add the Postgres app to the path permanently (remember?) with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mkdir -p /etc/paths.d &amp;amp;&amp;amp;
echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This was the first time I was seeing &lt;code&gt;tee&lt;/code&gt;, a &lt;a href="https://www.computerhope.com/unix/utee.htm"&gt;command used&lt;/a&gt; to write to two different places at the same time (by default, to a file and to standard output).&lt;br&gt;
But I questioned the permanent add to the path, so I added the postgres app location to the user &lt;code&gt;PATH&lt;/code&gt; in &lt;code&gt;.bash_profile&lt;/code&gt; and sourced it to pick up the changes.&lt;/p&gt;

&lt;p&gt;An &lt;code&gt;echo $PATH&lt;/code&gt; showed me that the changes are there, but the PATH itself was ever-growing and also full of duplicates because of the multiple &lt;code&gt;source&lt;/code&gt;s. How could I get rid of the duplicates?&lt;/p&gt;

&lt;p&gt;There are a bunch of suggestions out there on how to &lt;a href="https://unix.stackexchange.com/questions/40749/remove-duplicate-path-entries-with-awk-command"&gt;clean&lt;/a&gt; and &lt;a href="https://superuser.com/questions/121870/how-do-i-reset-the-path-variable-on-mac-os-x"&gt;reset&lt;/a&gt; PATH or &lt;a href="https://unix.stackexchange.com/questions/4965/keep-duplicates-out-of-path-on-source"&gt;avoid duplication&lt;/a&gt; &lt;a href="(https://unix.stackexchange.com/questions/14895/duplicate-entries-in-path-a-problem)"&gt;completely&lt;/a&gt;, but it would take too long to do it properly, I was still far away from being able to start coding. So I decided to chop everything off, reset PATH to what I believed was a clean slate and sourced again (MVPs, right?!)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PATH=/usr/bin:/bin:/usr/sbin:/sbin
source ~/.bash_profile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;gave me back something sensible and clean. Noice.&lt;/p&gt;

&lt;p&gt;Looking at my &lt;code&gt;.bash_profile&lt;/code&gt; configuration for environment managers, I noticed and commented out some nonsense shit about &lt;code&gt;rbenv&lt;/code&gt; that is not relevant and I realized that I didn't have &lt;a href="https://github.com/mururu/exenv"&gt;&lt;code&gt;exenv&lt;/code&gt;&lt;/a&gt; working anymore. But &lt;a href="https://asdf-vm.com/#/core-manage-asdf-vm"&gt;&lt;code&gt;asdf&lt;/code&gt;&lt;/a&gt; did indeed work, so I removed the first one permanently.&lt;/p&gt;

&lt;p&gt;With my brand new and shiny PATH, I could now try and call &lt;code&gt;pgstart&lt;/code&gt; again. The command run but it couldn't start the server. I looked at the logs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2019-10-09 07:43:43.634 CEST [37155] FATAL:  database files are incompatible with server
2019-10-09 07:43:43.634 CEST [37155] DETAIL:  The data directory was initialized by PostgreSQL version 9.4, which is not compatible with this version 12.0.
2019-10-09 07:54:17.196 CEST [49284] FATAL:  database files are incompatible with server
2019-10-09 07:54:17.196 CEST [49284] DETAIL:  The data directory was initialized by PostgreSQL version 9.4, which is not compatible with this version 12.0.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;O. K. &lt;/p&gt;

&lt;p&gt;I removed current installation, reinstalled everything with homebrew, because it was the fastest option. I could then &lt;a href="https://formulae.brew.sh/formula/postgresql"&gt;also upgrade&lt;/a&gt; the data with homebrew.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; brew postgresql-upgrade-database
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A pgstart later, the terminal still tried to start &lt;code&gt;pg_ctl&lt;/code&gt; from the Postegre.app installation directory. I needed to check where the &lt;a href="https://unix.stackexchange.com/a/544970"&gt;aliases&lt;/a&gt; where defined and which where currently available on my machine. I cleaned the aliases and resourced again the profile for bash, now &lt;code&gt;which pg_ctl&lt;/code&gt; gave me the correct directory, I can start the postgres server.&lt;/p&gt;

&lt;p&gt;The moment of truth, running &lt;code&gt;rake db:setup&lt;/code&gt; again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ActiveRecord::NoDatabaseError: FATAL:  role "postgres" does not exist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It was an error, but I had never been happier to see one. I dug again how to &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-use-roles-and-manage-grant-permissions-in-postgresql-on-a-vps--2"&gt;create a role&lt;/a&gt; within postgres. &lt;/p&gt;

&lt;p&gt;I issued &lt;code&gt;psql&lt;/code&gt; to check the current roles and users available, but&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;psql: FATAL:  database "molli" does not exist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I proceeded to &lt;a href="https://tomcam.github.io/postgres/#creating-a-database"&gt;create the db from the command line&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I had no idea which password my &lt;code&gt;molli&lt;/code&gt; user has, so I proceeded to look for &lt;a href="https://stackoverflow.com/a/28643961"&gt;how to reset user password&lt;/a&gt; in postgres and set a new one.&lt;/p&gt;

&lt;p&gt;I finally was able to create the role for postgres with the same privileges as my main one.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;db:setup&lt;/code&gt; works! &lt;code&gt;db:test:prepare&lt;/code&gt; works!&lt;/p&gt;

&lt;p&gt;8:50AM, time to go to work... I might finally be able to code.&lt;/p&gt;

</description>
      <category>hacktoberfest</category>
      <category>yakshaving</category>
      <category>shell</category>
      <category>postgres</category>
    </item>
    <item>
      <title>Yak Shaving My Way To Hacktoberfest - Day 1</title>
      <dc:creator>Monica </dc:creator>
      <pubDate>Tue, 08 Oct 2019 20:09:51 +0000</pubDate>
      <link>https://dev.to/nirnaeth/yak-shaving-my-way-to-hacktoberfest-day-1-1mkd</link>
      <guid>https://dev.to/nirnaeth/yak-shaving-my-way-to-hacktoberfest-day-1-1mkd</guid>
      <description>&lt;h4&gt;
  
  
  &lt;em&gt;On how I tried to get back to coding and all the things I learned along the way&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;Since more than a year now I’ve been promoted to a lead position. In my current company, this implies much more focus on people management and high level conversations around company priorities and goals than coding, or anything too technical for that matter.&lt;/p&gt;

&lt;p&gt;In order to not see my hard skills go more rusty than they are already at the moment, and because I’d like to contribute more to open source, I thought doing something for Hacktoberfest.&lt;/p&gt;

&lt;p&gt;So, two nights ago I opened my old and faithful personal MacBook Pro 2016, I evaded Netflix suggesting to keep watching the next episode of Star Trek TNG (yes, I’m rewatching all Star Trek in sequential order), went to &lt;a href="https://up-for-grabs.net"&gt;up-for-grabs.net&lt;/a&gt; and found an &lt;a href="https://gitlab.com/gitlab-org/gitlab/issues/7792"&gt;issue on the Gitlab repo&lt;/a&gt; I believe I can tackle in a reasonable amount of time.&lt;/p&gt;

&lt;p&gt;I fired iTerm and cloned the repo, ran &lt;code&gt;bundle&lt;/code&gt; and here starts the adventure: I had an old version of ruby, 2.4.9 (yes, I haven't updated in that long) and therefore unable to bundle much because Gitlab develop branch is currently running on 2.6.3. Fair enough, let's install 2.6.3. rbenv had no idea what I'm talking about, so I ran diligently &lt;code&gt;brew update &amp;amp;&amp;amp; brew upgrade ruby-build&lt;/code&gt; as suggested by rbenv itself.&lt;/p&gt;

&lt;p&gt;This was going to take a while, so I went again to up-for-grab.net and find a &lt;a href="https://github.com/diaspora/diaspora/issues/7442"&gt;second candidate issue on diaspora&lt;/a&gt;. Diaspora is not so up to date with ruby, but its &lt;code&gt;.ruby-version&lt;/code&gt; is asking for ruby 2.4 that... well, I kinda have since my rbenv instance has all ruby version from 2.4.0 till 2.4.9. Unable to make it work, because it's kind of impossible to get anything meaningful if you search for &lt;code&gt;.ruby-version version ruby&lt;/code&gt; on DuckDuckGo, I decided to just change the version to a compatible one on the file itself, and god help me. I ran &lt;code&gt;bundle&lt;/code&gt; and, magically, the console starts working its way through the Gemfile.&lt;/p&gt;

&lt;p&gt;All the while, many, many formulas afterwards, I installed 2.6.3. on the Gitlab repo directory. &lt;code&gt;bundle&lt;/code&gt; launched in the second terminal window, I waited. And waited. And waited.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR: Could not find a valid gem 'rails' (&amp;gt;= 0), here is why:
Unable to download data from https://rubygems.org/ - timed out
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The status page for RubyGems was telling me everything was cool, so I kept searching. StackOverflow suggested it was a DNS issue. After a &lt;code&gt;ping&lt;/code&gt; on RubyGems that returns a nice &lt;code&gt;unknown host: https://rubygems.org&lt;/code&gt;, I realized that, nice, too many people are trying to do something good for open source, and we are collectively DDoSing RubyGems. &lt;/p&gt;

&lt;p&gt;The bundle on the Diaspora repo directory also failed with the same error. I launched bundle in both windows again. It worked. Until it didn't work. The Gitlab bundling complained about a couple of gems, nothing that a quick check on DuckDuckGo and a &lt;code&gt;brew&lt;/code&gt;command couldn't help with. Same for diaspora. Keep going, keep going.&lt;/p&gt;

&lt;p&gt;I hit the very first wall on the Gitlab bundling, where while trying to install &lt;a href="https://github.com/ruby-prof/ruby-prof"&gt;&lt;code&gt;ruby-prof&lt;/code&gt;&lt;/a&gt;, I get the error&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;warning: implicit declaration of function 'clock_gettime'
error: 'CLOCK_REALTIME' undeclared (first use in this function)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;StackOverflow told me it's a problem of standard, the function is not available in &lt;a href="https://en.wikipedia.org/wiki/C99"&gt;C99&lt;/a&gt; - and that is the dialect my version of XCode developer tools &lt;a href="https://stackoverflow.com/questions/5313684/whats-the-term-ansi-c-specifies-if-it-used-with-gnu89-c89-gnu99-c99"&gt;currently supports&lt;/a&gt; - but &lt;a href="https://stackoverflow.com/a/13070009"&gt;it is available&lt;/a&gt; in &lt;a href="https://en.wikipedia.org/wiki/POSIX"&gt;POSIX&lt;/a&gt;, MacOS is POSIX-compatible, so I should add a declaration to set a specific flag in the code I'm running, before &lt;code&gt;time.h&lt;/code&gt; is called. O..kay, I guess?&lt;/p&gt;

&lt;p&gt;I open the gem, I add the declaration, but of course running &lt;code&gt;bundle&lt;/code&gt; again overwrites the content of the gem, deleting my changes. Dead end.&lt;/p&gt;

&lt;p&gt;In the mean time, Diaspora has stopped bundling for an error on another gem, fix that with another round of &lt;code&gt;brew install&lt;/code&gt;. The bundle completed. &lt;/p&gt;

&lt;p&gt;I run the specs out of habits, realized I am still missing the database.  After running &lt;code&gt;rake db:setup&lt;/code&gt;, bundle complained that it couldn't find the postgres gem. &lt;br&gt;
I found &lt;a href="https://github.com/diaspora/diaspora/blob/develop/Gemfile#L74"&gt;it's indeed in the Gemfile&lt;/a&gt;, but it's under the &lt;code&gt;:postgres&lt;/code&gt; group and it's optional. You can &lt;a href="https://bundler.io/guides/groups.html#optional-groups"&gt;run&lt;/a&gt; bundle with a &lt;code&gt;--with :&amp;lt;group_label&amp;gt;&lt;/code&gt; flag.&lt;br&gt;
Running bundle this time installed the &lt;a href="https://bitbucket.org/ged/ruby-pg/wiki/Home"&gt;&lt;code&gt;pg&lt;/code&gt; gem&lt;/a&gt;, but when attempting to run &lt;code&gt;db:setup&lt;/code&gt; again&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (fe80::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
/Users/molli/.rbenv/versions/2.4.9/bin/bundle:23:in `load'
/Users/molli/.rbenv/versions/2.4.9/bin/bundle:23:in `&amp;lt;main&amp;gt;'
Tasks: TOP =&amp;gt; db:setup =&amp;gt; db:schema:load_if_ruby =&amp;gt; db:create
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I ran my &lt;code&gt;pgstart&lt;/code&gt; shortcut. Command not found. I don't have it here, only on the laptop at work (&lt;a href="https://gist.github.com/nirnaeth/9a0a55990cb14d018707f7e1ea55a2bb#file-bashrc-L19"&gt;for the curious&lt;/a&gt;). I have postgres installed with homebrew, so I ran&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew services start postgresql
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;as stated in &lt;a href="https://wiki.postgresql.org/wiki/Homebrew"&gt;the PostgreSQL Wiki&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The service started, but running &lt;code&gt;db:setup&lt;/code&gt; gave me the same error. I had a vague recollection of installing PostGreSQL standalone at work, so I removed postgres from the formulas and installed &lt;a href="https://www.postgresql.org/download/macosx/"&gt;PostGreSQL standalone&lt;/a&gt;. While I was moving the app to the Application folder, I noticed a big forbidden sign on the icon. I hovered. The version is incompatible with my MacOS El Capitan (yes, I know).&lt;/p&gt;

&lt;p&gt;I could have installed an older version, but this was getting far more complicated than I wanted and somewhat ridiculous, and I might need to keep yak shaving until the end of October.&lt;/p&gt;

&lt;p&gt;The dreaded time had come. I needed to bit the bullet. I took the decision to upgrade the OS. This meant that I needed to do a backup first, because god knows when was the last time. I plug the HD with Time Machine in and launched it. Almost 6GB. It took its sweet time, since my last backup was August 2019. Quite impressive, if you think I only watched Netflix on this laptop since then. It is quite inconvenient to have to plug in the external drive every time I want to back up, so I went and &lt;a href="https://www.amazon.it/dp/B074DXNT7T/ref=cm_sw_r_cp_api_i_e16MDbXXFP999"&gt;started looking&lt;/a&gt; for &lt;a href="https://www.amazon.it/WDBVBZ0000NCH-EESN-Network-Attached-Storage-Diskless/dp/B01BIGST2U"&gt;a NAS&lt;/a&gt; that I can use with Time Machine. I realize I know nothing of NASes (teh-eh), but having one connected to Internet makes me uneasy regarding my data. I make &lt;a href="https://duckduckgo.com/?q=privacy+safe+wifi+nas+mac&amp;amp;t=ffab&amp;amp;atb=v70-1"&gt;some&lt;/a&gt; &lt;a href="https://duckduckgo.com/?q=wifi+time+machine+hard+disk+no+network&amp;amp;t=ffab&amp;amp;atb=v70-1"&gt;more&lt;/a&gt; &lt;a href="https://appleinsider.com/articles/18/05/10/nas-roundup-best-network-attached-storage-options-for-mac-iphone-and-ipad-users"&gt;researches&lt;/a&gt;. The backup being finally over, I could leave this problem for the future.&lt;/p&gt;

&lt;p&gt;The App Store presented me with Mac OS Catalina, all new and shiny. I launched the install. 1 hour. Kill me now. I came back straight from work at 7.30PM to do some coding, and here I was at 11PM, still waiting to even write a single line of it.&lt;/p&gt;

&lt;p&gt;I kept digging into the NAS thingy, since I didn't had anything better to do. I found that I can indeed take some measures to avoid people looking around my stuff, and that apparently &lt;a href="https://www.cloudwards.net/nas-security-guide/"&gt;Synology is very nice&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;At 12PM, the Mac told me it was time to install, I hit "Go", but the installer didn't like I had only a couple of GB available. I launched &lt;a href="https://www.omnigroup.com/more"&gt;OmniDiskSweeper&lt;/a&gt;, waited for it to find that I had 12GB to spare in the MobileSync folder if I would &lt;a href="https://discussions.apple.com/thread/8040253"&gt;delete an old iPhone&lt;/a&gt; backup. I killed the backup. The installer happily abode and restarted my laptop for the actual installation. 1AM, time to go to bed.&lt;/p&gt;

</description>
      <category>hacktoberfest</category>
      <category>shell</category>
      <category>macos</category>
      <category>yakshaving</category>
    </item>
  </channel>
</rss>
