<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
      <title>Recent Content on All About GO </title>
      <generator uri="https://hugo.spf13.com">Hugo</generator>
    <link>http://www.brianpaulson.com/index.xml</link>
    <language>en-us</language>
    <author>Brian Paulson</author>
    <copyright>Copyright (c) 2014, Brian Paulson; all rights reserved.</copyright>
    <updated>Fri, 08 Aug 2014 00:00:00 UTC</updated>
    
    <item>
      <title>Foramtting function for JavaScript strings</title>
      <link>http://www.brianpaulson.com/post/javascript-string-format</link>
      <pubDate>Fri, 08 Aug 2014 00:00:00 UTC</pubDate>
      <author>Brian Paulson</author>
      <guid>http://www.brianpaulson.com/post/javascript-string-format</guid>
      <description>&lt;p&gt;The project I work on has been around for about 10 years now. Due to the nature of the work a lot of the updates that should happen don&amp;rsquo;t due to how work is paid for. I am currently working on the task of taking our application that was mainly built and used by customers for IE 6 and making that work in all of the latest major browsers. As you can imagine there is a lot of problems that we are running into.&lt;/p&gt;

&lt;p&gt;One issue that I was dealing with recently was a large section of code that takes an array of JSON objects and pushes the data into a table. The code was building each row, cell and all the attribute individually in a loop, as well we use a lot of non-standard attributes on elements. Not only was this just not working and was not rebuilding the full table.&lt;/p&gt;

&lt;p&gt;I began trying to work out a solution where I could define a string representing the table row I was creating with the locations where I needed the data to be placed (think printf or any number of methods in many programming languages.) After several iterations I had a working solution but didn&amp;rsquo;t want to have to call the function as much as I just wanted to apply the formatting to the string, the result is the function below.&lt;/p&gt;

&lt;div class=&#34;highlight&#34; style=&#34;background: #272822&#34;&gt;&lt;pre style=&#34;line-height: 125%&#34;&gt;  &lt;span style=&#34;color: #f8f8f2&#34;&gt;String.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;prototype&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;format&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #66d9ef&#34;&gt;function&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;()&lt;/span&gt; &lt;span style=&#34;color: #f8f8f2&#34;&gt;{&lt;/span&gt;
      &lt;span style=&#34;color: #66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;s&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #66d9ef&#34;&gt;this&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;toString&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;();&lt;/span&gt;
      &lt;span style=&#34;color: #66d9ef&#34;&gt;for&lt;/span&gt; &lt;span style=&#34;color: #f8f8f2&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color: #66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #ae81ff&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;;&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;arguments&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;length&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;;&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;i&lt;/span&gt;&lt;span style=&#34;color: #f92672&#34;&gt;++&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color: #f8f8f2&#34;&gt;{&lt;/span&gt;       
        &lt;span style=&#34;color: #66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;reg&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #66d9ef&#34;&gt;new&lt;/span&gt; &lt;span style=&#34;color: #f8f8f2&#34;&gt;RegExp(&lt;/span&gt;&lt;span style=&#34;color: #e6db74&#34;&gt;&amp;quot;\\{&amp;quot;&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color: #e6db74&#34;&gt;&amp;quot;\\}&amp;quot;&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color: #e6db74&#34;&gt;&amp;quot;gm&amp;quot;&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;);&lt;/span&gt;             
        &lt;span style=&#34;color: #a6e22e&#34;&gt;s&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;s&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;replace&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;reg&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;arguments&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;[&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;i&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;]);&lt;/span&gt;
      &lt;span style=&#34;color: #f8f8f2&#34;&gt;}&lt;/span&gt;

      &lt;span style=&#34;color: #66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;s&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;;&lt;/span&gt;
    &lt;span style=&#34;color: #f8f8f2&#34;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;As you can see from the code we are replacing points in the strings formatted like this {1} with elements from the array. an actual string example would be like the section below for say making a table. Then simply call the rowTemplate.format(arguments) to have all your values inserted in to the string, and using jQuery insert the table into the DOM.&lt;/p&gt;

&lt;div class=&#34;highlight&#34; style=&#34;background: #272822&#34;&gt;&lt;pre style=&#34;line-height: 125%&#34;&gt;  &lt;span style=&#34;color: #66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;rowTemplate&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #e6db74&#34;&gt;&amp;#39;&amp;lt;tr style=&amp;quot;background:#ddd;cursor:pointer;&amp;quot; attribute1=&amp;quot;{0}&amp;quot; attribute2=&amp;quot;{1}&amp;quot;&amp;gt;&amp;lt;td&amp;gt;{2}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;{3}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;{4}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;{5}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;{6}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;{7}&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;#39;&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;;&lt;/span&gt;

    &lt;span style=&#34;color: #a6e22e&#34;&gt;rowTemplate&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;format&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;attribute1&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;attribute2&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell1&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell2&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell3&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell4&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell5&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell6&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Complete example&lt;/p&gt;

