<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Marc Wright</title>
    <description>ramblings on music and code</description>
    <link>https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//</link>
    <atom:link href="https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//feed.xml" rel="self" type="application/rss+xml" />
    <pubDate>Wed, 10 May 2017 16:19:22 +0000</pubDate>
    <lastBuildDate>Wed, 10 May 2017 16:19:22 +0000</lastBuildDate>
    <generator>Jekyll v3.4.3</generator>
    
      <item>
        <title>Refactor Songs and Code</title>
        <description>&lt;p&gt;I love to write code. It’s the only activity I’ve found that gives me the same buzz as writing a song. Here are some thoughts on similarities between writing code and writing a song.&lt;/p&gt;

&lt;p&gt;Generally, the word “dry” refers to something boring or uninteresting. In the programming world, DRY stands for “Don’t Repeat Yourself.” If we have a bit of code that we’re going to reuse then we’d refactor it into a structure/module like a function or a method.&lt;/p&gt;

&lt;p&gt;Songs are modular too. They can be approached as sections of reusable chords and lyrics. We reuse chord structures and repeat chorus lyrics all the time.&lt;/p&gt;

&lt;p&gt;A tightly written, well crafted song is very concise. Part of this is for airplay and not boring the listener. There is an idiom in the songwriting world- “Don’t bore us, get to the chorus.” The quicker you can get to the hook (generally the chorus) the better. A tightly written, interesting song doesn’t meander either musically or lyrically. There is purpose. Sometimes I’ll go back and revisit an older song of mine and find ways to edit, refactor and make it better.&lt;/p&gt;

&lt;p&gt;In the programming world we refactor all the time. We’ll try to condense multiple lines of code into fewer lines. We can encapsulate code into reusable functions and methods. Or, specifically in Ruby, I frequently use ternary operators to DRY up my code where appropriate.&lt;/p&gt;

&lt;!-- #### DRY CODE AND DRY LYRICS



#### MODULARITY IN CODE AND SONGS



#### Code is a craft like songwriting

#### Go back and refactor songs --&gt;
</description>
        <pubDate>Wed, 10 May 2017 10:29:23 +0000</pubDate>
        <link>https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2017/refactor-songs-and-code/</link>
        <guid isPermaLink="true">https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2017/refactor-songs-and-code/</guid>
        
        
      </item>
    
      <item>
        <title>The Clean Coder</title>
        <description>&lt;p&gt;I recently read an excellent book called &lt;a href=&quot;https://www.amazon.com/Clean-Coder-Conduct-Professional-Programmers/dp/0137081073&quot;&gt;The Clean Coder&lt;/a&gt; written by Robert C. Martin, a.k.a. Dr. Bob. I wanted to share a few excellent points that stuck with me.&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h4 id=&quot;using-the-word-try&quot;&gt;USING THE WORD “TRY”&lt;/h4&gt;

&lt;p&gt;Dr. Bob talks a lot about saying “yes”, “no” and how to manage client (or management’s) expectations. We want to be nice people and hate to disappoint. So when we’re asked if we can meet a particular deadline, even if it’s unrealistic, we frequently answer “I’ll try.” Deep down, we know that we probably won’t be able to deliver. However, instead of “i’ll try”, the client or management hears “Yes.” Part of being a good developer and professional is managing expectations and giving honest answers. Saying “no” upfront can be tough and uncomfortable… but it is better than not delivering something altogether or at the last minute.&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h4 id=&quot;testing&quot;&gt;TESTING&lt;/h4&gt;

&lt;p&gt;Dr. Bob is a huge Test Driven Development and Extreme Programming practitioner. He suggests that you are not a professional programmer unless you write tests before the code. One of the arguments against testing upfront is that “there isn’t time, we have to ship/deploy.” The idea is that testing takes too long. Unfortunately, the lack of writing tests will create technical debt that must be repaid. Eventually, bugs will happen, apps will break and you’ll have to spend panic time fixing those issues. A test suite upfront will provide peace of mind and help assure that your code is not brittle.&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h4 id=&quot;professional-development&quot;&gt;PROFESSIONAL DEVELOPMENT&lt;/h4&gt;

