<?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 Josh Cocciardi on Medium]]></title>
        <description><![CDATA[Stories by Josh Cocciardi on Medium]]></description>
        <link>https://medium.com/@jmc?source=rss-f8284782c44d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EYsdSUWg5-Nvg4yfl6iz7Q.jpeg</url>
            <title>Stories by Josh Cocciardi on Medium</title>
            <link>https://medium.com/@jmc?source=rss-f8284782c44d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 18:43:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jmc/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[Stumbling through Coding Problems: Optimizing the Cafeteria Seating Problem]]></title>
            <link>https://medium.com/@jmc/stumbling-through-coding-problems-optimizing-the-cafeteria-seating-problem-87014bd8851a?source=rss-f8284782c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/87014bd8851a</guid>
            <category><![CDATA[code-challenge]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[space-complexity]]></category>
            <category><![CDATA[time-complexity]]></category>
            <dc:creator><![CDATA[Josh Cocciardi]]></dc:creator>
            <pubDate>Wed, 23 Jul 2025 16:45:11 GMT</pubDate>
            <atom:updated>2025-07-23T16:45:11.543Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWKOwPEwfQTJpuD3PxOWCA.png" /></figure><h3>The Problem: Social Distancing in a Cafeteria</h3><p>Given a cafeteria table with N seats (numbered 1 to N), some already occupied, determine how many additional diners can be seated while maintaining social distancing. Each diner must have K empty seats on both sides.</p><p><strong>Input:</strong></p><ul><li>N: Total seats</li><li>K: Required empty seats on each side</li><li>M: Number of currently seated diners</li><li>S: Array of occupied seat positions</li></ul><p><strong>Example:</strong> N=10, K=1, M=2, S=[2,6]</p><ul><li>10 seats total, need 1 empty seat on each side</li><li>People are currently at seats 2 and 6</li><li>Expected result: 3 additional diners</li></ul><h3>My first try: Table Simulation</h3><p>My first instinct was to simulate the problem directly. I’d create an array representing the table and work through it position by position.</p><pre>def getMaxAdditionalDinersCount(N: int, K: int, M: int, S: List[int]) -&gt; int:<br>    # Create table representation<br>    table = [0] * N<br>    for seat in S:<br>        table[seat - 1] = 1  # Mark occupied seats (0-indexed)<br>    <br>    additional_diners = 0<br>    i = 0<br>    <br>    while i &lt; N:<br>        if table[i] == 1:<br>            # Skip ahead - we know next K positions are blocked<br>            i += K + 1<br>        else:<br>            if can_place_here(table, i, K, N):<br>                table[i] = 1<br>                additional_diners += 1<br>                i += K + 1  # Jump to next possible position<br>            else:<br>                i += 1  # Try next position<br>    <br>    return additional_diners<br><br>def can_place_here(table: List[int], i: int, k: int, n: int) -&gt; bool:<br>  steps = 1 <br>  while steps &lt;= k:<br>    if i+steps &gt;= n:<br>      print(&quot;outside list&quot;)<br>      break<br>    if table[i+steps] == 0:<br>      steps+=1<br>      print(f&quot;increase steps until k, {k}&quot;)<br>    else:<br>      print(f&quot;table[i+steps]=1, steps: {steps}, i: {i}&quot;)<br>      return False<br><br>  return True</pre><p>This solution worked, but I realized it had some inefficiencies. I was checking every position and validating spacing constraints repeatedly.</p><h3>Segmentation:</h3><p>While working through this, I thought, what if I could split the table into independent segments and solve each one separately?</p><p>This quickly turned into thinking about the information I was given: What indices are occupied, what are the spacing requirements, how should I split this up and why, and then do I still need to go through each segment linearly? Instead of simulating seat-by-seat placement, could I calculate the answer directly?</p><h3>AI is Amazing!</h3><p>The key realization is that for any empty segment of length L with spacing requirement K, there’s a formula for the maximum number of people you can place:</p><pre>max_people = (L + K) // (K + 1)</pre><p>But why does this work? The explanation that clicked for me was the <strong>“virtual padding”</strong> method:</p><p>Imagine adding K extra “virtual” positions at the end of your segment. Now every person (including the last) needs exactly K+1 positions (themselves + K spacing). With L + K total available positions and each person needing K + 1 positions, you get (L + K) // (K + 1) people maximum.</p><p><strong>Example:</strong> L=7, K=2</p><pre>Positions: 0 1 2 3 4 5 6 [ virtual: 0 1 2 3 4 5 6 7 8 ]<br>Optimal:   X _ _ X _ _ X [ virtual: X _ _ X _ _ X _ _ ]</pre><p>Formula: (7 + 2) // (2 + 1) = 3 people ✓</p><h3>The Three-Segment Solution</h3><p>With this mathematical insight, I restructured the problem into three segments:</p><ol><li><strong>Before the first occupied seat</strong></li><li><strong>Between consecutive occupied seats</strong></li><li><strong>After the last occupied seat</strong></li></ol><pre>def getMaxAdditionalDinersCount(N: int, K: int, M: int, S: List[int]) -&gt; int:<br>    # Edge case: no one is seated, entire table is available    <br>    if M == 0:<br>        return (N + K) // (K + 1)<br>    <br>    # Convert to 0-indexed positions and sort for processing<br>    occupied = sorted([s - 1 for s in S])<br>    total = 0<br>    <br>    # Segment 1: Empty seats before the first occupied seat<br>    # Calculate usable positions from start of table up to K positions before first diner<br>    usable_before_first = occupied[0] - K<br>    if usable_before_first &gt; 0:<br>        total += (usable_before_first + K) // (K + 1)<br>    <br>    # Segment 2: Empty seats between consecutive occupied seats<br>    # For each gap between two diners, calculate available positions<br>    # accounting for K-spacing requirements from both sides<br>    for i in range(M - 1):<br>        start_pos = occupied[i] + K + 1      # First available after current person<br>        end_pos = occupied[i + 1] - K        # Last available before next person<br>        <br>        if start_pos &lt; end_pos:<br>            segment_length = end_pos - start_pos<br>            total += (segment_length + K) // (K + 1)<br>    <br>    # Segment 3: Empty seats after the last occupied seat<br>    # Calculate usable positions from K+1 positions after last diner to end of table<br>    first_available_after_last = occupied[-1] + K + 1<br>    if first_available_after_last &lt; N:<br>        remaining_length = N - first_available_after_last<br>        total += (remaining_length + K) // (K + 1)<br>    <br>    return total</pre><p>One detail I found important: the loop runs M - 1 times because M occupied seats create M - 1 gaps between them. This kind of off-by-one relationship is crucial to get right.</p><h3>Complexity Analysis: A Dramatic Improvement</h3><p>The performance difference between approaches is substantial:</p><h3>Original Solution (Simulation)</h3><p><strong>Time Complexity:</strong> O(N × K)</p><ul><li>Visit up to N positions</li><li>Check up to K positions for each placement</li></ul><p><strong>Space Complexity:</strong> O(N)</p><ul><li>Table array of size N</li></ul><h3>Optimized Solution (Mathematical)</h3><p><strong>Time Complexity:</strong> O(M log M)</p><ul><li>Sort M occupied positions: O(M log M)</li><li>Process segments: O(M)</li></ul><p><strong>Space Complexity:</strong> O(M)</p><ul><li>Store M occupied positions</li></ul><h3>When Does This Matter?</h3><p>Consider a large cafeteria: N=1000, M=5, K=2</p><ul><li><strong>Original:</strong> O(1000 × 2) = 2,000 operations</li><li><strong>Optimized:</strong> O(5 × log 5) ≈ 12 operations</li></ul><p>The mathematical approach wins dramatically when:</p><ul><li>Table size (N) is large</li><li>Few seats are occupied (M &lt;&lt; N)</li><li>Large spacing requirements (K is big)</li></ul><h3>Key Takeaways</h3><p>This problem taught me several valuable lessons:</p><ol><li><strong>Look for mathematical patterns: </strong>Sometimes a simulation can be replaced with direct calculation.</li><li><strong>Segment the problem: </strong>Complex constraints often create natural boundaries.</li><li><strong>Question your data structures: </strong>Do you really need that array?</li><li><strong>Analyze complexity early: </strong>Understanding scaling helps identify optimization opportunities</li><li><strong>Edge cases matter: </strong>Boundary conditions often reveal the clearest thinking</li></ol><p>The journey from O(N×K) to O(M log M) wasn’t just about performance; it was about fundamentally understanding the problem structure. The cafeteria isn’t really about individual seats; it’s about the <strong>gaps between people</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87014bd8851a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Little shell Tidbits Part-1: Renaming and Copy/Pasting Files]]></title>
            <link>https://medium.com/@jmc/little-shell-tidbits-part-1-renaming-and-copy-pasting-files-357240c53aab?source=rss-f8284782c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/357240c53aab</guid>
            <category><![CDATA[cps]]></category>
            <category><![CDATA[zsh]]></category>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[exec]]></category>
            <category><![CDATA[bash]]></category>
            <dc:creator><![CDATA[Josh Cocciardi]]></dc:creator>
            <pubDate>Tue, 12 May 2020 16:03:00 GMT</pubDate>
            <atom:updated>2020-05-12T16:20:40.619Z</atom:updated>
            <content:encoded><![CDATA[<h3>Little Shell Tidbits Part-1: Renaming and Copy/Pasting Files</h3><p>As I explore the world of computers, my amazement never seems to end at how quickly things can be done with a little magical shell scripting.</p><p>Need to rename things in a sub directory?</p><pre>for file in *<br>do<br>mv $file &lt;prepended string&gt;$file<br>done</pre><p>Are there better ways to do this? Probably, but this will definitely work and quickly. I just renamed 300 files in a few sub directories by changing the &lt;prepended string&gt; based on the directory I was in. It took me all of 10 seconds. I will add this was on my local dropbox, which is even faster than having to do this via the dropbox website.</p><p>Another recent one, I needed to grab some nested files. The parent directory had 3 layers to the photo I wanted and I wanted that photo in a new directory. The idea is to use find to get all .jpgs at the very bottom and copy/paste them to the new directory I would like to use.</p><pre>find ./&lt;first directory name&gt;/*/&lt;third directory name&gt;/*.jpg -exec cp {} ./&lt;destination directory&gt; \;</pre><p>This one liner saved me easily 2 hours of just moving files on dropbox. In the working directory there are 4 named subdirectories. Each has many differently named subdirectories, each of those has files and one directory with my payload in it. You could use an * instead of the &lt;first directory name&gt; but I wanted to keep the 4 subdirectories of payloads separate so I did the above 4 times changing the first directory name. This could have of course been scripted as well but I think for the sake of Pareto, the above, four times, was plenty of time saving.</p><p>So what is happening above? I find all .jpgs in the target bottom layer sub/sub/sub directory, find is recursive, I then use-exec and cp to copy and paste every found item from the find query to their destination subdirectory in my current working directory. You can access the individually found items using ‘curly bois’, i.e.{} .</p><p>Have fun renaming and copy pasting stuff!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=357240c53aab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React useRef hook to capture and process uploaded CSV’s]]></title>
            <link>https://medium.com/@jmc/react-useref-hook-to-capture-and-process-uploaded-csvs-5ddea1c5fcb8?source=rss-f8284782c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ddea1c5fcb8</guid>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[d3]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[csv]]></category>
            <dc:creator><![CDATA[Josh Cocciardi]]></dc:creator>
            <pubDate>Mon, 11 May 2020 19:52:44 GMT</pubDate>
            <atom:updated>2020-05-11T19:52:44.230Z</atom:updated>
            <content:encoded><![CDATA[<p>Figured it out, well some kind of working version of figuring it out anyway. I did not see this clearly on stack anywhere so figured I should type this up. It is a mashup of my code and random stackoverflow snippets, thank you internet strangers.</p><p>D3 wants to parse a url or a string so I turned an uploaded file into a string.</p><p>First, get d3, I know there are other way to parse things. I am comfortable with d3, I assume you need to or want to use d3 otherwise why are you still here?</p><p>You will need to add d3 to your package.json</p><pre>npm install d3</pre><p>…or use the cdn in your html entrypoint.</p><pre>&lt;script src=&quot;https://d3js.org/d3.v5.min.js&quot;&gt;&lt;/script&gt;</pre><p>Here is the whole code block of a working component to upload a file and log the output.</p><pre>import React, { useRef } from &#39;react&#39;;<br>import * as d3 from &#39;d3&#39;;</pre><pre>const Load = () =&gt; {</pre><pre>const uploadFile = useRef(null);<br>  function handleFiles() {<br>   console.log(uploadFile.current.files);<br>   (async ()=&gt;{<br>     const text = await uploadFile.current.files[0].text();<br>     const data = await d3.csvParse(text);<br>//.............do something with you data.........<br>    console.log(data);<br>   })()<br>  }<br>  return (<br>    &lt;div&gt;<br>       &lt;input ref={uploadFile} onChange={handleFiles} type=&quot;file&quot; id=&quot;input&quot; multiple/&gt;<br>    &lt;/div&gt;<br>  )<br>};</pre><pre>export default Load;</pre><p>What is going on here? Import react and the useRef hook. Grab all of d3 name-spaced as d3 (if using npm).</p><p>React functional component as an example named Load. This component creates a null reference on the DOM input node.</p><p>&lt;Sidebar&gt;If you are using a component library read up on docs, you cannot do this on another functional component, many component libraries support ref forwarding (my preferred semantic UI React does via a Ref wrapper component and the prop innerRef. This only passes to the direct functional component child from what I can tell, if you are not sure what any of this is read up on it (<a href="https://reactjs.org/docs/forwarding-refs.html">https://reactjs.org/docs/forwarding-refs.html</a>).&lt;/Sidebar&gt;</p><p>The real life browser DOM node is captured in the reference.current. An event listener is added to the input for changes. When a file is added, handleFiles is called. This is logging the fileList. The input here has the ‘multiple’ attribute allowing more than one file to be added; fileList is an array of file objects.</p><p>I just need the one file I uploaded to be parsed. So, I create a string from it. Perhaps there is a better way to do this with blobs, alas, I did not make such attempts. The text() method is asynchronous. Notice my parsing action is wrapped in an async function. Once inside the async, I await the text conversion of the CSV. Armed with a long string, I use a little d3.csvParse magic to get the uploaded csv as now usable object. This is also asynchronous and so notice that data awaits d3 to parse. You know have a lovely parsed CSV object.I am logging it here but perhaps chucking it into state is a good idea.</p><p>Here is a way to add it to state, and check its been added with useEffect.</p><pre>import React, { useRef, useState, useEffect } from &#39;react&#39;;<br>import * as d3 from &#39;d3&#39;;</pre><pre>const Load = () =&gt; {<br>  const [ parsed, setParsed ] = useState({});<br>  const uploadFile = useRef(null);</pre><pre>useEffect(()=&gt;{<br>    console.log(parsed);<br>  },[parsed])</pre><pre>const handleFiles = () =&gt; {<br>    console.log(uploadFile.current.files);<br>    (async ()=&gt;{<br>      console.log(&#39;uploaded!&#39;);<br>        const text = await uploadFile.current.files[0].text();<br>        const data = await d3.csvParse(text);<br>        setParsed(data);<br>    })();<br>  }</pre><pre>return (<br>    &lt;div&gt;<br>      &lt;input ref={uploadFile} onChange={handleFiles} type=&quot;file&quot; id=&quot;input&quot; multiple/&gt;<br>    &lt;/div&gt;<br>  )<br>};</pre><pre>export default Load;</pre><p>Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ddea1c5fcb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adventures in Coding Part I]]></title>
            <link>https://medium.com/@jmc/adventures-in-coding-part-i-cf0fc1b5f723?source=rss-f8284782c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf0fc1b5f723</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[code-challenge]]></category>
            <category><![CDATA[github-api]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Josh Cocciardi]]></dc:creator>
            <pubDate>Tue, 12 Mar 2019 20:23:19 GMT</pubDate>
            <atom:updated>2019-12-26T15:58:46.710Z</atom:updated>
            <content:encoded><![CDATA[<p>We were given a challenge that, with the original nameless companies blessing, was passed along to my classmates and to myself. It involves utilizing the GitHub API to be able to access some basic user information and serve it up in some usable way (up to us).</p><p>Great, in my head I think, I will need a SPA built in REACT that takes in a username, fetches to the GitHub API and then renders the results in a simple component. Perhaps I can add these promise response objects to an array held in state and then allow the user to access select info from a dropping option list.</p><p>Step one, what the heck is the API for GitHub…</p><pre><a href="https://developer.github.com/v3/">https://developer.github.com/v3/</a><br><a href="https://developer.github.com/v3/auth/#basic-authentication">https://developer.github.com/v3/auth/#basic-authentication</a><br><a href="https://github.blog/2013-05-16-personal-api-tokens/">https://github.blog/2013-05-16-personal-api-tokens/</a><br><a href="https://github.com/settings/tokens/new">https://github.com/settings/tokens/new</a></pre><p>Okay let’s read about it. Hmmm, most info is given is reference in curl command line, not exactly sure what curl is, so I google it, have only ever really used bash/git/heroku/rvm.</p><blockquote>https://curl.haxx.se/</blockquote><blockquote><strong>command line tool and library</strong> <br>for transferring data with URLs</blockquote><p>That makes sense, but I would like to use javascript anyway and make my get request in my app instead of writing a command line tool, so what do I need to know about auth and how can I send those parameters? Docs say I can send in either the header or as params, but where is the auth token? I already have an account. Docs link to personal auth tokens within my GitHub account so I head over there to see if I can get a token.</p><p>In order to get a personal token I need to provide a scope for token request and what I need. Here I will just need read access to the user info I am requesting. Once I get my personal auth token I can start making requests following the API docs.</p><blockquote>OAuth2 token (sent in a header)</blockquote><blockquote>curl -H &quot;Authorization: token <em>OAUTH-TOKEN</em>&quot; <a href="https://api.github.com/">https://api.github.com</a></blockquote><blockquote>OAuth2 token (sent as a parameter)</blockquote><blockquote>curl <a href="https://api.github.com/?access_token=OAUTH-TOKEN">https://api.github.com/?access_token=<em>OAUTH-TOKEN</em></a></blockquote><p>Okay, got it!</p><pre>fetch(&#39;<a href="https://api.github.com/users/josh-sea&#39;,{">https://api.github.com/users/josh-sea&#39;,{</a><br>headers:<br>    {<br>&#39;Accept&#39;: &#39;application/vnd.github.v3+json&#39;,<br> Authorization: &#39;token &#39;ACTUAL_TOKEN_GOES_HERE&#39;<br>    }<br>})<br>.then(r=&gt;r.json())<br>.then(r=&gt;console.log(r))</pre><p>Here is what is logged in chrome dev tools where I am testing my fetch:</p><pre><em>{login: “josh-sea”, id: &lt;id&gt;, node_id: “&lt;node_id&gt;”, avatar_url: “https://avatars2.githubusercontent.com/u/&lt;id&gt;?v=4&quot;, gravatar_id: “”, …}</em></pre><pre>avatar_url: “https://avatars2.githubusercontent.com/u/<em>&lt;id&gt;</em>?v=4&quot;<br>bio: null<br>blog: “”<br>collaborators: 0<br>company: null<br>created_at: “2018–07–23T14:28:58Z”<br>disk_usage: 1642<br>email: null<br>events_url: “https://api.github.com/users/josh-sea/events{/privacy}&quot;<br>followers: 2<br>followers_url: “https://api.github.com/users/josh-sea/followers&quot;<br>following: 1<br>following_url: “https://api.github.com/users/josh-sea/following{/other_user}&quot;<br>gists_url: “https://api.github.com/users/josh-sea/gists{/gist_id}&quot;<br>gravatar_id: “”<br>hireable: true<br>html_url: “https://github.com/josh-sea&quot;<br>id: <em>&lt;id&gt;</em><br>location: null<br>login: “josh-sea”<br>name: null<br>node_id: “<em>&lt;node_id&gt;</em>”<br>organizations_url: “https://api.github.com/users/josh-sea/orgs&quot;<br>owned_private_repos: 0<br>plan: {name: “free”, space: 976562499, collaborators: 0, private_repos: 10000}<br>private_gists: 0<br>public_gists: 0<br>public_repos: 272<br>received_events_url: “https://api.github.com/users/josh-sea/received_events&quot;<br>repos_url: “https://api.github.com/users/josh-sea/repos&quot;<br>site_admin: false<br>starred_url: “https://api.github.com/users/josh-sea/starred{/owner}{/repo}&quot;<br>subscriptions_url: “https://api.github.com/users/josh-sea/subscriptions&quot;<br>total_private_repos: 5<br>two_factor_authentication: false<br>type: “User”<br>updated_at: “2019–03–04T17:45:17Z”<br>url: “https://api.github.com/users/josh-sea&quot;__proto__: Object</pre><p>The project is a success! I am going to publish the repo as public which will revoke my personal token but then the code is available. Here are some functioning screen shots though, or try your own personal auth token, and don’t publish that. : )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H4Z1mYuLPEjfXQcQOXw4EA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dtGD9qe4WRKdenX5jIlmwA.png" /><figcaption>simple search on load (left); conditional results render after search (right)</figcaption></figure><p>Code on GitHub: <a href="https://github.com/josh-sea/codechallenge-gh-api">https://github.com/josh-sea/codechallenge-gh-api</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf0fc1b5f723" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RegEx Practice and Tips]]></title>
            <link>https://medium.com/@jmc/regex-practice-and-tips-e913a205272d?source=rss-f8284782c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e913a205272d</guid>
            <category><![CDATA[regular-ex]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[regex]]></category>
            <dc:creator><![CDATA[Josh Cocciardi]]></dc:creator>
            <pubDate>Mon, 25 Feb 2019 17:53:41 GMT</pubDate>
            <atom:updated>2019-02-25T17:53:41.724Z</atom:updated>
            <content:encoded><![CDATA[<p>In your coding travels you have probably come across RegEx and wondered what the heck all those forward and backslashes meant. After a little reading and practice, you can start implementing regular expressions in your code confidently and in very meaningful way. I actually found them to change the way I looked at some problems.</p><p>To start, here is a very basic expression, let’s walk through what is going on here and how quickly we can add to it to improve its usefulness.</p><pre>const exampleReg = (/abc/)</pre><p>Above, a simple variable is assigned the regex /abc/. This doesn’t do much on its own but when paired with a string and method…</p><pre>“This is a string and it has in it the string abc”.match(exampleReg)</pre><pre>=&gt; <br>[&quot;abc&quot;, index: 45, input: &quot;This is a string and it has in it the string abc&quot;, groups: undefined]</pre><p>Wow, what just happened? We used the exampleReg we created as an argument in the RegExp match method. It looked through the string it was executed on and returned and array with the matched string, the starting index of the match as well as the original input. Cool! But what if there are multiple matched and we want to see every time something occurs in a string?</p><p>Let’s use a new regex to try and achieve this.</p><pre>const multpleReg = (/r/g)<br>“This is a string and it has in it the string abc”.match(multipleReg)</pre><pre>=&gt; <br>&quot;This is a string and it has in it the string abc&quot;.match(multipleReg)<br>(2) [&quot;r&quot;, &quot;r&quot;]</pre><p>What is different? We added what is called a flag after our search term.</p><pre>/pattern/flags</pre><p>We are looking for matches of the string ‘r’ which occurs twice in the string we are checking. To find multiple matches we use the ‘g’ flag. This flag continues to search after the first match is found. Flags are incredibly helpful and useful, here is another very helpful one, ‘i’, this makes your search case insensitive. Let’s check this out in practice, and oh by the way you can just put the regex right into the match method without separately declaring the variable for it.</p><pre>&#39;AaaaaaAAAaAH Real MONSTERS!&#39;.match(/a/gi)</pre><pre>=&gt; (12) [&quot;A&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;A&quot;, &quot;A&quot;, &quot;A&quot;, &quot;a&quot;, &quot;A&quot;, &quot;a&quot;]</pre><p>Look at that, not only did we use the ‘g’ flag to find all the instances but we added the ‘i’ flag to get both the capital and lowercase matches. We now know how to use regex and .match to find basic matches in a string lookup, but what if you don’t know the exact letter or character you are looking for but instead need a pattern, say two letters in a row followed by a number?</p><p>&#39;This is the string we are looking through for &quot;aa3&quot; two letters and a number&#39;</p><p>Without a regex, how would you find this? Maybe use split and turn it into an array and then look through the array somehow? Hmmm, good thing we have some simple regex to help!</p><pre>&#39;This is the string we are looking through for &quot;aa3&quot; two letters and a number&#39;.match(/\D\D\d/)</pre><pre>=&gt; [&quot;aa3&quot;, index: 47, input: &quot;This is the string we are looking through for &quot;aa3&quot; two letters and a number&quot;, groups: undefined]</pre><p>RegExp provides some great search terms, by using /\/ the backslash escapes the direct letter search so we are not looking for a D, instead, capital D is a wildcard for any non-digit character while \d is any digit, MDN docs below.</p><blockquote>Matches any character that is not a digit (Arabic numeral). Equivalent to [^0-9]. For example, /\D/ or /[^0-9]/ matches &quot;B&quot; in &quot;B2 is the suite number&quot;.</blockquote><blockquote>Matches any digit (Arabic numeral). Equivalent to [0-9]. For example, /\d/ or /[0-9]/ matches &quot;2&quot; in &quot;B2 is the suite number&quot;.</blockquote><p>There are a ton of character cases, \S for example</p><blockquote>Matches a single character other than white space. Equivalent to [^ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff].</blockquote><p>This is powerful because we can very quickly turn a string into a more useful array of characters.</p><pre>‘Some string with spaces, punctuation! and numbers 895.’.match(/\S/gi)</pre><pre>=&gt; (47) [“S”, “o”, “m”, “e”, “s”, “t”, “r”, “i”, “n”, “g”, “w”, “i”, “t”, “h”, “s”, “p”, “a”, “c”, “e”, “s”, “,”, “p”, “u”, “n”, “c”, “t”, “u”, “a”, “t”, “i”, “o”, “n”, “!”, “a”, “n”, “d”, “n”, “u”, “m”, “b”, “e”, “r”, “s”, “8”, “9”, “5”, “.”]</pre><pre>//or we could try \w</pre><pre>&#39;Some string with spaces, punctuation! and numbers 895.&#39;.match(/\w/gi)<br>(44) [&quot;S&quot;, &quot;o&quot;, &quot;m&quot;, &quot;e&quot;, &quot;s&quot;, &quot;t&quot;, &quot;r&quot;, &quot;i&quot;, &quot;n&quot;, &quot;g&quot;, &quot;w&quot;, &quot;i&quot;, &quot;t&quot;, &quot;h&quot;, &quot;s&quot;, &quot;p&quot;, &quot;a&quot;, &quot;c&quot;, &quot;e&quot;, &quot;s&quot;, &quot;p&quot;, &quot;u&quot;, &quot;n&quot;, &quot;c&quot;, &quot;t&quot;, &quot;u&quot;, &quot;a&quot;, &quot;t&quot;, &quot;i&quot;, &quot;o&quot;, &quot;n&quot;, &quot;a&quot;, &quot;n&quot;, &quot;d&quot;, &quot;n&quot;, &quot;u&quot;, &quot;m&quot;, &quot;b&quot;, &quot;e&quot;, &quot;r&quot;, &quot;s&quot;, &quot;8&quot;, &quot;9&quot;, &quot;5&quot;]</pre><p>\w can at once eliminate spaces and punctuation giving us a raw alphanumeric array.</p><p>There are many more flags and character searches you can use, feel free to peruse online but the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp">MDN docs</a> are great.</p><p>In addition to match there are also many other methods you can explore, quickly a particularly useful one .test, returns a boolean, this could be particularly useful in a filter for example. This uses a different arrangement, regex.test(string)</p><p>Here it is in practice:</p><pre>(/hey/i).test(&#39;this string does not contain h3y&#39;)</pre><pre>=&gt; false</pre><p>One interesting thing to note is that the pattern passed to a regex is taken literally, we cannot do the following:</p><pre>const reg = (/hey/gi)<br>&#39;some string&#39;.match(reg)</pre><pre>=&gt; null <br>// : (</pre><p>Instead, we can take advantage of the OO nature of the RegExp class and really step up our regex game to the next level so we can say map through values and pass them into a regex without having to write each expression out manually.</p><pre>const string = &#39;this is a sentence&#39;<br>const string2 = &#39;ABBA&#39;</pre><pre>string2.split(&#39;&#39;).filter(letter=&gt;{<br> return (/letter/).test(string) <br>})</pre><pre><br>=&gt; []</pre><p>See, we cannot look for the letter as the pattern, we can however create a new regex object and test it that way!</p><pre>const string3 = &#39;hi&#39;.match(/./g)<br>//turns the string &#39;hi&#39; into an array, the &#39;.&#39; is a complete wildcard</pre><pre><em>1 - string3.filter(letter=&gt;{<br>2 -  const </em>newReg = new RegExp(letter, &#39;gi&#39;)<br>3 -  console.log(newReg)<br>4 -  return (newReg).test(string) <br>5 - })</pre><pre>log:3 /h/gi<br>log:3 /i/gi<br>=&gt;<br>(2) [&quot;h&quot;, &quot;i&quot;]<br>the below is the console logging the regex being created on each loop.  The letter is passed in as the pattern and the</pre><p>What is happening here? Line 3 is being logged so we can see what the loop is creating, the regex pattern is the letter from the filter and the flags are added to the end. Now we can use an enumerable and create more dynamic pattern searches uses regex!</p><p>There is so much more you can do and learn but I found these few tools incredibly helpful in learning to use regex and add them to my toolbox. Explore online and read the MDN docs, they are helpful and you can get some creative ideas on how to apply regex. Also, keep in mind regex are common in most programming languages which means you are leaning a skill that translates well to whatever you learn next!</p><pre><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp">MDN RegExp</a><br><a href="https://regexone.com/lesson/introduction_abcs">Great tool to practice RegEx!</a></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e913a205272d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Events in React]]></title>
            <link>https://medium.com/@jmc/events-in-react-4fb198c85502?source=rss-f8284782c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fb198c85502</guid>
            <dc:creator><![CDATA[Josh Cocciardi]]></dc:creator>
            <pubDate>Wed, 30 Jan 2019 21:48:51 GMT</pubDate>
            <atom:updated>2019-01-31T18:01:03.369Z</atom:updated>
            <content:encoded><![CDATA[<h3>Utilizing State in React Synthetic Events</h3><p>My first attempt into the world of React was a bit shaky and reasonably so. I had only been introduced to it 48 hours before determining I would never understand it and should just give up.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o7TKtZ6eYyq506j04%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fhulu-cbs-i-love-lucy-3o7TKtZ6eYyq506j04&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7TKtZ6eYyq506j04%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="299" frameborder="0" scrolling="no"><a href="https://medium.com/media/124ae61072e8cf717b647fbb24a5718b/href">https://medium.com/media/124ae61072e8cf717b647fbb24a5718b/href</a></iframe><p>Sanity prevailed, after having completed a few labs in my code camp (Flatiron School) and working on this blog post in codeSandbox a bit, React started to come together and finally make <em>some</em> sense.</p><p>While working through the this very blog on demonstrating a few different kinds of React Synthetic Events and their attributes I came across the React Docs and found some interesting mouse events — drag related ones. This sent me down a rabbit hole of building a drag and drop example. Currently, there are some changes I would like to make in how it operates but more importantly, it needs to be abstracted into components. I plan to show the app differences on my personal site once I have abstracted each event react component and will link to that here.</p><p>To begin with I have a few react SyntheticEvents that are demonstrated using simple event handlers on html elements while others are taking advantage of the component state to leverage dynamic user interactions</p><p>The first example utilizes the onClick mouse event, something which will look familiar if you are familiar with vanilla javascript. In the code, the prop which makes the event listener is attached to an &lt;h1&gt; tag:</p><pre>// the tag in the App render — — — — — -&gt;</pre><pre>&lt;h1 onClick={this.handleEvent1}&gt;onClick&lt;/h1&gt;</pre><pre>// instance method — — — — — -&gt;<br>handleEvent1 = event =&gt; {<br>console.log(“event1”);<br>}; //<em>end event1</em></pre><p>The event is triggered on the h1 target set inline, this.method points to an instance method wrapped in the App class which logs a string letting use know we have triggered an event.</p><p>Next, something a little more fun…The second event is attached to an input with type attribute of text. This is how it is initially rendered, however it is not hardcoded this way. This is done by storing the type information as a string in the state (state.type = “text”). By initializing our app this way the input renders as a text input with placeholder value of onFocus/onBlur. In addition to the state declaration, we need two additional helpers in the App class to handle the onFocus and onBlur synthetic events. Here is the code…</p><pre>state = {<br>  type: “text”,</pre><pre>//don&#39;t worry about these three state keys yet....</pre><pre> classone: “draggable dragfrom”,<br> classfloat: “”, <br> classtwo: “draggable dragto”<br>};</pre><pre>onFocus = () =&gt; {<br> this.setState({<br>  type: “file”<br> });<br>};</pre><pre>onBlur = () =&gt; {<br> this.setState({<br>  type: “range”<br> });<br>};</pre><pre>///and here is how it is attached to the input element<br> &lt;input<br>  type={this.state.type}<br>  onFocus={this.onFocus}<br>  onBlur={this.onBlur}<br>  placeholder=&quot;onFocus and onBlur&quot;<br> /&gt;</pre><p>From the above code you may be able to tell what is happening. The input type is set to {this.state.type} which will be re-rendered anytime the state changes. The input carries two props, onBlur={this.onBlur} and onFocus={this.onFocus} both call on an instance method in App class to handle the event. Moving up to the instance methods we can see what the events are actually trigger, a state change! Each method changes the state.type to something user-defined, in this case I chose range and file input type attributes to showcase some different input types. The state is changed and the input re-renders, that’s it! thanks React!</p><p>The third example is a pretty straightforward synthetic event, similar to the first click example but it is demonstrating something called onContextMenu. This may or may not be something you are familiar with but very simply it triggers on a right click. Here I am pointing to an instance method which logs that right click was used and also adds the event.preventDefault() preventing the context menu (right click box) from popping up, cool!</p><p>Next up is the onKeyPress. A text input is rendered with a listener attached. The instance method that is called onKeyPress has access to the synthetic event which has an attribute of key allowing us to snag the string associated with the key that is pressed.</p><p>Finally, the one the one that sent me down the rabbit hole, onDrag … I saw this event in the list on the React Docs and began looking up how to use it which quickly led to me finding the ability to attribute ‘draggability’ to any html element! draggable=&quot;true&quot; it’s that easy. So I thought hey if dragging is this easy, what about drag and drop?</p><p>Conceptually, I don’t think it is too advanced, but testing each piece of the puzzle and the logic took some time to reason out in practice. Before I shared the state had a few more key value pairs besides the type: ‘text’. Similar to how the input field was changed from a text input to a file upload and then to a range onBlur, the drag and drop is using state to manipulate the a few elements but it is done across a few different event handlers and with some CSS. Initially, the page is rendered with two &lt;div&gt;’s with a border box and one holding a single smaller div that is centered. These divs were given border-radius of 50% of their size to make them appear as circles, mostly just for fun. Anyway, there are 4 main handlers to review.</p><pre>//props for dropzone<br>onDragOver={this.dragOver}<br>onDragEnter={this.dragEnter}<br>onDrop={this.dragDrop}<br>onDragLeave={this.dragLeave}</pre><pre>//props for dragging object<br>className={this.state.classone}<br>draggable=&quot;true&quot;<br>onDragStart={this.dragStart}<br>onDragEnd={this.dragEnd}</pre><pre>dragOver = event =&gt; {<br> event.preventDefault();<br>}; //<em>end of dragEnd</em></pre><pre>dragEnd = event =&gt; {<br> event.target.style.opacity = 1;<br>}; //<em>end of dragEnd</em></pre><pre>dragStart = event =&gt; {<br> event.target.style.opacity = 0.3;<br> if (event.target.id === &quot;one&quot;) {<br>  if (event.target.className === &quot;draggable dragfrom&quot;) {<br>   this.setState({ classfloat: &quot;draggable dragto&quot; });<br>  } else if (event.target.className === &quot;draggable dragto&quot;)<br>   this.setState({ classfloat: &quot;draggable dragfrom&quot; });<br> } else if (event.target.id === &quot;two&quot;) {<br>  if (event.target.className === &quot;draggable dragfrom&quot;) {<br>   this.setState({ classfloat: &quot;draggable dragto&quot; });<br>  } else if (event.target.className === &quot;draggable dragto&quot;)<br>   this.setState({ classfloat: &quot;draggable dragfrom&quot; });<br> }//end else if two<br>}; //<em>end of dragstart</em></pre><pre>dragDrop = event =&gt; {<br> event.preventDefault();<br> if (event.target.id === &quot;outerone&quot;) {<br>  this.setState({ classone: this.state.classtwo }, () =&gt; {<br>  this.setState({ classtwo: this.state.classfloat });<br>  });<br> } else if (event.target.id === &quot;outertwo&quot;) {<br>  this.setState({ classtwo: this.state.classone }, () =&gt; {<br>  this.setState({ classone: this.state.classfloat });<br>  });<br> }//end else if<br>}; //<em>end of dragDrop</em></pre><p>Okay, now let’s look at it in action! Try opening the codesandbox console to view the event output.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fqqq0jkp8q9&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fqqq0jkp8q9&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fqqq0jkp8q9%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/a17aaaa78ac9fdfe0369b5618de241ea/href">https://medium.com/media/a17aaaa78ac9fdfe0369b5618de241ea/href</a></iframe><pre>Resources I found handy...</pre><pre>--react docs synthetic events <a href="https://reactjs.org/docs/events.html">https://reactjs.org/docs/events.html</a><br>--focus/blur help <a href="https://codepen.io/comakai/pen/WvzRKp?">https://codepen.io/comakai/pen/WvzRKp?</a><br>editors=0010html input attributes -<a href="https://www.w3schools.com/tags/att_input_type.asp">https://www.w3schools.com/tags/att_input_type.asp</a><br>--drag and drop inspiration <a href="https://medium.com/the-andela-way/react-drag-and-drop-7411d14894b9">https://medium.com/the-andela-way/react-drag-and-drop-7411d14894b9</a><br>--MDN resource on dragstart https://developer.mozilla.org/en-US/docs/Web/Events/dragstart</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fb198c85502" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How does that thing work?]]></title>
            <link>https://medium.com/@jmc/how-does-that-thing-work-eef456c8c97?source=rss-f8284782c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/eef456c8c97</guid>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Josh Cocciardi]]></dc:creator>
            <pubDate>Thu, 10 Jan 2019 17:42:25 GMT</pubDate>
            <atom:updated>2019-01-10T17:55:06.998Z</atom:updated>
            <content:encoded><![CDATA[<h3>Probably math.</h3><p>Back in engineering school we learned a bit of advanced math which included the F<em>ast Fourier Transformation (FFT)</em>. This is isn’s the simplest idea to explain using the actual math but isn’t so bad if we look at some visual aids. The fourier transform is fundamental to many parts of our daily lives quietly working in the background. Has anyone heard of a JPG? How about an MP3? Maybe GPS?</p><p>Without doing too much math, simply, we can <em>transform</em> a signal in the time domain to its components in the frequency domain. No matter how crazy looking a time series plot looks, it can be represented by a sum of individual frequencies (sine waves)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FQ4TFjBrtYSo8%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fperfectloops-description-transform-Q4TFjBrtYSo8&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FQ4TFjBrtYSo8%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="348" frameborder="0" scrolling="no"><a href="https://medium.com/media/380c1946d7fd43c741833a49a6b0d769/href">https://medium.com/media/380c1946d7fd43c741833a49a6b0d769/href</a></iframe><p>Here, is an example of breaking down a square wave. We can take the total interference of sin waves and generate a square-wave, triangle, or sawtooth-wave. The side profile of the component wave heights represents the harmonics which comprise the original signal. The largest wave is the fundamental wave and each additional wave is a multiple of that wave frequency. These are know as harmonics which may sound familiar…</p><p>Indeed, it is something we come across in music. Below is a plot of a standing waves with the fundamental and the nodes of several harmonics (also known as partials or overtones). Without digressing too much a standing wave doesn’t look like it is moving, in musical instruments this would be due to resonance. The wave is traveling back and forth and interferes with itself producing areas of maximum constructive and destructive interference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*_gIUhRk--xQ2JKky.png" /><figcaption><a href="https://en.wikipedia.org/wiki/File:Harmonic_partials_on_strings.svg">https://en.wikipedia.org/wiki/File:Harmonic_partials_on_strings.svg</a></figcaption></figure><p>So we have known about the functional representation of fourier analysis for a long time but more recently it has been applied to technology to do some amazing things. Back to that JPG and MP3 reference.</p><p>Similar to how a sound may look like a complicated noise and yet is still composed of individual frequency components, the same is true for other analog or continuous time signals such as a photo. We can look at the digital nature of an image and see each pixel as a single color and we can take a step up from the pixel and look at a block of pixel, they may not be the same color but we can certainly approximate the color of the block of pixels using fourier analysis. Each block would have a fundamental frequency of color with technically an infinite number of harmonics adding together to create the true image block. What we would see is a single frequency that represents the entire block, a single color! This obviously wouldn’t be a very good representation of the image so we can add back another harmonic of image information, and so on until we get to a point where the image looks very close to the original. If we wanted to say, compress the size of the image by removing some information, we could simply use enough harmonics so the image looks good while removing the rest of infinite smaller harmonics. Rather than store all of that analog photo information, we now have a smooth looking approximation of the original that has been…. compressed!</p><p>Here are a few examples of poor jpeg compression to make the block approximation clear. JPEG actually uses tiny circle waves based off of fourier transforms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*0H_cWryK2MoRa-Dz" /><figcaption><a href="http://stephaniehurlburt.com/blog/2016/12/20/a-taste-of-fourier-transforms-and-jpeg-compression">http://stephaniehurlburt.com/blog/2016/12/20/a-taste-of-fourier-transforms-and-jpeg-compression</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*Dt3MWalDPVaX1UIM" /><figcaption><a href="http://stephaniehurlburt.com/blog/2016/12/20/a-taste-of-fourier-transforms-and-jpeg-compression">http://stephaniehurlburt.com/blog/2016/12/20/a-taste-of-fourier-transforms-and-jpeg-compression</a></figcaption></figure><p>Next up, MP3s. Now that we know generally how fourier analysis works it is easy to see how we can apply to additional mediums. MP3s utilize fourier to snip off the really high note information preserving the overall sound but dramatically reducing the size of the file.</p><p>What other complicated continuous signals could we break down to fundamental frequencies? Stocks?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/0*yn_OLAcardZhe4Fa.png" /><figcaption><a href="https://www.google.com/url?sa=i&amp;source=images&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjUhvWJ4-PfAhXHnOAKHYmvA8wQjRx6BAgBEAU&amp;url=https%3A%2F%2Fseekingalpha.com%2Finstablog%2F251422-brett-owens%2F95201-if-your-stock-is-so-cheap-why-arent-you-buying-back-shares-hand-over-fist&amp;psig=AOvVaw3MRou3iUwyU9yeOtNLureo&amp;ust=1547228912297191">stock img</a></figcaption></figure><p>Why not! Don’t get too excited, someone already thought of it. While fourier analysis can curve fit, its powers of prediction are limited. That is not to say it is not a useful tool. Here is a link to the <a href="https://www.google.com/url?sa=i&amp;source=images&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjUhvWJ4-PfAhXHnOAKHYmvA8wQjRx6BAgBEAU&amp;url=https%3A%2F%2Fseekingalpha.com%2Finstablog%2F251422-brett-owens%2F95201-if-your-stock-is-so-cheap-why-arent-you-buying-back-shares-hand-over-fist&amp;psig=AOvVaw3MRou3iUwyU9yeOtNLureo&amp;ust=1547228912297191">investopedia</a> page about fourier.</p><p>Algorithm stock trading, especially high frequency trading certainly can take advantage of fourier analysis. These tools are becoming so readily available you can access them in most stock packages or newer exciting algo tools such as <a href="https://www.quantopian.com/">Quantopian</a> that literally lets you code out trading algorithms that you can test on historical data and that real investors can use, cool!</p><p>Fourier transforms are used for even more than what is covered here and have very powerful curve fitting powers. Flatirons very own data science program may be a good resource to learn more about some of the existing tools and models utilizing fourier analysis.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eef456c8c97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open Source: More than Just a Software Story]]></title>
            <link>https://medium.com/@jmc/open-source-more-than-just-a-software-story-5eae501dae08?source=rss-f8284782c44d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5eae501dae08</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[3d-printing]]></category>
            <dc:creator><![CDATA[Josh Cocciardi]]></dc:creator>
            <pubDate>Thu, 13 Dec 2018 05:59:09 GMT</pubDate>
            <atom:updated>2018-12-13T14:33:50.136Z</atom:updated>
            <content:encoded><![CDATA[<p>Many people have probably heard of 3D printers, but have you ever seen one in real life? Maybe you’ve seen a news clip or read an article about some of the really cool things they are capable of. Or maybe you heard about them in the context of the more controversial things they are capable of printing, like a gun. The technology is incredible, for better or worse it is here and continues to evolve.</p><h3>So what is a 3D printer…?</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl2iNlSsrLaszStTSio%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fl2iNlSsrLaszStTSio&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl2iNlSsrLaszStTSio%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/73f2b914334bb02424c3d1e8eb221210/href">https://medium.com/media/73f2b914334bb02424c3d1e8eb221210/href</a></iframe><p><strong>Brief Tech Summary and Intro to the Technology:</strong></p><blockquote>“…being able to take the concept of something from your mind, translate that it into a 3D object, really intuitively on the computer, and then take that virtual 3d object and be able to make it real just by printing it… it is going to revolutionize design and manufacturing in the 21st century.”</blockquote><blockquote>-Elon Musk excerpt from ‘The Future of Design’</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FxNqs_S-zEBY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DxNqs_S-zEBY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FxNqs_S-zEBY%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/445118df1d3ca72c0e4e139415a6da9a/href">https://medium.com/media/445118df1d3ca72c0e4e139415a6da9a/href</a></iframe><p>A 3D printing production method is what is called additive manufacturing and is conceptually a lot less complex than you may believe. There are of course complex concepts and challenges that have emerged as the technology grows and changes but they all operate on a similar premise. <em>LAYERS</em>.</p><p>Something pretty familiar to most people is an MRI machine/MRI scan. When we go to a lab to get checked out, the machine scans over our body or a body part and takes images of tiny slices of cross section of said body part/body. For you math nerds, it is a bit like calculus where the discrete slices of the object are limited only by the printing resolution of the actual tool. We take little slices of an object at a time to work on and in this way, we can take a model of a complex 3D digital object and turn it into a physical reality. Each of these little slices can be built one by one on top of one another like a topographical map. The end result is the 3D dimensional object in real life.</p><p>So, simple really, chop an object into paper thin slices, physically build each slice one on top of another. Using some code and a glorified hot glue gun, we can now turn our literal thoughts into physical functional models and prototypes, POWERFUL. Additive manufacturing has existed for some time on an industrial scale with large and complex machines capable of using different materials and larger project build volumes (<a href="https://www.stratasys.com/">Stratasys</a>, <a href="https://www.3dsystems.com/">3DSystems</a>) it is only in the last 10–15 years we have seen consumer accessible technology become available. In fact, you can go to <a href="https://www.amazon.com/Monoprice-Select-Mini-Printer-Assembled/dp/B01FL49VZE/ref=sr_1_6?s=industrial&amp;ie=UTF8&amp;qid=1544711180&amp;sr=1-6&amp;keywords=3d+printer">amazon and order a 3D printer</a> for about $199 and start printing your own things. It wasn’t always this way…</p><p>The Open Source Story:</p><p>In 2005, Adrian Bowyer founded RepRap, an open source 3D printer capable of creating most of its own parts, running on open source software. The first models were rather simple, a heating element warming a nozzle and plastic was fed through, exactly like an automated hot glue gun but with a nozzle diameter on the order of a fraction of a millimeter wide. The hot end is attached some rails and stepper motors to precisely control the movement in a single plane. Many configurations offer moving print beds while some have the printing head also move up and down (z-axis). RepRap continued to grow in popularity and eventually inspiring makers and entrepreneurs to create their own printers and market them to the community and on platforms such as kickstarter. Different configurations with different pros and cons started to pop up everywhere.</p><p>Many of you may be familiar with the ‘maker community’, have heard of or even consider yourself a hobbyist or model maker. It is easy to see why being able to build you own factory at home is a powerful idea, and not just that, how to is free and open to the world to discuss and improve upon. It is a bit like this very medium, ‘Medium’. Medium offers a platform for people who want to create something so they can make and share their ideas. Consumer 3D printing opened the world to creativity in the physical world on a scale that had not existed previously.</p><p>Since those early days, the machines available to consumers have come a long way and are beginning to offer materials and UI/UX only seen on industrial levels. <strong><em>MarkForged</em></strong> and <strong><em>Desktop Metal </em></strong>are pushing the envelope of consumer grade ‘desktop’ sized printers that can create 3D prints from metal materials using Direct Metal Laser Sintering (DMLS). There are also some impressive consumer technologies that produce very high resolution prints, 25 microns layers, which is about one half to one third the thickness of a piece of computer paper. These use liquid resins and Stereolithography (SLA); a good example of this technology is a device from <strong><em>FormLabs</em></strong>.</p><p><a href="http://amosdudley.com/weblog/SLO-Camera">An incredible project put together using a FormLabs SLA printer:</a> An entire camera was printed, including…. the lenses! These aren’t perfect by any means but the images look a bit like cameras a few generations ago. Absolutely amazing to be able to have a factory that can make you a camera.</p><p><a href="https://www.flickr.com//photos/49572702@N02/albums/72157671585731802/show">Photos</a></p><p>As the machines have become more complex, so has the software. New companies offer different solutions to automate all the various configuration options and handle everything from a nice GUI in which you can manipulate your 3D model, to slicing it, to turning the slices into GCode, the language used to give instructions the machine can read, a bit like a compiler. I personally use Simplify3D, while not free, it offers considerable control over many aspects of the print.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*62LhnAEBle-uAlztXTkW7A.jpeg" /><figcaption>From Simplify3D — <a href="https://www.simplify3d.com/software/features/">https://www.simplify3d.com/software/features/</a></figcaption></figure><p>The first few were written for RepRap and used java (RepRap Host, developed by Adrian Bowyer and later python (Skeinforge developed by Enrique Perez) to slice the models and convert the information to usable GCode format.</p><p>A great idea was opened to the world for collaboration and in 15 years we have come from tabletop automated hot glue guns to laser resin and metal printers as well as entire software suites to handle the modeling and production optimization.</p><p>Let’s look at some other really interesting applications and results of the technology.</p><p>One of my favorites, the <a href="http://enablingthefuture.org/">E-Nable community</a>. This community has open source files for 3D printable prosthetics. The idea is that children who grow quickly need new prosthetics constantly. Each one is custom and can cost 10’s of thousands of dollars. Imagine growing up and instead of having to constantly buy shoes your parents needed to guy you a new arm. This has lead to a community of volunteers building and refactoring open source designs. The community also helps families get in touch with anyone with a 3D printer in the community to match what the child needs to an existing design and help them get a new limb.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FeWVHeWrxUAsLK%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Frobert-downey-jr-iron-man-rdj-eWVHeWrxUAsLK&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FeWVHeWrxUAsLK%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3d59b0329108544c686cf54f806c6f6/href">https://medium.com/media/d3d59b0329108544c686cf54f806c6f6/href</a></iframe><p>Another fascination outcome are open and free communities of 3D printable file sharing sites. <a href="http://thingiverse.com/">Thingiverse.com</a> is a major player, users create their own models and upload the designs as well as printing instructions (documentation), build guides, part lists and more. All open to anyone who wants to print it or take the design and modify it and share that.</p><p>How about new marketplaces? Got those too. <a href="https://www.3dhubs.com/">3DHubs</a> allowed people to use their own printers they had at home and print files on demand for anyone needing something without a printer themselves. They could go online, submit the file and get quotes to print from people in their local communities.</p><p>The world has had 3D printing for years on industrial level, but since the open sourcing of the RepRap project, there has been an explosion in the interest and proliferation of consumer level 3D printing technologies and ideas that are changing the world everyday and it is a very exciting thing to watch.</p><p>There’s more!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F12sQ4yPXbbPFXq%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fprinter-12sQ4yPXbbPFXq&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F12sQ4yPXbbPFXq%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c844cd0687033e116e269bdd30316bf/href">https://medium.com/media/3c844cd0687033e116e269bdd30316bf/href</a></iframe><p>Food: <a href="https://www.naturalmachines.com/">Foodini by Natural Foods</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FuUTBslT5xWHrATF8Vt%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Funreelco-cooking-printing-syn-uUTBslT5xWHrATF8Vt&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FuUTBslT5xWHrATF8Vt%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9fe45718a6ab99469dd3fcb3bda8a8f/href">https://medium.com/media/b9fe45718a6ab99469dd3fcb3bda8a8f/href</a></iframe><p>Molecular and Bio printers: <a href="https://cellink.com/">Cell Link</a></p><p>Additional links and resources: <a href="https://en.wikipedia.org/wiki/RepRap_project#Software">RepRap wiki</a>, <a href="https://www.desktopmetal.com/">Desktop Metal</a>, <a href="https://markforged.com/">Mark Forged</a>, <a href="https://formlabs.com/">FormLabs</a>, <a href="https://www.shapeways.com/">Shapeways</a>, <a href="https://www.thingiverse.com/">Thingiverse</a>, <a href="https://www.makerbot.com/">Makerbot</a>, <a href="https://www.3dhubs.com/">3DHubs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eae501dae08" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>