<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Hair of the Dog]]></title>
  <link href="http://jayturpin.com/atom.xml" rel="self"/>
  <link href="http://jayturpin.com/"/>
  <updated>2017-11-28T23:12:13+00:00</updated>
  <id>http://jayturpin.com/</id>
  <author>
    <name><![CDATA[Jay Turpin]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  
  <entry>
    <title type="html"><![CDATA[Writing Code with DHH: Take 3]]></title>
    <link href="http://jayturpin.com/archive/2016/10/31/take-3/"/>
    <updated>2016-10-31T00:00:00+00:00</updated>
    <id>http://jayturpin.com/archive/2016/10/31/take-3</id>
    <content type="html"><![CDATA[<p>I was listening to <a href="http://fourhourworkweek.com/2016/10/27/david-heinemeier-hansson">The Tim Ferris Show</a> with David “DHH” Heinemeier Hansson this weekend. DHH is the creator of <a href="http://rubyonrails.org">Ruby on Rails</a> and the founder of <a href="https://basecamp.com">Basecamp</a> (formerly <a href="http://fourhourworkweek.com/2010/03/08/why-grow-and-other-wisdom-from-37signals">37signals</a>).</p>

<p>He described his approach for writing code:</p>

<blockquote>
  <p>Take 1: Let’s get this working.</p>

  <p>Take 2: Let’s make this right.</p>

  <p>Take 3: let’s make this beautiful.</p>

  <p>Take 4: Let’s simplify this.</p>

  <p>Take 5: …</p>
</blockquote>

<p>This really resonated with me. So often we (myself included) tend to stop after Take 1. This leads to code that is buggy and difficult to maintain. Only rare individuals ever do three or four takes to create good quality code.</p>

]]></content>
  </entry>
  
  
  
  <entry>
    <title type="html"><![CDATA[Aurelia, With Style]]></title>
    <link href="http://jayturpin.com/archive/2016/05/07/aurelia_with_style/"/>
    <updated>2016-05-07T00:00:00+00:00</updated>
    <id>http://jayturpin.com/archive/2016/05/07/aurelia_with_style</id>
    <content type="html"><![CDATA[<p>Building upon the work done in my <a href="http://jayturpin.com/archive/2016/04/30/aurelia_from_scratch">previous article</a>, let’s add <a href="http://getbootstrap.com/">Bootstrap</a> to our application:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>jspm install bootstrap
</code></pre></div></div>

<p>While we’re at it, add the Typescript definition file too, just in case we want to programmatically display a modal or popover:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>typings install bootstrap --ambient --save
</code></pre></div></div>

<p>Now, update the the template, app.html:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;template&gt;
  &lt;require from="bootstrap/css/bootstrap.css"&gt;&lt;/require&gt;
  &lt;require from="toastr/build/toastr.css"&gt;&lt;/require&gt;
  &lt;div class="container"&gt;
    &lt;div class="row"&gt;
      &lt;div class="col-md-12"&gt;
        &lt;h1&gt;Toastr Message Generator&lt;/h1&gt;
        &lt;form submit.delegate="submit()" class="form-inline"&gt;
          &lt;div class="form-group"&gt;
            &lt;label&gt;Title&lt;/label&gt;
            &lt;input type="text" value.bind="title" class="form-control" placeholder="Enter title" /&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
            &lt;label&gt;Message&lt;/label&gt;
            &lt;input type="text" value.bind="message" class="form-control" placeholder="Enter message" /&gt;
          &lt;/div&gt;
          &lt;button type="submit" class="btn btn-success"&gt;Show Toast&lt;/button&gt;
        &lt;/form&gt;
      &lt;/div&gt;
    &lt;/div&gt;  
  &lt;/div&gt;
&lt;/template&gt;
</code></pre></div></div>

<p>Mainly, this is just some bootstrap styling around the previous markup. But, you will notice at the top of the template two lines:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;require from="bootstrap/css/bootstrap.css"&gt;&lt;/require&gt;
&lt;require from="toastr/build/toastr.css"&gt;&lt;/require&gt;
</code></pre></div></div>

<p>The <require> element ensure that the styles are loaded as part of the view load process. When used in this way the CSS will be added to the head of the document. And, if you <require> the CSS file from multiple templates or components, it will only be added to the document once.</require></require></p>

<p>That’s it. Now you can use bootstrap to make your application look awesome!</p>

<p><img src="/images/2016-05-07-with_bootstrap.png" alt="Toastr Generator with Bootstrap" /></p>

<p>Source code for this article can be found <a href="https://github.com/turp/aurelia_from_scratch/tree/bootstrap">here</a>.</p>

]]></content>
  </entry>
  
  
  
  <entry>
    <title type="html"><![CDATA[Aurelia From Scratch]]></title>
    <link href="http://jayturpin.com/archive/2016/04/30/aurelia_from_scratch/"/>
    <updated>2016-04-30T00:00:00+00:00</updated>
    <id>http://jayturpin.com/archive/2016/04/30/aurelia_from_scratch</id>
    <content type="html"><![CDATA[<p><a href="http://eisenbergeffect.bluespire.com/">Rob Eisenberg</a> first showed up on my radar in 2010 when he presented at the MIX conference. His presentation, <a href="http://channel9.msdn.com/Events/MIX/MIX10/EX15">Build Your Own MVVM Framework in 500 Lines</a> blew me away.</p>

<p>You see, at the time, Silverlight was the hot new technology and average developers, like me, struggled to understand all the intricacies of data binding and commands. Rob, without a lot of flash, demonstrated how to get rid of a ton a boilerplate code and simplify wiring up the view model to the view.</p>

<p>From those humble beginnings, Rob expanded on his framework to create <a href="http://caliburnmicro.com/">Caliburn.Micro</a>. In his words, “A small, yet powerful framework, designed for building applications across all XAML platforms”.</p>

<p>Fast-forward a couple years, and Rob turned his attention to Javascript and created <a href="http://durandaljs.com/">Durandal</a>. This lightweight framework brought many of application design concepts to the wild world of Javascript development. It provided strong support for MVC, MVP and MVVM. It is still an excellent framework if you need to use legacy browsers.</p>

<p>In 2014, Rob <a href="http://eisenbergeffect.bluespire.com/angular-and-durandal-converge/">joined</a> the <a href="http://aurelia.io">Angular</a> team to contribute to the design and development of Angular 2.0. But after 6 months, <a href="http://eisenbergeffect.bluespire.com/leaving-angular/">Rob left the effort</a> and began work on the Durandel’s successor, <a href="http://aurelia.io">Aurelia</a></p>

<blockquote>
  <p>Aurelia is a next gen JS client framework that leverages simple conventions to empower your creativity. Built for modern browsers, it enables a forward-thinking, elegant approach to development.</p>
</blockquote>

<h1 id="creating-a-super-basic-aurelia-app-from-scratch">Creating a (super) Basic Aurelia App from Scratch</h1>

<p>Create a new directory and open a command prompt. First, lets initialize our node package.json file:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm init
</code></pre></div></div>

<p>Just accept all of the defaults. Now we’ll install the <a href="http://jspm.io/">jspm</a>. jspm is a package manager for the SystemJS universal module loader, built on top of the dynamic ES6 module loader</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm install jspm --save-dev
</code></pre></div></div>

<p>Note: If you get errors while running this command, look at the following things:</p>

<ul>
  <li>If you are behind a firewall, make sure you’ve set your <a href="https://jjasonclark.com/how-to-setup-node-behind-web-proxy">HTTP_PROXY properly</a></li>
  <li>Add a rule to your virus protection software to exclude the directory you’re working with. I’ve seen some random issues occur while npm is attempting to delete temporary files.</li>
</ul>

<p>Now setup jspm:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>jspm init

Would you like jspm to prefix the jspm package.json properties under jspm? [yes]
Enter server baseURL (public folder path) [./]:
Enter jspm packages folder [.\jspm_packages]:
Enter config file path [.\config.js]:
Configuration file config.js doesn't exist, create it? [yes]:
Enter client baseURL (public folder URL) [/]:
Do you wish to use a transpiler? [yes]: NO
</code></pre></div></div>

<p>Now pull in Aurelia:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>jspm install aurelia-framework
jspm install aurelia-bootstrapper
jspm install jquery
jspm install toastr
</code></pre></div></div>

<p>If you’re interested in what just happened, take a peak in the config.js file. When “jspm install” is run, it looks in the global <a href="https://github.com/jspm/registry/blob/master/registry.json">jspm registry</a> to determine where the library and its dependencies are located. Most popular javascript libraries are already registered there.</p>

<p>If a library is not listed in that registry, you can still install it. For instance, even though <a href="https://github.com/HubSpot/PACE">pace</a> is a handy library to automatically add a progress bars to your web application. If you want to install it using jspm, you can reference it’s GitHub repository:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>jspm install pace=github:HubSpot/PACE
</code></pre></div></div>

<p>or it’s npm package</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>jspm install pace=npm:pace
</code></pre></div></div>

<p>Either way will work. pace= is the alias or nickname you give the library, so it can be whatever you want.</p>

<p>Finally, let’s create a simple webpage that will load up all of the javascript libraries using <a href="https://github.com/systemjs/systemjs">SystemJS</a></p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;!DOCTYPE html&gt;</span>
<span class="nt">&lt;html&gt;</span>
    <span class="nt">&lt;head&gt;</span>
        <span class="nt">&lt;meta</span> <span class="na">charset=</span><span class="s">"utf-8"</span><span class="nt">&gt;</span>
        <span class="nt">&lt;title&gt;</span>My First Aurelia App<span class="nt">&lt;/title&gt;</span>
        <span class="nt">&lt;link</span> <span class="na">rel=</span><span class="s">"stylesheet"</span> <span class="na">href=</span><span class="s">"jspm_packages/npm/toastr@2.1.2/package/toastr.css"</span> <span class="na">media=</span><span class="s">"screen"</span> <span class="na">title=</span><span class="s">"no title"</span> <span class="na">charset=</span><span class="s">"utf-8"</span><span class="nt">&gt;</span>
    <span class="nt">&lt;/head&gt;</span>
    <span class="nt">&lt;body&gt;</span>
        <span class="nt">&lt;script </span><span class="na">src=</span><span class="s">"jspm_packages/system.js"</span> <span class="na">charset=</span><span class="s">"utf-8"</span><span class="nt">&gt;&lt;/script&gt;</span>
        <span class="nt">&lt;script </span><span class="na">src=</span><span class="s">"config.js"</span> <span class="na">charset=</span><span class="s">"utf-8"</span><span class="nt">&gt;&lt;/script&gt;</span>
        <span class="nt">&lt;script </span><span class="na">type=</span><span class="s">"text/javascript"</span><span class="nt">&gt;</span>
            <span class="nx">System</span><span class="p">.</span><span class="k">import</span><span class="p">(</span><span class="s2">"toastr"</span><span class="p">).</span><span class="nx">then</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">toastr</span><span class="p">){</span>
                <span class="nx">toastr</span><span class="p">.</span><span class="nx">success</span><span class="p">(</span><span class="s2">"Loaded with System"</span><span class="p">);</span>
            <span class="p">});</span>
        <span class="nt">&lt;/script&gt;</span>
    <span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</code></pre></div></div>

<p>We’re almost there. Now we need some way to serve up our website. We will use the excellent <a href="https://www.browsersync.io/">BrowserSync</a> which will act as web server and automatically refresh the page whenever changes as made to the underlying files</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm install browser-sync --save-dev
</code></pre></div></div>

<p>And the scripts section in your package.json with:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>"scripts": {
	"start": "browser-sync start --server --files *.*"
},
</code></pre></div></div>

<p>Now let’s see if it works</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm run start
</code></pre></div></div>

<p>If everything is setup properly, your browser should be opened to <a href="http://localhost:3000/">http://localhost:3000/</a> and you should briefly see a green “Loaded with System” notification pop up for a couple seconds.</p>

<h1 id="typescript">Typescript</h1>

<p>Now let’s add a <a href="http://typescriptlang.org">Typescript</a> view model</p>

<p>First, add a Typescript configuration file, tsconfig.json:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}
</code></pre></div></div>

