<?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 Jon Pitcherella on Medium]]></title>
        <description><![CDATA[Stories by Jon Pitcherella on Medium]]></description>
        <link>https://medium.com/@jonpitch?source=rss-ef2206356551------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9AZNlVL_kXaNb80O.jpg</url>
            <title>Stories by Jon Pitcherella on Medium</title>
            <link>https://medium.com/@jonpitch?source=rss-ef2206356551------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 22:10:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jonpitch/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[Adding a new build notification to an Ember application]]></title>
            <link>https://medium.com/@jonpitch/adding-a-new-build-notification-to-an-ember-application-c657211289f6?source=rss-ef2206356551------2</link>
            <guid isPermaLink="false">https://medium.com/p/c657211289f6</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[service-worker]]></category>
            <category><![CDATA[progressive-web-app]]></category>
            <category><![CDATA[ember]]></category>
            <dc:creator><![CDATA[Jon Pitcherella]]></dc:creator>
            <pubDate>Wed, 26 Sep 2018 00:00:00 GMT</pubDate>
            <atom:updated>2018-09-28T01:41:34.422Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5SEPkvIoBQquUmF5dKrgg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/lPQIndZz8Mo?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Pablo García Saldaña</a></figcaption></figure><p>Continuous deployment of your Ember app is great; users with stale builds isn’t as great. Let’s take a look at building a new build notification using a service worker.</p><h3>Problem</h3><p>Users of my Ember application tend to have long running sessions. My team and I also prefer to release code often. Those releases usually come with corresponding backend changes. While we spend a lot of time making sure those releases are backwards compatible, it would be nice to have some assurance the old Ember builds are no longer in use after a reasonable amount of time.</p><p>Note that this isn’t specifically an Ember problem. While the approach and solution will be in the context of an Ember application, this could be adapted for any single page application.</p><h3>Approach</h3><p>We need the Ember application to know that there is a newer build available. There are a few ways to tackle this, but I’m going to use a <a href="https://developers.google.com/web/fundamentals/primers/service-workers/">Service Worker</a>. I like the service worker for this because not only will it make this notification simpler, it will set up my application for any future progressive web functionality.</p><p>The service worker is served from the server and will have a version associated with it. We need to rely on this always being the most up to date, so this file should never be cached or fingerprinted by a build process. We need to be able to GET /sw.js and know it’s the latest version.</p><p>When the user requests my application, the service worker gets registered. We’ll attach a handler to the onupdatefound event of the service worker registration. At the same time, we’ll set up a polling interval to tell the service worker to update itself, fetching the latest file from the server and re-registering itself. If the version of the service worker changes, our onupdatefound event will fire and we can handle it, showing the user a notification.</p><h3>Putting Pieces Together</h3><p>Start by adding a service worker, I’ll use <a href="https://github.com/DockYard/ember-service-worker">ember-service-worker</a>:</p><pre>ember install ember-service-worker</pre><p>This addon will put a service worker into your Ember build, but it won’t do much else. It will however offer us an ability to version this file with every build of our application.</p><p>Next we need to attach our onupdatefound handler. In the root of your Ember project, not /app, literally the root (outside of the app tree), add /service-worker-registration/index.js with the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14e9b1f0ab30f6cff9990d0c5811bcf7/href">https://medium.com/media/14e9b1f0ab30f6cff9990d0c5811bcf7/href</a></iframe><p>We are going to use window.isUpdateAvailable to know when a new build is available. For browsers that support <a href="https://caniuse.com/#search=Promise">Promises</a>, we create a promise that will hook in to the ember-service-worker lifecycle. When our service worker successfully installs, our function is invoked and we receive the service worker registration (reg). We add a little function to the onstatechange event, that when the service worker activates, resolves our promise.</p><p>We use addSuccessHandler here with ember-service-worker because we only want to attach this event handler once, on application load.</p><p>This next piece will likely be very application specific, since there’s a design element to it. In my application, I’m going to use the Material Web Component <a href="https://material.io/develop/web/components/snackbars/">snackbar</a> since that aligns with our design system. I’ll then create a component that gets put in my application.hbs template:</p><pre>ember g component new-build-notifier</pre><p>The component code will be:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e5ef90f7b8e54f5bc8275e94e87fc1e2/href">https://medium.com/media/e5ef90f7b8e54f5bc8275e94e87fc1e2/href</a></iframe><p>Let’s walk through this component:</p><h4>init</h4><p>The component is configured with some polling interval. Let’s go with 20 minutes for now.</p><h4>didInsertElement</h4><p>The component is inserted into the DOM and we wait for 20 minutes. After that time is up, we attach a handler to our window.isUpdateAvailable promise and re-request the service worker.</p><p>That initial delay is important. Because we’re not caching our initial web application request, users who load the application will be served the most recent build. What I’m really after are the folks who linger for a long time. The delay isn’t perfect, but it will catch the majority of the long sessions. If the delay wasn’t there, every time you visit /, you’ll immediately get a notification that a new build is available, which would be annoying.</p><h4>pollingTask</h4><p>Issue a GET /sw.js request and tell the service worker to update itself. When the next service worker installs, if the version differs from the initial version the user requested, our window.isUpdateAvailable promise will resolve, and we can fire a notification.</p><h3>Result</h3><p>I can deploy code often and users who have stale builds will see a very nice notification informing them to upgrade to the latest version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a8hHFZwA8-Guigso.png" /><figcaption>Shameless plug, you should encourage your company to take the <a href="https://app.bimpactassessment.net/">B Impact Assessment</a></figcaption></figure><p>If you have a similar implementation (or a better one), I’d love to hear about it; especially if there’s a better solution to that initial delay of polling for changes.</p><p><em>Originally published at </em><a href="https://jonpitcherella.com/2018/09/26/ember-new-build-notification/"><em>jonpitcherella.com</em></a><em> on September 26, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c657211289f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Turning My Jekyll Blog Into a Progressive Web Application]]></title>
            <link>https://medium.com/@jonpitch/turning-my-jekyll-blog-into-a-progressive-web-application-58f9046eb6b2?source=rss-ef2206356551------2</link>
            <guid isPermaLink="false">https://medium.com/p/58f9046eb6b2</guid>
            <category><![CDATA[progressive-web-app]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[jekyll]]></category>
            <dc:creator><![CDATA[Jon Pitcherella]]></dc:creator>
            <pubDate>Tue, 09 Jan 2018 00:00:00 GMT</pubDate>
            <atom:updated>2018-01-28T14:06:47.610Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y0blUdplcRki9eWqZq09wg.jpeg" /><figcaption>offline AF</figcaption></figure><p>In recent years, web technologies have started to catch up to mobile devices in terms of offering a first-class mobile experience. Here’s a step by step guide in the effort required to migrate my personal website to a progressive web application (PWA).</p><h3>Before Getting Started</h3><p>In order to track my progress, I made extensive use of the open-source project, <a href="https://github.com/GoogleChrome/lighthouse">Lighthouse</a>. There’s a handy chrome extension available <a href="https://developers.google.com/web/tools/lighthouse/">here</a>.</p><p>For those unfamiliar, Lighthouse will audit your site and give you a score over five categories:</p><ul><li>Progressive Web Application</li><li>Performance</li><li>Accessibility</li><li>Best Practices</li><li>SEO</li></ul><p>Scores range from 0 (worst) to 100 (best) and very often it will report tips or suggestions on improving your score.</p><h3>Establish a Baseline</h3><p>At the start of this project, this site is:</p><ul><li>Built with <a href="https://jekyllrb.com/">Jekyll</a></li><li>Uses <a href="http://hyde.getpoole.com/">Hyde</a> as a theme</li><li>Hosted on <a href="https://pages.github.com/">GitHub Pages</a></li></ul><p>Here’s that baseline score:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nR8u80IFS1qjlQOb.png" /><figcaption>gh-pages baseline</figcaption></figure><p>I’m immediately docked points for not using HTTPS. As of this blog post, GitHub does not offer HTTPS for static sites that use custom domains (they do offer HTTPS for non-custom domains, for free). There’s an <a href="https://github.com/isaacs/github/issues/156">open issue</a> around supporting it; but rather than wait for GitHub to maybe support this feature, I decided to migrate my site to <a href="https://www.netlify.com/">Netlify</a>, which offers SSL for custom domains.</p><p>I was initially worried I might have some performance degredation with Netlify over GitHub. I connected my repository and built my site. Here are the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*31VQZakv1hL76pDJ.png" /><figcaption>Netlify baseline</figcaption></figure><p>My scores increased with no effort and I saw comparable performance to GitHub pages. For example, I was seeing ~1 second to <a href="https://developers.google.com/web/tools/lighthouse/audits/first-meaningful-paint">first meaningful paint</a> on GitHub pages and ~1.3 seconds on Netlify. That was close enough without any optimization to move forward.</p><h4>Netlify + HTTPS</h4><p>Migrating my site to Netlify was a snap, so I won’t dive in to it. There is good documentation <a href="https://www.netlify.com/docs/">here</a> and <a href="https://www.netlify.com/blog/2017/05/11/migrating-your-jekyll-site-to-netlify/">here</a>.</p><p>After getting my repository connected:</p><ul><li>Enabled my custom domain</li><li>Enabled my free SSL certificate</li><li>Re-pointed my DNS from GitHub pages to Netlify</li></ul><p>Here are the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k-k-ZzKitVJPVgz2.png" /><figcaption>Netlify + SSL</figcaption></figure><h3>Asset Optimization</h3><p>This can be a complicated topic in web development, luckily this is literally a checkbox in Netlify (<a href="https://www.netlify.com/blog/2017/02/15/how-to-shave-time-off-of-your-load-time-its-really-really-easy/">here</a> is an overview).</p><p>Without asset optimization enabled, here are the asset requests:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cW7Sjm4TpYDX3G1g.png" /><figcaption>pre-asset optimization waterfall</figcaption></figure><p>And the lighthouse score:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z0I65Xu1qGyPst4Y.png" /><figcaption>pre-asset optimization lighthouse — performance</figcaption></figure><ul><li>First meaningful paint — 1.35 seconds</li><li>First interactive paint — 2.06 seconds</li></ul><p>After enabling the asset optimization feature:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sPuzMNS0rO1xE3jW.png" /><figcaption>post-asset optimization waterfall</figcaption></figure><p>And the lighthouse score:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ydaIkGQSiB2ff7k0.png" /><figcaption>post-asset optimization lighthouse — performance</figcaption></figure><ul><li>First meaningful paint — 1.04 seconds</li><li>First interactive paint — 1.7 seconds</li></ul><p>Now we’re back to GitHub levels of performance.</p><h3>Service Worker and Manifest</h3><p>Service worker is a recent web technology which enables things like push notifications, background sync, caching, etc. There’s a good overview <a href="https://developers.google.com/web/fundamentals/primers/service-workers/">here</a>. I found a great tutorial on service worker with Jekyll <a href="https://jamesiv.es/jekyll/amp/2017/05/09/serviceworkers-with-jekyll.html">here</a>.</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/Manifest">Web App Manifest</a> is another best practice for progressive web applications. In general, they provide metadata and allows users to “install” your site, similar to a native mobile application.</p><p>Here is the lighthouse score before having a service worker and a robust manifest:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ky_2P-qOC7NK4DaK.png" /><figcaption>pre-service worker and manifest lighthouse</figcaption></figure><p>Here are the results after:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FkRfjiEKvq1Gqrmj.png" /><figcaption>post-service worker and manifest lighthouse</figcaption></figure><p>:thumbs-up-emoji:</p><h3>Accessibility</h3><p>Most of my room for improvement here had to do with:</p><ul><li>Improving color contrast</li><li>Missing <a href="https://www.w3.org/TR/wai-aria-practices/examples/landmarks/HTML5.html">landmark</a></li></ul><p>I’m not a designer, so I found a couple great tools to help in this area. I installed a the <a href="https://chrome.google.com/webstore/detail/axe/lhdoppojpmngadmnindnejefpokejbdd">aXe</a> chrome extension. It adds a new tab to DevTools and will point out accessibility issues. I also used <a href="http://leaverou.github.io/contrast-ratio/">this</a> online tool to help compare color contrast.</p><p>Here are the results after:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O9X_3fhQ8QnQL-LU.png" /><figcaption>post-a11y updates</figcaption></figure><h3>Room for Improvement</h3><p>My best practices score seems to be out of my control:</p><pre>&#39;window.webkitStorageInfo&#39; is deprecated. Please use &#39;navigator.webkitTemporaryStorage&#39; or &#39;navigator.webkitPersistentStorage&#39; instead. </pre><pre>TypeError: Math.max is not a function at PerformanceObserver.window.PerformanceObserver.entryList (&lt;anonymous&gt;:8:30)</pre><p>I couldn’t track down the culprit, but I suspect it’s Chrome or some extension. If anyone knows where this comes from, let me know?</p><p>My performance score is almost 100, but is currently docked for <a href="https://developers.google.com/web/fundamentals/performance/critical-rendering-path/render-blocking-css">CSS blocking paint</a> by 250 milliseconds. I’m pretty happy with this score as is, but perhaps in the future I’ll optimize this further.</p><p>It would also be great to integrate lighthouse into <a href="https://github.com/ebidel/lighthouse-ci">CI</a>, also for another time.</p><h3>Wrapping Up</h3><p>I know this is a pretty trivial web site, but making it progressive was pretty simple. I’d love to hear about more complicated web applications, or single page web applications and how easy or difficult it is to build and maintain them as progressive web apps.</p><p>If you are a Jekyll user and like the Hyde theme, I made a <a href="https://github.com/jonpitch/progressive-hyde">progressive variant</a> that you can use to get started with your site.</p><p><em>Originally published at </em><a href="https://jonpitcherella.com/2018/01/09/personal-site-pwa/"><em>jonpitcherella.com</em></a><em> on January 9, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58f9046eb6b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Coffee Bot]]></title>
            <link>https://medium.com/@jonpitch/building-a-coffee-bot-61b6a41fa2cb?source=rss-ef2206356551------2</link>
            <guid isPermaLink="false">https://medium.com/p/61b6a41fa2cb</guid>
            <category><![CDATA[coffee]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jon Pitcherella]]></dc:creator>
            <pubDate>Sun, 30 Apr 2017 20:40:21 GMT</pubDate>
            <atom:updated>2017-04-30T20:40:21.296Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*82h3HoofmBPNO403syCPHQ.jpeg" /><figcaption>The percolations are imminent.</figcaption></figure><p>I didn’t choose the mug life, the mug life chose me.</p><p>The coffee situation in a crowded office can be difficult. If you don’t get the jump on a fresh pot of coffee, you might miss out entirely. Enter coffeebot.</p><h4>How Coffeebot Works</h4><p>Coffeebot monitors your drip coffee maker’s electrical current. More specifically, it monitors how long it takes a <a href="https://en.wikipedia.org/wiki/Capacitor">capacitor</a> to discharge while the coffee maker is drawing current. Fortunately, drip coffee makers draw electrical current in three distinct phases: <em>idle</em>, <em>brewing</em> and <em>heating</em>.</p><p>The coffeebot watches for the <em>brewing</em> phase. When it identifies the coffee maker as brewing, it sends a notification. When your coffee pot is done brewing, there’s another notification.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sX9NYty8Z9bC6f3WXeVCSA.png" /><figcaption>The most important Slack notification you’ll get all day.</figcaption></figure><p>Knowing exactly when coffee is ready is an incredible power; wield responsibly.</p><h4>Build Your Own</h4><p>If you would like to build your own, the source code and wiring diagram can be found <a href="https://github.com/jonpitch/coffeebot">here</a>.</p><p>If you’re in to JavaScript, robots and completely necessary things, make sure you check out my <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-1-dafd82003d36">kegerator</a>.</p><p><em>Originally published at </em><a href="https://jonpitcherella.com/2017/04/30/coffeebot"><em>jonpitcherella</em></a><em>.com on April 30th, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61b6a41fa2cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Danger Brewing: The JavaScript Powered Kegerator — Part 2 — Build Overview]]></title>
            <link>https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-2-build-overview-e61d35fc7a13?source=rss-ef2206356551------2</link>
            <guid isPermaLink="false">https://medium.com/p/e61d35fc7a13</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ember]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Jon Pitcherella]]></dc:creator>
            <pubDate>Mon, 02 Jan 2017 00:00:00 GMT</pubDate>
            <atom:updated>2017-01-02T22:40:27.053Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XPxeq5-DKxDCp-Qe.jpeg" /><figcaption>End result — A dope looking JavaScript powered beer dispensing piece of madness.</figcaption></figure><p>As mentioned in the <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-1-dafd82003d36">overview</a>, there are lots of ways to go about this build. For example, do a Google search for <em>keezer</em>, <em>coffin keezer</em> or <em>kegerator</em>, you’ll see what I mean.</p><h3>Getting Started</h3><p>I did a lot of research around different builds. I ultimately liked this rustic looking <a href="http://drewmcdowell.com/blog/9-uncategorised/81-kegerator">kegerator build</a> by Drew McDowell. There’s also a similar design in the comments of that blog post from a guy named Alex, which you can find <a href="https://brewingwithalex.wordpress.com/2015/06/10/new-kegerator-design-reclaimed-wood-and-pipe/">here</a>. The faux cement look was a little above my comfort level, but what I really liked was the wood look and the industrial style draft towers.</p><h3>The Skeleton</h3><p>The freezer itself sits on a piece of “project board” and has some 2x4s to hold it tightly in place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZrH0-mwcZzu4a0q7.jpeg" /><figcaption>Project board &amp; 2x4s</figcaption></figure><p>The frame itself is broken out into to sections, the base and lid. Here’s the base coming together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CsYk6bzMPcMM-YGJ.jpeg" /><figcaption>The base skeleton coming together</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kcH3loO3kpGoosY1.jpeg" /><figcaption>The base skeleton — finished</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1knfJrungzCvWaoi.jpeg" /><figcaption>There are tiny shims in the front of the skeleton — the freezer had a piece of plastic that prevented it from sitting flush.</figcaption></figure><p>The lid gets a little tricky. There are 2x4s on the sides, glued to the lid itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V5Iz8sZ00HSwcOto.jpeg" /><figcaption>The skeleton portion of the lid coming together — and some giant pipe clamps.</figcaption></figure><p>After those pieces are glued in, they get held tight with another 2x4 and more of the same finishing material that’s on the base.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O3Dkw8f7yhmAx63d.jpeg" /><figcaption>Lid skeleton — finished</figcaption></figure><p>After the frame is put together, I started attaching the finishing wood (pine) around the border.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q46SztxbPYeDMW5y.jpeg" /><figcaption>Pine trim around the base skeleton</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D97DQuWslVQV9uT3.jpeg" /><figcaption>Pine trim starting on the lid skeleton</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xDuAEiiJBK1oflTf.jpeg" /><figcaption>Pine trim on the lid — finished</figcaption></figure><p>The finishing material for the lid is tall on purpose. This will be used to create a cavity between the freezer lid and what will ultimately be the serving area. This cavity will allow me to hide some things, like the temperature controller and other electronics (described <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-3-tech-overview-6bb722013429">here</a>).</p><p>In its current state, the lid won’t open. There are sections cut out to allow the lid to hinge upward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KesdNSfGFTWx5wrr.jpeg" /><figcaption>Do admire the sweet chisel work</figcaption></figure><p>Now that the frame is in place and lid is put together, the freezer is starting to get really heavy. There are casters attached for mobility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GU0YBoqT4CGuPmrt.jpeg" /><figcaption>They call me Mr. Fahrenheit — Travelin’ at the speed of light.</figcaption></figure><h3>Let There Be Wood</h3><p>The idea was to find some reclaimed wood or pallet wood for a really rustic look. This proved difficult for two reasons:</p><ul><li>This wood isn’t as easy to find in my area. Because Hipsters?</li><li>The wood I did find was really inconsistent, had lots of nails or was in awful shape.</li></ul><p>I opted for generic white wood that I could buy off the shelf. It was marked up to look worn, the idea of which came from <a href="http://www.younghouselove.com/2011/04/at-long-last-a-completed-console/">Young House Love</a>. I have two different types of wood in play here: pine and white wood. Both of these take stain differently, so I did a lot of test strips before I made anything final.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Hzo8xrJVthR-C8Fp.jpeg" /><figcaption>I don’t think these are even all of the samples — just the better samples</figcaption></figure><p>The pine trim on the skeleton got stained first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yIqnGyNH3JG7XEjs.jpeg" /><figcaption>The pine border — stained</figcaption></figure><p>After a lot of permutations of stain color, time, pre-treating, sanding, etc. I wound up using Dark Walnut on the pine exclusively. For white wood pieces, some were stained with Ebony and others stained with Dark Walnut, between 1–2 minutes before wiping excess.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LBuDIt_44yYVtZFP.jpeg" /><figcaption>There’s a fair amount of variation even though there’s only two colors and two lengths of time.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HGGmcoI1sTAeQUuW.jpeg" /><figcaption>Side view of most of the base wood attached</figcaption></figure><p>On the other side, the freezer had an exhaust vent for its compressor. A wood frame was built around it and lined with a roof gutter guard — spray painted black.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cXCc8NRr0OXtJjbe.jpg" /><figcaption>Everything went better than expected.</figcaption></figure><p>I’ll cover assembling the wood for the lid later on when I go over the draft towers.</p><h3>Air Flow</h3><p>One of the common problems I kept coming across from fellow kegerator owners: <strong>air circulation</strong>. Those with poor air circulation ran into problems of inconsistent temperatures or mold and mildew. Some remedied these problems either using a product called <a href="http://www.damprid.com/">DampRid</a>, or with some small PC fans. Luckily I found what I think is a more elegant solution <a href="http://www.homebrewtalk.com/showthread.php?t=301204">here</a>. This is my first time kegging anything, so I didn’t want to take any chances.</p><p>The gist of this air flow system is a 2” PVC system that pulls air and circulates in the freezer with a bilge fan. I couldn’t physically fit 2” PVC and my kegs vertically without altering the interior lid height (I found this out the hard way), so I built a similar solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Wd0CR1t6leMUPVct.jpeg" /><figcaption>The air flow system — just 2&quot; PVC with some holes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OOy8lmlyFr3Dygus.jpeg" /><figcaption>There’s a bilge fan that pulls air through the kegerator — keeping things dry.</figcaption></figure><p>The bilge fan by itself pulls 2.4 amps, which means its louder than a world war attending a heavy metal concert. I connected the fan to what’s called a pulse-width modulator (PWM) motor control so I could safely limit the current to the fan, making it much quieter. The PWM I bought can be found <a href="https://www.amazon.com/gp/product/B00DVGGWC0">here</a>.</p><p>The original power supply I bought for the bilge fan didn’t push enough volts. When the power supply was directly connected to the fan, it worked fine, though loudly. When the PWM was in-between nothing happened. I had to buy a <a href="https://www.amazon.com/gp/product/B003TUMDWG">power supply with more voltage</a> and all was good.</p><p>Right now the fan runs non-stop on the next to lowest setting. It’s reasonably quiet and I haven’t had any mildew/water issues. My temperature also seems to remain fairly consistent. I’ll see how this goes over time, but down the road I might wire this up to a timer or by some other means to only run the fan when needed.</p><h3>Draft Towers</h3><p>I knew early on that I wanted to use industrial looking supplies. Galvanized steel and black steel pipe are generally readily available at any hardware store or plumbing supply company. I had considered using copper as well, but I don’t have the tools or the know how to make that happen; it also would have been significantly more expensive.</p><p>My biggest piece of advice with draft towers: Build them first. I say that for a few reasons:</p><ul><li>Their placement on the lid is critical. Measure and plan multiple times before you make anything permanent.</li><li>1.25” galvanized pipe and fittings may be larger than you expect. Acquire these pieces ahead of time. I went through 3 different sized beer shanks until I found one that fit.</li></ul><p>The materials used for my draft towers:</p><ul><li>2 1.25” flanges</li><li>2 1.25”x10” nipple fitting</li><li>2 1.25” T-fitting</li><li>4 1.25” right-angle fitting</li><li>4 1.25” to .75” bushing</li><li>4 2.5” <a href="https://www.amazon.com/gp/product/B00829HN88">beer shank with nipple</a></li><li>24” surface mount drip tray</li></ul><p>The beer shank is where I lost a lot of time and sanity. I originally purchased a 2.125” beer shank with a beer nut fitting. The difference is that the shank with the nut fitting already has a small amount of usable space. The locking nut and the beer line nut combined wouldn’t fit on my bushing. Here’s a photo of the 2.5” shank with the nipple assembled:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zsjTzyih-TiAHA5y.jpeg" /><figcaption>That’s a tight fit.</figcaption></figure><p>Notice that after the bushing length and the locking nut, there’s only a tiny amount of shank left. For my particular draft tower setup, the 2.125” shank was too small and a 3.125” was too long. The 2.5” was perfect.</p><p>With the towers mapped out, I could now map out the rest of the lid. There was nothing scientific about this process, just a lot of pretending like I was pouring myself a beer and seeing where things would line up.</p><p>However, it is important to note that I was going to be putting a fair amount of electronics between the freezer lid and the kegerator lid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rUZMGRhrMzaJK2Uq.jpeg" /><figcaption>It looks like a lot, but the temperature controller has ~6&#39; of slack on its power supply.</figcaption></figure><p>It was very important that I be able to get to this stuff to either troubleshoot or add on to in the future. So the way my lid is laid out, the drip tray, some wood to the right and the wood in the rear right corner (near the Raspberry Pi) are all removable. They all fit together very tight so it’s not noticeable to most, but it’s easily removable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ql0uc6NSg0Ekymhh.jpg" /><figcaption>The drip tray floats in place</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PcQp9kmDzMB93g8E.jpg" /><figcaption>The piece to the right of the drip tray easily slides out.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mDQfHocRI39mdHIb.jpg" /><figcaption>The three pieces in front of the pi also easily pop out.</figcaption></figure><p>After laying out the pieces where the draft towers were go, holes were cut to run the beer lines through.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uPN1KGCS-kK8yClZ.jpeg" /><figcaption>Figuring out drip tray and draft tower placement.</figcaption></figure><p>The wood was set in place and the flanges fixed to the lid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J14XgdSux6i23-YC.jpeg" /><figcaption>Flanges in place.</figcaption></figure><p>With the lid complete, the draft tower assembly could start. If you’re playing along at home, make sure you have a large pipe wrench to tighten the galvanized pipe. They only go so far tightening by hand and often not far enough for everything to appear symmetrical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W6bDVxIyl4dhXO8J.jpeg" /><figcaption>Lid complete — lines in place — ready for draft towers.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j55txLRGmoCsntg5.jpeg" /><figcaption>Draft towers being assembled.</figcaption></figure><p>The last step is to put the shanks and bushings together and connect to your beer line and get your faucets in place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aYS1AgznSR1e5nl-.jpeg" /><figcaption>Draft towers complete — 3 CO2 lines and 1 beer gas (stout) line</figcaption></figure><p>A couple of tips here:</p><ul><li>Use hot water to heat your beer line when attaching to a nipple that’s physically larger than the interior diameter of your beer line.</li><li>Oetiker clamps are designed to be permanent and are a huge pain in the ass to remove. If you have to remove one, cutting the crimp part with sharp set of linesman pliers works really well.</li><li>The locking nut on my shank was really tight in the galvanized steel bushing. I ended up filing them down a little bit so there was no chance of them rubbing while tightening.</li></ul><h3>Lessons Learned</h3><p>If I had to do it all over, there are a few things I’d either do differently or at least consider alternatives.</p><ul><li>The entire kegerator is unbelievably heavy. Even with casters, it’s really difficult to move on carpet.</li><li>The lid itself is very heavy. I do need to be able to swap kegs out and clean beer lines, so I’m nervous the lid is too much weight for the freezer hinges. I may build something like a car hood prop to add additional support.</li></ul><h3>Wrapping Up</h3><p>If you have any questions, comments, feedback or are planning to build a kegerator yourself, I’d love to hear about it.</p><p>Don’t forget to check <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-1-dafd82003d36">part 1</a> of this build as well as <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-3-tech-overview-6bb722013429">part 3</a> about the technical components.</p><p>Cheers!</p><p><a href="http://jonpitcherella.com/blog/tag/web-development/">Web Development</a>, <a href="http://jonpitcherella.com/blog/tag/ember/">Ember</a>, <a href="http://jonpitcherella.com/blog/tag/firebase/">Firebase</a>, <a href="http://jonpitcherella.com/blog/tag/javascript/">JavaScript</a>, <a href="http://jonpitcherella.com/blog/tag/raspberry-pi/">Raspberry Pi</a></p><p><em>Originally published at </em><a href="http://jonpitcherella.com//2017/01/02/danger-brewing-javascript-powered-kegerator-build/"><em>jonpitcherella.com</em></a><em> on January 2, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e61d35fc7a13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Danger Brewing: The JavaScript Powered Kegerator — Part 3 — Tech Overview]]></title>
            <link>https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-3-tech-overview-6bb722013429?source=rss-ef2206356551------2</link>
            <guid isPermaLink="false">https://medium.com/p/6bb722013429</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[ember]]></category>
            <dc:creator><![CDATA[Jon Pitcherella]]></dc:creator>
            <pubDate>Mon, 02 Jan 2017 00:00:00 GMT</pubDate>
            <atom:updated>2017-01-02T22:39:55.957Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0EWbmy7iflLgofgq.jpeg" /><figcaption>End result — A dope looking JavaScript powered beer dispensing piece of madness.</figcaption></figure><p>As mentioned in the <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-1-dafd82003d36">overview</a>, there were a lot of ways I could have went about this build. For example:</p><ul><li><a href="https://kegbot.org/">Kegbot</a></li><li><a href="http://raspberrypints.com/">Raspberry Pints</a></li><li><a href="https://learn.adafruit.com/adafruit-keg-bot/overview">Kegomatic</a></li></ul><p>I felt these projects either were too complicated for what I wanted to do or didn’t meet my objectives, etc. I also wanted to take the time to learn some new things along the way.</p><h3>Architecture</h3><p>I have a physical device (the freezer) in the real world collecting some data. I want to be able to see that data when I’m away from the actual freezer, so via my phone, computer, etc. The freezer data was likely to be collected by an Arduino, Raspberry Pi or something similar. Having the data with me at all times is likely to be a mobile app, website, etc.</p><p>I don’t have a lot of experience with electronics, so I wanted to spend most of my time learning that.</p><p>My first major architecture decision was to leverage <a href="https://firebase.google.com/">Firebase</a>. If you’re not familiar with it, it’s basically a “back end as a service” that also specializes in real-time data (sockets). So I need my kegerator to send data to Firebase and I need my web app / mobile app to read data from Firebase.</p><p>I decided to go the web application route for the user facing side of things since it would be more available to everyone and I could just leverage my knowledge of Ember to build something fast (<a href="https://emberway.io/ember-get-shit-done-36383c2ccc53">Ember is awesome by the way</a>). But at the same time, I wanted to explore some new areas of Ember, particularly <a href="https://ember-fastboot.com/">Fastboot</a> (server side rendering).</p><p>For the data collection, I stumbled across <a href="http://johnny-five.io/">Johnny Five</a>. Johnny Five seemed awesome. Building robots in JavaScript? Sold.</p><p>Decisions made. This seemed like the fewest moving parts that gave me the most amount of functionality. It also created a scenario where I could learn a lot of new things while still feeling really productive.</p><h3>Building The Prototype</h3><p>I started building the hub (the Raspberry Pi) portion of the project first. I had never used Johnny Five nor did I have an idea of what data I would collect from these sensors. So first things first, hub materials:</p><p>There weren’t any particular reasons why I chose those sensors. In hindsight, the better idea would have been to do more research on <a href="http://johnny-five.io/examples/">what works well</a> with Johnny Five. The temperature sensors I used didn’t play that well between Raspi-IO (The Firmata API) and Johnny Five, so I wound up looking for some external libraries to help me out.</p><p>The rest of building the prototype is just what you would expect; connecting things to the pi and breadboard, writing code and seeing what data I would get. Here’s what it looked like in its final prototype state:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IC7T-LfBbVDKswmr.jpeg" /><figcaption>The working prototype</figcaption></figure><p>There’s a much more in depth overview of setting up my Raspberry Pi and all of the sensors on the <a href="https://github.com/jonpitch/danger-brewing-hub">README</a> of the repository.</p><p>Before I integrated Firebase into my pi, I switched gears to build the web application. This was mainly so I could establish my data model and understand how I would communicate with Firebase from the kegerator. The web application code can be found <a href="https://github.com/jonpitch/danger-brewing">here</a>. There’s a brief overview of getting started.</p><p>With the web application in a good spot and the data model in place, I could then integrate Firebase into my pi. There’s some fairly good documentation for general web applications / node applications here. Now that my Raspberry Pi is talking to the same Firebase application that my Ember app is reading from, I could simulate how my kegerator could act in the real world and see how the two applications would work together.</p><p>Next comes the nerve-wrecking part, cutting all the wires so I could make it permanent.</p><h3>Making It Real</h3><p>Before making the prototype permanent, I had to assemble my liquid lines. First, wrap each flow meter with a substantial amount of teflon tape (I learned that lesson the hard way) and <a href="https://www.amazon.com/dp/B008TT393O">these</a> barbed fittings. Get an idea of where you want the flow meter to sit within the kegerator (I chose near the keg) and cut your beer lines. If your beer line interior diameter is physically smaller than 1/4”, make your life easier but sitting your beer lines in warm water for a minute or two before attaching to the barbed fitting. Ultimately, you should have something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IapIo6ajSEocw3jv.jpeg" /><figcaption>Be aggressive with the teflon tape.</figcaption></figure><p><strong>Pro Tip</strong>: Make sure you take note of which direction the flow is supposed to go before making your lines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4oTns04dcxqY2vWq.jpeg" /><figcaption>A finished beer line. As you can see, I did not follow my own advice.</figcaption></figure><p>Now we need to turn the breadboard prototype into a real circuit. For this I bought a project box and some perf board. There are plenty of options out there for these. I went with a larger project board so the Cobbler could travel with the circuit to make my life easier.</p><p>Muster up some courage and cut all of your sensors.</p><p>Assemble any way you see fit, here’s an overview of how my circuit came together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sne8llxPrHTy4s_E.jpeg" /><figcaption>Most wires are underneath — gotta have a clean look in your kegerator circuit…</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5QTn8ydp-IjU-7i3.jpeg" /><figcaption>Not as clean.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cwuj9elCleZp56DM.jpeg" /><figcaption>The circuit in its forever home.</figcaption></figure><p>After your circuit is made, it’s <strong>incredibly</strong> important that you take very careful notes as to what wire is soldered where. Triple check if you have to, it’ll be a lot more difficult to troubleshoot once it’s physically in the kegerator.</p><p>If you read <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-1-dafd82003d36">part 1</a> or <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-2-build-overview-e61d35fc7a13">part 2</a>, you’ll remember there’s a cavity between the freezer lid and the kegerator lid. This is where my circuit is going, out of sight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MPXs-vi2D2QvOmHW.jpeg" /><figcaption>Ultimately everything is tucked away — except the Pi. Stealth mode.</figcaption></figure><p>It’s in a large cavity with the freezer temperature controller, a power strip and the power adapter for my freezer air flow fan. There are two cuts in the project box:</p><ul><li>One for all of the wires to travel from the box into the freezer</li><li>A small slit for the ribbon of the Raspberry Pi to travel from the lid into the box</li></ul><p>If you’re not good at soldering, you’re about to be. Get enough wire to run all of your sensors into the freezer and solder your connections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pQVOPhuBhWd25Sul.jpeg" /><figcaption>Braiding the wires made them a little easier to work with.</figcaption></figure><p>For my DS18B20 sensor (the one that’s physically in the freezer), I put it in a travel shampoo container filled with rubbing alcohol. The alcohol won’t freeze and it’ll provide a more consistent temperature reading.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CrRmVcvhj1SevdpT.jpeg" /><figcaption>Bottom left corner — two temperature sensors in travel containers.</figcaption></figure><p>Re-attach your flow meter runs to their liquid lines and you should be done with your electronics. This is where you probably want to turn things on and make sure you soldering everything OK, things still work with Firebase, etc.</p><p>As far as testing the liquid lines, that’s hard to do until there’s actually liquid (beer hopefully) in your keg. I didn’t actually test these out until the entire build was done and I carbonated my homebrew to serve. For the record, it was probably the best thing I ever had to debug: <em>Making sure the flow meters poured the right amount of beer</em>. It was a few hours of sitting in the basement with a measuring cup, pouring variable amounts of beer and calibrating the sensor. After all, I think it was Ben Franklin who said:</p><blockquote><em>“Wasting beer is totally the worst thing a human can ever do.”</em></blockquote><p>I’m no historian, but I’m pretty sure that’s accurate.</p><h3>Contributing</h3><p>As mentioned throughout, the code for both the hub and web application are open source. They each have detailed instructions on getting started. You can find them here:</p><p>Feel free to contribute or help out in some way. If you’d like to see the project in action, you can check it out at: <a href="http://dangerbrewing.io/">dangerbrewing.io</a>. It’s using a Heroku free dyno, so please be patient with the loading time.</p><p>If you have any questions, comments, etc. I’d love to hear them.</p><p>Don’t forget to check out the <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-1-dafd82003d36">overview</a> of the entire project or the more in detail look at the <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-2-build-overview-e61d35fc7a13">build process</a>.</p><p>Cheers!</p><p><a href="http://jonpitcherella.com/blog/tag/web-development/">Web Development</a>, <a href="http://jonpitcherella.com/blog/tag/ember/">Ember</a>, <a href="http://jonpitcherella.com/blog/tag/firebase/">Firebase</a>, <a href="http://jonpitcherella.com/blog/tag/javascript/">JavaScript</a>, <a href="http://jonpitcherella.com/blog/tag/raspberry-pi/">Raspberry Pi</a></p><p><em>Originally published at </em><a href="http://jonpitcherella.com//2017/01/02/danger-brewing-javascript-powered-kegerator-tech/"><em>jonpitcherella.com</em></a><em> on January 2, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6bb722013429" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Danger Brewing: The JavaScript Powered Kegerator — Part 1]]></title>
            <link>https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-1-dafd82003d36?source=rss-ef2206356551------2</link>
            <guid isPermaLink="false">https://medium.com/p/dafd82003d36</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[ember]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Jon Pitcherella]]></dc:creator>
            <pubDate>Sun, 01 Jan 2017 00:00:00 GMT</pubDate>
            <atom:updated>2017-01-02T22:40:12.836Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fYB3C1Jacu5P98OX.jpeg" /><figcaption>End result — A dope looking JavaScript powered beer dispensing piece of madness.</figcaption></figure><p>This is a story about a completely unnecessary, over-engineered appliance that dispenses beer, has its own web application and reports data in real-time.</p><p>I wanted to keg my own beer since I started brewing 7 years ago, mostly because bottling beer is the worst. The initial plan was to build a <a href="https://www.northernbrewer.com/learn/resources/how-to-build-a-keezer-or-freezer-kegerator/">collar-style keezer</a>. But then I remembered I’m a software engineer, I like building things and I love a flimsy pretext to interject technology.</p><h3>Project Goals</h3><ul><li>Know how much beer I have left in a keg</li><li>Monitor the temperature of the fridge</li><li>Look like a piece of furniture rather than an appliance</li></ul><h3>Just To Say It</h3><p>Some important things to point out:</p><ul><li>This project isn’t economical — nor did I try to make much effort to be economical.</li><li>There are hundreds of ways to approach this project. I do not claim that this is the best approach by any means; it’s just how I went about it.</li><li>It’s completely unnecessary (but in our crazy world, <strong>very</strong> necessary).</li><li>Huge shout out to my buddy Mark who luckily for us, uses his tools and craftsmanship for good and not evil. I couldn’t have done it without him.</li><li>Also a huge shout out to my wife who was more than patient.</li></ul><h3>Freezer build</h3><p>Here’s where the journey started:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OlmvjcJfB7uWKXyO.jpeg" /><figcaption>Just a generic chest freezer. No big deal.</figcaption></figure><p>This is an off-the-shelf chest freezer from Home Depot, more specifically, <a href="http://www.homedepot.com/p/Frigidaire-7-2-cu-ft-Chest-Freezer-in-White-FFFC07M1QW/205555886">this one</a>. What may be the reason why I even embarked on this build in the first place is that a non-white chest freezer doesn’t exist. You can find a few of them out there, but they’re either enormous, too small or <a href="http://www.homedepot.com/p/White-Westinghouse-18-cu-ft-Chest-Freezer-in-Mossy-Oak-Break-Up-Infinity-Pattern-WWFC18M4RC/206386571">are trying to hide from other freezers</a>. None of those traits are acceptable for my purposes, so I purchased a white freezer and wrapped it in wood. The inspiration of which can be found <a href="http://drewmcdowell.com/blog/9-uncategorised/81-kegerator">here</a>.</p><p>There’s a 2x4 skeleton around the freezer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v5p0jvpR1TF47XpX.jpeg" /><figcaption>The skeleton around the lower portion of the freezer</figcaption></figure><p>With a similar skeleton around the lid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yIZ-VaOJSd-G9Lbd.jpeg" /><figcaption>The skeleton frame around the lid portion of the freezer</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_4-O_J6PGP8-284EICumPQ.jpeg" /><figcaption>On top of the skeleton is the finishing wood — pine.</figcaption></figure><p>The original goal was to use reclaimed wood, pallet wood or something up-cycled. This proved to be quite difficult to find enough consistent building materials. I ended up using generic “white wood” (I’m still not sure what this is exactly) and pine from the hardware store. The “reclaimed” look was inspiration from <a href="http://www.younghouselove.com/2011/04/at-long-last-a-completed-console/">Young House Love</a>. The wood was roughed up randomly and stained with two different colors at different time intervals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OjaO1WOvfBo3QLgh.jpeg" /><figcaption>The pine trim pieces — stained.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8BtfZiNKjNz-Sl4f.jpeg" /><figcaption>Interior pieces coming together. Each piece was stained at different time intervals and roughed up.</figcaption></figure><p>No worries about the freezer exhaust, it was accounted for:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B7w-ie_jpV_1BFf5.jpg" /><figcaption>The cover is a gutter guard spray painted black.</figcaption></figure><p>The draft towers are off the shelf 1.25” galvanized steel pipe and fittings. Most I was able to acquire locally with only a few pieces requiring purchase online.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r5X9zBAnc7Y-TuYZ.jpeg" /><figcaption>The lid is complete — about to assemble draft towers.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SQP9dnZWhV6SGxva.jpeg" /><figcaption>Assembling the draft towers</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KIfoUU5bCRRgZoHl.jpeg" /><figcaption>Fully assembled — side</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vXZ4OkSsqxKlVXz6.jpeg" /><figcaption>Fully assembled — front</figcaption></figure><p>One last finishing touch, a skull bottle opener and cap catcher.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TNv_g4YCVctT_T6p.jpg" /><figcaption>The most metal bottle opener.</figcaption></figure><p>To see more of the build process in detail, click <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-2-build-overview-e61d35fc7a13">here</a>.</p><h3>Kegerator Build</h3><p>The freezer I purchased fits three corny kegs (maybe a fourth if it was smaller in size and the gas tanks were on the outside), however there are four taps. This was so I could operate 3 CO2 beers at once or some combination of CO2 and Beer Gas (nitro).</p><p>There’s the standard equipment involved:</p><ul><li>3 Cornelius (corny) kegs</li><li>1 dual CO2 regulator and tank</li><li>1 NO2 regulator and tank</li><li>3 faucets, 1 stout faucet</li><li>Beer and gas lines, shanks, fittings, etc.</li><li>1 temperature controller</li></ul><p>To circumvent future moisture issues, an ingenious air flow solution was built, which I aggressively borrowed from <a href="http://www.homebrewtalk.com/showthread.php?t=301204">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0IF7OL_7fGoapIz6.jpeg" /><figcaption>There’s a bilge fan connected to 2&quot; PVC used to circulate air — no moisture in there.</figcaption></figure><p>The goal here is to keep some air circulating in the freezer to prevent mold and keep a consistent temperature. Because I chose not to build a collar or alter the height of my freezer, my implementation deviates from the original a bit. I couldn’t physically accommodate 2” PVC with kegs vertically so I only built half of the air flow solution — which works just as well.</p><h3>Technology</h3><p>Aside from monitoring keg volume and temperature, I wanted to use this project as a means to learn some new technologies. The kegerator is conceptually two main components:</p><ul><li>The hub — a <a href="https://www.raspberrypi.org/">Raspberry Pi</a></li><li>The web application — built with <a href="http://emberjs.com/">Ember</a></li></ul><p>The hub is a Raspberry Pi that sits on the lid of the kegerator (mostly just to look awesome).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cvcA10rZqQZ8Bh7W.jpg" /><figcaption>It has a matching wood shirt.</figcaption></figure><p>It is responsible for collecting sensor data and reporting it to my web application. There are three sensors being used:</p><ul><li>Flow meters — these are built into the beer lines and record liquid that passes through them.</li><li>Temperature sensor (in the fridge) — monitors the freezer temperature.</li><li>Temperature sensor (in the lid) — monitors temperature and humidity around the draft towers, outside of the freezer.</li></ul><p>The hub is running a Node application, built using <a href="http://johnny-five.io/">Johnny Five</a>. The data it collects is reported to <a href="https://firebase.google.com/">Firebase</a>. The web application is using the same Firebase project as its data source.</p><p>To read more about the technology build process in detail, click <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-3-tech-overview-6bb722013429">here</a>.</p><h3>Wrapping Up</h3><p>This project took a lot longer than I had anticipated. I was often discouraged, spent too much money and learned lessons the hard way. But ultimately, when I poured that first beer and saw my web application update in real time — holy. shit.</p><p>To see what I have on tap at any given moment or want to see how my freezer is doing, the web application can be found here: <a href="http://dangerbrewing.io/">dangerbrewing.io</a>. It’s currently hosted for free, so it may be slow to load. If you’re a complainer or some kind of jerk, feel free to send some dollars my way to fix that.</p><p>To read part 2 about the build process, click <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-2-build-overview-e61d35fc7a13">here</a>. Or part 3, which covers more about the technology involved, head <a href="https://medium.com/@jonpitch/danger-brewing-the-javascript-powered-kegerator-part-3-tech-overview-6bb722013429">here</a>.</p><p>If you embark on a similar journey, I’d love to hear about it.</p><p>Cheers!</p><p><a href="http://jonpitcherella.com/blog/tag/web-development/">Web Development</a>, <a href="http://jonpitcherella.com/blog/tag/ember/">Ember</a>, <a href="http://jonpitcherella.com/blog/tag/firebase/">Firebase</a>, <a href="http://jonpitcherella.com/blog/tag/javascript/">JavaScript</a>, <a href="http://jonpitcherella.com/blog/tag/raspberry-pi/">Raspberry Pi</a></p><p><em>Originally published at </em><a href="http://jonpitcherella.com//2017/01/01/danger-brewing-javascript-powered-kegerator-overview/"><em>jonpitcherella.com</em></a><em> on January 1, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dafd82003d36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Localization Is Hard: Here’s How We Solved It]]></title>
            <link>https://medium.com/@jonpitch/localization-is-hard-heres-how-we-solved-it-52dad61bfce3?source=rss-ef2206356551------2</link>
            <guid isPermaLink="false">https://medium.com/p/52dad61bfce3</guid>
            <category><![CDATA[ember]]></category>
            <category><![CDATA[language]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[product-design]]></category>
            <dc:creator><![CDATA[Jon Pitcherella]]></dc:creator>
            <pubDate>Sun, 28 Aug 2016 00:00:00 GMT</pubDate>
            <atom:updated>2016-08-29T01:58:43.361Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tq6Jk6W2SsyHfO_Ue4rLeQ.jpeg" /></figure><p>Localization is hard because language is hard. What makes localization especially challenging is that words and sentences can’t be approached in a vacuum by a translator. The more context you can provide, the better. For example, imagine a label on a web page that just read: <strong>High</strong>. If you’re the translator looking at the word, are we trying to convey height? Some sort of drug state?</p><p>In addition to context, meaning can often be hard to convey across languages. Because of cultural differences, not every word or sentence is a one-to-one swap. Your translator not only has to perform a difficult job of translating from one language to the other, they also have to translate your meaning.</p><p>Localization is also technically challenging. Most web applications have content in several places. There’s probably content in a database that needs to be localized. There’s also likely to be web application specific content (like form inputs, error messages, etc.) that need to be localized. What’s challenging is that providing a good user experience to someone who doesn’t speak the native language, is that all of these pieces have to align at the same time.</p><h3>Solutions</h3><p>Here’s a look at how we solved these problems at <a href="http://www.bcorporation.net/">B Lab</a>. Some of these solutions are specific to our stack, but the general concepts should be applicable to most. Let’s start with managing what needs to be translated.</p><h3>Crowdin</h3><p>We did a lot of research on translation management tools. We landed on <a href="https://crowdin.com/">Crowdin</a> because we liked its feature set and it solved all of our use cases. I won’t dive in to the details of this platform, but here’s what it gives us at a high level:</p><ul><li>We can store our content in key/value pairs, by uploading any type of file of our choosing. Think of Crowdin as a CMS for translations.</li><li>We can <strong>push</strong> and <strong>pull</strong> content to/from Crowdin through their <a href="https://crowdin.com/page/api">API</a> or <a href="https://crowdin.com/page/cli-tool">CLI</a> tool.</li><li>Someone on the business side of our application can manage the translation process. There’s rarely any developer intervention.</li><li>Translators are notified of new content; subsequently we can also be notified when translations are done (via webhooks).</li><li>Crowdin can automatically machine translate content. Content can also be crowd-sourced or you can invite your own translators.</li><li>Once something is translated, it’s stored in <strong>Translation Memory</strong>. So down the road, we aren’t duplicating translation efforts.</li></ul><p>That’s a lot of cool stuff. In brief, as long as we get content to Crowdin, our translators can translate it and we can pull it back when they’re done without much effort. So now let’s look at how we actually get content to Crowdin from different origins.</p><h3>Ember</h3><p>Our web applications are written in Ember (<a href="https://emberway.io/ember-get-shit-done-36383c2ccc53">because it’s fucking awesome</a>). For localization in our Ember apps, we use <a href="https://github.com/jamesarosen/ember-i18n">ember-i18n</a>. All of our strings are stored as JavaScript objects, per locale. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3bef4bbf8a65da0138fb2988eb080ef/href">https://medium.com/media/e3bef4bbf8a65da0138fb2988eb080ef/href</a></iframe><p>In this example, if the user’s locale is set to <strong>en</strong>, they would see the string Hello. When the locale switches to <strong>es</strong>, without any page reload or code change, the same string is instantly changed to Hola.</p><p>We also enforce localization as a practice with <a href="https://github.com/rwjblue/ember-cli-template-lint">ember-cli-template-lint</a>. If a developer puts a bare string in a template, tests fail. We think this is important for our users to never experience a situation where they see content that isn’t in the locale they chose.</p><h4>Localized Images</h4><p>We have a few assets that have text in them and of course, we want these to be localized as well. In order to do so, in our staging and production builds, we generate an asset map with <a href="https://github.com/rickharrison/broccoli-asset-rev">broccoli-asset-rev</a>. In these environments, our paths are fingerprinted, so we can’t actually refer to them in code that easily. We can however, generate an asset map and look up the path when required.</p><p>We use an <strong>instance-initializer</strong> to lookup our asset map and inject it into our <strong>i18n-image</strong> component. When that component renders it’s image, it gets its path from the asset map. Here’s an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b1a96d6069204a150ce4f7c0c8c4fcf/href">https://medium.com/media/2b1a96d6069204a150ce4f7c0c8c4fcf/href</a></iframe><h4>Integrating Ember-i18n with Crowdin</h4><p>Unfortunately, this takes a little workaround. If you recall the basic workflow of pushing and pulling files to and from Crowdin. Crowdin doesn’t recognize an ES6 JavaScript module. So what we do is instead of using JavaScript, we use JSON and use <a href="https://github.com/IvyApp/ember-cli-json-module">ember-cli-json-module</a> to convert JSON to JavaScript objects, so that:</p><ol><li>We can push/pull content to/from Crowdin</li><li>ember-i18n still works.</li></ol><p>Here’s an updated example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d161dd895590f5ca49a16c54649afa62/href">https://medium.com/media/d161dd895590f5ca49a16c54649afa62/href</a></iframe><p>It’s subtle, but this little change makes a huge difference for us. We can ship these .json files to Crowdin without modification and our content is brought in without issue. ember-cli-json-module also transpiles our .json files to JavaScript exports that ember-i18n understands, so everything still works well on that front.</p><h4>Other Caveats</h4><p>We initially ran in to some issues for form validations with the addon we were using. We switched over to <a href="https://github.com/offirgolan/ember-cp-validations">ember-cp-validations</a> and <a href="https://github.com/jasonmit/ember-i18n-cp-validations">ember-cp-i18n-validations</a> and haven’t looked back. If you’re not using either of these already and require localization, I would recommend making the change.</p><h3>Database Content</h3><p>With all this talk of shipping files, hopefully you’re wondering how we deliver and retrieve our database content. We manage this pretty easily with jobs. When English content changes, we queue up a job that grabs the relevant content we need to translate, creates a file and pushes it to Crowdin. As soon as the file gets to Crowdin, translators are notified and they translate the content. As soon as they’re done, a webhook lets us know, we queue up a new job and that content is pulled back, fully translated: Continuous Localization.</p><p>Here’s how we store our localized content in the database:</p><p><strong>Table A</strong>: <strong>id</strong>, <strong>some-meta-data-1</strong></p><p><strong>Table A — TL</strong>: <strong>id</strong>, <strong>table-a-id</strong>, <strong>locale</strong>, <strong>some-localized-content-1</strong></p><p><strong>Table A</strong> always stores meta data about the resource while <strong>Table A — TL</strong> stores localized content. When we request localized content, we join these two tables and filter by locale. Because this locale is driven by the user, as the user changes their locale, this code remains the same and the user gets different content.</p><h4>Other Caveats</h4><p>Something we haven’t quite solved yet is content length. Meaning, let’s say a column in the database is a 255 character string. Someone writing content in English, uses most of those characters, let’s say 240. When it’s translated to another language, it may end up as 258 characters. This doesn’t fit in our database and we don’t want to just truncate the string. Rather than just making everything a giant string value, like text or thousands of characters, we have just been dealing with it as it comes up. If you have any suggestions we’d love to hear them.</p><h3>Shipping Files</h3><p>We use <a href="https://www.docker.com/">Docker</a> for local development, so we have a <a href="https://hub.docker.com/r/impactbot/impact-platform-crowdin/">container</a> that pushes/pulls content to/from Crowdin for us. Based on our Crowdin config, a container is created, grabs the files we want and either pushes or pulls to/from Crowdin in a single command.</p><h3>Wrapping Up</h3><p>Localization is still damn hard. The benefit for us, is that we have at least removed developers from the process entirely. It’s also awesome that we can provide a really amazing global user experience without reloading the page. Our content creators and translators collaborate and we can continuously localize our application with almost no effort.</p><p>Let us know what you think! We’d love to hear your challenges and solutions to hard localization problems. We also don’t support any right to left languages at the moment, so let us know what to expect.</p><p><a href="http://jonpitcherella.com/blog/tag/web-development/">Web Development</a>, <a href="http://jonpitcherella.com/blog/tag/localization/">Localization</a>, <a href="http://jonpitcherella.com/blog/tag/products/">Products</a></p><p><em>Originally published at </em><a href="http://jonpitcherella.com/2016/08/28/solving-localization/"><em>jonpitcherella.com</em></a><em> on August 28, 2016.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52dad61bfce3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Write Better Ember Tests]]></title>
            <link>https://medium.com/@jonpitch/write-better-ember-tests-d2e22fb76bf2?source=rss-ef2206356551------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2e22fb76bf2</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[ember]]></category>
            <dc:creator><![CDATA[Jon Pitcherella]]></dc:creator>
            <pubDate>Wed, 27 Jul 2016 00:00:00 GMT</pubDate>
            <atom:updated>2016-07-28T22:30:56.923Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fq8IzVxeUrl3t-Mr7rf7VQ.jpeg" /></figure><p>If you’re not testing your code, well, you’ve got some nerve. For the rest of us rational people, let’s look at some basic tips for writing better Ember tests.</p><h3>What Makes a Good Test</h3><p>There are three core components:</p><h4>1. Easy to Reason</h4><p>Tests must be easy to understand. While <a href="https://medium.com/@jonpitch/code-quality-matters-4a7384f30f0e">code quality is important</a> for developers to understand, tests often communicate a business requirement or decision which is often more important.</p><h4>2. Specificity</h4><p>Tests should be very granular. Being specific is a great way of creating a manifest of all of the pathways, states and other vagaries that may not be immediately obvious.</p><h4>3. Speed</h4><p>Tests must be fast. The faster the test runs, the faster the developer can regression their code. The faster a developer can setup and write a test for their new code, the faster more code/tests can be written.</p><h3>Be Verbose</h3><p>By default, Ember uses <a href="http://qunitjs.com/">QUnit</a> under the hood. There are two ways we can leverage QUnit that make our tests easier to reason about.</p><p>Have a meaningful test name:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c87fcc4cb04641d37bd4a923915bd24/href">https://medium.com/media/5c87fcc4cb04641d37bd4a923915bd24/href</a></iframe><p>Even though an assertion message is optional, it provides a good overview of what you’re testing:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c233186ca51e2ac3f47257e31669dee8/href">https://medium.com/media/c233186ca51e2ac3f47257e31669dee8/href</a></iframe><h3>Page Object</h3><p>The <a href="http://martinfowler.com/bliki/PageObject.html">Page Object Design pattern</a> is a powerful one for writing re-usable, easy to understand tests. Here’s an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5328bbc08f3793183317c420450aa0db/href">https://medium.com/media/5328bbc08f3793183317c420450aa0db/href</a></iframe><p>In this trivial example, the first test demonstrates a problem where as you start to add more tests, you will end up writing the same selectors multiple times. In the second test, it should be clear that the page variable could be refactored and re-used across tests. Now all of your tests reference <strong>page.$button</strong>; One change to the page object now updates all of your tests using it.</p><p>An even better approach would be to leverage the <a href="http://ember-cli-page-object.js.org/docs/v1.4.x/">ember-cli-page-object</a> addon:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51961e4dc07f771074e4664cd28c7c8d/href">https://medium.com/media/51961e4dc07f771074e4664cd28c7c8d/href</a></iframe><p>In this example, we setup a page object which has all the parts of the page we care about, similar to the examples prior. With ember-cli-page-object, tests become much easier to reason because our assertions become almost human readable: <strong>page.button.isVisible</strong> could be understood by non-developers. ember-cli-page-object also makes writing tests faster for developers. Tests can be quickly read and understood without having to recall which jQuery selector to use to find your element.</p><p><strong>Pro Tip:</strong> I have found id and class selectors volatile over time. I have found using a <strong>data-test</strong> attribute to be much more stable. For example:</p><pre>&lt;p class=”strong” data-test=”description”&gt;Something&lt;/p&gt;</pre><p>In this piece of HTML, we have a &lt;p&gt; tag that has two attributes, <strong>class</strong> and <strong>data-test</strong>. <strong>class</strong> may change over time as styles change, or naming convention changes. <strong>data-test</strong> is more of a universal selector for this element that denotes what the element is and signals to the developer that it’s used by tests and should be changed with hesitation.</p><h3>Mock Server Requests</h3><p>Chances are your application works with some kind of backend or API. Mocking your API in Ember is a great idea for several reasons:</p><ul><li>No backend dependency to run your app tests</li><li>Data and state are ephemeral</li><li>It’s faster to mock various server scenarios</li></ul><p>There are a few ways to achieve this, but my personal favorite is <a href="http://www.ember-cli-mirage.com/">ember-cli-mirage</a>. <strong>TL;DR</strong>:</p><ul><li>Your application is going to make web requests, for example: <em>GET /api/things</em></li><li>You’re going to use Mirage to intercept web requests.</li><li>You’re going to send a “mock” response so your tests can run without actually hitting a backend.</li></ul><p><strong>Pro Tip:</strong> ember-cli-mirage does not currently support the idea of scenarios. For example, I want <em>GET /api/things</em> to return a specific response most of the time, but in some different case, I want it to return something else.</p><p>Here’s what I have found to be a good solution:</p><ul><li><a href="http://www.ember-cli-mirage.com/docs/v0.2.x/defining-routes/">Define your Routes</a> as if they were the “happy path” — the data that is returned most of the time.</li><li>In the test that expects something different, specifically override that route, for example:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6586cdf88bcbb1e6c4adbbdb7714429/href">https://medium.com/media/f6586cdf88bcbb1e6c4adbbdb7714429/href</a></iframe><p>This is recommended by Mirage and can be found in their documentation <a href="http://www.ember-cli-mirage.com/docs/v0.2.x/acceptance-testing/#asserting-a-server-call-was-made-in-a-test">here</a>.</p><h3>Final Thoughts</h3><p>Are you using a CI tool? You should be. There are <a href="https://xebialabs.com/the-ultimate-devops-tool-chest/continuous-integration/">a lot of options</a> out there. A popular option, <a href="https://travis-ci.org/">Travis</a>, is free for open source projects. As application complexity increases, or the number of developers increases, it becomes pretty difficult for any one person to know everything. Writing lots of good tests and having them pass before integrating new code is important for the sanity of the team and it helps build confidence in the application’s stability over time. Find a bug? No worries, write a test that reproduces it, fix the bug and never worry about it again.</p><p>Make no mistake, tests can be challenging. They often involve the same amount, or more code than your application. No matter how easy it is to write tests, they still take time, which could be time spent writing more features or fixing bugs. The real key to writing good tests is understanding their worth. Your time is the most valuable asset you have. Don’t waste it by debugging things a simple test would have caught.</p><p>Have some tips of your own? I’d love to hear them.</p><p><a href="http://jonpitcherella.com/blog/tag/web-development/">Web Development</a>, <a href="http://jonpitcherella.com/blog/tag/ember/">Ember</a>, <a href="http://jonpitcherella.com/blog/tag/javascript/">JavaScript</a>, <a href="http://jonpitcherella.com/blog/tag/testing/">Testing</a></p><p><em>Originally published at </em><a href="http://jonpitcherella.com/2016/07/27/write-better-ember-tests/"><em>jonpitcherella.com</em></a><em> on July 27, 2016.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2e22fb76bf2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ember Theming]]></title>
            <link>https://medium.com/@jonpitch/ember-theming-97e9562084c7?source=rss-ef2206356551------2</link>
            <guid isPermaLink="false">https://medium.com/p/97e9562084c7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ember]]></category>
            <dc:creator><![CDATA[Jon Pitcherella]]></dc:creator>
            <pubDate>Sat, 02 Apr 2016 00:00:00 GMT</pubDate>
            <atom:updated>2016-04-02T14:06:17.060Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r6j2WWrvRzcUzTmLQXQ0DQ.jpeg" /></figure><p>Theming a web application typically involves swapping out stylesheets or moving CSS classes around. But what if you have a single page application? It’s a little tricky, but <a href="http://emberjs.com/">EmberJS</a> and <a href="http://sass-lang.com/">SASS</a> make it incredibly easy.</p><h3>Goals</h3><p>There are two primary goals that I wanted to achieve:</p><h4>Swap Themes Quickly</h4><p>Rather than have code change colors, fonts, etc. on the fly, it makes a lot more sense to already have those styles pre-defined in CSS.</p><h4>Be Extensible</h4><p>When exposed as an Ember Addon, our implementation should allow for 3rd parties to add their own themes easily.</p><h3>How It Works</h3><p>This implementation assumes a few things:</p><ul><li><a href="https://guides.emberjs.com/v2.4.0/applications/services/">Ember Services</a></li><li><a href="https://github.com/aexmachina/ember-cli-sass">ember-cli-sass</a></li></ul><p>The bulk of the theme-switching work is done by a theme service and some SASS mixins.</p><h3>Let’s Get SASSy</h3><p>Let’s first look at the SASS code. There’s a <strong>$themes</strong> map declared. It’s written so that there are base themes and themes within the base. For example, suppose you had different areas of your application to theme, but they should still be a part of your overall theme (like a namespace):</p><ul><li><em>foo-primary</em></li><li><em>foo-secondary</em></li></ul><p>In this example, foo is the base theme and primary and secondary are the sub-themes.</p><p>The properties of the map are arbitrary, but they are what you’ll refer to later on in CSS, sort of like a theme API. Think of it like <em>“for this </em><strong><em>div.class-name</em></strong><em>, use the </em><strong><em>primary</em></strong><em> color for the background”</em>.</p><p><strong>Note:</strong> We will be using a <strong>data-theme</strong> attribute on HTML tags. I thought this was cleaner than swapping class attributes and the intent is clear in the markup.</p><p>Here is a gist of the SASS functionality to make theme switching happen. I’ll come back to using it momentarily.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4221ee4c247e688bf45e3d0199fea5c0/href">https://medium.com/media/4221ee4c247e688bf45e3d0199fea5c0/href</a></iframe><h3>Theme Service</h3><p>Now let’s take a look at the theme service. Anything that’s going to consume this service will be able to:</p><ul><li>bind to the current theme</li><li>set the base theme</li><li>set the sub-theme</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ffb085b0ea811ad0c2c2477e555dc3fe/href">https://medium.com/media/ffb085b0ea811ad0c2c2477e555dc3fe/href</a></iframe><h3>Theming Your Application</h3><p>How you determine when themes change is up to you. But here’s an example of swapping themes at a route:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8be1f066a6dafecbb07ed3670f4810ce/href">https://medium.com/media/8be1f066a6dafecbb07ed3670f4810ce/href</a></iframe><p>Determining what you want to theme is also up to you. Let’s assume you have a component, here’s an example of using the theme service:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/58d906f1c887dae8263cca642784b6d0/href">https://medium.com/media/58d906f1c887dae8263cca642784b6d0/href</a></iframe><p>Two things to note:</p><ul><li>Your component injects the theme service</li><li>Your template has a div with a <strong>data-theme</strong> attribute that is bound to the <strong>theme.name</strong>.</li></ul><p>As the <strong>theme.name</strong> property changes, your data-theme will as well.</p><p>Last, to wire this all together, you have to style your div with the theme property you want. For example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b645b7cc6e7172c7af93bf533cf3cc83/href">https://medium.com/media/b645b7cc6e7172c7af93bf533cf3cc83/href</a></iframe><p>Only the first couple lines are relevant, the remainder displays what the resulting CSS will look like.</p><h3>Extending</h3><p>In the SASS code, it merges a property <strong>$theme-additional</strong> if it exists into the <strong>$themes</strong> map. If this code were available as an addon, you could add your own themes as follows:</p><ul><li>Create your own theme map, so long as it is named <strong>$theme-additional</strong>.</li><li>Make sure you <strong>@import</strong> it prior to <strong>$themes</strong>.</li></ul><h3>Wrapping Up</h3><p>If you thought this was interesting, found a way to make it better or wound up doing something awesome with it, I’d love to hear about it.</p><p>Here’s an example of theme switching in action:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QkQXCMArp7htnlgl.gif" /><figcaption>B Impact Assessment — Theme Switching</figcaption></figure><p>If you want to view theme switching live and you want to make a difference in the world, why not try <a href="http://bimpactassessment.net/">Measuring What Matters Most</a>? You can also view a full gist <a href="https://gist.github.com/jonpitch/655194358902cf3a0c05647dc1aca6a0">here</a>.</p><p><a href="http://jonpitcherella.com/blog/tag/web-development/">Web Development</a>, <a href="http://jonpitcherella.com/blog/tag/ember/">Ember</a>, <a href="http://jonpitcherella.com/blog/tag/javascript/">JavaScript</a></p><p><em>Originally published at </em><a href="http://jonpitcherella.com/2016/04/02/ember-theming/"><em>jonpitcherella.com</em></a><em> on April 2, 2016.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97e9562084c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nobody is Going to Steal Your Dumb Idea]]></title>
            <link>https://medium.com/@jonpitch/nobody-is-going-to-steal-your-dumb-idea-3e85c8d66e44?source=rss-ef2206356551------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e85c8d66e44</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[humor]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <dc:creator><![CDATA[Jon Pitcherella]]></dc:creator>
            <pubDate>Sun, 24 Jan 2016 00:00:00 GMT</pubDate>
            <atom:updated>2016-01-24T19:40:51.268Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>Hey, you make apps, right?</em></strong></blockquote><p>Ugh, yeah, sure, I <em>make apps</em>.</p><blockquote><strong><em>I have an awesome idea, want to hear it?</em></strong></blockquote><p>Not particularly, but sure.</p><blockquote><strong><em>What if there was Uber for &lt;insert something ridiculous here&gt;, plus drones, for your phone…also internet of things!</em></strong></blockquote><p>Sorry, I spaced out there for a second. So I just Googled your idea, turns out there’s already 3–4 competing products. Why don’t you use one of those?</p><blockquote><strong><em>Bro, drones! Also my UI will be better.</em></strong></blockquote><p>Sure it will. What’s the current market like? Do you have a business plan? How are you going to market your idea? How will you make money?</p><blockquote><strong><em>That’s a lot of hard questions. I know at least a half dozen people who thought this was a good idea.</em></strong></blockquote><p>Aside from your mom, will those five people pay for it?</p><blockquote><strong><em>Totally.</em></strong></blockquote><p>So no.</p><blockquote><strong><em>Come on man, it won’t be that complicated to write. Help me out and I’ll cut you in for like 50%.</em></strong></blockquote><p>So, I get to do 99% of the work for 50% of the “revenue”? That sounds awesome. How do you know it won’t be that complicated, why don’t you write it then? Just because an app cost $0.99 doesn’t mean it won’t take a fair amount of effort. I also have a day job and a life. If I’m following along, I get to sacrifice all the precious free time I do have to work on your idea that isn’t even half baked for a non-majority of the revenue?</p><p>You do realize that ideas aren’t worth anything, right? Execution is everything.</p><blockquote><strong><em>Whatever dude, just don’t steal my idea.</em></strong></blockquote><p>Trust me, I’m not going to steal your dumb fucking idea.</p><p><em>Originally published at </em><a href="http://jonpitcherella.com/2016/01/24/nobody-will-steal-your-dumb-idea/"><em>jonpitcherella.com</em></a><em> on January 24, 2016.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e85c8d66e44" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>