<?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 Lucas McGartland on Medium]]></title>
        <description><![CDATA[Stories by Lucas McGartland on Medium]]></description>
        <link>https://medium.com/@lucasmcgartland?source=rss-2b3150c688d0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*CiYTafi-QnToCU-bnOP9og.png</url>
            <title>Stories by Lucas McGartland on Medium</title>
            <link>https://medium.com/@lucasmcgartland?source=rss-2b3150c688d0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 14:50:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lucasmcgartland/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[The HomePod is dead. Long live the HomePod.]]></title>
            <link>https://lucasmcgartland.medium.com/the-homepod-is-dead-long-live-the-homepod-ff6e04313bd5?source=rss-2b3150c688d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff6e04313bd5</guid>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[technology-product]]></category>
            <category><![CDATA[siri]]></category>
            <category><![CDATA[consumer-electronics]]></category>
            <category><![CDATA[homepod]]></category>
            <dc:creator><![CDATA[Lucas McGartland]]></dc:creator>
            <pubDate>Tue, 16 Mar 2021 18:54:11 GMT</pubDate>
            <atom:updated>2021-03-16T18:54:11.906Z</atom:updated>
            <content:encoded><![CDATA[<p>Re-examining great design and technology end-of-life support.</p><blockquote>This post originally appeared on <a href="https://lucasmcgartland.com/blog/long-live-the-homepod">lucasmcgartland.com</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*xLaef9enCQgBLtyq.png" /><figcaption>“Hey Siri, can you play audio from an aux input?”<br>“I’m sorry Luke, I’m afraid I can’t do that.”</figcaption></figure><h3>Like a radioactive isotope, we’ve reached the HomePod’s first half-life.</h3><p>Apple’s announcement to discontinue the original HomePod hardware yesterday was jolting, but not surprising for many HomePod owners. This was a moment expected from the beginning.</p><p>Launched in 2018, the original HomePod smart speaker had limitations that only the most loyal Apple fans accept. Apple’s subscription music service, Apple Music, and <a href="https://www.apple.com/airplay/">AirPlay</a> (a closed-source, proprietary P2P streaming protocol), were the only two ways to play audio on HomePod, with no way to connect an aux or Bluetooth input. As an interface, users were stuck with Siri and the small, capacitive buttons on the top of the unit (3 taps on top to rewind was, and is, obnoxious).</p><p>For Apple users already bought into the Apple ecoystem, a HomePod offered a convient way to interact with smart home devices through HomeKit in addition to playing Apple Music. Furthermore, all the voice activated features were billed with a “privacy-first” approach (despite the HomePod being the only mainstream smart speaker at the time without a mute switch).</p><p>The HomePod promised to deliver a premium audio experience by harnessing the computational prowess of the iPhone alongside Apple’s usual excellence and passion for precision industrial design. In spite of the clunky Siri interface, the HomePod largely succeeds in that goal. For me, it certainly does, and I enjoy using it daily for music, home automation, and getting the weather forecast.</p><p>However, Apple’s announcement makes me wonder what happens after the next half-life of the HomePod? What happens when software updates stop being released? What happens when Apple’s servers that help the HomePod perform its magic shut down? It seems like owners will be left with an overpriced paperweight that can’t even be used as a Bluetooth speaker.</p><p>Despite being barely a blip on Apple’s revenue radar, what responsibility does the world’s most valuable company have to consumers to support their products?</p><h3>Good design is long-lasting.</h3><p>The <a href="https://www.vitsoe.com/us/about/good-design">ten principles of good design</a>, as put forth by the legendary industrial designer Dieter Rams, have long been associated with Apple products. Under Steve Jobs, Apple was regarded as the pinnacle of the intersection of design and technology. The products were simple, intuitive, beautiful, and mostly “just worked”.</p><p>The other day I got out my iPod classic, charged it up, put some headphones in, and cringed at my late 2000’s music taste. But, despite the music player being over 14 years old, it could still faithfully fulfill its purpose <a href="https://www.youtube.com/watch?v=6SUJNspeux8">to keep 1000 (or more) songs in my pocket</a> — not that I used it regularly. It made me wonder though, why did I stop using a device that worked so well at what it did? How many other iPods are out there, sitting in a closet, waiting to be pulled out only for a trip down memory lane?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*h1icnhVvmEV_LwtX.png" /><figcaption>Rest in peace, cover flow.</figcaption></figure><p>Under Tim Cook, the company has reached an incredible scale as it continues to sell more and more iPhones. But the magic has slowly faded over the years, with the old Apple only being seen in glimpses such as AirPods, the M1 chip, and in my opinion, yes, the HomePod.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*3OVZYvgOnfmcqUo8.png" /><figcaption>Hold nearby for audio handoff is one my favorite features. This type of magical interface is something I’d like more of as our devices become spatially “aware” of each other.</figcaption></figure><p>Apple is notorious for locking down its software and tightly coupling it with the hardware. It freely gives away software as an incentive for people to buy its hardware. To date, they have a decent track record when it comes to supporting older devices with software updates (not that the Android OEM are setting the bar very high). I’ve enjoyed the lifespan of my Apple Watch Series 3, which has continued to recieve software updates, and feels snappy as the day I got it.</p><p>As the market becomes more and more saturated with consumers who aren’t interested in upgrading their working hardware devices, Apple is putting more focus on its “services” category. Getting consumers to subscribe to services like iCloud, Apple TV+, and Apple Fitness can keep revenue flowing as hardware sales slow down.</p><p>A cloud-based software service model better aligns with the ongoing cost of developing updated software and content. But in order for those services to work, both compatible versions of the cloud and client side software need to be running, and kept up-to-date. What happens though when either of those pieces of software becomes irrelevant to driving new sales?</p><h3>“Hey Siri, play Daft Punk”</h3><p>I’ve always had a great deal of respect for musicians, and for audiophiles. I’m not much of either, but I can sense that some folks can hear sound with the same kind of depth and intuition I feel I see when I look at visual design.</p><p>When Daft Punk <a href="https://www.youtube.com/watch?v=DuDX6wNfjqc">broke up</a> this month, it hit me as if they had actually died. The next few days my HomePod was pretty much a non-stop tribute jukebox, blasting the sonic landscapes of Tron: Legacy (the complete edition, <a href="https://www.billboard.com/articles/news/dance/9504522/daft-punk-complete-edition-tron-legacy-soundtrack/">just released on streaming services</a>), Random Access Memories, and Alive 2007 on repeat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*pEO_QrN6UUEA7n7W.png" /><figcaption>One could argue that Siri is certainly a “daft punk”</figcaption></figure><p>What I love about artists like Daft Punk is that they’ve made extraordinary sounds that can be appreciated by any listener — because their music speaks directly to the human soul. Playing their music through my HomePod was a completely seamless way to engage with their art, from both the perspective of ease of access and the auditory experience.</p><p>This leads to what I think all great design is: <strong>human souls speaking directly to other human souls</strong>. Technology products have been helpful in this regard in that they provide a level of intimacy, personalization, and accessibility that makes them indispensable to our daily lives. In some ways they are simply a channel or tool for consumption, but every now and then, that tool itself can elevate and transform the experience of using it. This was the magic of Steve Jobs’ Apple products.</p><p>Design isn’t just how something looks or sounds, it’s the entire experience. It’s how a product is marketed, sold, used, and yes, eventually retired. Killing off the HomePod without giving consumers a clear vision about the software end-of-life plan is poor design.</p><h3>Consumers deserve the right to install and modify the software on their devices</h3><p>Currently, Apple is <a href="https://9to5mac.com/2021/03/03/arizona-app-store-bill-alternative-payments/">battling a bill in Arizona</a> to maintain control over the walled garden of their App Store. The consequences of the suit could break down the barrier to mobile phone owners installing apps from other sources (Android has had this option for years but Google Play holds much of the Android app market).</p><p><strong>But what about a HomePod, which has no App Store?</strong></p><p>I’m lucky enough to have learned at a young age how to write software. And as more and more tasks become automated by machines, I see humans developing software for those machines only becoming more relevant.</p><p>Using and publishing open-source software is part of the DNA of any great technology company. However Apple, Amazon, Google and the other tech giants need to go above and beyond when it comes to making products with great design at the core. When a product reaches its end of life for a company, why not open-source it? Let someone else pick up where you’ve decided to leave off.</p><p>Technology companies should leave behind the deep instruction manual for folks who want to continue using their products long after the corporation decides it’s no longer in the shareholders’ best interest to support the product.</p><p><strong>In light of the end-of-life announcement for the original HomePod, Apple should take these steps now:</strong></p><ol><li>Release a software developer kit (SDK) for HomePod’s flavor of TvOS so developers can create third-party apps for HomePod.</li><li>Release an official AirPlay 2 protocol specification so third-party devices can use the HomePod speaker as an output.</li></ol><p>Good design is long-lasting. Apple, as a leader in consumer product design, needs to go above and beyond what is expected by consumers today. They have made <a href="https://www.apple.com/environment/">bold announcements of goals</a> to reduce their planet-scale carbon impact. But in the quest to sell more devices, planned obsolescence is still a part of the unspoken roadmap for most technology products. Building devices that last longer may be antithetical to selling more devices, but in the long run, the consumer wins. Open-sourcing software, opening up protocols for better interoperability amongst devices, and allowing users to install or upgrade software themselves all can help make technology products last longer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UKr9awWaDK2xYK-w.jpg" /><figcaption>One could argue that Siri is certainly a “daft punk”</figcaption></figure><h3>Imagining an Open-Source Audio Adapter</h3><p>Sadly, it’s unlikely that Apple will take any of the steps above to support the original HomePod. However, taking inspiration from other communities of practice that restore old products, I think there may be a path forward to get an aux input added wirelessly to HomePod.</p><p>As I’ve witnessed the constant cycle of digital obsolescence, I’ve come to appreciate physical and analog media more for what it is. As a child, I would tell my parents, “Physical media is dead!” Looking back, that’s quite a strange thing for a child to say with regular frequency (my parents can confirm).</p><p>Recently, I’ve become interested in the resurgance of Polaroid cameras and instant photography. With an <a href="https://us.polaroid.com/collections/polaroid-sx-70-cameras">SX-70 camera</a> I can fit in my pocket, I can instantly capture a moment as a photograph, which I don’t need to back up to the cloud or trade my privacy for to share with friends. A whole industry exists around preserving and refurbishing these cameras, some of which are now close to 50 years old. <strong>Good design is long-lasting.</strong></p><p>How could the useful lifespan of a HomePod be extended? The speaker itself is a good piece of hardware. In retrospect, it would have been remarkably easy for Apple to add an aux input, or even Bluetooth, and this would not be an issue. One option is to leverage the AirPlay support on the HomePod and create an adapter to stream music through that protocol.</p><h4>Analog to Digital AirPlay Device</h4><p>Since AirPlay 2 will foreseeably work locally for the far future, I intend to investigate building an analog to digital AirPlay device that could accept any aux input and stream to a HomePod in the best available quality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*wFjnLwkcjeGmuAoo.png" /></figure><p>Digital to Analog + Analog to Digital component by HiFiBerry (DAC + ADC)</p><p>Research at the time of this post suggests that I could use <a href="https://www.hifiberry.com/shop/boards/hifiberry-dac-adc/">HiFiBerry ADC</a> with a Raspberry Pi to create a device for processing the analog input. I imagine a device with a small OLED screen and a couple GameBoy like buttons to help pair would provide a delightful experience.</p><h4>Reverse Engineering the AirPlay 2 Protocol</h4><p>To date, it doesn’t seem like anyone has completely <a href="https://emanuelecozzi.net/docs/airplay2">reverse engineered AirPlay 2</a>. This <a href="https://github.com/openairplay/airplay2-receiver">repository</a> looks like a good start for AirPlay 2 reception.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff6e04313bd5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recreating Beats Music with React Native and Expo Snack]]></title>
            <link>https://blog.expo.dev/recreating-beats-music-with-react-native-and-expo-snack-172a33dbfe95?source=rss-2b3150c688d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/172a33dbfe95</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[music]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Lucas McGartland]]></dc:creator>
            <pubDate>Mon, 30 Apr 2018 17:45:09 GMT</pubDate>
            <atom:updated>2018-04-30T17:45:09.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ds1IjDNLFfQ31qOiEz6C8Q.jpeg" /><figcaption>A jukebox in the cloud</figcaption></figure><p><strong>Beats Music, we hardly knew ye. </strong>A music streaming service ahead of its time, Beats Music was unceremoniously replaced by Apple Music after Apple acquired Beats in 2014. I’m a huge fan of the design and user experience, and I think it holds up well despite being nearly four years old.</p><p>For a talk I recently gave about developing user interfaces with React, I thought it would be fun to use React Native to recreate the Beats Music interface, specifically the “Sentence” feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pOIvoW92R3mDxBsGJuwLQw.png" /><figcaption>My recreated version of the Sentence</figcaption></figure><p>The Sentence allowed users to generate a playlist by filling out a “Mad Libs” style interface.</p><p>I rebuilt the Sentence using React Native, <a href="http://snack.expo.io/">Expo Snack</a>, and the <a href="https://developer.napster.com/">Napster API</a>. Expo has a zero-configuration React Native dev environment called Snack that can be used to run the project, and the Napster API provided the music metadata. Here’s how you can set it up too.</p><h3>Running the Snack On Your Device</h3><p>First, you’ll need to download the <a href="https://expo.io/tools#client">Expo Client</a> app to your phone. You can get it on the <a href="https://itunes.apple.com/us/app/expo-client/id982107779?mt=8">App Store</a> or the <a href="https://play.google.com/store/apps/details?id=host.exp.exponent">Google Play</a> store. If you’re running iOS, you’ll need an account on <a href="https://expo.io/">Expo.io</a> as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zty1bw_jQXVmQAq4bKUYRQ.jpeg" /></figure><p>Once you have the app set up on your phone and your account created, you can go to the Beats Music snack here:</p><blockquote><a href="https://snack.expo.io/@iovineyoungdemo/beats-music"><strong>https://snack.expo.io/@iovineyoungdemo/beats-music</strong></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QAJ7CDhm67vcGAVcgu73lQ.png" /><figcaption>The project page you should see</figcaption></figure><p>This will take you to the project page. The next step is connecting your phone.</p><h4>Android</h4><p>Click <strong>Run On Device</strong>. Scan the QR code with the Expo app to launch the snack.</p><h4>iOS</h4><p>If you’re on iOS, the process is a bit trickier. First, you’ll need to be logged into Expo in both the web browser and on the app. Then you’ll have to save the project to your own account. Once the project is saved to your account, it should show up in the <a href="https://blog.expo.io/automatically-syncing-projects-in-development-to-the-expo-client-f8768463e371"><strong>Recently in Development</strong></a> section on the Expo app. You may need to refresh the page/app a few times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAqB_Fhd5bVBtCrvV1pn1g.png" /><figcaption>If the accounts are properly connected you’ll see the snack appear.</figcaption></figure><p>Tap on the snack to launch the project. You’ll get this running on your phone!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*AvOG-J0NbVxLkt9ysOCR3A.gif" /></figure><h3>Behind the Scenes: How the Code Works</h3><p>Recreating the interface was pretty straightforward. I created a new text component to match the text style. I used chroma to programmatically generate the colors in the gradients on lists. There is a component I wrote called FlipList that automatically wraps each of its children in an Animated view to achieve that staggered flip down animation when the screen mounts.</p><p>On the musical side, I used the Napster API to power all the playlist functionality. I associated sub-genres to the specific words in my dictionary and gave each of them a score. When <strong>Play New Sentence</strong> is pressed, it adds up the scores of the sub-genres and takes the highest two. Then the top songs endpoint is queried on the Napster API and the results are fed into the PlaylistView. It’s by no means a perfect solution, but it’s in the ballpark.</p><h3>Conclusion</h3><p>This was a fun weekend project, and I learned a lot about using Expo. They have some <a href="https://docs.expo.io/versions/v26.0.0/sdk/">fantastic APIs</a> that every React Native developer should check out.</p><p>I hope you can learn something from the source code of this project, and use it to make your own projects better! I still miss Beats Music, but at least now I have my own version.</p><p><em>Curious? Or want to chat more, whether about React or great typefaces? You can find our awesome guest-blogger Lucas McGartland on </em><a href="https://twitter.com/lucasmcgartland"><em>Twitter</em></a><em>, </em><a href="https://www.linkedin.com/in/lucasmcgartland/"><em>LinkedIn</em></a><em> or </em><a href="https://dribbble.com/lucasmcgartland"><em>Dribbble</em></a><em>, or reach him via his </em><a href="http://www.lucasmcgartland.com/"><em>website</em></a><em> or by </em><a href="/service/mailto:luke@thebeeinc.com"><em>email</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=172a33dbfe95" width="1" height="1" alt=""><hr><p><a href="https://blog.expo.dev/recreating-beats-music-with-react-native-and-expo-snack-172a33dbfe95">Recreating Beats Music with React Native and Expo Snack</a> was originally published in <a href="https://blog.expo.dev/">Exposition</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to manage file uploads in GraphQL mutations using Apollo/Graphene]]></title>
            <link>https://medium.com/free-code-camp/how-to-manage-file-uploads-in-graphql-mutations-using-apollo-graphene-b48ed6a6498c?source=rss-2b3150c688d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/b48ed6a6498c</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[Lucas McGartland]]></dc:creator>
            <pubDate>Fri, 13 Apr 2018 12:00:12 GMT</pubDate>
            <atom:updated>2018-04-14T20:18:51.270Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xCKDdyMn2NKAiufB7jtTwg.png" /><figcaption>Illustration made with Paper by <a href="https://medium.com/u/c0cc94eed79a">FiftyThree</a></figcaption></figure><p>GraphQL is an amazing way to query and manipulate data. You describe your data, ask for what you want, and get predictable results. The problem is, GraphQL only handles serializable data out of the box—there’s no way to upload files directly as part of your mutations.</p><p>But what if there were a way to combine the power of GraphQL with the ease of uploading files in a multi-part request? @jaydenseric has come up with a solution: <a href="https://github.com/jaydenseric/graphql-multipart-request-spec"><strong>graphql-multipart-request-spec</strong></a></p><blockquote>If you just want the code to make this work, jump to the end of this article to find JavaScript and Python implementations of the spec for Apollo and Graphene.</blockquote><h3>Handling File Uploads With GraphQL without Multipart Uploads (The Old Way)</h3><p>Vanilla GraphQL doesn’t support throwing raw files into your mutations. The data you can request and manipulate is limited to what you can serialize over the network. In practice, this looks like basic types: <strong>numbers, booleans, and strings</strong>. These work great—you can build almost everything you need with basic data types.</p><p>But what if you need to run a mutation that takes a file as an argument? For example: uploading a new profile picture. Here’s how you could deal with the problem with ordinary GraphQL:</p><h4>Option 1: Base64 Encoding</h4><p>Base64 encode the image and send it over the wire as a string in your mutation. This has several disadvatanges:</p><ol><li>A base64 encoded file will be approximately 33% larger than the original binary.</li><li>It’s more expensive operationally to encode and decode the file.</li><li>Complex to remember to encode and decode properly.</li></ol><h4>Option 2: Seperate Upload Requests</h4><p>Run a seperate server (or API) for uploading files. Upload the file in the first request, and then pass the resulting storage URL as part of your mutation (the second request).</p><p>However if you have to upload several files, you would have to wait until all the uploads are done before you could pass the URLs (to identify them) in your mutation, forcing a synchronous and slow process. It also adds another layer of complexity to make it handle all these requests separately in your client.</p><ol><li>It’s not asynchronous.</li><li>It’s complex to manage the other upload server.</li></ol><blockquote>Wouldn’t it be cool to just pass a file in as part of the mutation parameters?</blockquote><h3>Enter the Multipart Request Spec (The New Way)</h3><p>This is where the multipart request spec comes in. This GraphQL extension specification allows you to nest files anywhere within GraphQL mutations like this:</p><pre>{<br>  query: `<br>    mutation($file: Upload!) {<br>      uploadFile(file: $file) {<br>        id<br>      }<br>    }<br>  `,<br>  variables: {<br>    file: File // somefile.jpg<br>  }<br>}</pre><p>As you can see, adding in a file is as simple as adding in any other type of mutation parameter. To implement this spec, you have to install two parts: one that runs on the client, and another that runs on the server. Here’s what they do:</p><ul><li>The client spec defines how to map any file objects in a mutation into a key that locates where they are in a multipart request.</li><li>The server spec defines how to parse that map, and make the files re-accessible based on the key provided in the map.</li></ul><p>So in apollo-client, you can run a mutation that looks like this:</p><pre>this.props.mutate({variables: {file: yourFile}})</pre><h3>Multipart Request Spec Implementations</h3><p>If you’re looking to implement the multipart request spec with Apollo, you can easily integrate it with these packages written by Jayden Seric. These are for the JavaScript and Apollo ecosystem.</p><ul><li><a href="https://github.com/jaydenseric/apollo-upload-client">GitHub - jaydenseric/apollo-upload-client: A terminating Apollo Link for Apollo Client that fetches a GraphQL multipart request if the GraphQL variables contain files (by default FileList, File, Blob, or ReactNativeFile instances), or else fetches a regular GraphQL POST or GET request (depending on the config and GraphQL operation).</a></li><li><a href="https://github.com/jaydenseric/apollo-upload-server">jaydenseric/apollo-upload-server</a></li></ul><p>If you run your GraphQL API through Graphene and Django, you can implement the spec in Python by replacing your GraphQL view with this package I wrote here:</p><p><a href="https://github.com/lmcgartland/graphene-file-upload">lmcgartland/graphene-file-upload</a></p><h3>Conclusion</h3><p>This spec is an easy way to add file upload capability to your GraphQL application. Focus less on how to get your files, and more on what you get to do with them!</p><p>If you want to talk more, chat about GraphQL or great typefaces, <strong>hit me up on twitter @</strong><a href="https://twitter.com/lucasmcgartland"><strong>lucasmcgartland</strong></a><strong>. </strong>Or find me elsewhere on the web below:</p><blockquote><a href="http://www.lucasmcgartland.com/">Website</a> | <a href="/service/mailto:luke@thebeeinc.com">Email</a> | <a href="https://www.linkedin.com/in/lucasmcgartland/">LinkedIn</a> | <a href="https://twitter.com/lucasmcgartland">Twitter</a> | <a href="https://dribbble.com/lucasmcgartland">Dribbble</a></blockquote><h4>Further Reading:</h4><ul><li><a href="https://medium.com/@danielbuechele/file-uploads-with-graphql-and-apollo-5502bbf3941e">https://medium.com/@danielbuechele/file-uploads-with-graphql-and-apollo-5502bbf3941e</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b48ed6a6498c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/free-code-camp/how-to-manage-file-uploads-in-graphql-mutations-using-apollo-graphene-b48ed6a6498c">How to manage file uploads in GraphQL mutations using Apollo/Graphene</a> was originally published in <a href="https://medium.com/free-code-camp">We’ve moved to freeCodeCamp.org/news</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Set Up Multi-Camera Streaming to Facebook Live With Free Software]]></title>
            <link>https://medium.com/hackernoon/how-to-set-up-multi-camera-streaming-to-facebook-live-with-free-software-f6c66deb8619?source=rss-2b3150c688d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6c66deb8619</guid>
            <category><![CDATA[social-media-marketing]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[facebook-live]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[live-streaming]]></category>
            <dc:creator><![CDATA[Lucas McGartland]]></dc:creator>
            <pubDate>Wed, 04 Apr 2018 02:54:53 GMT</pubDate>
            <atom:updated>2019-05-23T08:32:52.940Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Note: This guide assumes you’re living in the walled garden of Apple and are using macOS and iOS devices, but the principles are the same for Windows and Linux.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pCFPF7xaBOVPeOniK-iWkQ.jpeg" /></figure><p>If you’re like my amazing friend Sarah Kassel and hosting your own <a href="http://popissodeep.com/">Facebook Live comedy show</a> — sometimes a single smartphone camera setup for <a href="https://hackernoon.com/tagged/facebook">Facebook</a> Live isn’t enough. What if you want to show different camera angles, cut to the audience, or overlay graphics? Using open source <a href="https://hackernoon.com/tagged/software">software</a>, you can create a studio level experience and increase the production value of your Facebook Live streams.</p><h3>Stream to Facebook Live from OBS Studio</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wfGZS4428EJma2tA5bZryQ.png" /></figure><p>OBS Studio is free and open source software for video recording and live streaming. You can use it to take different input sources and pipe them into a Facebook Live stream. Here’s how:</p><p>1. Grab a copy of OBS Studio from <a href="https://obsproject.com/">https://obsproject.com</a> and install it to your computer.</p><p>2. Next, open your web browser. Login to the Facebook page you want to live stream from and click on “Publishing Tools”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TRCMdQGIOChmXAJxGLgoRw.png" /><figcaption>This should be top of the dashboard you see on your Facebook Page.</figcaption></figure><p>3. Click “+ Create” to make a new post. Select <strong>Live Video</strong> as the type of post.</p><p>4. Once the Facebook Live viewer has appeared, choose <strong>Connect</strong> instead of Camera to connect OBS to Facebook Live. I checked “Secure Connection” for added security.</p><p>5. Copy the <strong>Stream Key</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HTDuheM8kK6VEOOfMj0tUw.png" /><figcaption>What the Connect interface looks like.</figcaption></figure><p>6. Open up OBS Studio and open the settings for streaming. Select <strong>Facebook Live</strong> as the Service and paste your Stream Key in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pvVNh-tQqYcmdTxzvFGyFA.png" /><figcaption>Paste your Stream Key in here</figcaption></figure><p>7. Hit “OK” and then you’re ready to start streaming! Once your audio/video devices are ready in OBS, and click “Start Streaming” to connect to Facebook Live. You’ll see your stream from OBS appear in the Facebook Live viewer in your web browser.</p><p>8. Click “Go Live” on Facebook to start your live stream!</p><blockquote>For more help with getting started on Facebook Live, consult <a href="https://www.facebook.com/facebookmedia/get-started/live">https://www.facebook.com/facebookmedia/get-started/live</a></blockquote><h3>Multi-Camera Wireless Streaming from iOS Devices</h3><p>While a wired connection provides the lowest latency, it can be helpful to be untethered as well. Here’s how to use an iOS device as a wireless video camera for your stream.</p><p>1. Install <a href="https://brew.sh/">Homebrew</a> if you don’t have it already.</p><p>2. Install Nginx (pronounced ‘engine-ex’) with Real-Time Messaging Protocol (RTMP) support using Homebrew. Run this command in terminal to add the source for nginx to Homebrew:</p><p>brew tap denji/nginx</p><p>Then run this command to install nginx with the necessary modules:</p><p>brew install nginx-full --with-rtmp-module --with-debug --with-http_ssl_module</p><blockquote>Nginx is a webserver that is commonly used for hosting websites. We’ll use it as server for piping and directing our local video streams.</blockquote><p>3. We’ll need to tweak the nginx configuration to allow RTMP streams. Open up the nginx config file located at /usr/local/etc/nginx/nginx.config with a text editor and add the following to the bottom:</p><pre>rtmp {<br>    server {<br>        listen 1935;<br>        chunk_size 4096;</pre><pre>        application live {<br>            live on;<br>            record off;<br>        }<br>    }<br>}</pre><p>4. Start the nginx server on your local machine sudo nginx. Your server will now be accessible at your computers IP address (which you can find in system preferences).</p><p>5. Install a RTMP capable camera app on your iOS device such as <a href="https://wmspanel.com/larix_broadcaster">Larix Broadcaster</a>.</p><p>6. In the app, point your broadcast at your server you just started. <strong>Your phone and computer must be on the same local network.</strong> If using Larix, try hitting the record button—the app will throw an error message if unable to connect.</p><p>7. Back in OBS Studio, add a new new media source by clicking the + button. Select ‘Media Source’ as the type. Uncheck ‘Local File’ and then set the input to the address of your RTMP server and with the key for your stream appended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RbHyRoSzzUCYQRDV9DpHFg.png" /><figcaption>Uncheck local and then set the input to the address of your RTMP server and with the key for your stream appended.</figcaption></figure><p>8. Start broadcasting from your phone and watch it appear!</p><p>Now you can use this source as you would any other in OBS Studio. There is a lot of latency, so use a hardwired connection instead to eliminate the lag.</p><h3>Tying it All Together</h3><p>Using RTMP, OBS Studio, iPhones, and a computer, you can easily create your own multi-camera setup for Facebook live streams, complete with overlays, transitions, and more.</p><p>Leave a comment below if you have any questions, I’ll do my best to help you troubleshoot!</p><p>If you want to talk more, chat about React or great typefaces, <strong>hit me up on twitter @</strong><a href="https://twitter.com/lucasmcgartland"><strong>lucasmcgartland</strong></a><strong>. </strong>Or find me elsewhere on the web below:</p><blockquote><a href="http://www.lucasmcgartland.com/">Website</a> | <a href="/service/mailto:luke@thebeeinc.com">Email</a> | <a href="https://www.linkedin.com/in/lucasmcgartland/">LinkedIn</a> | <a href="https://twitter.com/lucasmcgartland">Twitter</a></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6c66deb8619" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/how-to-set-up-multi-camera-streaming-to-facebook-live-with-free-software-f6c66deb8619">How to Set Up Multi-Camera Streaming to Facebook Live With Free Software</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Cross-Platform Applications with a Universal Component Library]]></title>
            <link>https://medium.com/hackernoon/building-cross-platform-applications-with-a-universal-component-library-e6292ca9a15?source=rss-2b3150c688d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6292ca9a15</guid>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[user-interface]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Lucas McGartland]]></dc:creator>
            <pubDate>Thu, 22 Feb 2018 18:08:44 GMT</pubDate>
            <atom:updated>2019-05-23T08:33:34.832Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to write an iOS, Android, and web app simultaneously while managing a design system (and throwing in some virtual reality fun for good measure).</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hdhMqYHgpb4jw9QIhA7mjQ.png" /></figure><p>Imagine this: You’re an engineer at a small startup. You’re in charge of both designing and developing the front-end user interface for your product. <em>And your product relies on being available to everyone on every device as part of its value prop. </em><strong>How are you supposed to build a platform with so many targets?</strong></p><h3>The Bee App</h3><p><a href="http://www.thebeeinc.com/">The Bee App</a> is a digital VIP pass for your favorite brands. It allows brands to deliver stories, host contests, and release exclusive products directly to their top tier fans (think the Nike app for every brand).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FFC35itb7rgU%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DFC35itb7rgU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FFC35itb7rgU%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/5a2d1010aea204180c7d5fc2110d7dfd/href">https://medium.com/media/5a2d1010aea204180c7d5fc2110d7dfd/href</a></iframe><p>Regardless of how a user accessed Bee, our team wanted to provide the best experience possible. This meant we couldn’t think of this as simply an app, but rather as a platform: <strong>any device, anytime, anywhere</strong>. The overhead for building so much with a small team (me + one other server-side engineer) was daunting, but as the mobile ecosystem has matured, so have the tools. We decided to create a library of cross-platform, reusable components in order to meet our goal of building synoptic web, iOS, and Android apps.</p><blockquote>By using universally renderable components, we were able to build three apps simultaneously while managing a design system.</blockquote><p>From concept to creation, we shipped The Bee App for iOS, Android and web simultaneously in less than 4 months.<strong> </strong>The only way to achieve this was by creating user interface components that were reusable across web, iOS, and Android. We call this our <strong>Universal Component Library</strong>. Here’s what we learned while building it.</p><h3>How to Build a Universal Component Library</h3><p>First, we decided to use <a href="http://reactjs.org/">React</a> as the framework to power our user interfaces. React allows you to define a user interface as a function of the data that it is provided with. What this means is that you can build UI declaratively—not imperatively.</p><p>Furthermore, React allows the definition of the user interface to be decoupled from the rendering engine that puts it on the screen. This is the feature we wanted to take advantage of.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bvpfI51JSA00s1zwOIzN6A.png" /><figcaption>We love React</figcaption></figure><p>React isn’t a write once, run anywhere kind of framework. Keeping the different flavors: React-Native, React-VR, etc. separate has been a very conscious decision by the React community.</p><p>However, people in the community have noticed that certain implementations of React have similarities. For instance, &lt;div&gt; in React-Dom and &lt;View&gt; in React-Native serve similar purposes as containers. Same with &lt;img&gt; and &lt;Image&gt;. This got the React community thinking: <strong>what if there were a common interface for these similar components?</strong></p><p>Well, some very talented and creative engineers at Airbnb created one called <a href="https://github.com/lelandrichardson/react-primitives/">React-Primitives</a>. React-Primitives represents the most commonly used subset of components in React and React Native, namely: View, Image, Text, StyleSheet, Animated, and Touchable. Support for React-VR and React-Sketchapp were added later.</p><blockquote>The library react-primitives allows for cross-platform React code by selecting the right dependency for the environment.</blockquote><p>This library allows us to do some crazy powerful stuff. We used React-Primitives to make user interfaces reusable across platforms and sync perfectly with our <a href="https://hackernoon.com/tagged/design">design</a> system.</p><h3>Constructing a Design Language System</h3><p>While all of this cross-platform reusable code stuff is great, what’s the best way to take advantage of it? Fortunately, more talented people at Airbnb have also come up with an answer (really we owe you a lot, drinks on the Bee team sometime).</p><p>A Design Language System (DLS) is a set of rules for building a visual identity that governs a user’s experience. This set of rules can define things like:</p><ul><li><strong>Typography</strong></li><li><strong>Colors</strong></li><li><strong>Layout</strong></li><li><strong>User interface components</strong></li></ul><p>All of which work together to construct a consistent experience across all product mediums.</p><p>Typically, the DLS will be stored in some sort of visual design document, such as a Sketch or Photoshop file. However, as the product changes, both the design documention and source code will need to be updated independently to stay in sync. This burdensome task is something that universal rendering can help solve.</p><h4>How do React + Universal Components + DLS Work Together?</h4><p>Jon Gold at Airbnb proposed the concept of the Single Source of Truth system, where definitions of all the pieces that make up a Design Language System (DLS) live. From there, many different applications can pull from that Single Source of Truth to ensure consistency across the user interfaces.</p><p>In theory, the system is completely platform agnostic. Our implementation lives within the JavaScript world— it uses React, React-Native, React-Sketchapp, and React-VR to make it possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CEKVWF2BAgUOxjloo1OZkA.png" /><figcaption>Our implementation of Airbnb and Jon Gold’s Single Source of Truth system.</figcaption></figure><p>Our DLS is defined and stored in one JavaScript package. The DLS contains information about colors, typestyles, sizes, and other <a href="https://medium.com/salesforce-ux/living-design-system-3ab1f2280ef7"><strong>design tokens</strong></a>. It also contains reusable base components that are frequently used in the application, like thumbnails, table cells, and headers. All of these are built as purely <a href="https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0"><strong>presentational components</strong></a> so that functionality can be customized.</p><h4>Creating Cross-Platform Components</h4><p>Here’s an example of a simple ProfileImage component built with React-Primitives:</p><pre>import { Image } from &#39;react-primitives&#39;;<br>import React from &#39;react&#39;</pre><pre>const ProfileImage = (props) =&gt; {<br>  return(<br>      &lt;Image<br>        style={{<br>          width: 40,<br>          height: 40,<br>          borderRadius: 20<br>        }}<br>        resizeMode=&quot;cover&quot;<br>        source={{uri: props.uri}}<br>      /&gt;<br>  )<br>}</pre><pre>ProfileImage.defaultProps = {<br>  uri: &quot;<a href="http://www.lucasmcgartland.com/profile_photo.jpg">http://www.lucasmcgartland.com/profile_photo.jpg</a>&quot;<br>}</pre><pre>export default ProfileImage</pre><p>In use this would look like:</p><pre>import { ProfileImage } from &quot;your-universal-components-package&quot;</pre><pre>export default class App extends React.Component{<br>  render(){<br>    // Add prop uri to &lt;ProfileImage/&gt; to pass in your own image<br>    return(<br>      &lt;ProfileImage/&gt;<br>    )<br>  }<br>}</pre><p>App could be your React web app, React-Native app, or even a React Sketch app. Yes, it really is that simple to use primitives.</p><h4>Rendering to all 5 Platforms</h4><p>Now that our cross platform code was working, it was time to implement components that could be reused across the platform.</p><p>We built out a simple DLS styleguide that included some colors, typestyles, and components. Here are screenshots of an early version of our DLS rendering to all five platforms simultaneously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MZUqQ6JMiE9KvL_oJoFmQ.jpeg" /><figcaption>Our early DLS rendering to all 5 platforms</figcaption></figure><p>What’s amazing about rendering out the DLS this way is that by changing one variable (say a color swatch) the apps will instantly re-render to reflect the change (thanks to hot module reloading).</p><p>With this framework now in place, we continued to build upon the DLS, creating more reusable buttons, icons, cells, and other components.</p><p>Here’s an example of an updates feed rendering across platforms:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x4mU_E_Gra7jnplpJEj76Q.png" /><figcaption>Rendering the same “updates feed” component across the 5 platforms. Note: React-VR currently doesn’t support multiple type styles.</figcaption></figure><h4>Animations</h4><p>We even found that we could share animations across the web and native applications. Here’s an example of a button with a little “spring” to it rendering on iOS and web:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*RJedzCm8ovmuAZGjaKZmYg.gif" /><figcaption>The button and the spring animation are cross platform thanks to the Animated API.</figcaption></figure><h4>Web VR</h4><p>Just for fun, we also tried rendering out the components into a React-VR environment. While we still don’t know when Bee will create a VR experience, it’s nice to know that we have the option of using our existing components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*saGDlub0l71jVZiYHpn16Q.gif" /><figcaption>Here are some story cards from the explore feed rendering in VR</figcaption></figure><h3>Project Structure</h3><p>Maintaining a Universal Component Library, web app, React-Native app, DLS Sketch rendering tool, and documentation is not an easy task. This is why we decided to use <a href="https://github.com/lerna/lerna/"><strong>Lerna</strong></a> to create a monorepo and break apart The Bee App into smaller pieces.</p><p>Here’s a look at our project structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zPY0UH_gk0g0NjRR9TpIxQ.png" /><figcaption>This is how our project is structured so that each part can reference the others.</figcaption></figure><p>This arrangement allows us share the component library and DLS easily between packages.</p><p>If you’re wondering about that GraphQL package, read on.</p><h3>Making Our API Universally Accessible</h3><p>In addition to making our user interfaces render universally, we needed to make data from our server universally available to them. We decided to use <a href="http://graphql.org/"><strong>GraphQL</strong></a> as the communication layer between the client apps and the server. GraphQL offers flexibility and integrates well with React.</p><p>This led to us creating a package of reusable GraphQL queries, mutations, and fragments (basically the definition of the requests you want to make against the server). These requests run within Javascript on any of the platforms, and their results can be pushed into the components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tkwR-2OhWAqyKyZCF66rDA.png" /><figcaption>We love GraphQL too</figcaption></figure><p>To make this process simple we used Apollo as our GraphQL client. This allowed us to wrap our presentational components from the Universal Component library with queries from our GraphQL package using higher order components. As soon as information that a component needs becomes available, the higher order component provides it via the props.</p><p><strong>Finally we had a system where we could:</strong></p><ol><li>Define what our app should look like, regardless of platform.</li><li>Specify what data a component needs, regardless of platform.</li><li>Reuse both components and data queries across platforms.</li></ol><h3>How Can a Universal Component Library Benefit Your Team?</h3><p>Using a Universal Component Library and Design Language System offers many benefits. Here’s what your team can expect to gain from this methodology:</p><h4><strong>Designers</strong></h4><ul><li>Prototype with real data. Ping your <a href="https://hackernoon.com/tagged/api">API</a> and pass the results directly into your mockups. This lets you see what your app will really look like (no more lorem ipsum).</li><li>Prototype internationalization. Use Google translate to test how user interfaces look in other languages and output results side by side.</li><li>Keep assets in sync with actual deployed code.</li></ul><h4>Developers</h4><ul><li>Less code to manage. If you can reuse code across platforms, you can save time, effort, and energy.</li><li>Code is all JavaScript. JavaScript powers the React side of all the applications, so engineers can seamlessly switch between working on the different platforms.</li></ul><h4>Business</h4><ul><li>Do the math. If one engineer can now build for three platforms instead of one you’re going to save a lot of money, and it takes less time to ship for multiple platforms.</li></ul><h3>Wrapping Up</h3><p>From here on out, our Design Language System will continue to grow and evolve along with our platform, becoming more modular and reusable. Going forward, I’d also like to build out a primitive interface for SVGs now that React-Sketchapp supports them.</p><p>I would really like to thank all the people who have contributed to React, React-Native, React-Primitives, and React-Sketchapp—none of what we built would have been possible without you. To the DLS team at Airbnb, thank you for showing us how a marriage between code and design can create amazingly powerful tools. <strong>And to the rest of the Bee team, who indulged my crazy dream of building a DLS pipeline for our crazy young startup, thank you.</strong></p><blockquote>If you’d like to join the Bee community, <a href="http://www.thebeeinc.com/">download the app</a> and use invite code <a href="https://www.thebeeinc.com/">072WT</a> to sign up (valid for first 25 users only)</blockquote><p>If you want to talk more, chat about React or great typefaces, <strong>hit me up on twitter @</strong><a href="https://twitter.com/lucasmcgartland"><strong>lucasmcgartland</strong></a><strong>. </strong>Or find me elsewhere on the web below:</p><blockquote><a href="http://www.lucasmcgartland.com/">Website</a> | <a href="/service/mailto:luke@thebeeinc.com">Email</a> | <a href="https://www.linkedin.com/in/lucasmcgartland/">LinkedIn</a> | <a href="https://twitter.com/lucasmcgartland">Twitter</a></blockquote><h4>Further Reading/Resources:</h4><ul><li>Painting With Code: <a href="https://airbnb.design/painting-with-code/">https://airbnb.design/painting-with-code/</a></li><li>Building a Visual Design Language: <a href="https://airbnb.design/building-a-visual-language/">https://airbnb.design/building-a-visual-language/</a></li><li>How Airbnb Is Using React Native: <a href="https://www.youtube.com/watch?v=8qCociUB6aQ">https://www.youtube.com/watch?v=8qCociUB6aQ</a></li></ul><h4>Libraries Used:</h4><ul><li><a href="https://github.com/lelandrichardson/react-primitives/">https://github.com/lelandrichardson/react-primitives/</a></li><li><a href="https://github.com/airbnb/react-sketchapp">https://github.com/airbnb/react-sketchapp</a></li><li><a href="https://github.com/apollographql/apollo-client">https://github.com/apollographql/apollo-client</a></li><li><a href="https://github.com/lerna/lerna/">https://github.com/lerna/lerna/</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6292ca9a15" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/building-cross-platform-applications-with-a-universal-component-library-e6292ca9a15">Building Cross-Platform Applications with a Universal Component Library</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Refreshing Token Based Authentication With Apollo Client 2.0]]></title>
            <link>https://lucasmcgartland.medium.com/refreshing-token-based-authentication-with-apollo-client-2-0-7d45c20dc703?source=rss-2b3150c688d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d45c20dc703</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[apollo-client]]></category>
            <dc:creator><![CDATA[Lucas McGartland]]></dc:creator>
            <pubDate>Thu, 21 Dec 2017 21:24:18 GMT</pubDate>
            <atom:updated>2018-04-14T20:19:47.225Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OR00yMsGBdM19GXwmtnEbg.png" /><figcaption>Apollo Client 2.0 provides many great features out of the box</figcaption></figure><p>If you use GraphQL, you’ve probably heard of Apollo Client. Apollo is fantastic for React projects because it can be incrementally adopted, has a great community, and great documentation. However, with the release of Apollo Client 2.0, there were some breaking changes, including the method of extending the interface to support your own access token/refresh token authentication flows.</p><p>A common method of authentication on the web is JSON Web Tokens (JWT). A user logs in using their username and password, and gets an access token and refresh token in response. The client then uses the access token for any requests with the server after that for authentication instead of the user’s password. Eventually, the access token will expire, and the user will need a new one. Refresh tokens allow the client to get a new access token without forcing the user to reauthenticate with their username and password.</p><p>Usually access tokens expire after an amount of time elapses, but the server can also expire them before that. So any request the client makes needs to be able to handle the scenario of an expired access token. We came up with this flow to handle it:</p><h3>Re-authentication Flow for Requests</h3><ol><li>Request is rejected with error message.</li><li>Refresh token is used to fetch new access token.</li><li>Request is retried with new access token.</li></ol><p>In practice, Apollo will handle making the actual requests to the server for you, letting you focus on your queries. However, to implement the re-authentication flow, we’ll need to extend that request making process, the network interface. In our research, we found an example of <a href="https://github.com/apollographql/apollo-client/issues/1784">someone who overrode the network interface</a> with their own version of the flow above for Apollo Client 1.0. However, the network interface is no longer exposed in Apollo Client 2.0.</p><h3>Using Apollo Client 2.0 ‘Links’ to extend the interface</h3><p>The new method of extending the Apollo Client network interface is through what they call links. <a href="https://www.apollographql.com/docs/link/overview.html">Here’s what the Apollo docs say about links</a>:</p><blockquote>“Apollo Link is designed to be a powerful way to compose actions around data handling with GraphQL. Each link represents a subset of functionality that can be composed with other links to create complex control flows of data.”</blockquote><p>What links allow you to do is create a set of functions that can interact and manipulate your request before it gets sent off to be fetched. Here is the <a href="https://www.apollographql.com/docs/react/recipes/authentication.html#Header">example</a> from the Apollo docs that creates a link to inject an authorization header into your request.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d62488f23a09982d5482edc52d0593ac/href">https://medium.com/media/d62488f23a09982d5482edc52d0593ac/href</a></iframe><p>An Apollo Client can be composed of many links. However, the set of links must always end with a <a href="https://www.apollographql.com/docs/link/overview.html#terminating"><strong>terminating link</strong></a>. Unlike the preceding links, the terminating link has to execute some operation from the parameters and return the results of the operation. Usually, this operation is a network request.</p><p>The default terminating link that Apollo provides is apollo-http-link. This terminating link executes the network request using fetch and sends back the result. You can create the link using the createHttpLink() function provided from the apollo-http-link package. createHttpLink() can take a number of options, which you can find <a href="https://www.apollographql.com/docs/link/links/http.html#options">here</a>. In the example above, we pass the URI for the graphql server so it knows where to send the request.</p><h3>Implementing the Re-Authorization Flow</h3><p>To implement the re-authozation flow listed above, we can override the fetch executed by the terminating link. We create a customFetch function that can execute the request and retry with a new token if it fails and pass that as an option to the apollo-http-link.</p><pre>const httpLink = createHttpLink({<br>    uri: &quot;/graphql&quot;,<br>    fetch: customFetch<br>})</pre><p>Here’s how we implemented a customFetch function and added it to the Apollo-Client:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b32ca1b2cf3158959cbd51f2d1486c77/href">https://medium.com/media/b32ca1b2cf3158959cbd51f2d1486c77/href</a></iframe><p>Now when a request is executed, it checks for a unauthorized error before returning the results. If the user has an expired access token, the link will get a new one using a refresh token and retry the request.</p><h3>Closing Words</h3><p>Hopefully this example helps you implement refresh token based re-authentication in your Apollo Client. Comment below if you have trouble getting this example to work and I’ll do my best to get back to you as quickly as possible!</p><p>If you want to talk more, let me know what you think about the new Star Wars, or whatever, hit me up on Twitter @<a href="https://twitter.com/lucasmcgartland">lucasmcgartland</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d45c20dc703" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Apollo Client 2.0 with Redux in Wix React Native Navigation]]></title>
            <link>https://lucasmcgartland.medium.com/using-apollo-client-2-0-with-redux-in-wix-react-native-navigation-8aa9590d4ea1?source=rss-2b3150c688d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8aa9590d4ea1</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[wix-navigation]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[apollo]]></category>
            <dc:creator><![CDATA[Lucas McGartland]]></dc:creator>
            <pubDate>Thu, 21 Dec 2017 03:16:19 GMT</pubDate>
            <atom:updated>2017-12-21T03:16:19.227Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k5aIltkF3GJPlvBgUQZzWA.jpeg" /></figure><p>In previous versions of Apollo, a Redux store could be used as the caching layer for Apollo Client. However, this no longer works with Apollo Client 2.0 as Redux support was dropped as to remove the dependency for developers who didn’t want to have to use it. You can read more about that decision <a href="https://www.apollographql.com/docs/react/2.0-migration.html#redux">here</a>.</p><p>To use Redux and Apollo Client 2.0 together, you simply have to wrap your Apollo Provider with a Redux Provider like this:</p><pre>&lt;Provider store={store}&gt;<br>  &lt;ApolloProvider client={client}&gt;<br>    &lt;YourComponent/&gt;<br>  &lt;/ApolloProvider&gt;<br>&lt;/Provider&gt;</pre><h3>Integrate both providers with Wix Navigation using Higher Order Components</h3><p>You can use a Higher Order Component (HOC) to reuse the logic wrapping your component with both providers as demonstrated above. Here’s an example of a HOC that will wrap your component with both providers, taking your component, Redux store, and Apollo Client as arguments.</p><pre>apolloAndReduxProviderHOC = (WrappedComponent, store, client) =&gt; {  </pre><pre>  class Enhance extends React.Component {    <br>    render () {      <br>      return (        <br>        &lt;Provider store={store}&gt;          <br>          &lt;ApolloProvider client={client}&gt;            <br>            &lt;WrappedComponent {...this.props} /&gt;          <br>          &lt;/ApolloProvider&gt;        <br>        &lt;/Provider&gt;      <br>      )    <br>    }  <br>  }  <br>  return Enhance</pre><pre>}</pre><p>Now you can wrap your components automatically when registering them with Wix Navigation:</p><pre>Navigation.registerComponent(name, () =&gt; apolloAndReduxProviderHOC(component, store, client));</pre><p>And that’s how it works! One caveat though: HOCs don’t transfer over static properties automatically, so if you use static navigator styles for Wix Navigation, you’ll need to have those copied over. We can use hoist-non-react-statics to auto copy those in our HOC. You’ll need to install that library first:</p><pre>npm install --save hoist-non-react-statics</pre><h4>Here’s the complete HOC example with copied statics:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03c1609993dc7373e7e72c8684054c59/href">https://medium.com/media/03c1609993dc7373e7e72c8684054c59/href</a></iframe><p>Now all your registered screens can access the Redux and Apollo stores, while maintaining any static properties they may have defined!</p><h3>Closing Words</h3><p>As a developer, I’ve always relied on the kindness of the online community to publish examples and tutorials for others. This is my first time sharing back by publishing an example online. I really do hope this post has been useful for you.</p><p>Comment below if you have trouble getting this example to work and I’ll do my best to get back to you as quickly as possible!</p><p>If you want talk more, chat about React or great typefaces, hit me up on Twitter @<a href="https://twitter.com/lucasmcgartland">lucasmcgartland</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8aa9590d4ea1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Computer science, meet exercise: How I built a push-up pedometer at a three day hackathon]]></title>
            <link>https://lucasmcgartland.medium.com/computer-science-meet-exercise-how-i-built-a-push-up-pedometer-at-a-three-day-hackathon-ffed78eef53e?source=rss-2b3150c688d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffed78eef53e</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[fitness]]></category>
            <category><![CDATA[hackathons]]></category>
            <dc:creator><![CDATA[Lucas McGartland]]></dc:creator>
            <pubDate>Mon, 16 Nov 2015 06:09:49 GMT</pubDate>
            <atom:updated>2015-11-16T06:09:49.590Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-xmwOm50QzdkXw7KeKu2SQ.png" /></figure><p>One of my favorite features of my phone is that it automatically measures my steps without me ever having to open an app. Recently though, I’ve been wanting a metric for measuring upper body activity and performance that can be automatically counted like pedometers can for steps. I use a lot of bodyweight exercises in my workouts and realized an automatic counter for push-ups and pull-ups would be extremely helpful for tracking my progress. Thus went the ideation for “Swole”, a pedometer for pushups. This weekend I had the incredible opportunity to try and create this concept at a 3 day hackathon called <a href="http://wearhacksla.splashthat.com/">Wearhacks LA</a> with a team from the <a href="http://iovine-young.usc.edu/">USC Iovine &amp; Young Academy</a>.</p><h4>Day One, 9:00pm—Midnight</h4><p>Hackathons, for the uninitiated, are events where people meet up to compete to program and build a solution to some problem, usually in a very limited amount of time. Often unhealthy amounts of junk food and little to no sleep are involved. As soon as the hackathon started, I rented out the hardware we would need. For measuring arm motion, I opted to get a <a href="https://www.myo.com/">Myo armband</a> from the hardware lab. The Myo is a motion tracker worn on the upper forearm that can connect to any bluetooth enabled phone or computer. It contains an IMU and 8 EMG sensors which allow it to detect the position of your arm and the articulation of your fingers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6iSxWbyCYjHU0T-aqrJniQ.jpeg" /><figcaption>Myo Armband by Thalmic Labs</figcaption></figure><p>I decided to limit our team’s app to counting only push-ups and use the Myo linked to a computer. I didn’t want to waste time writing an app for a mobile device or multiple algorithms that would only take more time to test. The Myo development site had a sample C++ program that dumped all the data (accelerometer, gyroscope, EMG) from a Myo-wearing person into spreadsheets. I put the Myo on, and did a few pushups while running the data collection program and graphed the results in Excel. I was surprised to see how identifiable a pattern was in the x axis among the noisy data. A quick Google search turned up two simple methods of smoothing data: exponential smoothing and moving average smoothing. I created formulas for both in Excel and applied them to the data in various configurations until my data looked smooth to my eye on the graph. The final smoothing algorithm included 4 passes of the exponential smoothing function with an alpha of .45 and moving average of the previous 4 points. I also ran tests on other team member’s pushup motion data to account for variation in technique.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q74frGkV6COjkDB-7dktmQ.jpeg" /><figcaption>Each major spike corresponds with a pushup</figcaption></figure><h4>Day Two, 9:00am—Midnight</h4><p>Now that I had a good dataset to work with, how would I actually detect a pushup? I’d never written anything like this before, but I knew of one place where similar algorithms are used all the time: <a href="https://msdn.microsoft.com/en-us/library/aa480673.aspx">Handwriting detection on tablets</a>. Basically, instead of trying to analyze the bitmap of some line after it’s been drawn, it’s easier to recognize patterns if the line is represented as a series of vectors illustrating the direction of the stroke over time. In order to make my 3 dimensional data work with a 2 dimensional gesture recognizer I combined the y-axis and z-axis data into one set of magnitudes — we’ll call it the w-axis for short — using the Pythagorean theorem. Now my I could use my original x-axis and w-axis data to simulate drawing lines on a screen for a gesture recognizer.</p><p>At this point I had to go back and start actually writing my application. I decided to use Java because it was the language I remembered most off the top of my head. I wrote a few lines to import the CSV file into some arrays, and then rewrote my Excel functions in Java to smooth the data there. Finally I added a method that transformed my point data into vector strings and output that to the console. I ran this Java program with my pushup data and put the resulting string of vectors into my Excel spreadsheet alongside the raw data. To my surprise, when I looked at the time periods where I knew a pushup occurred, I saw this sequence of vectors: “S — W — NW — NW — NW — N — N — N”. I checked my teammate’s data as well and saw similar sequences. I put all the sequences of vectors for each pushup side by side and color coded the vectors. There definitely was a pattern there. [Insert screenshot] I created a sequence of vector strings that I thought matched the data best, and decided to test it as our model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gZKnqqYs185N2be1CwWV1A.png" /><figcaption>The vector sequences and my model for the detecting them</figcaption></figure><p>Back in the Java program, I implemented a fuzzy string matching function that I found on <a href="https://code.google.com/p/google-diff-match-patch/">Google Code</a>. This allowed me to search the entire sequence of vectors for the specific sequence I had defined as the “perfect pushup model” and return the location of it. The fuzzy string matching also allowed me to tune how accurate the matches had to be and there approximate location (so I didn’t get duplicates). I tuned the function to my original data sets so it recognized the correct amount of pushups, and then it was time to test it. I put on the Myo and knocked out 50 quick push-ups. My Java program counted 43. In the interest of time, I decided the model worked well enough (the average accuracy was about 83%). This was at the end of the second day, so I would only have a few hours in the morning to help my teammates finish the web app that displayed the data.</p><h4>Day Three, 9:00am—1:30pm</h4><p>While I was designing the algorithm for counting pushups, my teammates were working on a website that would display useful metrics gleaned from the data, such as the current tally for the day, previous week’s and month’s tallies, averages, etc. We decided to use Parse for our backend, so the next morning I added a small bit of code to upload the count to our database after the data collection was done. The only thing I had left to do to create a smooth demo was automate running the Myo data collection program and my Java program that analyzed those results. Using Automator, I set up a folder action that would run a script every time a file was added to it. The script would run the Java program with the file name as an argument, and then delete the file after it had finished running. All I had to do now was run the data-collection program in that directory and the number of pushups would automatically be counted and sent to our Parse database, where our website could access the information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0YnFtssLPL9JawIQLJ9reA.png" /><figcaption>A screenshot from the final website</figcaption></figure><p>We ended up winning the prize for best design, but the Swole app isn’t stopping there. I’ve uploaded the code we used to <a href="https://github.com/lmcgartland/Swole">GitHub</a> for anyone to download and try running. Right now, our demo only counts pushups, but we could add other exercises using a combination of motion data from smartwatches and phones. The algorithm has a lot of room for improvement, and once the project is transitioned from the Myo to another, more readily available platform such as Apple Watch, I think I’ll be working on making it more accurate. I also want to create a new version of the web interface that supports data from other fitness tracking platforms so I would be able to see all my data side by side. Eventually this website would be able to analyze your data and recommend workouts to help you meet your fitness goals.</p><p>Overall, Wearhacks LA was an amazing experience, and I had so much fun creating this application. Shout-out to my teammates Jane, Jared, Joseph, and Sara for being such great sports and helping pull this hack off, thank you. If you’re at all interested in becoming a better programmer, or just want to make something cool, find a local hackathon and do it! You’ll be surprised at what you’re capable of creating when you push on the limits of your creativity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffed78eef53e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>