&lt;p&gt;It is your responsibility as a professional to not only maintain your current skill set, but to continually add new tools to it. One shouldn’t rely on his/her employer to do this. A professional should be proactive about daily code challenges, working on side projects, learning new libraries and languages, etc.&lt;/p&gt;
</description>
        <pubDate>Tue, 02 May 2017 08:29:23 +0000</pubDate>
        <link>https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2017/the-clean-coder/</link>
        <guid isPermaLink="true">https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2017/the-clean-coder/</guid>
        
        
      </item>
    
      <item>
        <title>Front-end is icing on the cake</title>
        <description>&lt;p&gt;Our students have 4-6 main projects that they create both individually and as a group during their time in WDI. One thing I preach to my students is process over product. Here are a few take-a-ways from a project week sprint that I feel are more valuable than having the most awesome project. Did the student…&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Learn and follow Git + GitHub best practices?&lt;/li&gt;
  &lt;li&gt;Write well commented and readable code?&lt;/li&gt;
  &lt;li&gt;Create User Stories?&lt;/li&gt;
  &lt;li&gt;Use a tool like Trello for project management?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the biggest issues that students run into is with project management. Students will sometimes work on making their app look good before finishing the functionality. So in a 5 day sprint, frequently a student may spend 3 or 4 days on polishing an app that doesn’t even work.&lt;/p&gt;

&lt;p&gt;Front-end is fun for most folks, especially newer devs. You get immediate visual feedback which is more satisfying for new developers. Databases and server-side programming can feel a little ‘black-boxy’ and more obtuse than rendering HTML/CSS/JS in the browser.&lt;/p&gt;

&lt;p&gt;Plus, when the back-end gets a little confusing or intimidating, it’s sometimes good to switch gears and work on something more visual and&lt;/p&gt;
</description>
        <pubDate>Thu, 17 Nov 2016 09:29:23 +0000</pubDate>
        <link>https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/front-end-icing/</link>
        <guid isPermaLink="true">https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/front-end-icing/</guid>
        
        
      </item>
    
      <item>
        <title>jquery append() v. appendTo()</title>
        <description>&lt;p&gt;As an exercise, I started creating a &lt;a href=&quot;http://codepen.io/marcwright/pen/NNgzbY&quot;&gt;tic-tac-toe game in Codepen&lt;/a&gt; using Javascript and jQuery only (no HTML or CSS). The difference between &lt;code class=&quot;highlighter-rouge&quot;&gt;append()&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;appendTo()&lt;/code&gt; is pretty straightforward, but I’d never really come across a sufficent reason to use one over the other until I started building my game. I had a interesting realization I wanted to share.&lt;/p&gt;

&lt;p&gt;Both methods append one object to another, but the difference lies in the way you want to order the objects. Let’s say that I wanted to &lt;code class=&quot;highlighter-rouge&quot;&gt;append()&lt;/code&gt; a new &lt;code class=&quot;highlighter-rouge&quot;&gt;div&lt;/code&gt; with the id of &lt;code class=&quot;highlighter-rouge&quot;&gt;container&lt;/code&gt; to &lt;code class=&quot;highlighter-rouge&quot;&gt;body&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'body'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;div id='container'&amp;gt;&amp;lt;/div&amp;gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;In this example, we create a jQuery object from the CSS selector &lt;code class=&quot;highlighter-rouge&quot;&gt;body&lt;/code&gt; then we &lt;code class=&quot;highlighter-rouge&quot;&gt;append()&lt;/code&gt; a new HTML element to it. Another way to do this would be to first create the new element, assign it to a variable, then use &lt;code class=&quot;highlighter-rouge&quot;&gt;appendTo&lt;/code&gt; to append it to the body object:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;newElement&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;div id='container'&amp;gt;&amp;lt;/div&amp;gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;newElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;appendTo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'body'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Both appear to give us the same result so when should we use one over the other?&lt;/p&gt;

&lt;p&gt;To build my gameboard, I used a &lt;code class=&quot;highlighter-rouge&quot;&gt;for&lt;/code&gt; loop to dynamically create 9 divs. I also needed to attach &lt;code class=&quot;highlighter-rouge&quot;&gt;click&lt;/code&gt; events to each div in order to track the moves.&lt;/p&gt;

