<?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 CodePile on Medium]]></title>
        <description><![CDATA[Stories by CodePile on Medium]]></description>
        <link>https://medium.com/@codepile_net?source=rss-4bb48b53773d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*864DM7tapva1LOkq.png</url>
            <title>Stories by CodePile on Medium</title>
            <link>https://medium.com/@codepile_net?source=rss-4bb48b53773d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 11:45:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@codepile_net/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[CodePile — real-time collaborative coding]]></title>
            <link>https://medium.com/@codepile_net/codepile-real-time-collaborative-coding-6ccbb08fc3a3?source=rss-4bb48b53773d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ccbb08fc3a3</guid>
            <category><![CDATA[openshift]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[angularjs]]></category>
            <dc:creator><![CDATA[CodePile]]></dc:creator>
            <pubDate>Thu, 09 Jun 2016 17:19:41 GMT</pubDate>
            <atom:updated>2016-06-09T17:19:41.625Z</atom:updated>
            <content:encoded><![CDATA[<p>If you haven’t heard, CodePile (<a href="http://www.codepile.net/home">www.codepile.net</a>) is a real-time, collaborative coding platform with lots of great features. One of the basic necessities has always been to implement live syncing of everything from user presence to all settings and updates, without the need to refresh the page. There is, of course, a level of that already built into the fact that the site is a Single Page App (built with AngularJS), but I also needed a websockets solution to sync all database changes to all connected clients.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*3JfxR_zCgeR-686Q4yutlw.png" /></figure><p>After some research, Firebase (<a href="http://firebase.google.com/">firebase.google.com</a>) was the obvious choice. Leveraging AngularFire’s 3-way data binding, which makes handling all of the headaches involved with setting up and managing websockets connections completely transparent, I was able to start implementing features right away instead of worrying about infrastructure and configuration.</p><p>Also, while I had never worked with a NoSQL database structure, Firebase was incredibly intuitive and the learning curve was quick and painless. The biggest mind-bend coming from a SQL environment was intentionally de-normalizing for ease of use and higher performance. For example, I needed to track the user who created every code snippet (every “Pile”), and I needed to display all Piles that the currently logged in user has created in their Profile. In SQL, I might have used an indexed “createdBy” field on the Pile table. That would give me access to the creator from the Pile, and I could get all Piles for a user with a query like:</p><pre>SELECT pileID FROM Pile WHERE createdBy = ‘[Current_User]’</pre><p>However, with Firebase, such a query is very expensive. Therefore, it is much more efficient to structure the data as follows:</p><pre> — Piles<br> — — [PileID]<br> — — — CreatedBy (UserID)<br> — Users<br> — — [UserID]<br> — — — UserPiles<br> — — — — [PileID]</pre><p>The downside to this structure is that we now have to remember to manage the user’s Pile associations in two places. However, once you get used to it, it’s not difficult to see the benefits of this methodology and adapt.</p><p>From the humble first proof-of-concept release, a respected developer friend of mine told me that including raw file access, much like GitHub, was a necessary feature for CodePile to be a viable go-to code hosting solution. This would allow him to test scripts from the terminal using commands like…</p><pre>curl <a href="https://www.codepile.net/pile/xyz123.py">https://www.codepile.net/pile/xyz123.py</a> | python</pre><p>…or include remote CSS &amp; Javascript resources in HTML files, hosted and editable on CodePile. This all sounded well and good, but as my initial goal was to build the service completely on Firebase, there was no managed backend at all.</p><p>Another note here…CodePile makes use of Firepad’s operational threading &amp; presence features, as well as the Ace text editor, completing the technical stack that powers the app. One thing about using Firebase/Firepad for creating “documents”, is that no file actually exists on any server anywhere. All updates to the content are saved as a stream of keystrokes that get fast-forwarded to build up the current state of the file at any point in time. This made the idea of “raw” file access even more difficult. I needed a way to create a “physical” document on the server containing the current state of the CodePile content at the time that it’s requested.</p><p>Enter OpenShift and Node! This was my first foray into working with Linux, and it was less painful than I had feared. OpenShift (<a href="http://www.openshift.com/">www.openshift.com</a>) is a great service offering easily bootstrapped free-tier Red Hat Enterprise Linux boxes. My Node Express app, hosted at the subdomain raw.codepile.net, is pretty simple, utilizing Firepad’s “headless” Node library to pull the current state of the CodePile document, which is then written to a file and served back via response.sendFile. I also specify the “text/plain” Content-Type header to allow the browser to display the content by default, or for it to be included as an embedded resource in your next project.</p><p>Overall, this works really well, and I now have a minimal backend on which I can build other features that just don’t work in a frontend-only implementation, like sending welcome and notification emails. This hybrid approach (Firebase + Node) gives me the ability to rapidly develop new features, leveraging all that Firebase has to offer and extending it only where a managed backend is required. I couldn’t be happier with the setup!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ccbb08fc3a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>