<?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: Glen Connolly</title>
    <description>The latest articles on Forem by Glen Connolly (@connollyglen93).</description>
    <link>https://forem.com/connollyglen93</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%2F58531%2F92d25153-c896-48aa-8969-5e6b4a1c17f1.jpg</url>
      <title>Forem: Glen Connolly</title>
      <link>https://forem.com/connollyglen93</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/connollyglen93"/>
    <language>en</language>
    <item>
      <title>Cat Login Detection</title>
      <dc:creator>Glen Connolly</dc:creator>
      <pubDate>Mon, 20 Jul 2020 08:33:33 +0000</pubDate>
      <link>https://forem.com/connollyglen93/cat-login-detection-4caa</link>
      <guid>https://forem.com/connollyglen93/cat-login-detection-4caa</guid>
      <description>&lt;p&gt;I was taking a quick break from work last week when my cat predictably took up napping position on my keyboard. When I looked at the monitor I noticed she had tried to login, and a question dawned on me: &lt;br&gt;
&lt;i&gt;In an age where we use machine learning to detect changes in the inflection in a voice and process hundreds of thousandths of images in seconds, why do we not tell the user that their cat is trying to login to the application they're using and impersonate them? &lt;/i&gt;&lt;/p&gt;

&lt;p&gt;OK maybe that's not what the cat is doing, but either way it seemed like a great opportunity for an easter egg.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZNyYSWYV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l9o0hs1ofif6ibfvik9x.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZNyYSWYV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l9o0hs1ofif6ibfvik9x.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Maybe not the smartest detection setup, but assuming the user is not using software to allow for non-blocking key input detection, I decided counting the characters provided and searching for a character which was entered more than 'X' amount of times would suffice. The aim here was to detect whether a cat is sitting on the keyboard, so sophistication was never a priority here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private function catInputDetected($s)
{
        return max(array_count_values(str_split($s))) &amp;gt; self::CAT_THRESHOLD;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And can you guess what self::CAT_THRESHOLD is?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const CAT_THRESHOLD = 9; //9 Lives
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;All that was left was to run this check against the username and password, and inform the user that their cat has no boundaries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if($this-&amp;gt;catInputDetected($username) || $this-&amp;gt;catInputDetected($password))
{
    throw new \LengthException(
        "
          It would appear your cat has attempted to log in. 
          Please remove your cat from the workspace and try again.
        "
        );
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xvMbxug1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k4k7rtly9rm4rdc494vu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xvMbxug1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k4k7rtly9rm4rdc494vu.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cat</category>
      <category>php</category>
      <category>security</category>
      <category>showandtell</category>
    </item>
    <item>
      <title>Solving the Fibonacci Sequence</title>
      <dc:creator>Glen Connolly</dc:creator>
      <pubDate>Wed, 08 Jul 2020 20:16:32 +0000</pubDate>
      <link>https://forem.com/connollyglen93/solving-the-fibonacci-sequence-52j8</link>
      <guid>https://forem.com/connollyglen93/solving-the-fibonacci-sequence-52j8</guid>
      <description>&lt;p&gt;I started Jon Calhoun's &lt;a href="https://algorithmswithgo.com/" rel="noopener noreferrer"&gt;Algorithms With Go&lt;/a&gt; course this week, and I have to say it's very enjoyable. I don't know whether it's the course content or getting my hands dirty writing Go Code but it really is a great course.&lt;/p&gt;

&lt;p&gt;Anyhoo - One of the algorithms included in the course is the calculation of the Fibonacci sequence.&lt;/p&gt;

&lt;p&gt;The Fibonacci sequence is defined as &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%2Fwikimedia.org%2Fapi%2Frest_v1%2Fmedia%2Fmath%2Frender%2Fsvg%2F0fff1a1716fcc169546079870357f92757ade5fa" 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%2Fwikimedia.org%2Fapi%2Frest_v1%2Fmedia%2Fmath%2Frender%2Fsvg%2F0fff1a1716fcc169546079870357f92757ade5fa"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;p&gt;F(n) = F(n-1) + F(n-2)&lt;/p&gt;

&lt;p&gt;I wrote the following solution (here's one I made earlier), but it's bothering me because I &lt;strong&gt;feel&lt;/strong&gt; like it could be written in even less lines of code. Anyone care to try? &lt;br&gt;
I'm not expecting Go, feel free to write it in any language you see fit, I'm just curious how compact the solution to a challenge like this can be. What better community to ask than the dev.to community?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func Fibonacci(n int) int {
    if n &amp;lt; 1 {
        return 0
    }
    if n &amp;lt; 3 {
        return 1
    }
    return Fibonacci(n-1) + Fibonacci(n-2)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>go</category>
      <category>algorithms</category>
      <category>challenge</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