&lt;p&gt;For my first attempt at this, I created a jQuery object out of &lt;code class=&quot;highlighter-rouge&quot;&gt;$('#container')&lt;/code&gt; then appended the newly created divs to it. When I clicked an individual &lt;code class=&quot;highlighter-rouge&quot;&gt;div&lt;/code&gt; I returned 9 &lt;code class=&quot;highlighter-rouge&quot;&gt;console.log&lt;/code&gt; messages instead of 1. I realized that somehow I had attached 9 click events to the &lt;code class=&quot;highlighter-rouge&quot;&gt;#container&lt;/code&gt;. Then I decided to try something like this:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&amp;lt;div class='cell' id='cel&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;'&amp;gt;&amp;lt;/div&amp;gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;one&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'click'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;moves&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;counter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;X&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;O&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; 
      &lt;span class=&quot;nx&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;appendTo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'#container'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Using &lt;code class=&quot;highlighter-rouge&quot;&gt;appendTo&lt;/code&gt; allowed me to FIRST successfully add click events to each &lt;code class=&quot;highlighter-rouge&quot;&gt;div&lt;/code&gt; BEFORE appending to the &lt;code class=&quot;highlighter-rouge&quot;&gt;#container&lt;/code&gt;. I learned that order matters.&lt;/p&gt;
</description>
        <pubDate>Tue, 29 Mar 2016 09:29:23 +0000</pubDate>
        <link>https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/jquery-append-to/</link>
        <guid isPermaLink="true">https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/jquery-append-to/</guid>
        
        
      </item>
    
      <item>
        <title>rails + angular + bower</title>
        <description>&lt;p&gt;Rails provides an excellent backend for your Javascript front-end framework.&lt;/p&gt;

&lt;h3 id=&quot;why-rails&quot;&gt;Why Rails?&lt;/h3&gt;
&lt;p&gt;Rails is a great lightweight, powerful server-side solution. You can add your front-end framework on top of it.&lt;/p&gt;

&lt;p&gt;The Rails motto is “convention over configuration”. Rails provides a set of standards that the community has agreed upon as best practice. So if another Rails dev is checking out your app, it’s easier to get up and running.&lt;/p&gt;

&lt;p&gt;Rails allows you to scaffold apps very quickly so it’s great for startups. It’s relatively painless to roll out a prototype.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;e.g.- AirBnB, Hulu, Twitter, Blue Apron, Plated, Daily Burn, GA website, Robinhood FAQ, Death Wish Coffee (Intuit Super Bowl Ad)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rails is “auto-magical”, which can be good or bad.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;GOOD - rapid prototyping&lt;/li&gt;
  &lt;li&gt;BAD - Sometimes you don’t always know what’s going on under the hood, but as long as you play in their sandbox you’re ok (e.g.- use their helper methods, sset pipeline, etc).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;rails-api&quot;&gt;Rails API&lt;/h3&gt;
&lt;p&gt;You may also use &lt;a href=&quot;https://github.com/rails-api/rails-api&quot;&gt;Rails for API-only&lt;/a&gt; Apps and scaffold a project with no views. This would allow you to host Rails on one server and your front end on another. This makes for an extremely lightweight Rails app since it takes out any middlewares and extra cruft that the views would normally use.&lt;/p&gt;

&lt;p&gt;For a clunky analogy… the Rails API would be like a hard-top convertible in that we can completely remove the views. A soft-top convertible is like scaffolding a  standard Rails app but ignoring the views (even though the functionality is always available).&lt;/p&gt;

&lt;h2 id=&quot;add-angular-to-a-rails-app&quot;&gt;Add Angular to a Rails app&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;CDN&lt;/li&gt;
  &lt;li&gt;Download angular files&lt;/li&gt;
  &lt;li&gt;Ruby Gem&lt;/li&gt;
  &lt;li&gt;Bower (what we’re using tonight)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;rails-app-code-along&quot;&gt;Rails App Code Along&lt;/h2&gt;
&lt;p&gt;Completed code for this article can be found &lt;a href=&quot;https://github.com/marcwright/books-angular-rails-demo&quot;&gt;here&lt;/a&gt;. Credit goes to this excellent &lt;a href=&quot;http://angular-rails.com/&quot;&gt;Angular-Rails&lt;/a&gt; tutorial. It was my reference for the initial Bower implementation.&lt;/p&gt;

