<?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 Joshua Kyle Small on Medium]]></title>
        <description><![CDATA[Stories by Joshua Kyle Small on Medium]]></description>
        <link>https://medium.com/@joshuakylesmall?source=rss-ab1d84987ca5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DirKym3xEnLuaW5Q0qS7Ww.jpeg</url>
            <title>Stories by Joshua Kyle Small on Medium</title>
            <link>https://medium.com/@joshuakylesmall?source=rss-ab1d84987ca5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 21:28:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@joshuakylesmall/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[Electron: Saving to file system, setting desktop background, taking photos, and more]]></title>
            <link>https://medium.com/@joshuakylesmall/electron-saving-to-file-system-setting-desktop-background-taking-photos-and-more-99fa3dfc23f1?source=rss-ab1d84987ca5------2</link>
            <guid isPermaLink="false">https://medium.com/p/99fa3dfc23f1</guid>
            <category><![CDATA[electron]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Joshua Kyle Small]]></dc:creator>
            <pubDate>Mon, 03 Apr 2017 05:48:53 GMT</pubDate>
            <atom:updated>2017-04-03T05:49:06.902Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>A little background:</strong></p><p>This is a bit of a continuation of <a href="https://medium.com/@joshuakylesmall/electron-with-react-redux-ce26fee86f9e">this blog post</a> if you haven’t stumbled upon it yet…</p><p>The plan here is to explain some of the technical difficulties we ran into when implementing our Electron, React, Redux application. The purpose of the application was to pull in random high-res images you could potentially use as a desktop background as well as use images taken by the webcam to set your background.</p><p><strong>Saving to file system and setting as background:</strong></p><p>All you need to know about here is a little thing called inter-process communication renderer, or, ipcRenderer for short. IpcRenderer is a module used to communicate between the main process and the render process. This can be done both synchronously and asynchronously. In our example the code in the render process looks like this…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/238ae26b9efd3b5c25504d7cf8a2d6df/href">https://medium.com/media/238ae26b9efd3b5c25504d7cf8a2d6df/href</a></iframe><p>Easy enough, right? The first line sends info and second and third block handle success or error. Now here is what the other piece of the puzzle looks like over in the main process…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03780a697afdf921985b069a6631783e/href">https://medium.com/media/03780a697afdf921985b069a6631783e/href</a></iframe><p>Here we are just accepting the info from the sender using the same keyword “save-photo. ” We then take the information sent and run our downloadPic function which uses “createWriteStream” to save the photo to the specified path. Once saved, we use a node package simply called “wallpaper” to set the desktop wallpaper.</p><p><strong>Taking, saving, and setting background with Photos:</strong></p><p>As you may expect, the process used to save and set the desktop background with photos is almost identical to the previous example. There are a few key differences that warrant it’s own blog section though. Of course the first step here is setting up the webcam and taking a photo. You can do this using one of two options, getUserMedia (the hard way), or react-webcam (the easy way). If you have time, I think it’s worth it to dive into getUserMedia (blog post coming soon) but if you don’t have the time or don’t want to reinvent the wheel, react-webcam is incredibly simple and easy to use. Just npm install react-webcam and add the following lines…</p><pre>import Webcam from ‘react-webcam’</pre><pre>&lt;Webcam ref=’webcam’ screenshotFormat=’image/png’ /&gt;</pre><p>and throw <em>this.refs.webcam.getScreenshot()</em> into a function to grab a screenshot. Once the photo has been taken, we use the same ipcRenderer to send the information to the main process. We then use a similar function to save the file to the file system and display as the background…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e36ec620c6d36e1d05e47afcbbe342c/href">https://medium.com/media/9e36ec620c6d36e1d05e47afcbbe342c/href</a></iframe><p>The main exception is that when the information comes back from the webcam, it is returned with a preceding string that you must remove. You’ll notice that the string contains the data type: image/png and the encoding: base 64. Since the info is encoded, we have to tell our writeFile method that this is the case by passing “base64data” in as one of the options.</p><p>And that’s about it! Everything you need to know about saving to file system, setting desktop background, taking photos, and more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99fa3dfc23f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Electron with React & Redux]]></title>
            <link>https://medium.com/@joshuakylesmall/electron-with-react-redux-ce26fee86f9e?source=rss-ab1d84987ca5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce26fee86f9e</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[electron]]></category>
            <dc:creator><![CDATA[Joshua Kyle Small]]></dc:creator>
            <pubDate>Mon, 03 Apr 2017 05:33:32 GMT</pubDate>
            <atom:updated>2017-04-03T05:50:27.318Z</atom:updated>
            <content:encoded><![CDATA[<p>The idea of writing a desktop application may seem intimidating to some but the folks at github have blessed us with The technology we know and love as Electron. Recently, my journey through the Turing school of software and design introduced us to this easy to navigate solution to creating your own desktop applications using the web frameworks us front-enders have grown accustomed to.</p><p>Our most recent project, SplashTop (I know, it sounds like a wet t-shirt contest), was a desktop application used to find and set your desktop background using either high-res photos from a well known website called Unsplash or ridiculous photos of you and your friends faces using your built in camera.</p><p>In this article I’ll walk you through our process implementing our application with Electron, the library/framework used with electron to implement our UI, and the reasons we chose this framework.</p><p><strong>Decision making:</strong></p><p>First and foremost we had to figure out which library/framework to use to display our user interface. The group vote was unanimous, we were going to use React with Redux. Why you ask? Well React with Redux is dope, for one. On top of that, the library is relatively lightweight compared to some of the other technologies I listed. This matched with our experience with React allowed us to take a deeper dive into how Electron works. Also, having worked with React a fair amount in the past I was also excited to see how it fit in with Electron and even more curious of how router would work for multi page navigation in a window that is missing an address bar. The application was small enough that it didn’t require that we use Redux but the boilerplate came with it already set up so what the hell.</p><p><strong>Getting started:</strong></p><p>At first we started by trying to create our own boilerplate and had a fair amount of success until we ran into a hot reloading road block. Eventually we decided that too much time had been devoted to trying to work out the issue with web pack and the solution was not within sight. We opted for the Electron-React-Boilerplate which was a bit bloated with things that we didn’t need but it was up and running within a couple minutes. The boilerplate did a lot of the setup heavy lifting so really all we had to do was start adding React components.</p><p><strong>Some stuff:</strong></p><p>The most important part of Electron is probably the main process. In the boilerplate, the main process is called main.development.js and looks like this to start:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d53e4a821df1aaa6cde38d96e8dd295f/href">https://medium.com/media/d53e4a821df1aaa6cde38d96e8dd295f/href</a></iframe><p>Again, the boilerplate gives us a little more than we need but essentially what this file does at this point is specify what happens on startup and shut down.</p><p>The next most important piece to the puzzle is what’s called the “render process.” The only function of this piece is exactly what the name implies: it renders elements on the page. For those who have used react, we generally start with an index.js at the top of the React hierarchy. This does not change when you use it within a Electron application. The role of this code is basically to attach your React components to the html element that you specify. Which is, in turn, taken by the main process and run in a webkit environment through Chromium.</p><p><strong>More Stuff:</strong></p><p>From here things were fairly simple. We created our React components as you normally would and React, Redux, and Electron got along fine. We pulled in photos from the Unsplash API with no issues and saved them in the Redux store without any issues. The next hurdle we had to jump over was getting React Router to work in this environment. This turned out not to be a hurdle at all. All we had to do was utilize hashHistory rather than browserHistory and everything worked like a peach.</p><p>We ran into a handful of other challenges along the way including saving photos in the file system, using selected images for desktop background and taking/using webcam photos to set desktop background. These are explained in more depth <a href="https://medium.com/@joshuakylesmall/electron-saving-to-file-system-setting-desktop-background-taking-photos-and-more-99fa3dfc23f1">here</a>.</p><p>If you want to take a look at the finished product, here is the <a href="https://github.com/noahpeden/SplashTop">repo</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce26fee86f9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>