<?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 Susanna Kosonen on Medium]]></title>
        <description><![CDATA[Stories by Susanna Kosonen on Medium]]></description>
        <link>https://medium.com/@susannakosonen?source=rss-c3c85074cd51------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Y9O2LXv5xpRUUvfTDYUHHQ.png</url>
            <title>Stories by Susanna Kosonen on Medium</title>
            <link>https://medium.com/@susannakosonen?source=rss-c3c85074cd51------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 11:26:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@susannakosonen/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[Coding a chatbot builder platform, Part 1: How to make a dumb chatbot]]></title>
            <link>https://medium.com/@susannakosonen/coding-a-chatbot-builder-platform-part-1-how-to-make-a-dumb-chatbot-605be5e84dca?source=rss-c3c85074cd51------2</link>
            <guid isPermaLink="false">https://medium.com/p/605be5e84dca</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[Susanna Kosonen]]></dc:creator>
            <pubDate>Thu, 06 Sep 2018 03:03:35 GMT</pubDate>
            <atom:updated>2018-09-21T13:56:39.062Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How I approached the challenge of programmatically creating “conversations”.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*__L6p-BkdylS90g1" /><figcaption>“blue plastic robot toy” by <a href="https://unsplash.com/@rocknrollmonkey?utm_source=medium&amp;utm_medium=referral">Rock&#39;n Roll Monkey</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Last week I decided to build a bot builder application. The goal was (and still is, as the project will be ready next week) to make an app that serves as a platform for users of all levels to build simple chatbots and host them on my site. In this two-part blog post I’ll cover my process and some valuable sources for building a platform for bots — first stupid ones, then, feature by feature, smarter ones. (When I write stupid, I don’t mean lame or bad. My chatbots are cool, but they’re far from intelligent)</p><h3>What makes a minimum viable chatbot?</h3><p>In all simplicity, <a href="https://apps.worldwritable.com/tutorials/chatbot/">finding the right response to a message is going through as many as possible checks before eventually offering the fallback answer</a>: “I don’t understand”. I decided to take this approach to build my chatbot. That way I can keep on adding more layers of “does the message match this piece of the stuff my bot knows” to my minimum adequate chatbot. Here were my initial goals:</p><ol><li>Users can script their own dialogues. A user can add “triggers”, meaning words or sentences, that their bot will respond to. They’ll be able to specify an array of different responses, as many as they like. If the bot is able to match a received message to it’s triggers, it will choose a random response. This forms the “scripts” of each bot.</li><li>Bots will be able to offer general scripts (such as greetings and answers to common questions) and fallback “I don’t understand” responses if the user chooses to include them</li><li>Bots should be decent at understanding what the user is telling them, even if it’s not an exact match to known triggers.</li></ol><p><a href="https://chatbotslife.com/ultimate-guide-to-leveraging-nlp-machine-learning-for-you-chatbot-531ff2dd870c">These characteristics make my bots “retrieval-based”, as this excellent article describes</a>. Retrieval-based conversational models are easier to implement, as they use a repository of predefined responses and some rules to choose them. The other option would have been to build chatbots that are able to generate their own responses, but that approach would have been much more time-consuming and prone to grammatical errors. It would have been unclear to me how to offer users the chance to script these bots with their custom input.</p><h3>Building the bot builder</h3><p>The simple goals translated well to actual incremental technical features. The scripting platform, which I implemented with React, is basically a dynamic form that grows and shrinks by user’s choosing. There’s no limit to how many triggers or responses you can add. At scripting phase, users can test out their bots and then save them once they’re pleased with their scripts. They’ll be able to edit the bot, chat with it, or share a link to anyone to chat with the bot, as it’s hosted on my site. Every message the bot receives, is sent to my Ruby on Rails backend, where a matching process tries to find the right response and sends it to the front-end (user).</p><p>At this stage, I had already implemented some simple string “cleaning”, like removing non-alphabetic characters and whitespace, but the bots were miserable at understanding other than very exact matches. They said to “I don’t understand” a lot, and this wasn’t a great user experience. It really highlighted the fact <a href="https://apps.worldwritable.com/tutorials/chatbot/">how difficult it is to mimic even simple human dialogue programmatically</a>.</p><p>After choosing the base logic that all my bots should implement, I set to scripting default triggers and responses. On the frontend bot-scripting platform, users could opt-in on small default scripts, such as greetings, goodbyes, easy questions (e.g. “how are you?”) and existential questions ( e.g. “what are you?”). The bots got slightly less stupid after this simple addition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*I--ar2KNxefKHpwJ9QH0hA.png" /><figcaption>Simple default scripts</figcaption></figure><h3>Fuzzy string matching for the win</h3><p>The final step for my dumb bot maker was to implement “fuzzy string matching”. <a href="https://github.com/kiyoka/fuzzy-string-match">There’s an amazing ruby gem and library for that</a>. Instead of comparing whether string1 == string2, fuzzy string match calculates the distance between two strings. The gem uses the the <a href="https://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance">Jaro-Winkler distance algorithm</a> to return a value between 0 and 1 to represent similarity between the strings. 1 means the words are the same, 0 means they’re not similar at all. I set my bots’ default match threshold to 0.8, because that seemed to get past typos or extra filler words while not fully missing meaningful differences. Initialising a comparison instance was easy (fuzzy_match = FuzzyStringMatch::JaroWinkler.create(:native) ) and so was using it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*QiOK8u7MpWiui3pLLFzfTg.png" /><figcaption>Using the gem “fuzzy-string-match” after initialising it.</figcaption></figure><p>My final “find the right response to this message”-method includes all of these three checks. I made some rules to prioritise the responses, in case some user message would match more than one trigger. At this point, these rules simply manifest in the order of my matching method.</p><p>1) matches to user’s scripts</p><p>2) default script matches</p><p>3) find clues from previous conversation (not yet implemented)</p><p>The three basic features together took the bots to a quite adequate level. I was happy to see my bots weren’t too bothered by typos, knew to prioritise user’s scripts, and knew to offer default answers to some common messages. I have experimented with basic and beginner friendly machine learning implementations to add extra understanding to my bot builder, which I will document for the next part of this blog post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=605be5e84dca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build a speech recognising app with JavaScript]]></title>
            <link>https://medium.com/@susannakosonen/how-to-build-a-speech-recognising-app-with-javascript-1d5e5ba2c2c9?source=rss-c3c85074cd51------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d5e5ba2c2c9</guid>
            <category><![CDATA[webapi]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[speech-recognition]]></category>
            <category><![CDATA[vanillajs]]></category>
            <dc:creator><![CDATA[Susanna Kosonen]]></dc:creator>
            <pubDate>Thu, 23 Aug 2018 17:23:36 GMT</pubDate>
            <atom:updated>2018-08-23T17:23:36.498Z</atom:updated>
            <content:encoded><![CDATA[<p><em>With a single javascript file, I was able to make my tiny web app transform speech to text.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*MmSNqamGi46p4XRAHX1Fww.png" /><figcaption>Goal: start and stop speech-to-text transcribing on command and respond to colors by changing background.</figcaption></figure><p><a href="https://developer.mozilla.org/en-US/docs/Web/API">Web APIs</a> are great, and it has been exciting exploring the possibilities they offer for your budding web applications. Location, for example, is a quite common and useful! But I think my favourite one of them is the speech recognition.</p><p>My discovery into this technology happened through the amazing and free <a href="https://javascript30.com/">javascript30</a> course by <strong>Wes Bos</strong>. Here is my version of a simple speech recognition app that starts and stops on button click, and changes color based on your commands.</p><h3>To get started, you’ll need</h3><ol><li>Javascript. Just vanilla JavaScript will do!</li><li>HTML. A simple HTML template will do, but you’ll need a container / DOM element to append your speech-to-text results to.</li><li>A package.json file. Speech recognition will not run if you’re not running a server. Simple node backend will do!</li><li>Optional: CSS</li></ol><p>You can git clone <a href="https://github.com/sxkosone/speech-and-color-recognition">my repo</a> to get all the files, or follow along and code from scratch!</p><p>First thing to note is that speech recognition needs a server to run on! It won’t work if you’re just opening HTML files on your browser, even when they’re linked to your valid JavaScript. Add the following code and file to your root folder.</p><pre>//speech-and-color-recognition/package.json<br>{</pre><pre>  &quot;name&quot;: &quot;gum&quot;,</pre><pre>  &quot;version&quot;: &quot;1.0.0&quot;,</pre><pre>  &quot;description&quot;: &quot;&quot;,</pre><pre>  &quot;main&quot;: &quot;speech_recognition.js&quot;,</pre><pre>  &quot;scripts&quot;: {</pre><pre>    &quot;start&quot;: &quot;browser-sync start --directory --server --files \&quot;*.css, *.html, *.js\&quot;&quot;</pre><pre>  },</pre><pre>  &quot;author&quot;: &quot;&quot;,</pre><pre>  &quot;license&quot;: &quot;ISC&quot;,</pre><pre>  &quot;devDependencies&quot;: {</pre><pre>    &quot;browser-sync&quot;: &quot;^2.12.5 &lt;2.23.2&quot;</pre><pre>  }</pre><pre>}</pre><p>Run npm install and then npm start when you’re finally ready to start your web app.</p><p>Make a simple HTML file to actually display your speech-to-text results. Here’s just the body from the HTML file. Notice I have some inline JS in the start button.</p><pre>//speech-and-color-recognition/speech_recognition.html</pre><pre>&lt;body&gt;</pre><pre>  &lt;h1&gt;Speech recognition&lt;/h1&gt;</pre><pre>  &lt;p&gt;&lt;em&gt;Hint: try saying a color name&lt;/em&gt;&lt;/p&gt;</pre><pre>  &lt;h1&gt;</pre><pre>    &lt;button onclick=&quot;startRecording()&quot;&gt;Start recording&lt;/button&gt;</pre><pre>    &lt;button id=&quot;stop&quot;&gt;Stop recording&lt;/button&gt;</pre><pre>  &lt;/h1&gt;</pre><pre>  &lt;div class=&quot;words-container&quot;&gt;&lt;/div&gt;</pre><pre>  &lt;script src=&quot;speech_recognition.js&quot;&gt;&lt;/script&gt;</pre><pre>&lt;/body&gt;</pre><p>Now for the fun part. Writing code for speech recognition can be split into three sections: The <em>initialisation</em>, <em>listening to and grabbing the results</em> and finally <em>doing something with those results</em>: like writing them to your page or recognising certain keywords. The full code for my speech_recognition.js is at the end of this blog.</p><h3>Initialisation: Make your own instance of SpeechRecognition</h3><p>Add this following code to your main javascript file</p><pre>window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;</pre><pre>const recognition = new SpeechRecognition();</pre><pre>recognition.interimResults = true; //show results even before finalised</pre><h3>Listen and write</h3><p>Now that you have your new recognition object, you can access some handy event listeners and methods through it! We’ll be listening for “results”, i.e. adding an event listener on an event called “results”. Each time we get a result from our speech recognition object, we want to do something with it. Our actual text, however, is quite nested inside another object called SpeechRecognitionResultList!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*s8tEE3g1TJngzyFBY1gPKQ.png" /><figcaption>Console logging the event target from every “result” event of my speech recognition.</figcaption></figure><p>Now that we know that the text is always inside a certain chain of keys and values, we can grab it and add it to a string that will eventually hold all the text results. That string should be put inside our text paragraph.</p><pre>recognition.addEventListener(&quot;result&quot;, e =&gt; {</pre><pre>  console.log(e.results) //testing purposes!</pre><pre>  const transcript = Array.from(e.results).map(result =&gt; result[0]).map(result =&gt; result.transcript).join(&quot;&quot;)</pre><pre>  p.innerText = transcript</pre><p>If you look at one SpeechRecognitionResultList, you can also see it has a key called isFinal . This holds a boolean value telling us whether speech recognition has determined this result to be the “final” result, such as when the person takes a break or finishes a sentence. We’ll use that boolean to be able to make paragraphs.</p><pre>//...continuation of previous function...<br>  if (e.results[0].isFinal) {</pre><pre>   p = document.createElement(&quot;p&quot;)</pre><pre>   words.appendChild(p)</pre><pre>}</pre><p>At this point, you’ll have a working program! Just call recognition.start() somewhere in your program or console, and you’ll be able to start the recognition! (<em>It will actually stop as soon as it receives a final result, but we’ll fix that in a bit.</em>)</p><p>Okay, here’s the final functionality to make your voice recognition do its thing on command: start and stop buttons. Remember to add a line of code to make your recognition start listening again every time it’s done with the previous result!</p><pre>function startRecording() {</pre><pre>  recognition.start();</pre><pre>  recognition.addEventListener(&quot;end&quot;, recognition.start)</pre><pre>  document.getElementById(&quot;stop&quot;).addEventListener(&quot;click&quot;, stopRecording)</pre><pre>}<br></pre><pre>function stopRecording() {</pre><pre>  recognition.removeEventListener(&quot;end&quot;, recognition.start)</pre><pre>  recognition.stop();</pre><pre>}</pre><h3>Extra fun: color recognition</h3><p>I wanted to make my program change its background color every time it “hears” a color name. I have an array of valid CSS color names, and for each transcript I receive from my speech recognition, I need to check if any of the color names are present in that transcript. Before my actual comparison, I had to modify my CSS colors to be all lowercase. Here’s the code for that:</p><pre>let body = document.querySelector(&quot;body&quot;)</pre><pre>let cap_css_colors = [&quot;AliceBlue&quot;,&quot;AntiqueWhite&quot;,&quot;Aqua&quot;,&quot;Aquamarine&quot;,&quot;Azure&quot;,&quot;Beige&quot;,&quot;Bisque&quot;,&quot;Black&quot;,&quot;BlanchedAlmond&quot;,&quot;Blue&quot;,&quot;BlueViolet&quot;,&quot;Brown&quot;,&quot;BurlyWood&quot;,&quot;CadetBlue&quot;,&quot;Chartreuse&quot;,&quot;Chocolate&quot;,&quot;Coral&quot;,&quot;CornflowerBlue&quot;,&quot;Cornsilk&quot;,&quot;Crimson&quot;,&quot;Cyan&quot;,&quot;DarkBlue&quot;,&quot;DarkCyan&quot;,&quot;DarkGoldenRod&quot;,&quot;DarkGray&quot;,&quot;DarkGrey&quot;,&quot;DarkGreen&quot;,&quot;DarkKhaki&quot;,&quot;DarkMagenta&quot;,&quot;DarkOliveGreen&quot;,&quot;Darkorange&quot;,&quot;DarkOrchid&quot;,&quot;DarkRed&quot;,&quot;DarkSalmon&quot;,&quot;DarkSeaGreen&quot;,&quot;DarkSlateBlue&quot;,&quot;DarkSlateGray&quot;,&quot;DarkSlateGrey&quot;,&quot;DarkTurquoise&quot;,&quot;DarkViolet&quot;,&quot;DeepPink&quot;,&quot;DeepSkyBlue&quot;,&quot;DimGray&quot;,&quot;DimGrey&quot;,&quot;DodgerBlue&quot;,&quot;FireBrick&quot;,&quot;FloralWhite&quot;,&quot;ForestGreen&quot;,&quot;Fuchsia&quot;,&quot;Gainsboro&quot;,&quot;GhostWhite&quot;,&quot;Gold&quot;,&quot;GoldenRod&quot;,&quot;Gray&quot;,&quot;Grey&quot;,&quot;Green&quot;,&quot;GreenYellow&quot;,&quot;HoneyDew&quot;,&quot;HotPink&quot;,&quot;IndianRed&quot;,&quot;Indigo&quot;,&quot;Ivory&quot;,&quot;Khaki&quot;,&quot;Lavender&quot;,&quot;LavenderBlush&quot;,&quot;LawnGreen&quot;,&quot;LemonChiffon&quot;,&quot;LightBlue&quot;,&quot;LightCoral&quot;,&quot;LightCyan&quot;,&quot;LightGoldenRodYellow&quot;,&quot;LightGray&quot;,&quot;LightGrey&quot;,&quot;LightGreen&quot;,&quot;LightPink&quot;,&quot;LightSalmon&quot;,&quot;LightSeaGreen&quot;,&quot;LightSkyBlue&quot;,&quot;LightSlateGray&quot;,&quot;LightSlateGrey&quot;,&quot;LightSteelBlue&quot;,&quot;LightYellow&quot;,&quot;Lime&quot;,&quot;LimeGreen&quot;,&quot;Linen&quot;,&quot;Magenta&quot;,&quot;Maroon&quot;,&quot;MediumAquaMarine&quot;,&quot;MediumBlue&quot;,&quot;MediumOrchid&quot;,&quot;MediumPurple&quot;,&quot;MediumSeaGreen&quot;,&quot;MediumSlateBlue&quot;,&quot;MediumSpringGreen&quot;,&quot;MediumTurquoise&quot;,&quot;MediumVioletRed&quot;,&quot;MidnightBlue&quot;,&quot;MintCream&quot;,&quot;MistyRose&quot;,&quot;Moccasin&quot;,&quot;NavajoWhite&quot;,&quot;Navy&quot;,&quot;OldLace&quot;,&quot;Olive&quot;,&quot;OliveDrab&quot;,&quot;Orange&quot;,&quot;OrangeRed&quot;,&quot;Orchid&quot;,&quot;PaleGoldenRod&quot;,&quot;PaleGreen&quot;,&quot;PaleTurquoise&quot;,&quot;PaleVioletRed&quot;,&quot;PapayaWhip&quot;,&quot;PeachPuff&quot;,&quot;Peru&quot;,&quot;Pink&quot;,&quot;Plum&quot;,&quot;PowderBlue&quot;,&quot;Purple&quot;,&quot;Red&quot;,&quot;RosyBrown&quot;,&quot;RoyalBlue&quot;,&quot;SaddleBrown&quot;,&quot;Salmon&quot;,&quot;SandyBrown&quot;,&quot;SeaGreen&quot;,&quot;SeaShell&quot;,&quot;Sienna&quot;,&quot;Silver&quot;,&quot;SkyBlue&quot;,&quot;SlateBlue&quot;,&quot;SlateGray&quot;,&quot;SlateGrey&quot;,&quot;Snow&quot;,&quot;SpringGreen&quot;,&quot;SteelBlue&quot;,&quot;Tan&quot;,&quot;Teal&quot;,&quot;Thistle&quot;,&quot;Tomato&quot;,&quot;Turquoise&quot;,&quot;Violet&quot;,&quot;Wheat&quot;,&quot;White&quot;,&quot;WhiteSmoke&quot;,&quot;Yellow&quot;,&quot;YellowGreen&quot;];</pre><pre>const CSS_COLORS = cap_css_colors.map(color =&gt; {<br> return color.toLowerCase()<br>}) //change all color names to lower case, because comparison between words will be case sensitive</pre><pre>recognition.addEventListener(&quot;result&quot;, e =&gt; {</pre><pre>  //...beginning of this function is above. Color matching needs to go inside this event listener!</pre><pre>CSS_COLORS.forEach(color =&gt; {<br>  if (transcript.includes(color)) {<br>  body.style.backgroundColor = color;<br>}</pre><pre>})</pre><p>Phew! That was a lot! I hope my code structure wasn’t too confusing, but just in case, the gist that contains the whole javascript file is at the bottom of this text.</p><p>In the end we have this beautiful voice-to-speech app that you can run with the command npm start !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*MmSNqamGi46p4XRAHX1Fww.png" /><figcaption>Speech recognition will start and stop transcribing on command AND change color if it hears one!</figcaption></figure><p>The downside is that it’s not the best at actually recognising speech yet…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*_2mGiBiCnjzsjSeAaCko5A.png" /><figcaption>Not quite what I was talking about with my friend.</figcaption></figure><p>Anyway, here’s the full code! Have fun!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7b394bfb2f27440c3de1b300a6d540ab/href">https://medium.com/media/7b394bfb2f27440c3de1b300a6d540ab/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d5e5ba2c2c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Everything you wanted and didn’t want to know about arrow functions in JavaScript]]></title>
            <link>https://medium.com/@susannakosonen/everything-you-wanted-and-didnt-want-to-know-about-arrow-functions-in-javascript-89c2a826ccc0?source=rss-c3c85074cd51------2</link>
            <guid isPermaLink="false">https://medium.com/p/89c2a826ccc0</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[arrow-functions]]></category>
            <dc:creator><![CDATA[Susanna Kosonen]]></dc:creator>
            <pubDate>Thu, 09 Aug 2018 19:08:40 GMT</pubDate>
            <atom:updated>2018-09-22T03:48:36.121Z</atom:updated>
            <content:encoded><![CDATA[<p>Here’s how arrow functions came to be, and why you should embrace them sooner rather than later. This blog assumes you already know what arrow functions are, but haven’t started using them all over the place yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Kp4Er8Eo8XkA1afD" /><figcaption>“yellow Awesome-printed signage” by <a href="https://unsplash.com/@jontyson?utm_source=medium&amp;utm_medium=referral">Jon Tyson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>ES6 standardised the Arrow functions into JavaScript</h3><p>Arrow functions were introduced in the 6th Edition of the ECMAScript standard (ES6), which was released in 2015. In a developer survey that very same year, arrow functions were already reported as one of the most used features of ES6!</p><p>(<em>Here’s a side note, in case you’re curious about what ECMAScript refers to. </em><a href="https://codeburst.io/javascript-wtf-is-es6-es8-es-2017-ecmascript-dca859e4821c"><em>ECMAScript is the standard on which JavaScript build on</em></a><em>. JavaScript is currently the most popular implementation of ECMAScript, although not the only one. ECMA is the “</em><a href="http://www.ecma-international.org/memento/history.htm"><em>European association for standardizing information and communication systems</em></a><em>”. The abbreviation comes from its old name, European Computer Manufacturers Association. They’re located in Geneva, Switzerland.</em>)</p><p>Back to arrow functions. Who can we thank for bringing them to JavaScript? Turns out it’s this person called <strong>Jason Orendorff</strong>, who kindly identifies himself in an excellent <a href="https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functions/">in-depth blog about JS arrow functions</a>.</p><blockquote>ES6 arrow functions were implemented in Firefox by me, back in 2013. Jan de Mooij made them fast. Thanks to Tooru Fujisawa and ziyunfei for patches.</blockquote><h3>Arrow functions in Callback functions</h3><p>Event handlers most often involve callback functions, eg. passing a function into another function as an object. Arrow functions make great one-liner, short functions. Implicit return, which means that you don’t have to explicitly type out “return”, makes arrow functions even easier on the eyes.</p><p>Consider functions as event handlers — you want to pass the function object, <em>not</em> invoke it. You also want to pass some parameters. Unfortunately you cannot do this:</p><pre>myElement.addEventListener(&quot;click&quot;, someFunction(parameters)) <br>// this will invoke the function, not pass the function as an //object!</pre><p>Arrow functions will solve this by providing an easy wrap.</p><pre>myElement.addEventListener(&quot;click&quot;, () =&gt; someFunction(parameters))<br>//you&#39;re passing it a function within a function, thus avoiding //invoking your original function while passing parameters</pre><h3>Arrow functions in binding this to the enclosing value</h3><p>Arrow functions were introduced to also fix the this problem: Sometimes you want the function to hold on to the this it had upon definition (the enclosing scope), not grab a new this from where you’re invoking the function. Non-arrow functions always get a this from the surrounding execution context, whether you want it or not. This is not ideal in event handlers, setTimeouts or setIntervals, where you define the function at first, but want to invoke it later, in another context.</p><p>Consider this case of two employee objects, both of which will start getting a raise every second from the moment they’re created. NormalEmployee object will not have a working getRaise function, as it has a this that refers to the callback function, not the employee object! Meanwhile, our arrow function will work.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Frepl.it%2Frepls%2FLemonchiffonEnergeticFeed%3Flite%3Dtrue&amp;url=https%3A%2F%2Frepl.it%2Frepls%2FLemonchiffonEnergeticFeed%3Flite%3Dtrue&amp;image=https%3A%2F%2Frepl.it%2Fpublic%2Fimages%2Freplit-logo-800x600.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=repl" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ecad1230b89d04dd5716946c5a7689a/href">https://medium.com/media/2ecad1230b89d04dd5716946c5a7689a/href</a></iframe><p>It’s good to keep in mind that <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">arrow functions do not have their own </a><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">this </a>at all. More about that at the end of this blog.</p><h3>This all combined: React</h3><p>Arrow functions come very handy in React, where the bound this and short syntax are put to good use. In React, when you want to pass information from child component to its parent, you use callback functions. These callback functions are passed as props to the child and invoked in the child component, but may need to change the state of the parent component. The following handleClick will correctly toggle the state of the parent component, even though it is passed on as props to another context, a child component!</p><pre>class ParentComponent extends React.Component {<br>  constructor() {<br>    super()<br>    this.state = { clicked: false }</pre><pre>  }</pre><pre>  <br>  handleClick = () =&gt; {<br>   const newValue = !this.state.clicked    <br>   this.setState({ clicked: newValue });<br>  }<br><br>  render() {<br>    return (<br>      &lt;ChildComponent onClick={this.handleClick} text=&quot;Click me!&quot;/&gt;<br>    );<br>  }<br>}</pre><p>Remember: if you want to pass arguments to your handleClick callback function, you can always wrap it in another arrow function inside the curly braces!</p><pre>&lt;ChildComponent onClick={() =&gt; this.handleClick(argument1, argument2)} text=&quot;Click me!&quot;/&gt;</pre><h3>Quick warnings about when not to use arrow functions</h3><p>There are some use cases where you’re better off without arrow functions. You cannot use them as constructors, due to their dependency on the declarative context (surrounding scope). Can’t call new, or super(). Arrow functions might not be very useful as object methods either, since you want the function to receive this from the new surrounding context!</p><blockquote><a href="https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functions/">Use non-arrow functions for methods that will be called using the </a><a href="https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functions/">object.method() syntax</a>. Those are the functions that will receive a <em>meaningful</em> this value from their caller.</blockquote><p>Also, be careful with curly braces in your arrow functions. Can you tell the difference between this object literal {} and this code block {}? Well, neither can the JavaScript engine! If you want to use object literal inside your arrow function, you have to wrap it in a parenthesis. Otherwise it will be interpreted as an expression and will error out.</p><pre>const newPersonnel = oldPersonnel.map(employee =&gt; {//some new employee obj}) //will not work!</pre><pre>const newPersonnel2 = oldPersonnel.map(employee =&gt; ({//some new employee obj})) //will work!</pre><p>By using methods and arrow functions for everything else, you may avoid having to type the word “function” 99% of your coding time!</p><h3>That other JS arrow function you didn’t know about</h3><p>I was very surprised to find out that the arrow function isn’t actually the only arrow function around in JavaScript. Take a look at this pretty loop!</p><pre>let x = 5<br>while(x--&gt;0) {console.log(“countdown”, x)}</pre><pre>/////this will work and produce the following logs<br>//LOG:countdown 4<br>//LOG:countdown 3<br>//LOG:countdown 2<br>//LOG:countdown 1<br>//LOG:countdown 0</pre><p>How does it work? <a href="https://stackoverflow.com/questions/1642028/what-is-the-operator-in-c">Magic</a>!*</p><p>*It’s just the same thing as writing while( (x--) &gt; 0) { //do something } .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89c2a826ccc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 useful terminal commands and how to launch them from your ruby program]]></title>
            <link>https://medium.com/@susannakosonen/5-useful-terminal-commands-and-how-to-launch-them-from-your-ruby-program-ee8470898da4?source=rss-c3c85074cd51------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee8470898da4</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Susanna Kosonen]]></dc:creator>
            <pubDate>Thu, 26 Jul 2018 20:03:15 GMT</pubDate>
            <atom:updated>2018-07-26T20:03:15.333Z</atom:updated>
            <content:encoded><![CDATA[<p>Here are some terminal commands I recently learnt. They’ve proven quite useful (or just entertaining) on my Mac.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a8AHjrcOLZotxmP3" /><figcaption>Pic by <a href="https://unsplash.com/@alexandruz?utm_source=medium&amp;utm_medium=referral">Alexandru Zdrobău</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Cat</h3><p>Displays the content of your file. <a href="https://searchdatacenter.techtarget.com/answer/What-can-you-do-with-the-cat-command">You can pass it flags</a> (extra specifications, usually take the form of a dash, followed by a letter or two) for some more functionality. Like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*8jqqkRAEmsHLih74mAF22Q.png" /></figure><p>The flag -n added line numbering to my terminal output. You can use this, or any other terminal command in your Ruby program by wrapping it in backticks. This returns the output of running that same command in the shell. You can also wrap your commands in %x( cat -n README.md ) or %x{ see_previous }These are methods that that belong to the Ruby Kernel module, which is included in the Ruby Object class. Because of this, you’ll have access to them in every Ruby object. You can save the result of your terminal command in a variable for later use.</p><h3>Kill</h3><p>This command terminates your running processes. In case you’ve ever been wondering what on earth is slowing your computer down so much. This is how to do task manager in your terminal. But before we can terminate, we must find. Run <strong>ps -ax </strong>to list all running processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*NOme6eQkyC9NublarxIU1Q.png" /></figure><p>It might return quite a long list. If you want to only list processes that match your search terms, runps -ax | grep YOUR_SEARCH_TERM. I’ve done this to hunt down my running rails programs.</p><p>I’m interested in the PID, Process ID. Pass the PID of the process you want to terminate to your kill command: kill 64776 . You can also pass your kill command <strong>-9</strong> as a flag, which will force the process to terminate immediately: kill -9 64776. <a href="https://en.wikipedia.org/wiki/Signal_(IPC)#List_of_signals">Why number 9? No particular reason, it’s random</a>.</p><h3>Date</h3><p>Typing in this command returns the current date, time and timezone. That seems simple enough, so I won’t get deeper into it.</p><h3>Ping</h3><p>Ping will help you determine if a certain site is up and running. Run ping, followed by the website url address (or IP address) and you’ll “ping” it endlessly until your cancel the process with ctrl+c. If you want it to ping the site only <em>n </em>times, pass it the flag of -c, followed by the <em>n</em>. Like this: ping -c 10 whitehouse.gov . Might become more useful if you have your own websites or web applications running, and you need to verify if they’re up.</p><h3>History</h3><p>Type just history to list out the terminal commands you used before. This is very useful when you can’t remember the exact command, but you know you used it. Again, add a helpful grep filter to only list the commands that match your search word: history | grep YOUR_SEARCH_WORDS .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee8470898da4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Ruby’s #cycle to create surprisingly useful looping arrays]]></title>
            <link>https://medium.com/@susannakosonen/using-rubys-cycle-to-create-surprisingly-useful-looping-arrays-79348d640927?source=rss-c3c85074cd51------2</link>
            <guid isPermaLink="false">https://medium.com/p/79348d640927</guid>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Susanna Kosonen]]></dc:creator>
            <pubDate>Thu, 05 Jul 2018 14:47:00 GMT</pubDate>
            <atom:updated>2018-07-05T14:47:00.459Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I’ll describe how to create loops from arrays using two Ruby methods: #cycle and #next. These may come in handy if you want to iterate over arrays on item at a time, and just hop back to the beginning once you reach the end.</p><h3>Array#cycle</h3><p><a href="https://ruby-doc.org/core-2.2.0/Array.html#method-i-cycle">Cycle is a Ruby method for Arrays</a>. If given integer <em>n</em>, it will loop the array <em>n</em> times. Given a block, will repeat that block for each item of array <em>n</em> times. However, if no <em>n</em> and no block are given, it will return an <a href="https://ruby-doc.org/core-2.2.0/Enumerator.html">Enumerator</a> object, which is what I’ll be operating on.</p><p>Enumerator objects are used to iterate over arrays, but you usually may not notice that because it oftentimes still returns an array, either the original one or a modified one. <strong>But when you call #cycle (or some other iteration method, like #map or #each) on an array without passing it a code block, it will return an Enumerator object. </strong>This way you can use Enumerators to create these “loopy arrays”, for example.</p><p>Let’s say you want to always get the next value of your array, and if you’re at the end, you want to loop back to the beginning. How would you normally do this? Maybe you’d have a counter and you’d check at every iteration, whether your counter is ≥ the length of your array, and then set the counter back to zero.</p><p>However, <strong>#cycle</strong> and <strong>#next</strong> <em>(which gives you the next value of your Enumerator)</em> are neat methods for this type of iteration. You can also call <strong>#peek</strong> on an Enumerator, and (not surprisingly) just peek at the next value, without iterating to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i0SB1OIrEADlFwTtEvttAA.png" /></figure><h3>First example: #cycle and #next in a Vigènere encryption</h3><p>One fun coding task is writing a method for the Vigenère encryption. You may already know the simpler Caesar cipher. Given a key (a number), it will shift each letter in the plaintext that many steps forward in the alphabet. Given a key of 2, letter “a” would become “c”. The Vigenère cipher is more complex, and takes in a word as a key. Each letter of the keyword is translated to it’s index in the alphabet. Index of “a” is 0, “b” is 1 and so forth.</p><blockquote>If Vigenère himself wanted to say HELLO to someone confidentially, using a keyword of, say, ABC, he would encrypt the H with a key of 0 (i.e., A), the E with a key of 1 (i.e., B), and the first L with a key of 2 (i.e., C), at which point he’d be out of letters in the keyword, and so he’d reuse (part of) it to encrypt the second L with a key of 0 (i.e., A) again, and the O with a key of 1 (i.e., B) again. And so he’d write HELLO as HFNLP. <a href="https://docs.cs50.net/problems/vigenere/vigenere.html">Source: CS50</a></blockquote><p>In Vigenère, the keyword is looped to match the length of the plaintext. For example, the iterating and looping of the keyword can be accomplished by calling #cycle and #next! Here’s a method for encrypting and decrypting:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XfU_tEAziCu1CFR-duAvTw.png" /></figure><p><strong>Fun fact:</strong> <a href="https://www.simonsingh.net/The_Black_Chamber/vigenere_cracking.html">Created in the 16th century, the Vigenère encryption was considered unbreakable</a>, until about 200 years later a guy named Charles Babbage found a way to break. <a href="https://en.wikipedia.org/wiki/Charles_Babbage">He’s also the person who came up with the idea of a digital programmable computer</a>. Programmers are cool.</p><h3>Second example: #cycle and #next to create a color wheel</h3><p>Imagine this: you want a rad color spectrum on your new website. You’ll need to iterate through an array of colors, always choosing the next one and starting from the beginning once you run out of colors. Below is the code I added in my <em>model</em>, <em>controller</em> and <em>view</em> to be able to use the color wheel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7DVlfYxbRfJpFWoYmkLg6Q.png" /></figure><p>I pass a looping color wheel to my view page, and for each post title, I call on the next color of that wheel. The result looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*VeyqBRaNuLWbzEdWyWdInA.png" /><figcaption>Gorgeous and not at all distracting background spectrum</figcaption></figure><h3>Third example: light switch</h3><p><a href="http://www.rubyguides.com/2017/10/7-powerful-ruby-methods/">I liked this one a lot</a>. Imagine you have a switch or a button with two possible values: on/off, active/inactive, etc. You want to be able to toggle the value without having to check for the current value: whatever it is, you just want to change it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*xE-g715zsIAmp979gMb2fg.png" /></figure><p>Happy looping! You’ll never have to pluck another flower again!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79348d640927" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get started with data analysis using Ruby and APIs]]></title>
            <link>https://medium.com/@susannakosonen/get-started-with-data-analysis-using-ruby-and-apis-35f81d09587c?source=rss-c3c85074cd51------2</link>
            <guid isPermaLink="false">https://medium.com/p/35f81d09587c</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[open-data]]></category>
            <dc:creator><![CDATA[Susanna Kosonen]]></dc:creator>
            <pubDate>Thu, 21 Jun 2018 17:55:49 GMT</pubDate>
            <atom:updated>2018-06-21T17:55:49.660Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*97-bLG3WIpLolaHV" /><figcaption>Photo by <a href="https://unsplash.com/@adigold1?utm_source=medium&amp;utm_medium=referral">Adi Goldstein</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve been interested in working with open data for several years now, but only last week I learned how to wrangle it on my own. I wish I wouldn’t have waited so long. Collecting, analysing, and visualising big amounts of data can be challenging, but getting started isn’t. If you’ve fiddled around with Ruby programming language a little bit, and know your hashes, this tutorial will be perfect for you!</p><p>In this post, I’ll describe how to download and sort public datasets with a few lines of Ruby programming language, some useful Ruby gems, and just one URL address (of your choosing). You’ll need to have your <strong>Ruby development environment</strong> set up, a <strong>code editor </strong>(I’m using VS Code) and the <strong>Ruby gem bundler</strong>. You can find <a href="https://cloud.google.com/ruby/docs/setup">installation instructions here</a>.</p><h3>Locate your data (and grab the URL)</h3><p>Let’s get started by finding our URL. We will simply access the API by adding this URL address to our code. API stands for <em>Application Programming Interface</em>, and it refers to data or functionalities that institutions and companies open up for anyone to use. In our example, we’ll be retrieving open data through an API endpoint. That’s the URL address where our program will send a request to get the information.</p><p>For my project, I was interested in open data from the city of Washington, DC. They make a lot of it available on their site, but I decided to choose this dataset about crime incidents in the last 30 days. On the API explorer tab I could get the “query URL”. I’ll be looking only at crime incidents in the first police district, to narrow my dataset down a bit. The site displays my search URL, which looks like this: <a href="https://maps2.dcgis.dc.gov/dcgis/rest/services/FEEDS/MPD/MapServer/8/query?where=1%3D1&amp;outFields=*&amp;returnGeometry=false&amp;orderByFields=district&amp;outSR=4326&amp;f=json">https://maps2.dcgis.dc.gov/dcgis/rest/services/FEEDS/MPD/MapServer/8/query?where=1%3D1&amp;outFields=*&amp;returnGeometry=false&amp;orderByFields=district&amp;outSR=4326&amp;f=json</a></p><p>This URL may look long and cryptic, but it also contains readable information about your output choices, such as:</p><ul><li>&amp;returnGeometry=false <em>(I didn’t want to include geometry)</em></li><li>&amp;orderByFields=district <em>(Order by “district” field, ascending)</em></li></ul><p>(I’m sorting them by district and only grabbing the first district, so I can narrow my dataset down to about 500 crime incidents.)</p><p>Anyway, if you click on the URL, you’ll be taken to an ugly looking page. That’s unformatted JSON data. Despite it’s appearance, JSON is pretty awesome, because it’s “understandable” in almost all coding languages. Our Ruby program will be able to read and manipulate it. I use a <a href="https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa?hl=en">Chrome extension for my JSON formatting</a>, so my JSON objects usually look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*ViNgrnZTZggMVWIF09xjcg.png" /><figcaption>Formatted JSON (JavaScript Object Notation)</figcaption></figure><p>You can see that under a key called “features”, there’s another object with a key of “attributes”. The actual data from each crime incident is nested all the way in here. If you want to find your data from another source, you should find out similarly, which key (and any keys, values or arrays inside of that) contains the information you want.</p><h3>Use Ruby gems to parse the JSON</h3><p>I used the following Ruby gems to get and translate the data to my Ruby program: <em>net/http</em>, <em>open-uri</em> and <em>json</em>. You should require these to the top of your code file (see snippet below). Remember to run `bundle install` on your terminal to get these gems. The following code will use these three gems to get the URL address, send an HTTP request to retrieve that data, and parse it to JSON for your program to use.</p><p>Your essential code is 5 lines long, and now you have all of the data you need saved in variable incidents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2dcd38a107acc76f80e5d815afd1eef/href">https://medium.com/media/d2dcd38a107acc76f80e5d815afd1eef/href</a></iframe><h3>Refine your data object</h3><p>Now that you have a big or a huge hash saved, you can query it with iterations and other Ruby methods! Side note: some APIs, like the one I’m using, return records only up to a certain limit. I’m interested in the first 500 or so records, but it’s important to know that my API request is limited to 1000 records.</p><p>I know from looking at my JSON object that all of my crime incidents are in a key called “features”. I can retrieve an array of hashes by calling incidents[&quot;features”]. Looking at the hash structure, it appears that my final data hash is inside yet another hash, with the key [&quot;attributes&quot;] .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*7fBXnim9Qsy-mJ7aW_anug.png" /><figcaption>Part of an object that contains data for an individual crime incident in District 1. I can access the data with my_object[“features”][index_number_for_that_case][“attributes”]</figcaption></figure><p>I wanted to look at crime in Police District 1 of DC, so I should iterate over my initial data hash and select only the ones where the value of key &quot;DISTRICT&quot;==”1&quot; . Like this:</p><p>incidents_D1 = incidents[&quot;features&quot;].select{|incident| incident[&quot;attributes&quot;][&quot;DISTRICT&quot;]==&quot;1&quot;}</p><p>That returns an array of hashes with a length of 509, which should be approximately how many reported crime incidents there have been in the first police district of Washington DC in the last 30 days.</p><p>One more (extra)thing. I still have a somewhat nested hash, where the actual data hash is a value inside another hash, behind the key of &quot;attributes&quot; . I don’t like that, so I want to iterate over my array of hashes and assign the actual data hash as it’s own first level hash inside my array. I just want to get rid of the middleman (-key).</p><p>just_incidents_D1 = incidents_D1.collect {|incident_hash| incident_hash[&quot;attributes&quot;]}</p><h3>Asking questions from your data object</h3><p>Now I have a hash I can easily query! For example, how many of these incidents were described as thefts? Actually, how many occurrences were there of each separate offence? I’ll just grab all the offence descriptions to a new array, because I might want to ask more questions on this topic.</p><p>offences = just_incidents_D1.collect{|incident|incident[&quot;OFFENSE&quot;]}.sort</p><p>Let’s do a wonderful iteration method that counts the occurrence of each unique value in array, and returns that as a new hash: #each_with_object</p><p>offences_count = offences.each_with_object(Hash.new(0)){|offence, hash| hash[offence] += 1}</p><p>Now we have a new hash, offences_count , which contains all of our offences as keys and their frequency as values.</p><pre>=&gt; {&quot;THEFT/OTHER&quot;=&gt;297, &quot;MOTOR VEHICLE THEFT&quot;=&gt;32, &quot;THEFT F/AUTO&quot;=&gt;134, &quot;ASSAULT W/DANGEROUS WEAPON&quot;=&gt;13, &quot;ROBBERY&quot;=&gt;32, &quot;BURGLARY&quot;=&gt;10, &quot;SEX ABUSE&quot;=&gt;4, &quot;HOMICIDE&quot;=&gt;3}</pre><p>The final code for this whole tutorial looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b7911505f99e72b8bd6ad3d23e5b75ee/href">https://medium.com/media/b7911505f99e72b8bd6ad3d23e5b75ee/href</a></iframe><p>I added a final line of code to output my hash as a list. Now I can easily see that there were…</p><pre>297 theft/others<br>32 motor vehicle thefts<br>134 theft f/autos<br>13 assault w/dangerous weapons<br>32 robberys<br>10 burglarys<br>4 sex abuses<br>3 homicides</pre><p>…in the first police district of Washington, DC. By mostly iterating through the API data I retrieved, I can now find out interesting facts about crime in DC.</p><p>Thanks for reading, and happy API coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35f81d09587c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>