&lt;p&gt;1) &lt;code class=&quot;highlighter-rouge&quot;&gt;rails new books -T --database=postgresql&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This command will create a new rails project + directory called books. &lt;code class=&quot;highlighter-rouge&quot;&gt;-T&lt;/code&gt; tells Rails not to scaffold a test suite. &lt;code class=&quot;highlighter-rouge&quot;&gt;--database=postgresql&lt;/code&gt; will automatically bundle the &lt;code class=&quot;highlighter-rouge&quot;&gt;gem pg&lt;/code&gt; so we may use a PostgreSQL database. By default Rails uses SQLite.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;2) &lt;code class=&quot;highlighter-rouge&quot;&gt;cd books &amp;amp;&amp;amp; bin/rake db:create&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This will &lt;code class=&quot;highlighter-rouge&quot;&gt;cd&lt;/code&gt; into the project directory and create our database. Rake is Ruby Make, a standalone Ruby utility used for common administration tasks, especially sophisticated ones that build off of each other.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;3) At this point, we can start our Rails server with &lt;code class=&quot;highlighter-rouge&quot;&gt;rails server&lt;/code&gt; and checkout the welcome page at &lt;a href=&quot;http://127.0.0.1:3000&quot;&gt;http://127.0.0.1:3000&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;add-and-configure-angular--bootstrap-using-bower&quot;&gt;Add and configure Angular + Bootstrap using Bower&lt;/h2&gt;
&lt;p&gt;Bower was created by Twitter specifically to manage front-end assets. We’ll use it to set up our front-end packages and dependencies.&lt;/p&gt;

&lt;p&gt;4) Add &lt;code class=&quot;highlighter-rouge&quot;&gt;gem 'bower-rails'&lt;/code&gt; to the &lt;code class=&quot;highlighter-rouge&quot;&gt;Gemfile&lt;/code&gt;. From the command line, run &lt;code class=&quot;highlighter-rouge&quot;&gt;bundle install&lt;/code&gt; to add the library.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Ruby gems are similar to npm modules, the &lt;strong&gt;Gemfile&lt;/strong&gt; is similiar to &lt;strong&gt;package.json&lt;/strong&gt; and &lt;strong&gt;bundle install&lt;/strong&gt; is very similar to &lt;strong&gt;npm install&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;5) Next, on the command line, run &lt;code class=&quot;highlighter-rouge&quot;&gt;touch Bowerfile&lt;/code&gt;. This will create a &lt;code class=&quot;highlighter-rouge&quot;&gt;Bowerfile&lt;/code&gt; in the root of the project. Then add the following to that file:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# This will add Angular and Bootstrap-Sass&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;asset&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'angular'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;asset&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'bootstrap-sass-official'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;6) Run &lt;code class=&quot;highlighter-rouge&quot;&gt;rake bower:install&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Bower installs dependencies in &lt;code class=&quot;highlighter-rouge&quot;&gt;vendor/assets/bower_components&lt;/code&gt;. The Rails &lt;a href=&quot;https://launchschool.com/blog/rails-asset-pipeline-best-practices&quot;&gt;asset pipeline&lt;/a&gt; dictates that 3rd party code lives in the &lt;code class=&quot;highlighter-rouge&quot;&gt;vendor&lt;/code&gt; directory.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;7) Let’s add the Angular require paths to &lt;code class=&quot;highlighter-rouge&quot;&gt;app/assets/javascripts/application.js&lt;/code&gt;. &lt;a href=&quot;http://guides.rubyonrails.org/working_with_javascript_in_rails.html&quot;&gt;Turbolinks&lt;/a&gt; is a gem that uses Ajax to speed up page rendering in most applications. We’ll remove turbolinks since it can hinder performance for front-end frameworks. Your requires should look like so:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;sr&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;jquery&lt;/span&gt;
&lt;span class=&quot;sr&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;jquery_ujs&lt;/span&gt;
&lt;span class=&quot;sr&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;angular&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;angular&lt;/span&gt;
&lt;span class=&quot;sr&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;require_tree&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;8) Let’s import our bootstrap stylesheets in &lt;code class=&quot;highlighter-rouge&quot;&gt;app/assets/stylesheets/application.css.scss&lt;/code&gt; beneath all of the comments. Also, be sure to add the &lt;code class=&quot;highlighter-rouge&quot;&gt;.scss&lt;/code&gt; extension to the file name so it will &lt;code class=&quot;highlighter-rouge&quot;&gt;@import&lt;/code&gt; correctly:&lt;/p&gt;

&lt;div class=&quot;language-scss highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@import&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;bootstrap-sass-official/assets/stylesheets/bootstrap-sprockets&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@import&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;bootstrap-sass-official/assets/stylesheets/bootstrap&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;add-a-doorway-route-for-our-angular-app&quot;&gt;Add a doorway route for our Angular app&lt;/h2&gt;