<p>Now, let’s update our tooling:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm install concurrently --save-dev
npm install typescript --save-dev
</code></pre></div></div>

<p>And replace the scripts section in package.json with:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>"scripts": {
	"start": "tsc &amp;&amp; concurrently \"npm run tsc:w\" \"npm run serve\" ",
	"postinstall": "typings install",
	"serve": "browser-sync start --server --files *.*",
	"tsc": "tsc",
	"tsc:w": "tsc -w",
	"typings": "typings"
},
</code></pre></div></div>

<p>Now, let’s add a view model and template to the application. First, add a view model called app.ts:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>import * as toastr from "toastr";

export class App {
  public title: string = "";
  public message: string = "";

  constructor() { }

  submit() {
    if (!this.title &amp;&amp; !this.message) {
      toastr.error("Please fill in the form!", "error");
    }
    else {
      toastr.success(this.message, this.title);
    }
  }
}
</code></pre></div></div>

<p>Since your browser can’t directly interpret Typescript, you have to transpile it into javascript:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm run tsc
</code></pre></div></div>

<p>At first, you’ll get some errors because it doesn’t know what toastr is. We need to install the type definition files.</p>

<p>First install the <a href="https://github.com/typings/typings">Typescript Definition Manager</a> globally:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm install typings -g
</code></pre></div></div>

<p>Now, install the type definition files for toastr and jquery:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>typings install toastr --ambient --save
typings install jquery --ambient --save
typings install es6-shim --ambient --save
</code></pre></div></div>

<blockquote>
  <p>Note: If you’re behind a firewall, you will need to create a .typingsrc file to register the proxy server so this command will work. It will look a lot like your .npmrc file</p>
</blockquote>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>proxy=http://proxy.mycompany.com:8080
</code></pre></div></div>

<p>Now try it again</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm run tsc
</code></pre></div></div>

<p>and you should see app.js generated</p>

<p>In Aurelia, every view model needs a corresponding template file, so let’s create app.html:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;template&gt;
  &lt;require from="toastr/build/toastr.css"&gt;&lt;/require&gt;
  &lt;form submit.delegate="submit()"&gt;
    &lt;input type="text" value.bind="title" placeholder="Enter title" /&gt;
    &lt;input type="text" value.bind="message" placeholder="Enter message" /&gt;
    &lt;button type="submit"&gt;Show toastr&lt;/button&gt;
  &lt;/form&gt;
