<?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: Bobby Bates</title>
    <description>The latest articles on Forem by Bobby Bates (@bobbybates).</description>
    <link>https://forem.com/bobbybates</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%2F845311%2F5f2e02b4-f70e-4188-a46d-4600917d930f.jpg</url>
      <title>Forem: Bobby Bates</title>
      <link>https://forem.com/bobbybates</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bobbybates"/>
    <language>en</language>
    <item>
      <title>Web Server Kill Process on Ports</title>
      <dc:creator>Bobby Bates</dc:creator>
      <pubDate>Mon, 15 Aug 2022 01:35:27 +0000</pubDate>
      <link>https://forem.com/bobbybates/web-server-kill-process-on-ports-3ej2</link>
      <guid>https://forem.com/bobbybates/web-server-kill-process-on-ports-3ej2</guid>
      <description>&lt;p&gt;Here are a few things you can do when a locally-run web server port is in use and your server won't start back up.&lt;/p&gt;

&lt;p&gt;This issue presented itself to me during Phase 3 of &lt;a href="https://flatironschool.com/courses/coding-bootcamp"&gt;Flatiron School&lt;/a&gt;: Four weeks of learning &lt;a href="https://www.ruby-lang.org/en/"&gt;Ruby&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/SQL"&gt;SQL&lt;/a&gt;, &lt;a href="https://guides.rubyonrails.org/active_record_basics.html"&gt;Active Record&lt;/a&gt;, and &lt;a href="https://github.com/sinatra/sinatra#readme"&gt;Sinatra&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/a/41429055/7931329"&gt;Live or hot reloading&lt;/a&gt; all possible things makes me happy, so I was glad to implement &lt;a href="https://github.com/alexch/rerun"&gt;rerun&lt;/a&gt; on my server immediately after learning about it. &lt;/p&gt;

&lt;p&gt;It's great fun to not manually restart a local server on every change in your program, except for this very occasional issue I've come across. This happened when I would tab out of my VS Code window (configured to autosave my app as I leave), which triggers a rerun-fueled refresh in my browser.&lt;/p&gt;

&lt;p&gt;I'd often &lt;code&gt;Command + R&lt;/code&gt; my webpage anyway to restart my user path, and with the right timing, I would get an error along the lines of &lt;code&gt;port is in use&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;My first stop on Google was &lt;a href="https://stackoverflow.com/a/32592965/7931329"&gt;this Stack Overflow page&lt;/a&gt; which gave me a two-step solution: See if any processes were listening to the port my server was on by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lsof -i:9292
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(ruby was indeed listening to that port, which meant it was blocking my server from restarting on that port), and then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kill $(lsof -t -i:9292)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to clear the way for a server restart.&lt;/p&gt;

&lt;p&gt;Soon after running into this myself, the same issue came up in class and &lt;a href="https://www.npmjs.com/package/kill-port"&gt;another solution&lt;/a&gt; was shown:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx kill-port 9292
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ruby</category>
      <category>programming</category>
      <category>beginners</category>
      <category>database</category>
    </item>
    <item>
      <title>Comparing English and Spanish Words in JavaScript</title>
      <dc:creator>Bobby Bates</dc:creator>
      <pubDate>Tue, 05 Jul 2022 02:39:10 +0000</pubDate>
      <link>https://forem.com/bobbybates/comparing-english-and-spanish-words-in-javascript-3dhb</link>
      <guid>https://forem.com/bobbybates/comparing-english-and-spanish-words-in-javascript-3dhb</guid>
      <description>&lt;p&gt;I've been working on a &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/SPA"&gt;single page web application&lt;/a&gt; using &lt;a href="https://reactjs.org/"&gt;React&lt;/a&gt;. One feature uses a &lt;code&gt;JSON&lt;/code&gt; list of Colombian cities:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;colombiaCities&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;city&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bogotá&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lat&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;4.6126&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lng&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;74.0705&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;country&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Colombia&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;iso2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CO&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;adminName&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Distrito Capital&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;capital&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;population&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;9464000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;populationProper&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;7963000&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="c1"&gt;// ...515 other cities&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A user can search for a country to get some details. Their input will be in English, with no accent marks. They could type them if they wanted to, but they choose not to. That's not very cosmopolitan of them.&lt;/p&gt;