&lt;p&gt;9) Add &lt;code class=&quot;highlighter-rouge&quot;&gt;root 'home#index'&lt;/code&gt; to &lt;code class=&quot;highlighter-rouge&quot;&gt;routes.rb&lt;/code&gt;. This will be the main route that will serve as the doorway to our Angular app.&lt;/p&gt;

&lt;p&gt;10) Let’s create a controller for that route. Create &lt;code class=&quot;highlighter-rouge&quot;&gt;app/assets/controllers/home_controller.rb&lt;/code&gt; and add:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;HomeController&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ApplicationController&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;index&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;instantiate-our-angular-app&quot;&gt;Instantiate our Angular App&lt;/h2&gt;

&lt;p&gt;11) For this demo we’re gonna use a Book Model so we’ll call this our bookApp. Let’s create &lt;code class=&quot;highlighter-rouge&quot;&gt;app/assets/javascripts/app.js&lt;/code&gt; and add code to instantiate our Angular app:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;angular&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'bookApp'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[])&lt;/span&gt;
 &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;controller&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'BooksController'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BooksController&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BooksController&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;names&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Marc&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Maren&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Diesel&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;We’re using &lt;code class=&quot;highlighter-rouge&quot;&gt;var vm&lt;/code&gt; here for view model. I’ve also included some dummy data to make sure our view is wired up correctly.&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;create-a-view&quot;&gt;Create a view&lt;/h2&gt;

&lt;p&gt;12) Create &lt;code class=&quot;highlighter-rouge&quot;&gt;app/assets/views/home/index.html.erb&lt;/code&gt; and add:&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;container-fluid&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;ng-app=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;bookApp&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;panel panel-success&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;panel-heading&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
      
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;h1&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;ng-if=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;Hello, {{name}}&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
      
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;panel-body&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;form-inline&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;form-group&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;form-control&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;placeholder=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Enter your name&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;autofocus&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;ng-model=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;panel panel-success&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;ng-controller=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;BooksController as ctrl&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;panel-heading&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;ul&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;ng-repeat=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;book in ctrl.names&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
        
        Hello, {{book}}
        
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;You could also add &lt;code class=&quot;highlighter-rouge&quot;&gt;ng-app&lt;/code&gt; to the &lt;code class=&quot;highlighter-rouge&quot;&gt;body&lt;/code&gt; tag in &lt;code class=&quot;highlighter-rouge&quot;&gt;app/assets/views/layouts/application.html.erb&lt;/code&gt;. Then our entire app would belong to &lt;code class=&quot;highlighter-rouge&quot;&gt;booksApp&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;13) We can start up our &lt;code class=&quot;highlighter-rouge&quot;&gt;rails server&lt;/code&gt; and go to &lt;code class=&quot;highlighter-rouge&quot;&gt;localhost:3000&lt;/code&gt; to make sure that Angular is working.&lt;/p&gt;

&lt;h2 id=&quot;create-the-book-model--add-some-seed-data&quot;&gt;Create the Book model + add some seed data&lt;/h2&gt;

&lt;p&gt;14) &lt;code class=&quot;highlighter-rouge&quot;&gt;rails g model Book title author&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We’ll create a model for Book with title and author fields (both Strings,  by default)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;15) Let’s add some seed data to &lt;code class=&quot;highlighter-rouge&quot;&gt;db/seed.rb&lt;/code&gt; to populate our database:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;no&quot;&gt;Book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;destroy_all&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;Book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;title: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;50 Shades&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;author: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Schmitty&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;title: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Lawyer Books&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;author: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Grisham&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;title: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;The Hunger Games&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;author: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Collins&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;title: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;JS Good Stuff&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;author: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Crockford&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;16) From the command line run &lt;code class=&quot;highlighter-rouge&quot;&gt;rake db:migrate db:seed&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This will create our schema file and seed our database&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;set-up-our-rest-ful-api-endpoint-to-serve-the-json&quot;&gt;Set up our REST-ful api endpoint to serve the JSON&lt;/h2&gt;

