<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sean Dever on Medium]]></title>
        <description><![CDATA[Stories by Sean Dever on Medium]]></description>
        <link>https://medium.com/@sdever?source=rss-857272877aab------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8EfE6WTs05FrA3i5qL9Eaw.jpeg</url>
            <title>Stories by Sean Dever on Medium</title>
            <link>https://medium.com/@sdever?source=rss-857272877aab------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 14:14:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sdever/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Importing Local Packages in Go]]></title>
            <link>https://sdever.medium.com/importing-local-packages-in-go-57d23c8a932d?source=rss-857272877aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/57d23c8a932d</guid>
            <dc:creator><![CDATA[Sean Dever]]></dc:creator>
            <pubDate>Sun, 27 Dec 2020 04:06:16 GMT</pubDate>
            <atom:updated>2020-12-27T04:06:16.547Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w2oOJEUlgblPMIx9" /><figcaption>Photo by <a href="https://unsplash.com/@mattseymour?utm_source=medium&amp;utm_medium=referral">Matt Seymour</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We all know that with go, we need a “main.go” file to execute in order to run our application. And though we can hold everything within a main.go file, as our app gets larger in size and more functions are made things could get really messy really fast. As good developers, we want to have clean, easy to read code and we want to separate our concerns and abstract the functions, and organize them into different groups.</p><p>If you’ve ever used any of the other built-in Go packages like “fmt” you’re already halfway there!</p><pre>package main</pre><pre>import &quot;fmt&quot;</pre><pre>func main() {<br> fmt.Println(&quot;Hello, world&quot;)<br>}</pre><p>When importing local packages, however, there are some rules we need to abide by:</p><ol><li>For the functions, structs, variables, or other types of data we’re exporting, the first letter must be capitalized.</li><li>You must have the correct path to the file you’re importing</li></ol><p>Here is an example of an application structure</p><pre>application-name<br>├── Example<br>|  |──example.go<br>|<br>└── main.go</pre><p>example.go:</p><pre>package example</pre><pre>import &quot;fmt&quot;</pre><pre>var Message string = &quot;An apple a day will keep the doctor away&quot;</pre><pre>type User struct {<br> name string<br> age int32<br> location string<br>}</pre><pre>func SayHello(str string) {<br> fmt.Println(&quot;Hello, %v!!&quot;, str)<br>}</pre><p>main.go</p><pre>package main</pre><pre>import (<br> Example &quot;app-name/Example&quot; <br> &quot;fmt&quot;<br>)</pre><pre>func main() { <br> fmt.Println(Example.Message)<br> Example.SayHello(&quot;User&quot;) <br> fmt.Println(Example.User{name: &quot;NewUser&quot;, age: 25, location: &quot;The World&quot;}</pre><p>Hopes this helps to organize your projects! Happy Hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57d23c8a932d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Speech Recognition in React]]></title>
            <link>https://sdever.medium.com/speech-recognition-in-react-a5e36d32ea03?source=rss-857272877aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5e36d32ea03</guid>
            <dc:creator><![CDATA[Sean Dever]]></dc:creator>
            <pubDate>Mon, 21 Dec 2020 05:30:26 GMT</pubDate>
            <atom:updated>2020-12-21T05:30:26.064Z</atom:updated>
            <content:encoded><![CDATA[<p>Speech recognition is when a user is able to speak into their computer’s microphone, the speech gets processed into something the readble for the computers on the other end. The servers on the other end then return the interpreted speech into text! Now before I go any further I do want to bring up the fact that this API is not available on all browsers. Check <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API">here</a> if you browser is compatible. Though you can utilize the Web Speech API on it’s own, the react-speech-recognition package is going to make life a lot easier for us for how easy the syntax is.</p><h3>Getting Started</h3><p>Let’s create first initiate our app using the command create-react-app to build the scaffold for our application.</p><pre>npx create-react-app speech-recognition</pre><p>Once that is done building, we’re going to get rid of the boilerplate code it provides so in our App.js we’re just left with a barebones functional component</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c19edd07844bb05d01bbc418acb7ed12/href">https://medium.com/media/c19edd07844bb05d01bbc418acb7ed12/href</a></iframe><h3>Implimenting Speech Recognition</h3><p>Next we want to build a separate component that will handle the speech recognition. But before we do that let’s go and add our package that will set us up for that.</p><pre>npm install --save react-speech-recognition</pre><pre>or</pre><pre>yarn add react-speech-recognition</pre><p>Once that package has been added we’ll create a file named SpeechToText.js. We’ll import our package, what this package provides top us is a hook useSpeechRecognition() that provides us a bunch of functions to work with. for this example we’re just going to need the transcript and reset transcript functions from that hook. The transcript function is going to be the function that collects the speech and returns that speech to text, and the resetTranscript function will clear out our current transcript. For our application we’ll want to initiate the voice recognition once the component is mounted. So we will be adding a useEffect hook to start the speech recognition. The speech recognition on it’s own will stop once the user pauses speaking so there is a parameter we can set that we can set to have it continuously listen until. Then of course when we unmount the component we need to clean up our voice recognition so it doesn’t continuously run causing memory leaks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54a90ddf81b2d31148129d209a30fbaf/href">https://medium.com/media/54a90ddf81b2d31148129d209a30fbaf/href</a></iframe><h3>Displaying the Results of the Speech Recognition</h3><p>Now that we have our speech recognition set up, we’re going to need to display the results somewhere on the component. In this example let’s create a form that when submitted will give us an alert that will give us a pop up with the results of the transcript and the function to submit the form which we’ll call handleSubmit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97720def0548162bb2c520855380ed70/href">https://medium.com/media/97720def0548162bb2c520855380ed70/href</a></iframe><p>All that is left to do is import our SpeechToText.js component into our App.js and we’re all good to go!</p><p>Result:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Finspiring-banach-og0y7%3Ffontsize%3D14%26hidenavigation%3D1%26theme%3Ddark&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Finspiring-banach-og0y7%3Ffontsize%3D14%26hidenavigation%3D1%26theme%3Ddark&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fog0y7%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/a74aced5a96543a58fe3a0330008b225/href">https://medium.com/media/a74aced5a96543a58fe3a0330008b225/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5e36d32ea03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pointers in the Go Programming Language(golang)]]></title>
            <link>https://sdever.medium.com/pointers-in-the-go-programming-language-golang-56a9ee1976dd?source=rss-857272877aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/56a9ee1976dd</guid>
            <dc:creator><![CDATA[Sean Dever]]></dc:creator>
            <pubDate>Sun, 13 Dec 2020 04:42:54 GMT</pubDate>
            <atom:updated>2020-12-13T04:42:54.026Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vzcrmyxaCH74j2ie" /><figcaption>Photo by <a href="https://unsplash.com/@jannerboy62?utm_source=medium&amp;utm_medium=referral">Nick Fewings</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Like many other programming languages, there are two ways in which we can pass data in Go. You can either pass by value where Go will make a literal copy of the data you want to use(this uses more memory because it is making a copy of the data) or you can pass by reference where you are referring to the address in memory in which the data itself is stored rather than making a copy of the original data. When you pass by reference any changes made to the data effect where it is originally stored as they’re both pointing to the same address in memory.</p><h3>Syntax for Pointers</h3><p>When we want to point to certain elements there are two characters we use when using pointers. There is the “*” operator which declares that it will be a pointer to an address in memory. Then we have the “&amp;” operator which will refer to the address of the original variable. Here is a very basic example of how we would go about using pointers:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/81101f09663f3ed9227a02019ade2938/href">https://medium.com/media/81101f09663f3ed9227a02019ade2938/href</a></iframe><p>Notice how the output for the j variable is giving us “0xc000016158” instead of 11. Why is that? It’s because we are assigning j to point to the address in memory where “i” is so that string of characters are actually it’s place in memory. If we wanted to extract the value from that address in memory, we would use the dereferencing operator which also happens to use this character: “*”. So to fix our previous example</p><pre>var i int = 11<br>var j *int = &amp;i</pre><pre>fmt.Println(i)<br>fmt.Println(*j) //dereferencing operator placed before the variable</pre><pre>//Output:<br>11<br>11</pre><p>One thing to remember about pointers and to be careful of is that <strong>any changes made to the originating variable will also affect the any other variables that point to that variable.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/025b08e956280f49341f53446a57f253/href">https://medium.com/media/025b08e956280f49341f53446a57f253/href</a></iframe><h3><strong>Pointers as a Datatype</strong></h3><p>Pointers are a great use case when you’re dealing with structs. In the example below we are creating a struct that holds contains a number attribute and name attribute. You’ll be able to see how we use pointers to create new instances of the struct and see how we use the “new” syntax.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/682129738c3247eeaef9d91bc365ac4a/href">https://medium.com/media/682129738c3247eeaef9d91bc365ac4a/href</a></iframe><p>This is just a brief introduction into pointers, as you use them for projects and play around with them you can really see for yourself how great of a tool they are!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56a9ee1976dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sliding Window Algorithm Approach(Go example)]]></title>
            <link>https://sdever.medium.com/sliding-window-algorithm-approach-go-example-9df848c76077?source=rss-857272877aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/9df848c76077</guid>
            <dc:creator><![CDATA[Sean Dever]]></dc:creator>
            <pubDate>Mon, 07 Dec 2020 03:02:46 GMT</pubDate>
            <atom:updated>2020-12-07T03:02:46.998Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KlWGdwcNqVI5xs7k" /><figcaption>Photo by <a href="https://unsplash.com/@seabas?utm_source=medium&amp;utm_medium=referral">Sebastian Staines</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Why use the Sliding Window?</h3><p>Nowadays, brute force quadratic time(O(N²)) solutions consisting of nested for loops just don’t cut it. The Sliding Window method is a great alternative to some brute force solutions. It typically of linear time(O(N)) complexity, and with space complexity of 0(1). If you are unfamiliar with time and space complexities check out <a href="https://medium.com/u/f68e8e1bdbb9">Colton Kaiser</a>’s articles on them <a href="https://levelup.gitconnected.com/big-o-time-complexity-what-it-is-and-why-it-matters-for-your-code-6c08dd97ad59">here</a>.</p><h3>What is the sliding window?</h3><p>How we go about creating a sliding window utilizes pointers. We would get an array, assign the first pointer to one index signifying where the window starts, and the second pointer to another index signifying where the window ends. Between those two points gives us subsets of data we can work with, we can shift these points over to access other points within the array and create a new subset of data to check. just like how a window slides over, so does our subset of data. Hence the name Sliding Window! Here is an example question where we could make good use of the sliding window:</p><pre>Given an array of integers and a number, write a function which finds the maximum sum of a subarray with the length of the number passed to the function. If</pre><pre>ex:<br>maxSubarraySum([]int{1, 1, 2, 4, 2, 3, 5, 1}, 4) //14<br>maxSubarraySum([]int{100, 200, 300, 400}, 2) //700<br>maxSubarraySum([]int{}, 2) //0</pre><p>Before we write any code, let&#39;s plan out the steps we want to take to come to a solution.</p><ol><li>Write a check for the edge case if the array’s length is smaller than the subarray’s length. If it is then we return 0.</li><li>Assign a variable that will hold the highest sum(we’ll call it maxSum)</li><li>Assign a variable that will hold the sum of the current subarray we’re looking at. (we’ll call this tempSum)</li><li>Create a loop that will Loop through 1 time to get the sum of the first set of numbers</li><li>Set maxSum to equal the sum of our first loop and assign the tempSum to equal the current maxSum.</li><li>Loop through the length of the whole array starting from the index of the next number after the first set.</li><li>To get the sum of this set, instead of iterating we get the current tempSum move down the number of indexes equal to n, subtract that number, then add the number of the current loops index and assign that to be our new tempSum</li><li>Compare the new tempSum and the current maxSum, whichever of the two is larger is the new maxSum, and continue until the loop is finished.</li></ol><p>Now that we have a plan in place let’s write it out!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d030ae136fef46b40785012b77aedb58/href">https://medium.com/media/d030ae136fef46b40785012b77aedb58/href</a></iframe><h3>When should I use the Sliding Window?</h3><p>Sliding Window won’t solve every problem but there are a lot of use cases for sliding window. Some good indicators that you might want to use the sliding window method are if it’s asking for the longest of shortest sequence, things involving a subarray like the example above, problems involving arrays and strings that you need to iterate through.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9df848c76077" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frequency Counter Algorithm Pattern(Go Example)]]></title>
            <link>https://sdever.medium.com/frequency-counter-algorithm-pattern-go-example-835a108ccdfa?source=rss-857272877aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/835a108ccdfa</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[patterns]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Sean Dever]]></dc:creator>
            <pubDate>Sun, 29 Nov 2020 03:07:08 GMT</pubDate>
            <atom:updated>2020-11-29T03:20:17.656Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*z7QlExVHvoZr6Q3yPpAP_g.jpeg" /><figcaption>Image from <a href="https://www.shutterstock.com/">Shutterstock</a></figcaption></figure><h3>Why should we use it?</h3><p>There are many different ways to approach solving problems. However usually, the most obvious ones aren’t the optimal solution. An example would be using nested loops. We call this the brute force method or the naive approach, and the reason these aren’t optimal solutions is that they are very slow. These solutions run at quadratic time(<strong>O(n²)</strong> Time complexity). The frequency counter pattern looks to give us a solution that is usually a lot faster(Typically at Linear Time; <strong>O(n) </strong>Time Complexity<strong>).</strong></p><h3>How does it work?</h3><p>How the frequency pattern works is you would get a collection of data and store them within objects or maps with the key being the element we’re keeping track of and the value being the number of occurrences we run into that element. With this data, we can do things like comparing two arrays or finding the first duplicate, and many other common problems you may run into.</p><h3>Example</h3><p>Here is an example question where using the frequency counter pattern might be a good approach!</p><pre>Given two strings, write a function to determine if the second string is an anagram of the first. If it is an anagram return true, if not return false.</pre><pre>ex: <br>validAnagram(“helloworld”, “oowldlrhle”) //true<br>validAnagram(“racecar”, “racekar”) //false</pre><p>Before we write out any code, let&#39;s plan out the steps we should take to come to a viable solution.</p><ol><li>Create a check to see if the strings are of the same length, if they are not we know it’s not an anagram and we should return false.</li><li>Split both of the strings, so we can get an array of letters that composes the string.</li><li>Initiate an empty map that we’ll use to store our characters in the first array.</li><li>Iterate through each letter of the first string and place them in the map with the key being the character and value being the number of occurrences</li><li>Iterate through the second string and lookup to see if the map contains all the letters within the second string, If there are any that do not exist within the map, return false.</li><li>Otherwise, return true because the number of occurrences for each letter within the second string matches up with the ones in the first string.</li></ol><p>Now that we have a solid plan, now let’s write out some code!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d6cad31abd15128c15b189a347f5be3/href">https://medium.com/media/3d6cad31abd15128c15b189a347f5be3/href</a></iframe><p>Hope this helped in understanding use cases for this pattern and why would want to take this approach to solve algorithms. As always Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=835a108ccdfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What are Go Structs? (golang)]]></title>
            <link>https://sdever.medium.com/what-are-go-structs-golang-1c26cb74edfe?source=rss-857272877aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c26cb74edfe</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <dc:creator><![CDATA[Sean Dever]]></dc:creator>
            <pubDate>Sun, 22 Nov 2020 05:13:50 GMT</pubDate>
            <atom:updated>2020-11-22T05:13:50.151Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*u0Gi7FHyVwi4kSFbrEgV7g.png" /></figure><p>Most programming languages typically follow one of two styles, Functional programming(software construction by creating pure functions) or Object-oriented programming(a class-based structure working primarily with objects). Go is a multi-paradigm programming language which means that it’s a language capable of doing both. But Go does not have classes so how could we do anything object-orient related? Go has <strong>Structs </strong>that function a lot like classes in other languages.</p><h3>Creating a Struct</h3><p>To initiate a struct we use the keyword type, the name you wish to call the struct, the keyword struct accompanied by some curly braces.</p><pre>type Superhero struct {<br> firstName string<br> lastName  string<br> planet    string<br> age       int<br> powers    []string<br>}</pre><p>In the example above, we are creating a Superhero struct and within it lies attributes a superhero could have accompanied by the datatype allowed for that attribute. So now that we’ve set up our struct, let&#39;s create our first instance of a superhero.</p><pre>wonderWoman := Superhero{<br> firstName: &quot;Diana&quot;,<br> lastName:  &quot;Prince&quot;,<br> planet:    &quot;Earth-Two&quot;,<br> age:       800,<br> powers: []string{<br>  &quot;Super Strength&quot;,<br>  &quot;Telepathy&quot;,<br>  &quot;Astral Projection&quot;,<br> },<br>}</pre><p>Simple as that! Now if we wanted to access specific pieces of data within the superhero we would use the “.” operator.</p><pre>fmt.Println(wonderWoman.firstName) //Diana</pre><pre>fmt.Println(WonderWoman.powers[1]) //Telepathy</pre><h3>Anonymous Struct</h3><p>That isn’t the only way we can create structs. We can create anonymous structs. We aren’t able to create these within the package level because it is a struct with no name(hence being called anonymous). So the way we would make these are within a variable.</p><pre>myDog := struct {<br> name string<br> breed string<br> age int<br>}{name: &quot;Bro&quot;, breed: &quot;Chihuahua&quot;, age: 10}</pre><p>What are the use cases for an anonymous struct? One way is: say if we only needed to create a struct where we only plan to have one instance of it. Instead of creating a struct on the package level, we can create it within a variable like the example above.</p><h3>Embedding</h3><p>Go does not use inheritance as Object-oriented programming languages do. Go does have a feature called composition through embedding which acts like inheritance.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1744fde8a63326acad14cab64a1f1743/href">https://medium.com/media/1744fde8a63326acad14cab64a1f1743/href</a></iframe><p>One other thing to point out about structs is unlike maps, structs are value types so you can assign a variable to an existing struct instance and it will not overwrite the original instance, it will create a literal copy of it. You can use the “&amp;” operator and make it a pointer if you so wish. Structs are a great tool that almost every go program uses at least one. It also allows us to use validations through the use of tags. As always thanks for reading, hope you enjoyed this one! Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c26cb74edfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic SQLite Commands]]></title>
            <link>https://sdever.medium.com/basic-sqlite-commands-8c3b011e4064?source=rss-857272877aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c3b011e4064</guid>
            <dc:creator><![CDATA[Sean Dever]]></dc:creator>
            <pubDate>Sun, 15 Nov 2020 07:01:37 GMT</pubDate>
            <atom:updated>2020-11-15T07:01:37.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hHirAlvQ9Pib5Zn4" /><figcaption>Photo by <a href="https://unsplash.com/@max_duz?utm_source=medium&amp;utm_medium=referral">Max Duzij</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Being able to work with a database is important. With SQLite we’re able to create new data tables, retrieve certain information from those tables, run queries to match certain data we want to retrieve, and much more. Here are the SQL commands that are most commonly used when working with a SQLlite database.</p><h3>Creating a table</h3><p>When creating a new table for a database, the command we use is “CREATE TABLE” followed by the name of the table and the attributes you want to include and their respective data types. It’s also important to have some form of ID in your tables and list it as a primary key</p><pre>CREATE TABLE bears (id INTEGER PRIMARY KEY, name TEXT, age INTEGER, gender TEXT, color TEXT, temperament TEXT);</pre><h3>Inserting data into a table</h3><p>To insert data into our newly created table we use “INSERT INTO” with the name of the table we’re inserting data into. Then we list the attributes of the table we want to add, followed by the keyword “VALUES” with the values of the new data you’re inserting matching the order of the attributes.</p><pre>INSERT INTO bears (id, name, age, gender, color, temperament, alive) VALUES(1,&quot;Pooh&quot;, 20, &quot;Male&quot;, &quot;dark brown&quot;, &quot;calm&quot;)</pre><h3>Adding Columns</h3><p>Let’s say that, after creating a database and creating a table to live inside that database, we decide we want to add a column. We can do so with the “ALTER TABLE” statement.</p><pre>ALTER TABLE bears ADD COLUMN alive BOOLEAN;</pre><h3>Delete a table</h3><p>Deleting a table is very simple we just simply use the “DROP TABLE” statement followed by the name of the table</p><pre>DROP TABLE bears;</pre><h3>Retrieving data from a table</h3><p>So we have data within our table now and now we want to retrieve some of that data. The “SELECT” Statement helps us do just that. We select the names of the columns we are going to select(you can use a * if you want to select all) then use the FROM keyword and pick the table we are selecting from.</p><pre>SELECT * From bears;</pre><p>But this will return us every instance from that table, if we want to be more specific on which data we want to get back we would include conditionals using the “WHERE” statement.</p><pre>SELECT * FROM bears WHERE name = &quot;Pooh&quot;;</pre><pre>SELECT * from bears WHERE age &gt; 5;</pre><h3>Updating data</h3><p>If we wanted to update, or change, data in our table rows. We do this with the “UPDATE” keyword. The Update statement uses a “WHERE” clause to grab the row you want to update. It identifies the table name you are looking in and resets the data in a particular column to a new value.</p><pre>UPDATE bears SET age = 21 WHERE name = &quot;Pooh&quot;;</pre><h3>Delete data from a table</h3><p>If we wanted to delete some data from a table we use the “DELETE” statement, the table we want to access, then the conditional to find a specific piece of data to delete</p><pre>DELETE FROM bears WHERE id = 1;</pre><h3>Ordered list</h3><p>If we wanted to retrieve data in a certain order based on certain attributes in a table we use the “ORDER BY” statement. This modifier allows us to order the table rows returned by a certain “SELECT” statement. we can use “ASC” for ascending order and “DESC” for descending order.</p><pre>SELECT * FROM bears ORDER BY age DESC;</pre><h3>Limit</h3><p>If we want to select extremes from a database table — for example, what if we only wanted the youngest or oldest bear? we can use ORDER BY in conjunction with LIMIT.</p><p>LIMIT is used to determine the number of records you want to return from a dataset.</p><pre>SELECT * FROM bears ORDER BY age DESC LIMIT 1;</pre><h3>Count</h3><p>Count is a SQL aggregate function that will count the number of records that meet a certain condition.</p><pre>SELECT COUNT(gender) FROM bears WHERE gender = &quot;Female&quot;;</pre><p>This will return us the total count of bears in our database that are female.</p><h3>Grouping data</h3><p>If we wanted to group our data based on certain column we use the “GROUP BY” statement.</p><pre>SELECT gender, COUNT(gender) FROM bears GROUP BY gender;</pre><p>This will return us a data table with a count of how many male and female bears we have.</p><p>These are some of the common SQLite commands that are used mst frequently and are good to have handy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c3b011e4064" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with Slices in Go(golang)]]></title>
            <link>https://sdever.medium.com/working-with-slices-in-go-golang-4194b78c4654?source=rss-857272877aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/4194b78c4654</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <dc:creator><![CDATA[Sean Dever]]></dc:creator>
            <pubDate>Sun, 08 Nov 2020 05:18:54 GMT</pubDate>
            <atom:updated>2020-11-08T05:18:54.609Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*loFh5EAItGvFJH69GAhigA.jpeg" /></figure><p>In other programming languages like JavaScript, slices are a function that we call that returns a shallow copy of a portion of an array into a new array. In Go, they do very much the same thing, but the syntax is a bit different. It looks just like an array but with some key differences. First off, unlike arrays that are a fixed length, a slice’s length is dynamic so to declare a slice we just leave the area within square brackets empty. We could either initiate it with some elements or use an already existing array to extract certain elements to work with.</p><pre>//Initiaing the slice to have the integers 1 ,2 3 in it.<br>mySlice := [ ]int{1, 2, 3}</pre><p>One important thing to point out is that when you are assigning different variables to a slice, any changes made to that new variable will also be made to the slice as it is not a copy of the slice, but it is pointing to the actual slice itself.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3664b331735fc8001a2db93dcb8b59d/href">https://medium.com/media/d3664b331735fc8001a2db93dcb8b59d/href</a></iframe><p>The real power of a slice comes with it’s ability to grab different elements from within an array. How we get these elements is by referencing the array, and just like how we would access a certain element in an array(ex: array[0] to get first element in array) we do the same thing but with a colon. To the left of the colon will be the index in which we want to start, and to the right of the colon will grab the elements up to that index. Check out the example below of how we’re grabbing certain elements from an array.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/891ab7891cd67f12739e8f3ad2b01855/href">https://medium.com/media/891ab7891cd67f12739e8f3ad2b01855/href</a></iframe><p>Important to note: Changing the elements of a slice <strong>modifies the corresponding elements of its underlying array. </strong>So you do need to be careful on changing elements in a slice or you may get some unwanted side-effects.</p><p>Because slices are dynamic in length, we are able to add and remove elements. If you’re coming from another programming language you may know of keywords like pop, shift, push, and unshift. Go does not use these keywords, so how we would go about applying the same functionality goes as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c76a9e7a744c7da0cc8af417272791b/href">https://medium.com/media/7c76a9e7a744c7da0cc8af417272791b/href</a></iframe><p>With slices we have a lot more power at our fingertips than we do with arrays as they’re a lot more unrestrictive, thus having more practical uses. Hope these examples helped! As always, Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4194b78c4654" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with Arrays in Go(golang)]]></title>
            <link>https://sdever.medium.com/working-with-arrays-in-go-golang-9b6738b8995c?source=rss-857272877aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b6738b8995c</guid>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[arrays]]></category>
            <dc:creator><![CDATA[Sean Dever]]></dc:creator>
            <pubDate>Sat, 31 Oct 2020 04:15:56 GMT</pubDate>
            <atom:updated>2020-10-31T04:17:12.913Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*l9JuBHzyUEtvCznsY-2Ibw.png" /></figure><p>In every programming language, there are ordered series or arrangements of elements called arrays. But Go handles arrays differently compared to some other like JavaScript or Ruby. Let us take a look at Arrays, how they’re structured, and how to write them in Go! These examples were heavily influenced by <em>Michael Van Sickle’s course posted on freecodecamp</em> and the link for the resource will be at the bottom.</p><h3>Arrays</h3><p>Go is a statically typed language elements within the array must be of the same data type. Arrays in Go must be of a fixed length meaning that if you initializing an array to have 3 elements, that means that the program is allocating that much memory to the length of that array, no more and no less. When declaring an array, we start with the square brackets with the size of the array within those brackets. It is then followed by the datatype that the array can store.</p><pre>var students = [3]string</pre><p>If you want to initialize the array with values next to the datatypes you place curly brackets with the values.</p><pre>var numbers = [3]int{27, 42, 11}</pre><p>When initiating arrays with values, you don’t need to have an index of the array within the square brackets. Instead, you can fill it with […] which means set the array length equal to the number of elements you’re initializing with.</p><pre>var animals = [...]string{&quot;Lion&quot;, &quot;Gorilla&quot;, &quot;Cat&quot;, &quot;Dog&quot;}</pre><p>If we wanted to check the length of an array Go has a function “len( )” which will return us back the length of the element you pass in.</p><pre>students := [...]string{&quot;Sean&quot;, &quot;Elaina&quot;, &quot;Clark&quot;}<br>fmt.Println(len(students)) //method used to print to console</pre><pre>//returns 3 as we have 3 elements in the array</pre><h3>Nested Arrays</h3><p>So we know now how to make an array, let’s talk about how we can make an array of arrays also known as nested arrays.</p><pre>var twoDimendionalArray[3][3]int = [3][3]int{[3]int{1, 1, 0}, [3]int{0, 1, 1}, [3]int{0, 0, 1}}</pre><p>You might be thinking “Whoa, making an array looked so simple, now there&#39;s so many 3’s and 1&#39; and 0’s. What&#39;s going on here?” let’s write this out in a different way that might be a little bit easier to read and break it down.</p><pre>/*<br>We initializing our array to contain 3 elements within the array and the arrays within that array are going to also contain 3 elements.<br>arrays are 0 indexed, meaning that they start from zero instead of starting at 1.</pre><pre>we are then assigning first element of the array to contain an array with 1, 1, 0 and following the same process with the second and third element in the array<br>*/</pre><pre>var twoDimendionalArray[3][3]int<br>twoDimendionalArray[0] = [3]int{1, 1, 0}<br>twoDimendionalArray[1] = [3]int{0, 1, 1}<br>twoDimendionalArray[2] = [3]int{0, 0, 1}</pre><p>So if we were to print this out, it would give us this result</p><pre>[<br> [1,1,0]<br> [0,1,1]<br> [0,0,1]<br>]</pre><h3>Array Pointer</h3><p>In Go arrays are considered values meaning that if we have the variable array1 store an array, and we have the variable array2 being assigned to array1. array2 is not array1 but an exact copy of array1. So since array2 is just a copy of array1 and changes that are made will not affect the other. But depending on the size of the array, this could take up a lot of memory since we are just making a whole new copy of the first array.</p><pre>array1 := int[3]{33,63,74}<br>array2 := firstArray</pre><p>Say we did want to assign a new array but have it affect the original array as well. That is where pointers come in!</p><pre>array1 := int[3]{33,63,74}<br>array2 := &amp;array1<br>array2[0] = 69</pre><pre>fmt.Println(array1)<br>fmt.Println(array2)<br>//Output:<br>/* <br> [69,63,74]<br> [69,63,74]<br>It changes both of the arrays because array2 is not pointing to array1 instead of just making a copy of array1<br>*/</pre><p>That is all the basics of arrays for now, in my next code along i’ll be going over ways we can manipulate arrays, through <strong>slices</strong>!</p><h3>Resources</h3><p><em>Learn Go Programming — Golang Tutorial for Beginners:</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FYS4e4q9oBaU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYS4e4q9oBaU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FYS4e4q9oBaU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/74b1dd978b1cfb6b90860da0523f0271/href">https://medium.com/media/74b1dd978b1cfb6b90860da0523f0271/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b6738b8995c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Variables in the Go Programming Language]]></title>
            <link>https://sdever.medium.com/variables-in-the-go-programming-language-a40a5bf39a3c?source=rss-857272877aab------2</link>
            <guid isPermaLink="false">https://medium.com/p/a40a5bf39a3c</guid>
            <category><![CDATA[variables]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[google]]></category>
            <dc:creator><![CDATA[Sean Dever]]></dc:creator>
            <pubDate>Sat, 24 Oct 2020 20:17:57 GMT</pubDate>
            <atom:updated>2020-10-31T04:38:25.667Z</atom:updated>
            <content:encoded><![CDATA[<h3>Variables in the Go Programming Language(golang)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*uQYp-XBGGjnS_Nqk6Ag5xw.jpeg" /></figure><p>Before going into how Go goes about handling its variables I want to do a brief explanation of the language and why someone would want to use the language in the first place. The Go programming language(also referred to as golang)is an open-source language that was developed at Google. The problem that Go tries to solve is that other languages at the time like C, Python, and Java had really slow compile times, and had complex type systems. Go is statically typed, has very fast compilation times, easy to read, and has garbage collection. Go is very unique with how it goes about its syntax. It’s it is taking elements from other programming languages like JavaScript, C, Python, and puts it together into an easy to read format.</p><h3>Assigning a variable</h3><p>If you’ve written in the JavaScript before this syntax will look very familiar. Go uses the “var” keyword followed by the name of the variable and the datatype associated with that variable. As is we are declaring the variable but has no value, we are telling go we are going to assign it a value at a later time.</p><pre>//Variable is declared.<br>var codingLanguage string</pre><pre>//Variable is assigned.<br>codingLanguage = &quot;GO&quot;</pre><p>This is fine but as good developers we want to have our code to look nice and clean, so we can actually just write all this in one line</p><pre>var codingLanguage string = &quot;golang&quot;</pre><p>There is also another method to assigning a variable that is even cleaner than the last one.</p><pre>number := 11</pre><p>This method of assigning a variable is using type inference. Go will assume it’s datatype based on the value it is assigned to it. There is one caveat to this, the above variable is recognized as an integer, what if we don’t want it to be an integer, but a float? Just simply add a “.” at the end and it will be recognized as a float64 datatype(note: you cannot set it as a float32 with this method so keep that in mind).</p><p>*** Note: The “:=” operator can only be used within a function, you cannot assign variables this way within the global scope.</p><h3>Block variables</h3><p>In Go you can also write a variable block, lets say I want to take down attributes for athletes. Instead of writing it like this:</p><pre>var sport string = &quot;Football&quot;<br>var position string = &quot;Quarterback&quot;<br>var playerName string = &quot;Jimmy Garoppolo&quot;<br>var playerNumber int = 10</pre><p>we can make it a bit easier to read this way and have the same functionality</p><pre>var (<br> sport string = &quot;Football&quot;<br> position string = &quot;Quarterback&quot;<br> playerName string = &quot;Jimmy Garoppolo&quot;<br> playerNumber int = 10<br>)</pre><h3>Constants</h3><p>Go also has constant variables. These variables are immutable meaning that once they are assigned, cannot be redeclared with a new value.</p><p>Ex:</p><pre>const randomFact string = &quot;Pteronophobia is the fear of feathers or being tickled by feathers&quot;</pre><pre>randomFact = &quot;Bananas are curved because they grow closer to the sun&quot;</pre><pre>//This would return an error because we&#39;ve already declared that the random fact will be and it cannot be overwritten</pre><p>with constants you may also exclude the datatype if you so wish and Go will infer the datatype based on the value assigned, just like the “:=” operator.</p><h3>Shadowing</h3><p>Shadowing pertains to scope. Shadowing is when you have a variable with in the global scope, as well as that same variable within that function’s scope. The variable within the inner-most scope will take precidence.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1db7b8ab855c1c63fa51a05762100e8/href">https://medium.com/media/b1db7b8ab855c1c63fa51a05762100e8/href</a></iframe><p>As you can see by the output the first time we print favoriteMeme we get it on the global scope level, then once it’s reassigned in the function’s scope, favoriteMeme is now Doge.</p><h3>Converting Datatypes</h3><p>You may also change the datatypes of previously assigned variables in Go.</p><p>In the example below, first we have a variable “a” assigned to an int with the value 11. We have variable “b” declared as a float32, then we are assigning b’s value to equal a but wrapped in a float32 function in order to convert a’s value to float. If we applied this same logic to converting an integer to a string, we actually don’t get the output we would expect. If we tried to convert an int to a string with the same method, it would return us the unicode character that is tied to that integer value. So in that case we would need a separate package called strconv to convert our integer to a string of the same numerical value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0fd2e9caa0dd581ab58a7e5d6e3312aa/href">https://medium.com/media/0fd2e9caa0dd581ab58a7e5d6e3312aa/href</a></iframe><p>I love the simplicity and readability of variables in the Go programming language and hope this clears some things up regarding on how to work with variables in Go!</p><p>As always, Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a40a5bf39a3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>