&lt;/template&gt;
</code></pre></div></div>

<p>Finally, update the index.html file to bootstrap the Aurelia application. Replace the contents of the file with this:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;!DOCTYPE html&gt;</span>
<span class="nt">&lt;html&gt;</span>
  <span class="nt">&lt;head&gt;</span>
    <span class="nt">&lt;meta</span> <span class="na">charset=</span><span class="s">"utf-8"</span><span class="nt">&gt;</span>
    <span class="nt">&lt;title&gt;</span>My First Aurelia App<span class="nt">&lt;/title&gt;</span>
  <span class="nt">&lt;/head&gt;</span>
    <span class="nt">&lt;body</span> <span class="na">aurelia-app</span><span class="nt">&gt;</span>
        <span class="nt">&lt;script </span><span class="na">src=</span><span class="s">"jspm_packages/system.js"</span> <span class="na">charset=</span><span class="s">"utf-8"</span><span class="nt">&gt;&lt;/script&gt;</span>
        <span class="nt">&lt;script </span><span class="na">src=</span><span class="s">"config.js"</span> <span class="na">charset=</span><span class="s">"utf-8"</span><span class="nt">&gt;&lt;/script&gt;</span>
        <span class="nt">&lt;script </span><span class="na">type=</span><span class="s">"text/javascript"</span><span class="nt">&gt;</span>
            <span class="nx">System</span><span class="p">.</span><span class="k">import</span><span class="p">(</span><span class="s2">"aurelia-bootstrapper"</span><span class="p">);</span>
        <span class="nt">&lt;/script&gt;</span>
    <span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</code></pre></div></div>

<p>Now spin up browser-sync again using your brand new NPM script:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm run start
</code></pre></div></div>

<p>This command compiles all of your typescript files, watching them and recompiling them when you make changes and concurrently, starts up browser-sync.</p>

<p>You should now see a page with two text boxes, allowing you to specify the title and message you want to display in a toast.</p>

<p>If you want to see browser-sync in action, add a header to  the app.html and save the file.</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;template&gt;
  &lt;require from="toastr/build/toastr.css"&gt;&lt;/require&gt;
  &lt;h1&gt;Toastr Message Generator&lt;/h1&gt;
  &lt;form submit.delegate="submit()"&gt;
    &lt;input type="text" value.bind="title" placeholder="Enter title" /&gt;
    &lt;input type="text" value.bind="message" placeholder="Enter message" /&gt;
    &lt;button type="submit"&gt;Show toastr&lt;/button&gt;
  &lt;/form&gt;
&lt;/template&gt;
</code></pre></div></div>

<p>And the browser will automatically refresh.</p>

<h1 id="summary">Summary</h1>

<p>Even though Aurelia offers a comprehensive set of <a href="http://aurelia.io/docs.html#/aurelia/framework/1.0.0-beta.1.2.2/doc/article/getting-started">skeleton projects</a> to kick start your development efforts, I find it useful to walk through the steps myself so I can gain a better understanding of how everything works together. Hopefully, you found this article useful.</p>

<p>Source code for this article can be found on <a href="https://github.com/turp/aurelia_from_scratch/tree/basic">Github</a>.</p>

<h1 id="acknowledgments">Acknowledgments</h1>