&lt;p&gt;17) Add a route to our &lt;code class=&quot;highlighter-rouge&quot;&gt;app/config/routes.rb&lt;/code&gt; file under our &lt;code class=&quot;highlighter-rouge&quot;&gt;root&lt;/code&gt; route.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'/books'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'books#index'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;A route consists of the HTTP verb, the URL and the controller/action.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;18) Eventually, we’re gonna use &lt;code class=&quot;highlighter-rouge&quot;&gt;$http.get&lt;/code&gt; in our Angular controller to grab our data. Let’s create a controller to handle the JSON data from our API. Create a file in &lt;code class=&quot;highlighter-rouge&quot;&gt;app/assets/controllers/books_controller.rb&lt;/code&gt;. Then, let’s make all the books available via JSON in our &lt;code class=&quot;highlighter-rouge&quot;&gt;BooksController&lt;/code&gt; index action:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;BooksController&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;ApplicationController&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;index&lt;/span&gt;
    &lt;span class=&quot;vi&quot;&gt;@books&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;all&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;19) We’re gonna use &lt;a href=&quot;https://github.com/rails/jbuilder&quot;&gt;jbuilder&lt;/a&gt; to serve our books API data. Let’s create &lt;code class=&quot;highlighter-rouge&quot;&gt;app/assets/views/books/index.json.jbuilder&lt;/code&gt; and add:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;array!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;vi&quot;&gt;@books&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;book&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;extract!&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;book&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:author&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;20) Now we can start our server &lt;code class=&quot;highlighter-rouge&quot;&gt;rails server&lt;/code&gt; and go to &lt;code class=&quot;highlighter-rouge&quot;&gt;http://localhost:3000/books.json&lt;/code&gt; (try it in a new window) to see that Rails is serving our data as JSON.&lt;/p&gt;

&lt;h2 id=&quot;consume-the-data-with-angular&quot;&gt;Consume the data with Angular&lt;/h2&gt;

&lt;p&gt;21) Let’s add some code to grab all the books from our endpoint in &lt;code class=&quot;highlighter-rouge&quot;&gt;app/assets/javascripts/app.js&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;angular&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'bookApp'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[])&lt;/span&gt;
 &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;controller&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'BooksController'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BooksController&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BooksController&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;$http&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;names&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Marc&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Maren&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Diesel&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
  
  &lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;books&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;getBooks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;success&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;vm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;books&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;getBooks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;$http&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'http://localhost:3000/books.json'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;We’ll add a getBooks() function to grab all the books from our REST-ful endpoint. We’ll assign the results of that function to the variable &lt;code class=&quot;highlighter-rouge&quot;&gt;vm.books&lt;/code&gt;. Also, don’t forget to inject &lt;code class=&quot;highlighter-rouge&quot;&gt;$http&lt;/code&gt; into &lt;code class=&quot;highlighter-rouge&quot;&gt;BooksController&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;update-our-view&quot;&gt;Update our view&lt;/h2&gt;

&lt;p&gt;22) Let’s go to our &lt;code class=&quot;highlighter-rouge&quot;&gt;app/assets/views/home/home.html.erb&lt;/code&gt; page and make some small tweaks. First, we’ll adjust our &lt;code class=&quot;highlighter-rouge&quot;&gt;ng-repeat&lt;/code&gt; so it repeats our &lt;code class=&quot;highlighter-rouge&quot;&gt;vm.book&lt;/code&gt; variable. We’ll also add some code to render the &lt;code class=&quot;highlighter-rouge&quot;&gt;title&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;author&lt;/code&gt; of each book. Here’s the code for our &lt;code class=&quot;highlighter-rouge&quot;&gt;ul&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;ul&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;ng-repeat=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;book in ctrl.books&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  
  Title: {{book.title}} &lt;span class=&quot;nt&quot;&gt;&amp;lt;/br&amp;gt;&lt;/span&gt; 
  Author: {{book.author}}
  
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;I really love Rails. It’s great to pair the rapid prototyping ability of Rails with an Angular front-end!&lt;/p&gt;

</description>
        <pubDate>Tue, 15 Mar 2016 20:29:23 +0000</pubDate>
        <link>https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/rails-angular-bower/</link>
        <guid isPermaLink="true">https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/rails-angular-bower/</guid>
        
        
      </item>
    
      <item>
        <title>Gear Freaks</title>
        <description>&lt;p&gt;There are gear freaks in both the music and tech worlds.&lt;/p&gt;

&lt;p&gt;If you go to guitar center on a Saturday (or anytime actually) you’ll see folks raging on crazy pieces of gear always into the latest and greatest effects pedal, etc. I was never one of those people. Admittedly, I usually didn’t have the patience to sit down and figure out a crazy pedal board or effects box. I can barely manage a simple delay pedal with 3 knobs on it.&lt;/p&gt;