&lt;p&gt;HTML table&lt;/p&gt;

&lt;div class=&#34;highlight&#34; style=&#34;background: #272822&#34;&gt;&lt;pre style=&#34;line-height: 125%&#34;&gt;&lt;span style=&#34;color: #f92672&#34;&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
    &lt;span style=&#34;color: #f92672&#34;&gt;&amp;lt;tbody&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;id=&lt;/span&gt;&lt;span style=&#34;color: #e6db74&#34;&gt;&amp;quot;mytableBody&amp;quot;&lt;/span&gt;&lt;span style=&#34;color: #f92672&#34;&gt;&amp;gt;&lt;/span&gt;
        &lt;span style=&#34;color: #f92672&#34;&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
            &lt;span style=&#34;color: #f92672&#34;&gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span style=&#34;color: #f92672&#34;&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
    &lt;span style=&#34;color: #f92672&#34;&gt;&amp;lt;/tbody&amp;gt;&lt;/span&gt;
&lt;span style=&#34;color: #f92672&#34;&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;JavaScript&lt;/p&gt;

&lt;div class=&#34;highlight&#34; style=&#34;background: #272822&#34;&gt;&lt;pre style=&#34;line-height: 125%&#34;&gt;  &lt;span style=&#34;color: #f8f8f2&#34;&gt;String.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;prototype&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;format&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #66d9ef&#34;&gt;function&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;()&lt;/span&gt; &lt;span style=&#34;color: #f8f8f2&#34;&gt;{&lt;/span&gt;
      &lt;span style=&#34;color: #66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;s&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #66d9ef&#34;&gt;this&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;toString&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;();&lt;/span&gt;
      &lt;span style=&#34;color: #66d9ef&#34;&gt;for&lt;/span&gt; &lt;span style=&#34;color: #f8f8f2&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color: #66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #ae81ff&#34;&gt;0&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;;&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;arguments&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;length&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;;&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;i&lt;/span&gt;&lt;span style=&#34;color: #f92672&#34;&gt;++&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color: #f8f8f2&#34;&gt;{&lt;/span&gt;       
        &lt;span style=&#34;color: #66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;reg&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #66d9ef&#34;&gt;new&lt;/span&gt; &lt;span style=&#34;color: #f8f8f2&#34;&gt;RegExp(&lt;/span&gt;&lt;span style=&#34;color: #e6db74&#34;&gt;&amp;quot;\\{&amp;quot;&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color: #e6db74&#34;&gt;&amp;quot;\\}&amp;quot;&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color: #e6db74&#34;&gt;&amp;quot;gm&amp;quot;&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;);&lt;/span&gt;             
        &lt;span style=&#34;color: #a6e22e&#34;&gt;s&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;s&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;replace&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;reg&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;arguments&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;[&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;i&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;]);&lt;/span&gt;
      &lt;span style=&#34;color: #f8f8f2&#34;&gt;}&lt;/span&gt;

      &lt;span style=&#34;color: #66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;s&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;;&lt;/span&gt;
    &lt;span style=&#34;color: #f8f8f2&#34;&gt;}&lt;/span&gt;

   &lt;span style=&#34;color: #66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;table&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;$&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color: #e6db74&#34;&gt;&amp;quot;#mytableBody&amp;quot;&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;);&lt;/span&gt;
    &lt;span style=&#34;color: #66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;rowTemplate&lt;/span&gt; &lt;span style=&#34;color: #f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color: #e6db74&#34;&gt;&amp;#39;&amp;lt;tr style=&amp;quot;background:#ddd;cursor:pointer;&amp;quot; attribute1=&amp;quot;{0}&amp;quot; attribute2=&amp;quot;{1}&amp;quot;&amp;gt;&amp;lt;td&amp;gt;{2}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;{3}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;{4}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;{5}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;{6}&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;{7}&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;#39;&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;;&lt;/span&gt;

    &lt;span style=&#34;color: #a6e22e&#34;&gt;table&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;append&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;rowTemplate&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;format&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;attribute1&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt; &lt;span style=&#34;color: #a6e22e&#34;&gt;attribute2&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell1&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell2&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell3&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell4&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell5&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;,&lt;/span&gt;&lt;span style=&#34;color: #a6e22e&#34;&gt;cell6&lt;/span&gt;&lt;span style=&#34;color: #f8f8f2&#34;&gt;));&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;A clean solution for a common problem that seems to have a million different methods to accomplish. Hope this solution works for you please comment if you have any suggestions on making it better.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Cuberific A rubiks cube timer application</title>
      <link>http://www.brianpaulson.com/project/cuberific-rubiks-cube-timer</link>
      <pubDate>Sat, 21 Jun 2014 00:00:00 UTC</pubDate>
      <author>Brian Paulson</author>
      <guid>http://www.brianpaulson.com/project/cuberific-rubiks-cube-timer</guid>
      <description>