&lt;p&gt;This user will fail to get their information with no &lt;a href="https://en.wikipedia.org/wiki/Diacritic"&gt;accent marks&lt;/a&gt; (sometimes). When the accentless string is compared to the accented string in the object above (equalizing case using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase"&gt;toLowerCase()&lt;/a&gt;), it is compared character by character. All is well until the &lt;code&gt;a&lt;/code&gt; in &lt;code&gt;Bogota&lt;/code&gt; is put up against &lt;code&gt;á&lt;/code&gt; in &lt;code&gt;Bogotá&lt;/code&gt;. They need a way to compare these words as equals.&lt;/p&gt;

&lt;p&gt;Thus began my search. I first came across the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize"&gt;&lt;code&gt;normalize()&lt;/code&gt; method&lt;/a&gt;. It looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt; &lt;span class="o"&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;parsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;normalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;NFD&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;[\u&lt;/span&gt;&lt;span class="sr"&gt;0300-&lt;/span&gt;&lt;span class="se"&gt;\u&lt;/span&gt;&lt;span class="sr"&gt;036f&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parsed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions"&gt;Regular Expressions&lt;/a&gt; still scare me off, so I moved on to the next search result: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare"&gt;localeCompare()&lt;/a&gt;. This looked more my speed, plus it's already doing the comparing I need. It looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;enStr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bogota&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;esStr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bogotá&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="nx"&gt;enStr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;localeCompare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;esStr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;es-CO&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;sensitivity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;base&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I actually looked into this term before &lt;code&gt;localeCompare()&lt;/code&gt;: Full Text Search. It's pretty heavy duty. In JavaScript, this can come in the form of a library dependency like &lt;a href="https://github.com/nextapps-de/flexsearch"&gt;FlexSearch&lt;/a&gt;. Far too bulky for the humble sorting task I have at hand.&lt;/p&gt;

&lt;p&gt;I will choose &lt;code&gt;localeCompare()&lt;/code&gt; for my word comparison and city sorting features.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is the Meaning of Life?</title>
      <dc:creator>Bobby Bates</dc:creator>
      <pubDate>Mon, 11 Apr 2022 03:55:40 +0000</pubDate>
      <link>https://forem.com/bobbybates/what-is-the-meaning-of-life-168e</link>
      <guid>https://forem.com/bobbybates/what-is-the-meaning-of-life-168e</guid>
      <description>&lt;p&gt;I was hung up on this one for a long time. After much reading of Existentialism, Stoicism, and pop-psych articles, I eventually decided that the meaning, for me anyway, lies in my day-to-day actions. If I want to live a life worth living, I need to make those actions count. By count, I mean that it must be meaning*&lt;em&gt;ful&lt;/em&gt;* to me. So what's meaningful to me?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Equal rights for all beings, human and nonhuman&lt;/li&gt;
&lt;li&gt;Human-powered transportation (i.e., walking, bicycles)&lt;/li&gt;
&lt;li&gt;Bicycle infrastructure&lt;/li&gt;
&lt;li&gt;Helping others&lt;/li&gt;
&lt;li&gt;Laughing with others&lt;/li&gt;
&lt;li&gt;Being in control of most of my time&lt;/li&gt;
&lt;li&gt;Consistent full nights of sleep (7.5 or 9 hours work best for me)&lt;/li&gt;
&lt;li&gt;Stretching my body&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm vegan, an animal rights activist, a former bike messenger, former and long-time bike commuter. I am generally successful with incorporating the other bullet points into my life. I have also pursued programming for some years now. Is that meaningful to me? Why yes, it's challenging, and I share the communal feeling among coders of delight after pushing through the dim, hopeless middle of a problem and landing on the other side with a solution.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;But it didn't make the meaningful list; what gives?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Yeah, well, it should be up there because I can spend days on end working on a project, Googling this method and that extension, truly delighting myself in building something well, and that looks good, too. Having something like that is &lt;strong&gt;superb&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;What am I on about? I'm uncovering why I'm pursuing software development. Problem-solving brings direct meaning to me, as well as the collaborative aspects of coding (after I push past the shyness, the social anxiety, and the imposter syndrome). High demand and pay for programmers come into play as well. Also, I am done beating my body up with physical labor for a paycheck; super glad to have the privilege and opportunity to change the majority of my waking hours to healthier activity.&lt;/p&gt;

&lt;p&gt;What about future meaning? This is still uncomfortably undefined at the moment. I know that I'll have refined my coding skills by the end of this Flatiron Software Development course and will be ready to start the programmer's path professionally, wherever that will take me. It'll be fully remote. Other than that, it is, and I am, wide open.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>bootcamp</category>
      <category>career</category>
      <category>meaning</category>
    </item>
  </channel>
</rss>