&lt;p&gt;I think tech is great and can be used for inspiration, but it shouldn’t be relied on. If your song doesn’t translate with the purity of one guitar and one voice then all the over-production in the world won’t save it.&lt;/p&gt;

&lt;p&gt;I love going to songwriter nights and hearing the writers perform their work. The artists that recorded the tracks may have world class voices and talent, but it didn’t matter. The songs were just as powerful with an ok musician and vocalist performing them because the raw songs themselves are bulletproof.&lt;/p&gt;

&lt;p&gt;I noticed that the really great songwriters that I worked with or talked to kept it really simple. They’d usually write on an acoustic guitar or piano. They’d occasionally have a loop to keep things interesting.&lt;/p&gt;

&lt;p&gt;I think the essence of a song is about whether it translates when everything else is stripped away. A great song is a great song whether it’s way overproduced or stripped down.&lt;/p&gt;

&lt;p&gt;I feel the same way about code. There’s always a new technology or framework that will be the new kid on the block. Using fancy tech doesn’t make you a great developer, however, a great developer can use those tools to make his/her simple “acoustic guitar demo” code something great.&lt;/p&gt;

&lt;p&gt;I hear students asking about what they should be learning- Angular, Angular 2, React, Ionic, Backbone… the sheer amount of choices can be overwhelming. I tell my students that the goal should be to be really good at Javascript and not rely on libraries or frameworks. Those libraries and frameworks (e.g. - effects pedals) will do you know good if you can’t craft your code without them.&lt;/p&gt;

&lt;p&gt;There will always be a new tech but can you create without them.&lt;/p&gt;
</description>
        <pubDate>Thu, 25 Feb 2016 00:00:00 +0000</pubDate>
        <link>https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/gear-freaks/</link>
        <guid isPermaLink="true">https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/gear-freaks/</guid>
        
        
      </item>
    
      <item>
        <title>Python + Ruby Differences</title>
        <description>&lt;p&gt;I’m taking a Data Science course that incorporates Python. I thought I’d write a quick + dirty summary of some key (cool) differences between the two languages. Forgive me if the syntax is slightly off as I’m writing this from memory.&lt;/p&gt;

&lt;h4 id=&quot;methods&quot;&gt;Methods&lt;/h4&gt;
&lt;p&gt;Python and Ruby both use the method declaration &lt;code class=&quot;highlighter-rouge&quot;&gt;def&lt;/code&gt;, but Python also uses &lt;code class=&quot;highlighter-rouge&quot;&gt;():&lt;/code&gt; at the end of the declaration. In Ruby, the parens are optional. In Python, the parens and colons are required. Python also requires colons for for loops and if/else statements.&lt;/p&gt;

&lt;p&gt;Python does not need the &lt;code class=&quot;highlighter-rouge&quot;&gt;end&lt;/code&gt; keyword to signify the end of a method block. Python relies on whitespace and indentation to signify the end of a block of code.&lt;/p&gt;

&lt;p&gt;In Ruby, methods return the last line of code that is evaluated. In Python, you must be explicit and use &lt;code class=&quot;highlighter-rouge&quot;&gt;return&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;objects&quot;&gt;Objects&lt;/h4&gt;
&lt;p&gt;In Ruby, a collection that uses index is called an Array. Python calls them lists.&lt;/p&gt;

&lt;p&gt;In Ruby, a collection of key/value pairs is called a Hash. Python calls them Dictionaries.&lt;/p&gt;

&lt;h4 id=&quot;classes&quot;&gt;Classes&lt;/h4&gt;
&lt;p&gt;Ruby uses the &lt;code class=&quot;highlighter-rouge&quot;&gt;initialize&lt;/code&gt; method to instatiate new instances of a class. Python uses &lt;code class=&quot;highlighter-rouge&quot;&gt;__init()__&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In Python, you must pass in the keyword &lt;code class=&quot;highlighter-rouge&quot;&gt;self&lt;/code&gt; as the first argument in a method. In Ruby, you can assign a method to self as in &lt;code class=&quot;highlighter-rouge&quot;&gt;self.name_of_method&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;--operators&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;amp;&amp;amp;&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;||&lt;/code&gt; operators&lt;/h4&gt;
&lt;p&gt;Ruby uses &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;amp;&amp;amp;&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;||&lt;/code&gt; for comparisons. Python uses the keywords &lt;code class=&quot;highlighter-rouge&quot;&gt;and&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;or&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;whitespace-and-colons&quot;&gt;Whitespace and colons&lt;/h4&gt;