&lt;h1 id=&#34;toc_0&#34;&gt;Cuberific&lt;/h1&gt;

&lt;p&gt;Cuberific is a Rubik&amp;rsquo;s Cube timer web application. The back end service is written in Go &lt;a href=&#34;http://Golang.org/&#34;&gt;Golang.org&lt;/a&gt;. The front end is an &lt;a href=&#34;https://angularjs.org/&#34;&gt;Angular JS&lt;/a&gt; application. On the web server front &lt;a href=&#34;https://nginx.org/&#34;&gt;Nginx&lt;/a&gt; was used to serve the Angular JS application and proxy the Go web service. For the database &lt;a href=&#34;http://www.mongodb.org/&#34;&gt;MongoDB&lt;/a&gt; was used.&lt;/p&gt;

&lt;figure &gt;
    
        &lt;img src=&#34;/media/ScreenShot.png&#34; alt=&#34;Cuberific&#34; /&gt;
    
    
&lt;/figure&gt;

&lt;h3 id=&#34;toc_1&#34;&gt;THIS APPLICATION IS NOT READY FOR PRODUCTION USE&lt;/h3&gt;

&lt;p&gt;Shortcuts were taken with some aspects of security and would need to be fixed before used in production.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Currently no password to connect to mongo&lt;/li&gt;
&lt;li&gt;API Security needs more work.&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;toc_2&#34;&gt;Disclaimer&lt;/h2&gt;

&lt;p&gt;If you find and errors with this documentation please let me know and I will update the document ASAP. As well if you modify the code and wish to have it added to the repository issue pull requests.&lt;/p&gt;

&lt;p&gt;Also keep in mind I was learning both Angular and GO when working on this application so it may not be a perfect example of how to write Go/Angular code properly. With that said I have a couple thousand solves in my local server that I have been running.&lt;/p&gt;

&lt;h2 id=&#34;toc_3&#34;&gt;Prerequisites&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Golang &lt;a href=&#34;http://golang.org/&#34;&gt;http://golang.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Nginx &lt;a href=&#34;http://nginx.org/&#34;&gt;http://nginx.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;MongoDB &lt;a href=&#34;http://www.mongodb.org/&#34;&gt;http://www.mongodb.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;GOHOME and GOPATH Environment variables set correctly&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;toc_4&#34;&gt;Getting the code&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;$ git clone https://github.com/spectre013/cuberific
$ cd $PATH TO CODE/src/cuberific
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Get the dependencies&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ go get code.google.com/p/gorest
$ go get code.google.com/p/go.crypto
$ go get github.com/nu7hatch/gouuid
$ go get labix.org/v2/mgo
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&#34;toc_5&#34;&gt;building the go service&lt;/h2&gt;

&lt;p&gt;Since this is the complete application and Cuberfic was not meant as a go library it is not set up to be used with go get.&lt;/p&gt;

&lt;p&gt;A couple things need to be done before we can run the service.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a database called cuberific in your MongoDB Server.&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Open main.go and go to line 386 and change the path to the solves.json (only need to do this if you want to import some solves for testing purposes)&lt;/p&gt;

&lt;p&gt;$ cd $PATH TO CODE/src/cuberific
$ go build
$ cuberific&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Eventually you will want to run the cuberific as a service. For now it would be best to run in the console until you have every thing working correctly.&lt;/p&gt;

&lt;h2 id=&#34;toc_6&#34;&gt;Web Front end&lt;/h2&gt;

&lt;p&gt;Only changes that need to be made here is to add the domain for the cookies to be stored in.&lt;/p&gt;

&lt;p&gt;Navigate to /var/www/vhosts/&lt;SITE_NAME&gt;/httpdocs/js/controllers.js and open it in your editor of choice.&lt;/p&gt;

&lt;p&gt;Replace &lt;SITE_NAME&gt; with the domain name / IP your are using to access the site.&lt;/p&gt;

&lt;h2 id=&#34;toc_7&#34;&gt;Nginx conf&lt;/h2&gt;