<p>Thanks to <a href="http://nojaf.com/2015/07/08/using-toastr-with-aurelia/">Florian Verdonck</a> for a great article that helped me put a lot of these pieces together!</p>
]]></content>
  </entry>
  
  
  
  <entry>
    <title type="html"><![CDATA[My Git Cheatsheet]]></title>
    <link href="http://jayturpin.com/archive/2016/04/23/my_git_cheatsheet/"/>
    <updated>2016-04-23T00:00:00+00:00</updated>
    <id>http://jayturpin.com/archive/2016/04/23/my_git_cheatsheet</id>
    <content type="html"><![CDATA[<p>I collected tips and tricks for using <a href="https://git-scm.com/">Git</a> and <a href="https://github.com">Github</a> from many places over the years. This is my attempt to consolidate some of this knowledge into a single spot. I am primarily a Windows user, so some of the file paths may be different in your environment.</p>

<h2 id="gitconfig-file">.gitconfig file</h2>

<p>Add the following lines to your <strong>.gitconfig</strong> (found in c:\users\your_idsid)</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[user]
    name = Your Name
    email = your.name@company.com
[credential]
[http]
    proxy = http://your-proxy.company.com:8080
[https]
    proxy = http://your-proxy.company.com:8080
[push]
    default = simple
[url "https://"]   
	insteadOf = git://

[alias]
    co = checkout
    ec = config --global -e
    up = !git pull --rebase --prune $@ &amp;&amp; git submodule update --init --recursive
    cob = checkout -b
    cm = !git add -A &amp;&amp; git commit -m
    save = !git add -A &amp;&amp; git commit -m 'SAVEPOINT'
    wip = !git add -u &amp;&amp; git commit -m "WIP" 
    undo = reset HEAD~1 --mixed
    amend = commit -a --amend
	nuke = !git reset --hard &amp;&amp; git clean -fdx
    wipe = !git add -A &amp;&amp; git commit -qm 'WIPE SAVEPOINT' &amp;&amp; git reset HEAD~1 --hard &amp;&amp; git clean -fd
    bclean = "!f() { git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs -r git branch -d; }; f"
    bdone = "!f() { git checkout ${1-master} &amp;&amp; git up &amp;&amp; git bclean ${1-master}; }; f"
	squash = !git checkout master &amp;&amp; git merge --no-ff --no-commit
</code></pre></div></div>

<h2 id="windows-clients">Windows Clients</h2>
<p>First, install <a href="https://git-for-windows.github.io/">Git For Windows</a>). This provides you with the basic command line tools needed to interact with Git and Github.</p>

<p>My GUI client of choice is <a href="https://tortoisegit.org/">TortoiseGit</a>. This open source client integrates directly into File Explorer and provides an intuitive set of tools to do just about everything you need to do with Git.</p>

<p>There are other good clients available too: <a href="https://www.sourcetreeapp.com/">Atlassian Sourcetree</a> and <a href="https://desktop.github.com/">Github for Windows</a> are both quality clients for interacting with Git repositories.</p>

<h2 id="command-line">Command Line</h2>

<p>But for raw speed, sometimes the command line is best. Navigate to a local directory where you want to store you repositories and open a command prompt.</p>

<h3 id="clone">Clone</h3>

<p>The first time you work on a project, you will need to <a href="http://git-scm.com/docs/git-clone">clone</a>, or download, the repository to your machine.</p>

<p>Get the URL for the repo (you can find it on the main page of any github project) - it will look something like this: <a href="https://github.com/jquery/jquery">https://github.com/jquery/jquery.git</a>. Now, execute the following command:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone url_for_git_repo
</code></pre></div></div>

<h3 id="checkout">Checkout</h3>

<p>Before creating a new branch or continuing work on master, make sure that your working directory is up to date with the server (origin). First run <a href="http://git-scm.com/docs/git-pull">pull</a>:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git pull --rebase --prune
</code></pre></div></div>

<p>This pulls changes from the server. If there are any local commits, it’ll rebase them to come after the commits that are on the remote server. The –prune option removes remote-tracking branches that no longer exist on the remote.</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git submodule update --init --recursive
</code></pre></div></div>

<p>This command will update any <a href="http://git-scm.com/docs/git-submodule">submodules</a> (links to other git repositories) referenced by the project.</p>

<p>You can execute both of these commands by simply running the alias (from your .gitignore file):</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git up
</code></pre></div></div>

<h3 id="commit">Commit</h3>

<p>Commit your work often. The more often you commit, the less likely you are to lose work and encounter merge conflicts.</p>

<p>To find out the <a href="http://git-scm.com/docs/git-status">status</a> of your repository, type:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git status
</code></pre></div></div>

<p>This will show all of the changes since your last commit.</p>

<p>Now mark any new files to be added into the repo by using the <a href="http://git-scm.com/docs/git-add">add</a> command:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git add -A
</code></pre></div></div>

<p>Now you commit the changes to your <em>local repository</em>:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git commit -m "PUT YOUR COMMENT HERE"
</code></pre></div></div>

<p>You must specify a comment.</p>

<p>This activity is performed so often, you should use the following alias:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git cm "PUT YOUR COMMENT HERE"
</code></pre></div></div>

<h3 id="push">Push</h3>

<p>First, create a branch</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git branch NAME_OF_BRANCH
git co NAME_OF_BRANCH
</code></pre></div></div>

<p>When you are ready to push to central repository the first time, execute this command:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git push --set-upstream origin NAME_OF_BRANCH
</code></pre></div></div>

<p>In the future, you can just perform a normal</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git push
</code></pre></div></div>

<p>If you want to pull down the branch that your coworker just pushed to the server, execute:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git co --track origin/NAME_OF_BRANCH
</code></pre></div></div>

<h3 id="merge-a-branch">Merge a branch</h3>

<p><strong>The Goal:</strong> Get a list of all files changed in a feature branch and compare each one’s initial state against its final state, without any noise from merges from master.</p>

<p><strong>The Approach:</strong> Pretend I’m going to <a href="http://git-scm.com/docs/git-merge">merge</a> the feature into master but don’t commit it. Diff the pending changes and send my recommendations. Then throw away the changes and clean everything up.</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git checkout master
git merge ‑‑no‑ff ‑‑no‑commit name_of_branch
</code></pre></div></div>

<p>The <strong>‑‑no‑ff</strong> (No-fast-forward) flag makes the feature join into master with a single, explicit merge commit. This tells git, even if it could perform a fast-forward merge, where it applies each of the feature-branch commits as if they had been committed straight to master, please don’t. The ‑‑no‑ff option provides a single, show-me-everything commit.</p>

<p>The second flag, <strong>‑‑no‑commit</strong>, is even more important: Stage them but don’t commit them.</p>

<p>You can also use the alias</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git squash name_of_branch
</code></pre></div></div>

<p>Tackle and merge conflicts and use your favorite diff tool to inspect the changes.</p>

<p>If you choose to accept the changes into master, perform a commit</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git cm "Added cool new feature"
</code></pre></div></div>

<p>If you decide it needs more work, you’ll want to clean up your working directory. Here are the commands to discard the changes.</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git reset ‑‑hard
git clean ‑fdx
</code></pre></div></div>

<p>This will blow away everything not under source control (nuget and npm packages, bin obj, etc)</p>

<p>You can also use the alias:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git nuke
</code></pre></div></div>

<h3 id="delete-branch">Delete branch</h3>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git branch -D branch_name
git push origin --delete branch_name
</code></pre></div></div>

<h2 id="submitting-a-pull-request">Submitting a Pull Request</h2>

<p>There is a really good article about using forks and pulls requests to contribute changes to a project at <a href="http://blog.scottlowe.org/2015/01/27/using-fork-branch-git-workflow">Using the Fork-and-Branch Git Workflow</a></p>

<p>If you want to get right to it, follow these steps:</p>

<p>Go to a <a href="https://github.com/{owner}/{repository}">Github</a> and fork the repository to your personal account</p>

<p>Clone the repository to your desktop:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/{your_account}/{repository}.git
</code></pre></div></div>

<p>You will already have a remote link to your Github repository, but it is also handy to create a link to the repository you created the fork from. We will call this <strong><em>upstream</em></strong> (Note: this is a one-time activity. Unless you physically delete your local repository, you shouldn’t have to do this again). For more details, see <a href="https://help.github.com/articles/configuring-a-remote-for-a-fork">this article</a></p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git remote add upstream https://github.com/{owner}/{repository}.git
</code></pre></div></div>

<p>Now create a feature branch to do your changes</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git checkout -b {feature_branch} {source_branch}
</code></pre></div></div>

<p>For example:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git checkout -b MyFeatureBranch master
</code></pre></div></div>

<p>Now interact with your code as normal. Edit code, run tests, commit often. When you are ready to push changes up to your personal Github repo, you will need to set the default remote repo first.</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git push --set-upstream origin MyFeatureBranch
</code></pre></div></div>

<p>After that, you can just push as normal:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git push
</code></pre></div></div>

<blockquote>
  <p>Try to keep the number of changes you are making restricted to the feature. It is difficult to read a pull request for changes made to dozens of files.</p>
</blockquote>

<h3 id="create-pull-request">Create Pull Request</h3>

<p>Go to your branch <a href="https://github.com/{your_account}/{repository}">https://github.com/{your_account}/{repository}</a> and click the big green <strong><em>Compare &amp; pull request</em></strong> button. Enter a Title and some comments and press <strong><em>Create pull request</em></strong>.</p>

<p>Now the conversation begins. Other team members can leave general comments or comment on a line of code. You can continue to commit changes to your branch and they will be automatically displayed in the pull request. Once the owner is satisfied with the change, they can merge the change into the main repo.</p>

<h3 id="cleaning-up">Cleaning Up</h3>

<p>Once your pull request has been merged, you can delete your branch. First delete the local branch</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git checkout master
git branch &lt;branchName&gt; -D
git push origin master
</code></pre></div></div>

<p>Then delete the remote branch:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git push origin --delete &lt;branchName&gt;
</code></pre></div></div>

<h3 id="sync-your-repo-from-upstream">Sync your repo from UPSTREAM</h3>

<p>Syncing your repo with GTD/MRA is pretty straightforward. For more details, see <a href="https://help.github.com/articles/syncing-a-fork">this article</a></p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git fetch upstream
</code></pre></div></div>

<p>Check out your fork’s local master branch.</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git checkout master
</code></pre></div></div>

<p>Merge the changes from upstream/master into your local master branch. This brings your fork’s master branch into sync with the upstream repository, without losing your local changes. After merging, push the changes up to your repo.</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git merge upstream/master
git push origin master
</code></pre></div></div>

<p>Now you are ready to start on another feature branch</p>

<h2 id="migrate-svn-repository-to-git">Migrate SVN Repository to Git</h2>

<p>Based on this guide: http://www.troyhunt.com/2014/08/migrating-from-subversion-to-git-with.html</p>

<p>Basically:</p>

<p>Install ruby - <a href="http://rubyinstaller.org/downloads">http://rubyinstaller.org/downloads</a> - you might have to add the c:\rubyXXX\bin folder to your PATH</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>SET HTTP_PROXY=http://your-proxy.company.com:8080
gem install svn2git
</code></pre></div></div>

<p>Setup folder to get ready for migration</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mkdir _code\github\your_repo
cd _code\github\your_repo 
</code></pre></div></div>

<p>Kick off the Svn-&gt;Git migration (note: do not include /trunk):</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>svn2git https://your-svn-server.company.com:8443/svn/your_repo 
</code></pre></div></div>

<p>While you wait for it to complete, go to <a href="https://github.com">Github</a> and create a new repository for your project - do not add a readme or .gitignore file</p>

<p>Once svngit is complete, execute:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git remote add origin https://github.com/{owner}/{your_repository}.git
git push
</code></pre></div></div>

<h3 id="good-articles">Good Articles</h3>

<p><a href="http://haacked.com/archive/2014/07/28/github-flow-aliases/">http://haacked.com/archive/2014/07/28/github-flow-aliases/</a></p>

<p><a href="http://lostechies.com/sharoncichelli/2014/08/15/reviewing-git-feature-branches-when-you-dont-have-pull-requests">http://lostechies.com/sharoncichelli/2014/08/15/reviewing-git-feature-branches-when-you-dont-have-pull-requests</a></p>

<p><a href="http://sethrobertson.github.io/GitFixUm/fixup.html">http://sethrobertson.github.io/GitFixUm/fixup.html</a></p>

]]></content>
  </entry>
  
  
  
  <entry>
    <title type="html"><![CDATA[Christmas Lights with Raspberry Pi]]></title>
    <link href="http://jayturpin.com/archive/2015/12/12/raspberry-pi/"/>
    <updated>2015-12-12T00:00:00+00:00</updated>
    <id>http://jayturpin.com/archive/2015/12/12/raspberry-pi</id>
    <content type="html"><![CDATA[<p>I finally caught the bug. After seeing a neighbor choreograph his entire outdoor light display with music, I set about trying to figure out how to do something similar. I’m starting small, just trying to automate 6-8 different sets of lights on a tree, but you never know where this will end.</p>

<p>After a quick google search, I stumbled upon this article on by <a href="http://www.instructables.com/member/Osprey22/">Osprey22</a> on Instructables <a href="http://www.instructables.com/id/Raspberry-Pi-Christmas-Tree-Light-Show/?ALLSTEPS">Raspberry Pi Christmas Tree Light Show</a></p>

<p>I bought some gear to get started:</p>

<p><img src="/images/raspberry-pi/SainSmart-8-Channel-Relay-Module.jpg" alt="SainSmart 8-Channel Relay Module" /></p>

<p><a href="http://www.amazon.com/gp/product/B0057OC5WK">SainSmart 8-Channel Relay Module</a> - this is used to turn power on and off to the individual power outlets</p>

<p><a href="http://www.amazon.com/gp/product/B00M5WLZDW">Jumper Wire Cables</a></p>

<p><a href="http://www.amazon.com/gp/product/B008XVAVAW">CanaKit Raspberry Pi 2 Complete Starter Kit with WiFi</a> - to get me started easily</p>

<p>I hooked them up to a wireless keyboard/mouse and a monitor (using a HDMI cable), popped the SD card into the Raspberry Pi (RaPi) and installed Raspian operating system using the NOOBS installer. This already cam installed on the SD card, but you can also visit the <a href="https://www.raspberrypi.org/help/noobs-setup/">Raspberry Pi NOOBS Setup</a> page to learn how to do this yourself</p>

<p>Next I started following the instructions in the Instructables article</p>

<h2 id="static-ip-address">Static IP Address</h2>

<p>I setup a static IP address by right-clicking on my wifi connection and selecting WiFi Networks (dhcpcdui) Settings. Select interface and wlan0 and set the IP address and Router number</p>

<h2 id="install-telnet">Install Telnet</h2>

<p>Next, I <a href="http://www.ronnutter.com/raspberry-pi-enabling-telnet/">installed telnet</a>:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt-get install telnetd
sudo /etc/init.d/openbsd-inetd restart 
</code></pre></div></div>

<p>Verify the telnet by opening a command prompt:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>netstat -a | grep telnet
</code></pre></div></div>

<p>You should only see something like this:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>tcp 0 0 *:telnet *:* LISTEN
</code></pre></div></div>

<p>but once you connect to it from another machine using telnet, you’ll see something like:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>tcp 0 0 *:telnet *:* LISTEN
tcp 0 0 raspberrypi.loca:telnet 192.168.15.161:49610 ESTABLISHED
</code></pre></div></div>

<p>Finally, if you want to restrict who can login:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo nano /etc/hosts.allow
</code></pre></div></div>

<p>and add lines similar to these at the bottom of the file:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>in.telnetd : 192.168.1.161 : allow
in.telnetd : 192.168.15. : deny
</code></pre></div></div>

<p>Save and restart the service:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo /etc/init.d/openbsd-inetd restart 
</code></pre></div></div>

<h2 id="ftp-services">FTP Services</h2>

<p>Next, I installed an <a href="https://mike632t.wordpress.com/2015/11/29/setting-up-a-secure-ftp-server/">FTP Server</a></p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt-get update
sudo apt-get upgrade
sudo apt-get install vsftpd
</code></pre></div></div>

<p>Let’s see if it’s installed</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>netstat -npl|grep vsftpd
tcp6   0      0 :::21           :::*            LISTEN      1984/vsftpd     
</code></pre></div></div>

<p>That’s it. If you want to configure the service (like add security features) check out the article linked above.</p>

<h2 id="install-pygame">Install PyGame</h2>

<p>To write scripts to play audio, install <a href="https://www.raspberrypi.org/forums/viewtopic.php?f=32&amp;t=33157&amp;p=332140&amp;hilit=croston%2bpygame#p284266">pygame for Python 3</a>. I also referenced this <a href="http://www.philjeffes.co.uk/wordpress/?p=259">article</a></p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt-get install mercurial 
hg clone https://bitbucket.org/pygame/pygame
cd pygame

sudo apt-get install libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev 
sudo apt-get install libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev
sudo apt-get install python3-dev python3-numpy

python3 setup.py build 
sudo python3 setup.py install
</code></pre></div></div>

<p>Wiring up Relay Module</p>

<p><a href="https://www.youtube.com/watch?v=oaf_zQcrg7g">This great video</a> made it really clear about how to connect the Rasberry Pi to the SainSmart relay module. He talks about an issue he had with the Raspberry Pi 2 Model B, but I never experienced it.</p>

<p>Wired the board up using GPIO.Board configuration. Plugged it in and ran the basic.py test script:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>python ./basic.py
</code></pre></div></div>

<p>and everything worked</p>

<h2 id="automatic-lightshow">Automatic Lightshow</h2>

<p>I found an <a href="https://chivalrytimberz.wordpress.com/2012/12/03/pi-lights/">article</a> by Chivalry Timbers (it could be his real name) about running a light show directly from a MIDI file. About three paragraphs in, he referenced a project called <a href="http://lightshowpi.org/download-and-install/">Lightshow Pi</a> that will allow you to use a MP3 instead.</p>

<h3 id="download-lightshow-pi">Download Lightshow Pi</h3>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code># Install git (if you don't already have it)
sudo apt-get install git-core

# Clone the repository to /home/pi/lightshowpi
cd ~
git clone https://togiles@bitbucket.org/togiles/lightshowpi.git

# Grab the stable branch
cd lightshowpi
git fetch &amp;&amp; git checkout stable
</code></pre></div></div>

<h3 id="install-lightshow-pi">Install LightShow Pi</h3>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cd /home/pi/lightshowpi
sudo ./install.sh
</code></pre></div></div>

<p>The install process can take several minutes. You should reboot after the install completes:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo reboot
</code></pre></div></div>

<h3 id="verifying-your-hardware-configuration">Verifying Your Hardware Configuration</h3>

<p>You can verify your hardware setup and configuration are setup properly by blinking each channel one at a time using the following command from the main LightShow Pi directory (/home/pi/lightshowpi if you’ve followed the default install steps):</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo python py/hardware_controller.py --state=flash
</code></pre></div></div>

<p>You can also fade each channel in and out using software PWM using the following command:</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo python py/hardware_controller.py --state=fade
</code></pre></div></div>

<p>Press <CTRL>-C in the same terminal window to stop the blinking / fading lights test.</CTRL></p>

]]></content>
  </entry>
  
  
  
  <entry>
    <title type="html"><![CDATA[Is The Tesla Powerwall Worth It?]]></title>
    <link href="http://jayturpin.com/archive/2015/06/21/is_tesla_powerwall_worth_it/"/>
    <updated>2015-06-21T00:00:00+00:00</updated>
    <id>http://jayturpin.com/archive/2015/06/21/is_tesla_powerwall_worth_it</id>
    <content type="html"><![CDATA[<p><img src="http://www.teslamotors.com/sites/default/files/images/powerwall/section-hero@2x.jpg" alt="Tesla Powerwall" />
I was listening to the <a href="http://www.dotnetrocks.com/default.aspx?showNum=1154">Energy Storage Geek Out</a> episode on <a href="http://www.dotnetrocks.com">dotnetrocks.com</a> and they were talking about the new <a href="http://www.teslamotors.com/powerwall">Tesla Powerwall</a>. I really love this concept - charge the battery at night when electricity is cheap and then use the power from the battery during peak hours when electricity is expensive. Brilliant!</p>

<p>But it got me wondering: does it make financial sense? So I pulled out my calculator and crunched some numbers.</p>

<p>Here are my assumptions (which could all be wrong, so make sure you do your own homework):</p>

<ul>
  <li>The daily-use Powerwall can provide 7kWh per day and costs about $3000 (plus installation).</li>
  <li>According to the podcast, the unit is designed to be used for 5000 days (a little over 13 years) before it starts to degrade.</li>
</ul>

<h2 id="in-phoenix">In Phoenix</h2>

<p>I live in the Phoenix area and most people here use a time-of-use plan. So that means, in June, we pay about 7 cents a kWh during the evenings and about 19 cents during the middle of the day. That means if I use the <a href="http://www.teslamotors.com/powerwall">Tesla Powerwall</a>, I can use 7 kWh of electricity during the heat of the day. Since I charge the battery in the evening, I only paid 49 cents instead of almost $1.40, saving me 84 cents per day (7kWh x 12 cents = 84 cents)</p>

<p>Now we have different rates during each season, so I applied this logic for an entire year:</p>

<table>
  <thead>
    <tr>
      <th>Season</th>
      <th style="text-align: right">Hi/Low Diff</th>
      <th style="text-align: right">Days</th>
      <th style="text-align: right">Savings/Day</th>
      <th style="text-align: right">Savings/Year</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Nov-Apr</td>
      <td style="text-align: right">0.0309</td>
      <td style="text-align: right">180</td>
      <td style="text-align: right">0.2163</td>
      <td style="text-align: right">38.934</td>
    </tr>
    <tr>
      <td>May-Jun</td>
      <td style="text-align: right">0.1219</td>
      <td style="text-align: right">61</td>
      <td style="text-align: right">0.8533</td>
      <td style="text-align: right">52.0513</td>
    </tr>
    <tr>
      <td>Jul-Aug</td>
      <td style="text-align: right">0.1485</td>
      <td style="text-align: right">62</td>
      <td style="text-align: right">1.0395</td>
      <td style="text-align: right">64.449</td>
    </tr>
    <tr>
      <td>Sep-Oct</td>
      <td style="text-align: right">0.1219</td>
      <td style="text-align: right">61</td>
      <td style="text-align: right">0.8533</td>
      <td style="text-align: right">52.0513</td>
    </tr>
    <tr>
      <td>Total</td>
      <td style="text-align: right"> </td>
      <td style="text-align: right"> </td>
      <td style="text-align: right"> </td>
      <td style="text-align: right">207.4856</td>
    </tr>
  </tbody>
</table>

<p>So, by my calculation, with a savings of $207/year, it will take 14.5 years to recoup the initial investment of $3000. Bummer.</p>

<h2 id="los-angeles">Los Angeles</h2>

<p>I wanted to get at least one more data point, so I looked up time-of-use rates from <a href="https://ladwp.com/ladwp/faces/ladwp/aboutus/a-financesandreports/a-fr-electricrates/a-fr-er-electricrateschedules">Los Angeles Department of Water and Power</a>. As near as I determine from their site, it looks like it will take even longer to recoup the cost</p>

<table>
  <thead>
    <tr>
      <th>Season</th>
      <th style="text-align: right">Hi/Low Diff</th>
      <th style="text-align: right">Days</th>
      <th style="text-align: right">Savings/Day</th>
      <th style="text-align: right">Savings/Year</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Jun-Sep</td>
      <td style="text-align: right">0.08</td>
      <td style="text-align: right">122</td>
      <td style="text-align: right">0.56</td>
      <td style="text-align: right">68.32</td>
    </tr>
    <tr>
      <td>Oct-May</td>
      <td style="text-align: right">0.01</td>
      <td style="text-align: right">243</td>
      <td style="text-align: right">0.07</td>
      <td style="text-align: right">17.01</td>
    </tr>
    <tr>
      <td>Total</td>
      <td style="text-align: right"> </td>
      <td style="text-align: right"> </td>
      <td style="text-align: right"> </td>
      <td style="text-align: right">85.33</td>
    </tr>
  </tbody>
</table>

<p>Over 35 years to get your money back.</p>

<h2 id="conclusion">Conclusion</h2>

<p>Perhaps if I had solar panels on my roof, this might make more sense. I’m not sure what the trade-off is for storing power in a battery compared to selling it back to the grid. Maybe in other area, where the difference between peak and off-peak rates is greater, it would also make more sense.</p>

<p>But until the prices come down for this technology, it doesn’t make financial sense for me.</p>

<h2 id="references">References</h2>

<p><a href="https://ladwp.com/ladwp/faces/ladwp/aboutus/a-financesandreports/a-fr-electricrates/a-fr-er-electricrateschedules">Los Angeles Department of Water and Power</a></p>

<p><a href="http://www.srpnet.com/prices/home/tou.aspx#rates">Phoenix Salt River Project Time-of-use Rates</a></p>
]]></content>
  </entry>
  
  
  
  <entry>
    <title type="html"><![CDATA[Developer Reading List]]></title>
    <link href="http://jayturpin.com/archive/2015/05/26/developer_reading_list/"/>
    <updated>2015-05-26T00:00:00+00:00</updated>
    <id>http://jayturpin.com/archive/2015/05/26/developer_reading_list</id>
    <content type="html"><![CDATA[<p>Developers need to learn many things: how to write clean code; how to test; how to automate the build; the basics of design; the syntax and idiosyncrasies of language(s) they are working in. Many companies assume that college graduates already know most of this information.</p>

<p>Robert C “Uncle Bob” Martin once compared software development to martial arts. He likened college grads to white or gold belt level. They know the basic kicks and punches, but still have a long way to go before they can be considered black belts. The only way to get to that level if through experience and learning from higher level practitioners.</p>

<p>With that end in mind, I’ve pulled together some of my favorite articles, books and videos that have helped me along my journey to becoming a better developer.</p>

<h2 id="agile">Agile</h2>
<ul>
  <li><a href="http://www.amazon.com/dp/0201616416">Extreme Programming Explained, v.1</a> by Kent Beck - one of <em>the</em> most influential programming books of the past generation. Beck inspired me, and tens of thousands of developers to write tests, pair program, refactor and write better code. IMHO, this is the book the sparked the entire agile movement.</li>
  <li><a href="http://martinfowler.com/articles/newMethodology.html">The New Methodology</a> by Martin Fowler - everything Fowler writes is gold. A great article describing agile development (mainly eXtreme Programming).</li>
  <li><a href="https://collaboration.csc.ncsu.edu/laurie/Papers/Kindergarten.PDF">All I Really Need to Know about Pair Programming I Learned In Kindergarten</a> by Laurie Williams and Robert Kessler</li>
  <li><a href="http://alistair.cockburn.us/Characterizing+people+as+non-linear,+first-order+components+in+software+development">Characterizing people as non-linear, first-order components in software development</a> by Alistair Cockburn - a really dry title, but a very interesting paper. Discusses the importance of people as part of a team. My favorite concept: when attempting to introduce any improvement to the process, “I discovered: Problem 1. The people on the projects were not interested in learning our system. Problem 2. They were successfully able to ignore us, and were still delivering software, anyway.”</li>
</ul>

<h2 id="embrace-your-craft">Embrace Your Craft</h2>
<ul>
  <li><a href="https://pragprog.com/the-pragmatic-programmer">The Pragmatic Programmer</a> by Dave Thomas and Andy Hunt - not a programming book, per se, but a book about <em>how</em> to be a developer. Outstanding book.</li>
  <li><a href="http://www.amazon.com/dp/0132350882">Clean Code</a> and <a href="http://www.amazon.com/dp/0137081073">Clean Coder</a> by Robert C Martin - describes the what code should look like and how to write it yourself.</li>
</ul>

<h2 id="practice-your-craft">Practice Your Craft</h2>
<ul>
  <li>Take on ownership of your team’s build process - learn the build process inside and out</li>
  <li>Participate in an open source project of your choosing. Contribute one change by the end of the year (enhancement, bug fix, documentation)</li>
  <li>Attend a one-day Code Retreat <a href="http://coderetreat.org">http://coderetreat.org</a>. Already attended a retreat? Facilitate one instead.</li>
</ul>

<h2 id="oo-design-patternsprinciples">OO Design Patterns/Principles</h2>
<ul>
  <li><a href="http://www.amazon.com/dp/0135974445">Agile Software Development</a> - Robert C Martin (aka Uncle Bob) – This book is misnamed. It’s really about some the principles of good object oriented design. It talks about the underlying concepts and principles that will allow you and your teammates determine if a design is good, or lacking. Read Chapters 1-12; There is also a version for <a href="http://www.amazon.com/dp/0131857258">C#</a>. Object Mentor,  also offers a <a href="http://www.objectmentor.com/omTraining/course_ood_patterns.html">class</a> and Bob has a number of videos at <a href="http://cleancoders.com">http://cleancoder.com</a>.</li>
  <li><a href="http://www.amazon.com/dp/0596007124">Head First Design Patterns</a> - An entertaining and informative book that will walk you through the most common design patterns for an OO language.</li>
  <li><a href="http://martinfowler.com/ieeeSoftware/failFast.pdf">Fail Fast</a> – Jim Shore - Great little article that helped me understand why I want my application to fail quickly.</li>
  <li><a href="http://www.developerdotstar.com/mag/articles/PDF/DevDotStar_Reeves_CodeAsDesign.pdf">Code as Design</a> - Jack Reeves – A precursor to the agile movement, the author does a great job of describing why code is the best way to represent the design. Junior and senior developers will find this paper to be enlightening.</li>
  <li><a href="http://martinfowler.com/articles/designDead.html">Is Design Dead?</a> - Martin Fowler - For many that come briefly into contact with Extreme Programming, it seems that XP calls for the death of software design. Not just is much design activity ridiculed as “Big Up Front Design”, but such design techniques as the UML, flexible frameworks, and even patterns are de-emphasized or downright ignored. In fact XP involves a lot of design, but does it in a different way than established software processes. XP has rejuvenated the notion of evolutionary design with practices that allow evolution to become a viable design strategy. It also provides new challenges and skills as designers need to learn how to do a simple design, how to use refactoring to keep a design clean, and how to use patterns in an evolutionary style.</li>
  <li><a href="http://www.amazon.com/dp/0201485672">Refactoring</a> by Martin Folwer - pages 1-87</li>
</ul>

<h2 id="how-to-test">How to Test</h2>
<ul>
  <li><a href="http://www.amazon.com/dp/0321146530">Test Driven Development</a> - Kent Beck - The master teaches how to do TDD using Java and a small banking application</li>
  <li><a href="http://www.amazon.com/dp/1933988274">The Art of Unit Testing: With Examples in .Net</a> - Roy Osherove walks through unit testing is C#.</li>
  <li><a href="http://jamesshore.com/Blog/Lets-Play/">James Shore’s Let Play Video Series</a> If you prefer learning via video, check out these 15-minute videos by James Shore. He records over 100 sessions of coding an application using TDD</li>
</ul>

<h2 id="continuous-integrationautomated-build">Continuous Integration/Automated Build</h2>
<ul>
  <li><a href="http://martinfowler.com/articles/continuousIntegration.html">Continuous Integration</a> - Martin Fowler - Continuous Integration is a software development practice where members of a team integrate their work frequently, usually multiple times a day - leading to multiple builds per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly. This article is a quick overview of Continuous Integration summarizing the technique and its current usage.</li>
  <li><a href="http://www.ericsink.com/vcbe">Version Control By Example</a> - In this free book, Erik Sink covers all of the common source code control practices. If you’re new to source code control, or need a refresher to bone up on the more advanced topics, check this out.</li>
  <li><a href="http://jamesshore.com/Blog/Continuous-Integration-on-a-Dollar-a-Day.html">Continuous Integration on a Dollar-a-Day</a> - James Shore</li>
  <li><a href="http://martinfowler.com/articles/evodb.html">Evolutionary Database Design</a> - Martin Folwer and Pramod Sadalage - Over the last few years we’ve developed a number of techniques that allow a database design to evolve as an application develops. This is a very important capability for agile methodologies. The techniques rely on applying continuous integration and automated refactoring to database development, together with a close collaboration between DBAs and application developers. The techniques work in both pre-production and released systems.</li>
  <li><a href="http://ccnet.thoughtworks.com/">CruiseControl.Net</a> - CruiseControl is the one of the first continous integration servers in the .Net world. Originally ported from Java, CrusieControl.Net is responsible for kicking off the builds of literally tens of thousands software project around the world. It integrates with all the most popular source code control systems and is very flexible in how it notifies the team about broken builds</li>
  <li><a href="http://www.jetbrains.com/teamcity/features/continuous_integration.html">Team City</a> - Another continuous integration server is TeamCity by Jetbrains (the makers of Resharper)</li>
</ul>

]]></content>
  </entry>
  
  
  
  <entry>
    <title type="html"><![CDATA[Setting up a blog on Github]]></title>
    <link href="http://jayturpin.com/archive/2015/05/24/setting_up_blog_on_github/"/>
    <updated>2015-05-24T00:00:00+00:00</updated>
    <id>http://jayturpin.com/archive/2015/05/24/setting_up_blog_on_github</id>
    <content type="html"><![CDATA[<p>While this is certainly not new, it was new for me. So I wanted to make sure I recorded what I learned this weekend.</p>

<h1 id="some-context">Some Context</h1>

<p>I was having lunch with a co-worker a couple weeks ago and he started talking about hosting websites on Github. I’ve been thinking about starting a blog over the past few months, but just haven’t been able to decide on the right platform to host it on. I’ve played around with Weebly, Squarespace and even Ghost hosted on Azure, but I was looking for low cost and a reasonable level of control and none of them quite fit the bill.</p>

<p>I remembered seeing an <a href="http://haacked.com/archive/2013/12/02/dr-jekyll-and-mr-haack/">article</a> from Phil Haack some time ago talking about how he ported his blog to Github. To say that Phil inspired my site would be an understatement - I cloned his site and then started replacing images, links and posts to personalize it. Standing on the shoulders of giants. Thanks Phil!</p>

<h1 id="getting-started">Getting Started</h1>

<p>The first thing I did was create a github project to host my site. I could have created a user page repository called <a href="https://github.com/turp/turp.github.io">https://github.com/turp/turp.github.io</a>, but since I was following Phil’s lead, I created a project called <a href="https://github.com/turp/jayturpin.com">https://github.com/turp/jayturpin.com</a> to host this blog.</p>

<p><img src="/images/setting_up_blog_on_github/01-create-repo.jpg" alt="Create Repository" /></p>

<p>If you’re really interested, you can read more about the difference between user and project pages at <a href="https://help.github.com/articles/user-organization-and-project-pages/">https://help.github.com/articles/user-organization-and-project-pages/</a>.</p>

<p>To see something quickly, I let Github do some of the work for me. I clicked the Settings button and scrolled down to the Github Pages section and clicked the Automatic Page Generator</p>

<p><img src="/images/setting_up_blog_on_github/03-automatic-page-generator.jpg" alt="Automatic Page Generator" /></p>

<p>Then I entered the name of my site and selected a theme;</p>

<p><img src="/images/setting_up_blog_on_github/04-pick-theme.jpg" alt="Pick a Theme" /></p>

<p>And that’s it. You’ll see a new branch setup in your repo called gh-pages and see files that look something like this:</p>

<p><img src="/images/setting_up_blog_on_github/05-basic-site.jpg" alt="Repository" /></p>

<p>Point your browser to <a href="http://turp.github.io/jayturpin.com">http://turp.github.io/jayturpin.com</a></p>

<h1 id="jekyll">Jekyll</h1>

<p>Github Pages are created with <a href="http://jekyllrb.com/">Jekyll</a>, a Ruby library that converts <a href="http://daringfireball.net/projects/markdown/">Markdown</a> script into HTML. It was created with blogs in mind, so it understands permalinks, categories, pages and posts, making blogging pretty easy.</p>

<p>If you want to be able to run your site locally, while your fine tuning the layout, you will need to install a few things. Follow the instructions <a href="https://help.github.com/articles/using-jekyll-with-pages/">here</a> to install Ruby, Bundler and Jekyll. I also recommend that you install <a href="https://www.python.org/downloads/">Python</a> too, since Jekyll uses it to perform code highlighting.</p>

<p>Once you have everything installed, run from the root of your local repository</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>jekyll serve
</code></pre></div></div>

<p>and visit <a href="http://localhost:4000">http://localhost:4000</a></p>

<h1 id="custom-domain">Custom Domain</h1>

<p>While it’s cool to be able to send people to a such memorable web address as <a href="http://turp.github.io/jayturpin.com">http://turp.github.io/jayturpin.com</a>, I wanted to be able to use my own domain. Luckily, Github makes it easy.</p>

<p>First, create a file called <a href="https://github.com/turp/jayturpin.com/CNAME">CNAME</a> (I assume spelling and capitalization is important) and place it in the root of your repository. Add a single line to that file with the name of your domain, in my case</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>jay.turpin.com
</code></pre></div></div>

<p>Once that is done, visit your domain registrar (I use <a href="http://namecheap.com">Namecheap.com</a> and point your domain name to <strong>[username].github.io.</strong>:</p>

<p><img src="/images/setting_up_blog_on_github/06-namecheap_setup.jpg" alt="Namecheap" /></p>

<p>It may take a few minutes to propagate, so don’t freak out if it doesn’t work right away.</p>

<p>I also added a subdomain called feeds to redirect to my <a href="http://feedburner.com">Feedburner</a> site to allow me to track the three family members that will eventually subscribe to my blog.</p>

<h1 id="creating-posts">Creating Posts</h1>

<p>All blog posts are stored in the _posts folder. I created a folder for each year, but that is optional. If you want to work on posts and not make them public yet, store them in a folder called _drafts. You can see how them look by running Jekyll with the draft option</p>

<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>jekyll serve --drafts
</code></pre></div></div>

<h1 id="conclusion">Conclusion</h1>

<p>And that’s it! If you want a different theme, there are dozens available at <a href="http://jekyllthemes.org">jekyllthemes.org</a> that you can use for your site.</p>

]]></content>
  </entry>
  
  
  
  <entry>
    <title type="html"><![CDATA[Welcome]]></title>
    <link href="http://jayturpin.com/archive/2015/05/17/welcome/"/>
    <updated>2015-05-17T00:00:00+00:00</updated>
    <id>http://jayturpin.com/archive/2015/05/17/welcome</id>
    <content type="html"><![CDATA[<p><img src="/images/JayTurpin-300x300.jpg" height="100" width="100" class="pull-left" /> My name is Jay Turpin. I’m a big dog owner, beer brewer, father of two and husband of one for over two decades. I have been developing software since 1993, and am passionate about new technologies and practices.</p>

<p>As a software developer currently working at <a href="http://intel.com">Intel Corporation</a>, I am an outspoken proponent of agile practices and have been employed them on over a half dozen teams since 2001.</p>

<p>Over the years, I have taught numerous agile classes, given presentations and coached teams on how to take the first step in their journey towards becoming agile.</p>

<p>I love coding. My day-to-day work is primarily focused on Typescript and Angular on the front-end, C# and SQL Server on the backend. I love Ruby and have used it for build scripts for years.</p>
]]></content>
  </entry>
  
  
</feed>