&lt;p&gt;…to be continued&lt;/p&gt;
</description>
        <pubDate>Tue, 23 Feb 2016 13:29:23 +0000</pubDate>
        <link>https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/python-ruby-differences/</link>
        <guid isPermaLink="true">https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/python-ruby-differences/</guid>
        
        
      </item>
    
      <item>
        <title>Taylor Swift HTML</title>
        <description>&lt;p&gt;&lt;strong&gt;in progress…&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/marcwright/taylor-swift-ruby-script&quot;&gt;GitHub&lt;/a&gt;
&lt;a href=&quot;http://codepen.io/marcwright/pen/XdWVrG&quot;&gt;CodePen&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Both songwriting and good code are about patterns. We encapuslate our code for readability and reusability. Songs are similar. When building a track, you may reuse a snippet of audio from one verse to pop into another. When you’re using Logic or Pro Tools you also want your environment to be very clean and use good naming conventions.&lt;/p&gt;

&lt;p&gt;With that in mind, I decided to take stab at what Taylor Swift’s “Style” would look like as scaffolded in HTML5. Here are some assumptions…&lt;/p&gt;

&lt;p&gt;####I needed a song that was very consistent and linear
This song has only 4 chords and can be easily broken down into 2 bar sections.&lt;/p&gt;

&lt;p&gt;####Headers will be the main section dividers
I’m gonna use headers to encapsulate the song into the main sections of INTRO, VERSE, CHORUS, BRIDGE, OUTRO&lt;/p&gt;

&lt;p&gt;####I’ll use classes for the sonic variety
Just as CSS rules are the adjectives for the different sonic patterns:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;vocals&lt;/li&gt;
  &lt;li&gt;guitar&lt;/li&gt;
  &lt;li&gt;bass&lt;/li&gt;
  &lt;li&gt;drums&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;####Each Chord change will be an &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;ol&amp;gt;&lt;/code&gt; of 2 bars represented by &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;li&amp;gt;&lt;/code&gt; tags&lt;/p&gt;
</description>
        <pubDate>Mon, 08 Feb 2016 20:29:23 +0000</pubDate>
        <link>https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/taylor-swift-html/</link>
        <guid isPermaLink="true">https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/taylor-swift-html/</guid>
        
        
      </item>
    
      <item>
        <title>Why Fire Ready Aim?</title>
        <description>&lt;p&gt;I’ve wanted to set-up Jekyll for a while to blog about my musical and development ramblings. I see a lot of similarities between the musical and development worlds.&lt;/p&gt;

&lt;p&gt;Here is an article on &lt;a href=&quot;http://digitalsparkmarketing.com/uncategorizedlearning-from-failure/&quot;&gt;learning and failure&lt;/a&gt;. It’s a perfect metaphor for Fire Ready Aim.&lt;/p&gt;

&lt;p&gt;It tells a story of a pottery class that was split into two groups. One group would be graded on the quantity of what they produced and the other group would be graded on the quantity. So, group #1 worked to make one pot as perfect as possible, while group #2 focused on creating several.&lt;/p&gt;

&lt;p&gt;The “moral” of the story is that the group that created 10 pots ended up making better ones than the group that focused on one. The quantity group learned from their mistakes and became better craftsmen.&lt;/p&gt;

&lt;p&gt;As a songwriter, I can relate to over-thinking. I’ve often spent too much time attempting to craft the perfect song instead of crafting ten and learning from my mistakes. I’m definitely a perfectionist (most of us are), sometimes against my own best interest. I will try to be ok with failure.&lt;/p&gt;

&lt;p&gt;Check out the &lt;a href=&quot;https://marcwrightmusic.wordpress.com/&quot;&gt;Marc’s WDI Wordpress Blog&lt;/a&gt;.&lt;/p&gt;

</description>
        <pubDate>Mon, 08 Feb 2016 20:29:23 +0000</pubDate>
        <link>https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/welcome-to-jekyll/</link>
        <guid isPermaLink="true">https://marcwright.github.io/marcwright-jekyll/marcwright-jekyll//2016/welcome-to-jekyll/</guid>
        
        
        <category>jekyll</category>
        
        <category>update</category>
        
      </item>
    
  </channel>
</rss>