&lt;p&gt;For a front facing server Nginx was used. Below is the site configuration that will work. Replace &lt;SITE_NAME&gt; in the root to the path where the code is, and the &lt;SITE_NAME&gt; in the server_name line with the domain/IP that you want Nginx to respond to.&lt;/p&gt;

&lt;p&gt;The port in the proxy_pass line will need to change if the Go server is running on a different port.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;server {
        listen 80;

        root /var/www/vhosts/&amp;lt;SITE_NAME&amp;gt;/httpdocs;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name &amp;lt;SITE_NAME&amp;gt;;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.html /api;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }
        location /api {
                proxy_pass        http://localhost:9090;

                proxy_set_header Host $host;
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_redirect   off;
       }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;start the server and navigate to &lt;a href=&#34;http://localhost&#34;&gt;http://localhost&lt;/a&gt; or the domain or IP used to create the server.&lt;/p&gt;

&lt;h2 id=&#34;toc_8&#34;&gt;Getting Started&lt;/h2&gt;

&lt;p&gt;Navigate to the domain / IP used in the Nginx section and you should be presented with the web application if not please view the Nginx logs or the console that the go service is running in to look for errors.&lt;/p&gt;

&lt;h2 id=&#34;toc_9&#34;&gt;Mongo Collections&lt;/h2&gt;

&lt;p&gt;In this file you will find the collections for mongo. This is mostly for reference as the application will create the applications as needed.&lt;/p&gt;

&lt;h2 id=&#34;toc_10&#34;&gt;License&lt;/h2&gt;

&lt;p&gt;MIT License&lt;/p&gt;

&lt;p&gt;THE SOFTWARE IS PROVIDED &amp;ldquo;AS IS&amp;rdquo;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Basic Web Skeleton</title>
      <link>http://www.brianpaulson.com/project/webskeleton</link>
      <pubDate>Fri, 20 Jun 2014 00:00:00 UTC</pubDate>
      <author>Brian Paulson</author>
      <guid>http://www.brianpaulson.com/project/webskeleton</guid>
      <description>

&lt;h2 id=&#34;toc_0&#34;&gt;Web Skeleton&lt;/h2&gt;

&lt;p&gt;Web Skeleton is a simple http/net server set up with routing, template rendering with the only external library being Mux for routing.&lt;/p&gt;

&lt;p&gt;Implementing Web Skeleton
Using Web Skeleton is simple. First use go get to install the latest version of the library.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ go get github.com/spectre013/webskeleton
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Once you have the source navigate to webskeleton directory and run.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ go run main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will start the server at &lt;a href=&#34;http://localhost:3000&#34;&gt;http://localhost:3000&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The handlers are all defined in handlers.go and rendering templates is done my calling the render function.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Render(w, &amp;quot;index&amp;quot;, &amp;quot;Test&amp;quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;the render function has the ability to render multiple templates. If you wanted to add a sidebar you would add&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;? template &amp;quot;sidebar&amp;quot; . ?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;to the index.html file. In sidebar.html file you would need to define the content.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;? define &amp;quot;sidebar&amp;quot; ?&amp;gt;
    &amp;lt;!-- ... some html here ... --&amp;gt;
&amp;lt;? end ?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;then would need to add the template to the render call.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Render(w, &amp;quot;index,sidebar&amp;quot;, &amp;quot;Test&amp;quot;)
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>Go 1.3 Released</title>
      <link>http://www.brianpaulson.com/post/go-1.3-released</link>
      <pubDate>Thu, 19 Jun 2014 00:00:00 UTC</pubDate>
      <author>Brian Paulson</author>
      <guid>http://www.brianpaulson.com/post/go-1.3-released</guid>
      <description>&lt;p&gt;The latest Go release, version 1.3, arrives six months after 1.2, and contains no language changes. It focuses primarily on implementation work, providing precise garbage collection, a major refactoring of the compiler tool chain that results in faster builds, especially for large projects, significant performance improvements across the board, and support for DragonFly BSD, Solaris, Plan 9 and Google&amp;rsquo;s Native Client architecture (NaCl). It also has an important refinement to the memory model regarding synchronization. As always, Go 1.3 keeps the promise of compatibility, and almost everything will continue to compile and run without change when moved to 1.3.&lt;/p&gt;

&lt;p&gt;List of changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;supported operating systems and architectures&lt;/li&gt;
&lt;li&gt;Changes to the memory model&lt;/li&gt;
&lt;li&gt;Changes to the implementations and tools&lt;/li&gt;
&lt;li&gt;Performance&lt;/li&gt;
&lt;li&gt;Changes to the standard library&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For more information on all the changes please see the release notes: &lt;a href=&#34;http://golang.org/doc/go1.3&#34;&gt;Go 1.3 Release Notes&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>