<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:scottbartell.com,2005:/posts</id>
  <link rel="alternate" type="text/html" href="http://scottbartell.com"/>
  <link rel="self" type="application/atom+xml" href="http://scottbartell.com/posts.atom"/>
  <title>scottbartell.com</title>
  <updated>2013-05-02T23:17:00Z</updated>
  <entry>
    <id>tag:scottbartell.com,2005:Post/23</id>
    <published>2013-05-03T00:09:09Z</published>
    <updated>2013-05-23T03:18:39Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/intro-to-turbolinks-and-properly-configuring-analytics"/>
    <title>Intro to Turbolinks &amp; Properly Configuring Analytics</title>
    <content type="html">&lt;p&gt;Rails 4 has a new JavaScript plugin that is turned on by default, &lt;a href="https://github.com/rails/turbolinks/"&gt;Turbolinks&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It&amp;#39;s important to understand how Turbolinks works because it can have a significant impact on the functionality of your application - most notably your JavaScript.&lt;/p&gt;

&lt;h2&gt;What does Turbolinks do?&lt;/h2&gt;

&lt;p&gt;Turbolinks makes it faster for a user to switch between pages of your website by only updating the body and the title of the page when a link is followed. When a link is followed, the full page is not reloaded thus reducing the browser rendering time and minimizing request data.&lt;/p&gt;

&lt;p&gt;For more about Turbolinks check out the &lt;a href="https://github.com/rails/turbolinks/#readme"&gt;documentation&lt;/a&gt; or the &lt;a href="http://railscasts.com/episodes/390-turbolinks"&gt;Railscast&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Why do I need to know this?&lt;/h2&gt;

&lt;p&gt;Because the full page is not always reloaded between a visitor&amp;#39;s page views, JavaScript events might not fire as expected. To combat this, Turbolinks provides some &lt;a href="https://github.com/rails/turbolinks/#events"&gt;events&lt;/a&gt; that fire on &lt;code&gt;document&lt;/code&gt;; most notably &lt;code&gt;page:load&lt;/code&gt; (here&amp;#39;s a &lt;a href="https://github.com/rails/turbolinks/#events"&gt;full list&lt;/a&gt; of the events).&lt;/p&gt;

&lt;p&gt;Without a full page reload, you cannot rely on typical events (such as &lt;code&gt;DOMContentLoaded&lt;/code&gt; or &lt;code&gt;jQuery.ready()&lt;/code&gt;) to trigger your code. Instead you should listen to the &lt;code&gt;page:load&lt;/code&gt; event.&lt;/p&gt;

&lt;p&gt;Here&amp;#39;s a great example in CoffeeScript from the &lt;a href="http://railscasts.com/episodes/390-turbolinks"&gt;Turbolinks Railscast&lt;/a&gt; that you should watch:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="nv"&gt;ready = &lt;/span&gt;&lt;span class="nf"&gt;-&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;  &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;click&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;.edit_task input[type=checkbox]&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;-&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;    &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;form&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;submit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-4"&gt;
&lt;/span&gt;&lt;span id="line-5"&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-6"&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;page:load&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This makes sure that the &lt;code&gt;ready()&lt;/code&gt; function gets called on every page reload.&lt;/p&gt;

&lt;h2&gt;What about my Analytics?&lt;/h2&gt;

&lt;h3&gt;How does Turbolinks work with Gauges?&lt;/h3&gt;

&lt;p&gt;Typically with any web analytics software you&amp;#39;re expected to put a piece of JavaScript right below the the closing &lt;code&gt;&amp;lt;/body&amp;gt;&lt;/code&gt; tag on every page of your website. In &lt;a href="http://gaug.es"&gt;Gaug.es&lt;/a&gt; the code looks something like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;_gauges&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_gauges&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-4"&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;script&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-5"&gt;    &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;text/javascript&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-6"&gt;    &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;async&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-7"&gt;    &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;gauges-tracker&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-8"&gt;    &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;data-site-id&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;this is different for each gauge&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-9"&gt;    &lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;//secure.gaug.es/track.js&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-10"&gt;    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementsByTagName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;script&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-11"&gt;    &lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parentNode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;insertBefore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-12"&gt;  &lt;span class="p"&gt;})();&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-13"&gt;&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Because the full page isn&amp;#39;t always reloaded, this script isn&amp;#39;t always reloaded. This means that &lt;em&gt;by default&lt;/em&gt; &lt;strong&gt;some pageviews are not recorded&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So, how can you fix this? Gaug.es allows you to force a pageview using: &lt;code&gt;_gauges.push([&amp;#39;track&amp;#39;]);&lt;/code&gt;. Now what you need to do is to listen for the &lt;code&gt;page:change&lt;/code&gt; event and force a pageview if it occurs. &lt;/p&gt;

&lt;p&gt;Keep in mind that if you simply add &lt;code&gt;_gauges.push([&amp;#39;track&amp;#39;]);&lt;/code&gt; to every page, you will likely be counting pageviews multiple times. This is because the normal Gagu.es JavaScript snippet still records pageviews on full page loads and full page loads may still happen on several occasions. For example, the first time that someone comes to your website a full page load will occur and also  some older browsers don&amp;#39;t support the technology that Turbolinks relies on will always fully load pages.&lt;/p&gt;

&lt;p&gt;Here&amp;#39;s a simple example that might work for you:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;page:change&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;-&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;  &lt;span class="nx"&gt;_gauges&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;track&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For more information check out the &lt;a href="http://get.gaug.es/documentation/tracking/"&gt;Gaug.es documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;How does Turbolinks work with Google Analytics?&lt;/h3&gt;

&lt;p&gt;To get Turbolinks to work with Google Analytics you first need to make sure the JavaScript snippet is before the closing &lt;code&gt;&amp;lt;/body&amp;gt;&lt;/code&gt; - it cannot be within the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; Next you need to add the following script within the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; of the document (written in CoffeeScript).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;on&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;page:change&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;-&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_gaq&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;    &lt;span class="nx"&gt;_gaq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;_trackPageview&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-4"&gt;  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pageTracker&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-5"&gt;    &lt;span class="nx"&gt;pageTracker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_trackPageview&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here&amp;#39;s a &lt;a href="https://github.com/rails/turbolinks/issues/166"&gt;related issue&lt;/a&gt; in Github.&lt;/p&gt;

&lt;p&gt;Credit for the Google Analytics solution can be found &lt;a href="http://reed.github.io/turbolinks-compatibility/google_analytics.html"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;UPDATE&lt;/h2&gt;

&lt;p&gt;I just ran into a few issues getting Google Analytics and Gauges to work properly with this very blog so I thought I&amp;#39;d share.&lt;/p&gt;

&lt;p&gt;Every time Turbolinks was loading a page, both of my analytics scripts were running and reinserting JavaScript into the head.&lt;/p&gt;

&lt;p&gt;At this point I had both of the scripts right before the closing &lt;code&gt;body&lt;/code&gt; tag. In order to try and fix this I stumbled across a new feature added in Turbolinks: &lt;code&gt;data-turbolinks-eval&lt;/code&gt;. If you set this attribute to &lt;code&gt;false&lt;/code&gt; on a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag it will make sure the script is not re-evaluated. &lt;a href="https://github.com/rails/turbolinks#evaluating-script-tags"&gt;Read more&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;text/javascript&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;data-turbolinks-eval=&lt;/span&gt;&lt;span class="s"&gt;false&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Unfortunately, this didn&amp;#39;t work. Instead of only loading the file once in the head, it just never ran. My final solution was to move the two analytics &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags to the head, &lt;strong&gt;above Turbolinks&lt;/strong&gt;. Anything that is above the Turbolinks include will not be run through Turbolinks.&lt;/p&gt;

&lt;p&gt;This fixed my issue. Hopefully that saves someone some time!&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/22</id>
    <published>2013-04-29T16:36:01Z</published>
    <updated>2013-04-29T16:36:01Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/adding-line-numbers-to-pygmentsrb"/>
    <title>Adding Line Numbers to Pygments.rb</title>
    <content type="html">&lt;p&gt;On this blog I use &lt;a href="https://github.com/tmm1/pygments.rb"&gt;Pygments.rb&lt;/a&gt; for Github-like syntax highlighting. When I set Pygments.rb up, I couldn&amp;#39;t find much documentation on how to add line numbers; so I figured I share how I did it.&lt;/p&gt;

&lt;p&gt;If you look through the &lt;a href="http://pygments.org/docs/formatters/"&gt;Pygments documentation&lt;/a&gt; you&amp;#39;ll notice that there a few different options for adding line numbers.&lt;/p&gt;

&lt;p&gt;Most notably: &lt;code&gt;linenos&lt;/code&gt; - If this option is set to &lt;code&gt;table&lt;/code&gt;, Pygments will output line numbers as a table with two cells: one containing the line numbers, the other the whole code.&lt;/p&gt;

&lt;p&gt;This might suit your needs perfectly, however I wanted to use CSS to display my line-numbers, so this wasn&amp;#39;t what I was looking for. I needed a way to wrap each of the lines in an element that I could style. Luckily, there&amp;#39;s an option for this: &lt;code&gt;linespans&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;linespans&lt;/code&gt; - If set to a nonempty string, e.g. foo, the formatter will wrap each output line in a span tag with an id of foo-linenumber&lt;/p&gt;

&lt;p&gt;Here&amp;#39;s the code I used:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;block_code&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;language&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;    &lt;span class="no"&gt;Pygments&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;highlight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;lexer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;language&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to_sym&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;linespans&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;line&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-4"&gt;  &lt;span class="k"&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-5"&gt;    &lt;span class="n"&gt;code&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-6"&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-7"&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This wraps each line of code with a &lt;code&gt;span&lt;/code&gt; elements each having a unique id representing the current line and the prefix &lt;code&gt;line-&lt;/code&gt;. Like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;highlight&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;  &lt;span class="nt"&gt;&amp;lt;pre&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;line-1&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;span&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-4"&gt;    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;line-2&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;span&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-5"&gt;    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;line-3&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;span&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-6"&gt;    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;line-4&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;span&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-7"&gt;  &lt;span class="nt"&gt;&amp;lt;/pre&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-8"&gt;&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now we are able to select each line using CSS like so:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="nc"&gt;.highlight&lt;/span&gt; &lt;span class="nt"&gt;pre&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;span&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;  &lt;span class="k"&gt;font-size&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;.9em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;  &lt;span class="k"&gt;color&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#aaa&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-4"&gt;  &lt;span class="k"&gt;content&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;linenumbers&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-5"&gt;  &lt;span class="k"&gt;counter-increment&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linenumbers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-6"&gt;  &lt;span class="k"&gt;left&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-3.2ex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-7"&gt;  &lt;span class="k"&gt;position&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-8"&gt;  &lt;span class="k"&gt;text-align&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;right&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-9"&gt;  &lt;span class="k"&gt;width&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2.5ex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-10"&gt;  &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;webkit&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;touch&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;callout&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-11"&gt;  &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;webkit&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-12"&gt;  &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;khtml&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-13"&gt;  &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;moz&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-14"&gt;  &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-15"&gt;  &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-16"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The user-select properties at the bottom make it so that the line numbers are not selectable. This makes it easier for someone to copy and paste code.&lt;/p&gt;

&lt;p&gt;For more information check out the &lt;a href="https://github.com/scottbartell/scottbartell.com"&gt;source code for this blog&lt;/a&gt; over on Github.&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/21</id>
    <published>2013-04-23T08:12:12Z</published>
    <updated>2013-04-23T08:12:12Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/javascript-logical-operators"/>
    <title>JavaScript &amp;&amp; and || Logical Operators</title>
    <content type="html">&lt;p&gt;JavaScript support three different logical operators: &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; (AND), &lt;code&gt;||&lt;/code&gt; (OR), and &lt;code&gt;!&lt;/code&gt; (NOT)&lt;/p&gt;

&lt;p&gt;When using logical operators it’s important to know that the values:  &lt;code&gt;null&lt;/code&gt;, &lt;code&gt;undefined&lt;/code&gt;, &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;” “&lt;/code&gt;, and &lt;code&gt;NaN&lt;/code&gt;, are &lt;strong&gt;the only JavaScript values that return &lt;code&gt;false&lt;/code&gt;&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;All  other JavaScript values will return&lt;/strong&gt; a boolean value of &lt;strong&gt;&lt;code&gt;true&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;How they work&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;  &lt;span class="c1"&gt;// =&amp;gt; false&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;&lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;  &lt;span class="c1"&gt;// =&amp;gt; true&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;&lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;  &lt;span class="c1"&gt;// =&amp;gt; true&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-4"&gt;&lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="c1"&gt;// =&amp;gt; false&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-5"&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="c1"&gt;// =&amp;gt; false&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-6"&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="c1"&gt;// =&amp;gt; true&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;&amp;amp;&amp;amp; (AND)&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; performs the Boolean AND operation on the two values. Generally, it will only return &lt;code&gt;true&lt;/code&gt; if the values on both sides are &lt;code&gt;true&lt;/code&gt;. If any value is &lt;code&gt;false&lt;/code&gt;, it will return &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;|| (OR)&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;||&lt;/code&gt; is very similar to &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; except it preforms the Boolean OR operation on the two values. Generally, it will only return &lt;code&gt;false&lt;/code&gt; if both sides are &lt;code&gt;false&lt;/code&gt;. If any value is &lt;code&gt;true&lt;/code&gt;, then it will return &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;! (NOT)&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;!&lt;/code&gt; is a unary (takes a single value) operator that inverses the given value. For example: &lt;code&gt;!true // =&amp;gt; false&lt;/code&gt; and &lt;code&gt;!false // =&amp;gt; true&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;Some interesting details&lt;/h2&gt;

&lt;p&gt;It turns out that both the &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; and &lt;code&gt;||&lt;/code&gt; operators don&amp;#39;t necessarily output Boolean values (hence the &amp;#39;generally&amp;#39; I used above). If these operators are applied to Boolean values (like the previous example), they will certainly return a Boolean value. However, when these operators are applied to other values that are not Booleans, the return value is one of the given arguments.&lt;/p&gt;

&lt;h3&gt;Why does this work with non-Boolean arguments?&lt;/h3&gt;

&lt;p&gt;Remember how all JavaScript values return &lt;code&gt;true&lt;/code&gt; except &lt;code&gt;null&lt;/code&gt;, &lt;code&gt;undefined&lt;/code&gt;, &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;” “&lt;/code&gt;, and &lt;code&gt;NaN&lt;/code&gt;? Well, when &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; and &lt;code&gt;||&lt;/code&gt; evaluate each side they use these rules.&lt;/p&gt;

&lt;h3&gt;So, which value is returned?&lt;/h3&gt;

&lt;p&gt;Both the &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; and &lt;code&gt;||&lt;/code&gt; work in a specific order; from left to right.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How the &amp;amp;&amp;amp; works:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;  &lt;span class="c1"&gt;// =&amp;gt; 0 : true is true, so return 0&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;&lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;  &lt;span class="c1"&gt;// =&amp;gt; null : null is false, so return null&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;&lt;span class="mi"&gt;123&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="mi"&gt;456&lt;/span&gt;  &lt;span class="c1"&gt;// =&amp;gt; 456 : 123 is true, so return 456&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; operator follows this pattern:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Look at the value on the left&lt;/li&gt;
&lt;li&gt;If it converts to Boolean false, return that value&lt;/li&gt;
&lt;li&gt;If it converts to Boolean true, return the value on the right&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;How the || works:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;  &lt;span class="c1"&gt;// =&amp;gt; true : true is true, so return true&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;&lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;  &lt;span class="c1"&gt;// =&amp;gt; true : null is false, so return true&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;&lt;span class="mi"&gt;123&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;456&lt;/span&gt;  &lt;span class="c1"&gt;// =&amp;gt; 123 : 123 is true, so return 123&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;||&lt;/code&gt; operator follows this pattern:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Look at the value on the left&lt;/li&gt;
&lt;li&gt;If it converts to Boolean true, return that value&lt;/li&gt;
&lt;li&gt;If it converts to Boolean false, return the value on the right&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Some important implications&lt;/h3&gt;

&lt;p&gt;Because these operators behave this way, the expression on the right is only evaluated when necessary. This means that the expression on the right might &lt;em&gt;never&lt;/em&gt; be evaluated. Consider the following code:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;&lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;  &lt;span class="c1"&gt;// =&amp;gt; 123 : y is true, so return y.x&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-4"&gt;&lt;span class="nx"&gt;z&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="c1"&gt;// =&amp;gt; null : null is false, so return z and don&amp;#39;t evaluate z.x&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The code &lt;code&gt;z.x&lt;/code&gt; should raise a &lt;code&gt;TypeError&lt;/code&gt; but it is never evaluated because the value on the left was false.&lt;/p&gt;

&lt;p&gt;This behavior also provides us with a pretty powerful tool that we can leverage in several practical cases. Here&amp;#39;s an example from &lt;a href="http://eloquentjavascript.net/chapter2.html"&gt;Eloquent Javascript&lt;/a&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;What is your name?&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Kilgore Trout&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;&lt;span class="nx"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Well hello &amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;dear&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;  &lt;span class="c1"&gt;// if no name was given, default to &amp;quot;dear&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Basically, in this example you can use the &lt;code&gt;||&lt;/code&gt; operator to easily set a default value.&lt;/p&gt;

&lt;p&gt;For more information check out &lt;a href="http://eloquentjavascript.net/chapter2.html"&gt;Eloquent Javascript Chapter 2 - Basic JavaScript: values, variables, and control flow&lt;/a&gt;&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/20</id>
    <published>2013-04-22T20:56:44Z</published>
    <updated>2013-04-22T21:01:08Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/parallel-assignment-in-ruby"/>
    <title>Parallel Assignment in Ruby</title>
    <content type="html">&lt;p&gt;In Ruby an assignment specifies one or more values &lt;em&gt;(rvalues)&lt;/em&gt; for one or more &lt;em&gt;lvalues&lt;/em&gt;.  &lt;em&gt;rvalue&lt;/em&gt; refers to whatever appears on the right side of the assignment operator and &lt;em&gt;lvalue&lt;/em&gt; on the left.&lt;/p&gt;

&lt;p&gt;There are three forms of assignment in Ruby: &lt;strong&gt;simple assignment&lt;/strong&gt;, &lt;strong&gt;abbreviated assignment&lt;/strong&gt;, and &lt;strong&gt;parallel assignment&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Parallel assignment is an assignment that has more than one &lt;em&gt;lvalue&lt;/em&gt; or more than one &lt;em&gt;rvalue&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I have found parallel assignment very useful for two different cases in particular:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Swapping the values of two variables&lt;/li&gt;
&lt;li&gt;Assigning the same value to multiple variables&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;Swapping values&lt;/h2&gt;

&lt;p&gt;In ruby you can swap the values of two different variables on a single line.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;  &lt;span class="c1"&gt;# Set x to 1 and y to 2&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="c1"&gt;# Swap x and y values&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;&lt;span class="n"&gt;x&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-4"&gt;&lt;span class="c1"&gt;# =&amp;gt; 2&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-5"&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-6"&gt;&lt;span class="c1"&gt;# =&amp;gt; 1&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Assigning the same value to multiple variables&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;# Set x to 1, y to 1, and z to 1&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This can get kind of messy so we can clean it up by creating a list:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/19</id>
    <published>2013-04-18T15:40:23Z</published>
    <updated>2013-04-18T17:59:32Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/migrating-data-from-my-old-blog"/>
    <title>Migrating Data From My Old Blog</title>
    <content type="html">&lt;p&gt;Recently I decided to create a new rails app for this blog (here&amp;#39;s the &lt;a href="https://github.com/scottbartell/sb.com"&gt;repo&lt;/a&gt;!). My old blog was a &lt;a href="https://github.com/scottbartell/scottbartell.com"&gt;fork&lt;/a&gt; of &lt;a href="http://soff.es/"&gt;Sam Soffes&amp;#39;s blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One of the challenges I faced was migrating my old database (I previously was running a different rails app that I was hosting at Heroku) to my new app that I am hosting on Digital Ocean.&lt;/p&gt;

&lt;p&gt;Because I only need to transfer a small amount of data I decided to simply generate some text directly from rails console (on my Heroku server) and to paste that into a seed file. Then run that seed file on my new production server.&lt;/p&gt;

&lt;h2&gt;Exporting&lt;/h2&gt;

&lt;p&gt;My old blog had two models: posts, tags, and taggings. The taggings table was a junction table created because of the many-to-many relationship between posts and tags. Because I changed this in my new blog (now I just have a one-to-many, categories and posts) I was only concerned with the data in the posts table so I was able to safely ignore both tags, taggings, and any associated relationships.&lt;/p&gt;

&lt;p&gt;Open rails console on Heroku:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;heroku run rails c
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Iterate through each Post and put each Post create to console:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="n"&gt;posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;all&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;&lt;span class="n"&gt;posts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-4"&gt;  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Post.create(title: &amp;#39;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;#39;, permalink: &amp;#39;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;permalink&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;#39;, published_at: &amp;#39;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;published_at&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;#39;, content: &amp;#39;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;#39;)&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-5"&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ideally I would be able to just copy and paste the output into my &lt;code&gt;seeds.rb&lt;/code&gt; file. However, of course there&amp;#39;s likely to be some complications... in my case my post&amp;#39;s content (&lt;code&gt;p.content&lt;/code&gt;) was not just plain text: it was filled with markup... this means that I need to preserve special characters, there might be both single and double quotes within my content, ect. Therefore simply outputting the content between single quotes would not work.&lt;/p&gt;

&lt;h3&gt;Using heredoc&lt;/h3&gt;

&lt;p&gt;My solution is the &lt;a href="http://en.wikipedia.org/wiki/Here_document"&gt;heredoc&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="n"&gt;posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;all&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;
&lt;/span&gt;&lt;span id="line-3"&gt;&lt;span class="n"&gt;posts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;each_with_index&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-4"&gt;  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;post_&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; = &amp;lt;&amp;lt;END&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-5"&gt;  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-6"&gt;  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;END&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-7"&gt;  &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Post.create(title: &amp;#39;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;#39;, permalink: &amp;#39;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;permalink&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;#39;, published_at: &amp;#39;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nb"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;published_at&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;#39;, content: post_&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;)&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-8"&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This &lt;em&gt;should&lt;/em&gt; work just fine. Basically, this creates a unique variable for each post e.g.) &lt;code&gt;post_0&lt;/code&gt; and puts the content of that post in that variable using a heredoc. Then when the post is created it references the specific variable for that post&amp;#39;s content.&lt;/p&gt;

&lt;h2&gt;Importing&lt;/h2&gt;

&lt;p&gt;Now, all that&amp;#39;s left to do is to take the output and paste it into the new app&amp;#39;s &lt;code&gt;seeds.rb&lt;/code&gt; file and to run it.&lt;/p&gt;

&lt;h3&gt;Test locally&lt;/h3&gt;

&lt;p&gt;First, test the &lt;code&gt;seeds.rb&lt;/code&gt; file locally.&lt;/p&gt;

&lt;p&gt;If you haven&amp;#39;t created your database yet you can run: &lt;code&gt;rake db:setup&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Or, if your database has already been created, try running:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;rake db:seed
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Getting an error?&lt;/h3&gt;

&lt;p&gt;At some point I ran across this error message: &lt;code&gt;invalid multibyte char (US-ASCII)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here is a &lt;a href="http://stackoverflow.com/questions/1739836/invalid-multibyte-char-us-ascii-with-rails-and-ruby-1-9/2105210#2105210"&gt;pretty neat solution&lt;/a&gt;. Simply add &lt;code&gt;# encoding: utf-8&lt;/code&gt; to the top of the &lt;code&gt;seeds.rb&lt;/code&gt; file like so:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;&lt;span class="c1"&gt;# encoding: utf-8&lt;/span&gt;
&lt;/span&gt;&lt;span id="line-2"&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Run in production&lt;/h3&gt;

&lt;p&gt;Finally it&amp;#39;s time to run the &lt;code&gt;seeds.rb&lt;/code&gt; on your production database.&lt;/p&gt;

&lt;p&gt;SSH into your server and setup your database:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span id="line-1"&gt;rake db:setup &lt;span class="nv"&gt;RAILS_ENV&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production
&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And we are all done!&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/1</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/5-characteristics-of-a-great-service-organization"/>
    <title>The 5 Characteristics of a Great Service Organization</title>
    <content type="html">&lt;p&gt;&lt;a href="http://www.amazon.com/Service-Operations-Management-3rd-Edition/dp/1405847328"&gt;Service Operations Management&lt;/a&gt; by Johnston and Clark is an insightful and thought provoking book which intelligently discusses services-orientated operations management. In one section of the book the authors explains each of the 5 characteristics that all world class service organizations share. These characteristics are: &lt;a href="#great-leadership"&gt;Great leadership&lt;/a&gt;, &lt;a href="#great-vision"&gt;great vision&lt;/a&gt;, &lt;a href="#clear-concept"&gt;clarity of concept&lt;/a&gt;, &lt;a href="#supportive-culture"&gt;supportive culture&lt;/a&gt;, and a &lt;a href="#strategy"&gt;well-developed (and communicated) strategy&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;&lt;a id="great-leadership"&gt;&lt;/a&gt;Great Leadership&lt;/h3&gt;

&lt;p&gt;In Jim Collins’ book, &lt;a href="http://www.jimcollins.com/article_topics/articles/good-to-great.html"&gt;Good to Great&lt;/a&gt;, Collins discusses exactly what makes a great leader. Collins places leaders on a 5 level hierarchy with a &lt;a href="http://www.jimcollins.com/media_topics/level-5.html"&gt;level 5 leader&lt;/a&gt; having the highest degree of executive capability. A level 5 leader has a perfect blend of personal humility and professional will – basically a level 5 leader puts their own self-interest to the side and focuses on doing what is right for the organization. In doing so, not only do level 5 leaders make decisions that are in the organization’s best interest, but employees become aware that decisions are made because they are what is best for the company, not the leader.&lt;/p&gt;

&lt;p&gt;By their very nature, many small businesses do not have level 5 leaders. These leaders are pursuing their own self-interest’s and that is exactly what drives their leadership style. As a result businesses decisions seem to often not be in the best interest of the company, its customers, or its employees. While this is never actually mentioned, it becomes evident through the decisions that are made by the leader. This type of leader not only frustrates employees but actually hurts the business because every decision is not necessarily the best for the company.&lt;/p&gt;

&lt;p&gt;The leaders of many small business are also not very humble. One of the most frustrating experiences that I have had as an employee, is providing a great idea having it taken by a superior along with the credit for the idea. By asserting this position of self-importance this leader has eliminated any motivation for employees to provide insightful information or ideas to the company. How is an organization supposed to improve if its staff is unwilling to provide feedback?&lt;/p&gt;

&lt;p&gt;A leader can have all of the determination, focus, effort, and skill possible &lt;em&gt;but if they lack humility who will want follow them? When employees are forced to follow a leader, there is a significant limitation on what can be done in an organization and how successful it will be&lt;/em&gt;. The key to great leadership is getting your followers to want to do what you need them to do.&lt;/p&gt;

&lt;h3&gt;&lt;a id="great-vision"&gt;&lt;/a&gt;Great Vision&lt;/h3&gt;

&lt;p&gt;Creating a clear vision seems to fall back on having great leadership. Many small businesses seem to lack a clear vision that works to motivate their staff. One of the biggest issues that I see is that there is no clear &amp;quot;big picture&amp;quot; vision that is projected to the staff – just &amp;quot;more&amp;quot;. For example: &amp;quot;Next month we’ll do better and we will make more money.&amp;quot; This is a problem because a clear vision could work to feed employee motivation and better the service and customer experience.&lt;/p&gt;

&lt;h3&gt;&lt;a id="clear-concept"&gt;&lt;/a&gt;Clarity of Concept&lt;/h3&gt;

&lt;p&gt;Again, this seems to stem from leadership. In Good to Great Collins defines his &amp;quot;&lt;a href="http://www.jimcollins.com/media_topics/hedgehog-concept.html"&gt;hedgehog concept&lt;/a&gt;&amp;quot; as &amp;quot;simplifying a complex world into a single organizing idea, a basic principle or concept that unifies and guides everything.&amp;quot; Basically the company focuses on a single simplified principle which drives all of the organization’s actions and decisions.&lt;/p&gt;

&lt;p&gt;This is a big problem that many small businesses face. First of all, fail to provide a clear message to their staff communicating organizational goals. Often the small business’s concept is entirely inferred by the staff; it is never vocalized and it has never been written down. This can be a very big problem. For example, this could cause employees to work towards very different goals rather than work together towards a single unified goal. If employees were given a single centralized concept that simplified their organizational goals into a basic principle they would be able to incorporate this message into every decision that was made in the business. This would clarity of concept would give the business an opportunity to become a true market leader.&lt;/p&gt;

&lt;h3&gt;&lt;a id="supportive-culture"&gt;&lt;/a&gt;Supportive Culture&lt;/h3&gt;

&lt;p&gt;Yet again this is something that is derived from leadership. Because of the lack of humility some small businesses have,  these organizations may be heading in the wrong direction in terms of employee attitude and customer relationships. Once a companies leadership starts to discount the importance of their customers trouble starts to arrise. For example, sometimes customers can be difficult. The best decision for the company would likely be to do as much as you can to ensure that the customer leaves happy. However some companies that are led by self-motivated leaders may do things a little differently and have the mentality - if a customer gives us a hard time, we should not have to deal with it and we have the right to dismiss them as a client. While this might seem like a good idea in the short run (especially when you have to deal directly with these clients), building a culture with this attitude is sure to have some significant long-term implications. When a company’s culture is built around this idea, it allows employees to continuously take the easy way out and undoubtedly will have  negative long-term implications on the company. The culture should be built along the idea of customer satisfaction and should work to create creative techniques for properly dealing with upset clients.&lt;/p&gt;

&lt;h3&gt;&lt;a id="strategy"&gt;&lt;/a&gt;A Well Developed Strategy&lt;/h3&gt;

&lt;p&gt;And once again leadership play a key role in a well developed strategy. Many small businesses simply lack well defined goals. The only motivation that some small businesses offer their employees is simply money. Many small businesses never provide any written goals. Commonly one of the only goals that an organization provides is more. While &amp;quot;more&amp;quot; is wonderful, the lack of an actual number takes away from any motivation that could be created and also makes it difficult to measure performance. In order to have a well developed strategy &lt;a href="http://en.wikipedia.org/wiki/SMART_criteria"&gt;SMART goals&lt;/a&gt; need to be laid out so that employees can be motivated to meet them and improve the organization. &lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/2</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/the-customer-satisfaction-spectrum"/>
    <title>The Customer Satisfaction Spectrum</title>
    <content type="html">&lt;p&gt;Let’s face it, to compete in today’s business world you really need to have much more than just customer satisfaction. Competition is fierce. All of your competitors are trying to have more satisfied, more loyal customers than you. There a so many different degrees of satisfaction and just plain &amp;quot;customer satisfaction&amp;quot; is really just the base line. This is why we’ve placed customer satisfaction on a spectrum with multiple levels of satisfaction.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://cdn.scottbartell.com/wp-content/uploads/2011/12/customer-satisfaction-spectrum.png" alt="The Customer Satisfaction Spectrum" title="The Customer Satisfaction Spectrum"&gt;&lt;/p&gt;

&lt;p&gt;Extreme customer delight is at the very top and extreme customer dissatisfaction is at the bottom. Customer expectations (of your product or service) fall somewhere in the middle. Interestingly, what people might not understand is that customer action (complaining, praising, telling their friends) rises as a customer moves to each end of the spectrum. This may result in a serious problem: &lt;em&gt;if your customers fall somewhere in the middle of the spectrum it’s very difficult to understand what they like and what they dislike about your service&lt;/em&gt;.&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/5</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/obtaining-followers-passively-best-practices"/>
    <title>Obtaining Followers Passively: Best Practices</title>
    <content type="html">&lt;p&gt;I previously wrote a post about &lt;a href="http://www.scottbartell.com/obtaining-google-followers-the-correct-way-passively"&gt;the difference between active and passive attempts at obtaining followers&lt;/a&gt;; basically passive attempts likely result in a dramatic increase of overall effectiveness  If you take your time and answer the following 4 questions completely you will likely have a successful strategy.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;em&gt;What is your goal?&lt;/em&gt; - It’s not enough to just act, you need to first take a step back and think... what exactly is it that we want to achieve?&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Who are you trying to market to?&lt;/em&gt; - Understand who your target market is. Determine exactly what your typical customer looks like.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;What does your target market value?&lt;/em&gt; - Determine what your target market likes or values. What is it that makes your target market tick. What is it that they seem to enjoy?&lt;/li&gt;
&lt;li&gt;&lt;em&gt;What value can I provide (give away) to my target market?&lt;/em&gt; - Determine what you can give to your target market that they will love. This is the critical part; you need to provide your target market with something that they will truly enjoy.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It’s important to understand that followers are not interchangeable. A follower is actually a person and depending on a person’s individual wants and needs their interest in your message changes. Therefor followers the sheer quantity of followers is not enough, you must consider their quality.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Passive followers care&lt;/em&gt;: If a person wants to follow you because of the message and the value that you provide, they likely will be &amp;quot;high quality&amp;quot; followers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Passive followers will likely result in&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Increased CTR&lt;/li&gt;
&lt;li&gt;Improved Interactions &amp;amp; Conversations&lt;/li&gt;
&lt;li&gt;Improved Amplification of Your Message&lt;/li&gt;
&lt;li&gt;Sustainability&lt;/li&gt;
&lt;li&gt;Long Term Growth&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Back to the question: How can I get more followers?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well, there really is no simple answer. A question like this cannot and should not be answered in 140 characters or less. In order to fully answer this questions one needs to have a full grasp of your company, your product, and your customers. You also need to understand what a customer will see when they look at your Google+ page or your Twitter Page. What will they like? What will they dislike? What will make them want to follow you? What type of content do they want from you?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Bonus:&lt;/em&gt; What if not all of my customers value the same thing…? this is where circles in Google+ (market segmentation) comes into play.&lt;/p&gt;

&lt;p&gt;Use your Google+ Circles to divide your followers into categories based on what they value. Provide value accordingly.&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/6</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/obtaining-google-followers-the-correct-way-passively"/>
    <title>Obtaining Google+ Followers The Correct Way, Passively</title>
    <content type="html">&lt;p&gt;I previously wrote about the importance of Google+ pages because of Google’s integration of Google+ with their search results. Recently I have heard more and more concern about how to get Google+ Page follower. This became evident while participating in #inboundchat where the same question kept coming up over and over again: how do I get more Google+ followers?&lt;/p&gt;

&lt;p&gt;While this might seem like a very important question to ask… after deeply thinking about exactly why people are asking this question I would like to offer some advice. &lt;em&gt;Don’t actively try to obtain Google+ followers, obtain them passively&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Please keep in mind this applies to any social network (Facebook, Twitter, ect) and not just Google+ Pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Active vs. Passive&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Actively Obtaining Followers&lt;/em&gt; – consists of an active attempt to get users to add you or follow you. This can be done by offering a promotion to users e.g. a customer will receive a $25 discount if they follow our twitter account. Or exploiting reciprocal following e.g. I plan to follow 100 people, wait 3 days and unfollow those who didn’t follow me back, rinse and repeat until I have 100,000 followers.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Passively Obtaining Followers&lt;/em&gt; - consists of employing a passive strategy that will make users want to follow your profile. This can be achieved by providing content (or value) that is unique and targeted to a specific type of person (your followers or your target market).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why are passive attempts better?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You need to understand that all followers are not treated equal. Followers are not interchangeable. A follower is a person, a customer. &lt;em&gt;I don’t care if you have 100,000 followers or 1 million followers... what I do care about is WHO your followers are. Quality is much more important that quantity.&lt;/em&gt; You need to obtain followers who are REAL people (not bots), who care about what you have to say, and who can actually be clients (for the most part). For instance: if you have a local pizza place and you just started a Twitter account you need to understand who you want to follow you and you need to think about how valuable a follower that is that lives 100 miles away.&lt;/p&gt;

&lt;p&gt;By their nature active attempts at obtaining followers usually result in low quality followers who are not very interested in your content. Passive attempts result in high quality followers and a much higher CTR for any links you post. Remember: passive users will always care more about what you have to say.&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/7</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/why-google+-pages-should-not-be-ignored"/>
    <title>Why Google+ Pages Should Not Be Ignored</title>
    <content type="html">&lt;p&gt;On November 7th 2011 Google released Google+ pages for Businesses, Brands, Places &amp;amp; more. Since then there has been some serious debate over the importance of maintaining a business presence on Google+. It seems that businesses have spent countless hours with their Facebook page, twitter account, blog, website, ect. and they simply do not want to take the time to learn a new technology. However, I think that these businesses may be ignoring a serious opportunity.&lt;/p&gt;

&lt;p&gt;Here’s why: &lt;em&gt;Google is incorporating Google+ information into search results.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://cdn.scottbartell.com/wp-content/uploads/2011/11/google-plus-search-results.png?9d7bd4" alt="Google Search Results Example" title="Example from Google Search Results"&gt;&lt;/p&gt;

&lt;p&gt;The image above shows a sample search that I ran when I was logged into Google+. Notice how the search results include information that is entirely unique to my personal Google+ profile, specifically including what the people and pages in my circles have shared. While it is possible for people to share your website even if you do not have a Google+ you need to consider the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If Google+ users add you or your business to their circles you will be able to influence what they see when they do a Google search.&lt;/li&gt;
&lt;li&gt;Shared pages on Google+ will likely have a greater chance of being clicked in the Google results pages.&lt;/li&gt;
&lt;li&gt;Google search results may help you expand your online influence, presence, and followers – Danny Sullivan’s result has an &amp;quot;add to circles&amp;quot; button.&lt;/li&gt;
&lt;li&gt;Google+ Direct Connect will give your brand even more exposure in Google’s search results.&lt;/li&gt;
&lt;li&gt;Google is sure to incorporate further integrations with Google+ Pages in the near future.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With over &lt;a href="http://www.bloomberg.com/news/2011-10-10/google-s-u-s-search-market-share-rises-to-65-3-yahoo-declines.html"&gt;65% market share&lt;/a&gt; Google is the most popular search engine in the world. Google now gets &lt;a href="http://siteanalytics.compete.com/google.com/"&gt;over 165 million unique visitors a month&lt;/a&gt; making it the most popular website on the internet. &lt;em&gt;With the amount of influence that Google has on the internet shouldn’t you be taking Google+ more seriously?&lt;/em&gt;&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/3</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/the-importance-of-change"/>
    <title>The Importance of Change</title>
    <content type="html">&lt;p&gt;The world is constantly changing around us. Inch-by-inch billions and billions of little changes are adding up to formulate larger – big picture – fundamental changes that drastically alter the way the world is and the ‘norms’ on which business is conducted. With all if this change happening some people or businesses might not be willing, or able, to change at the same pace or even at all.&lt;/p&gt;

&lt;p&gt;It’s those companies who see how the world is changing and change with it that end up being successful. This might be risky but the reward is often worth the risk.&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/8</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/stumbleupon-is-growing"/>
    <title>StumbleUpon is Growing...Fast!</title>
    <content type="html">&lt;p&gt;StumbleUpon is growing fast. This graph (from Compete) compares StumbleUpon’s traffic with Twitter and Reddit to help illustrate StumbuleUpon’s much higher growth rate. In August 2011 Compete reports that StumbleUpon had 6.7 million unique visitors. &lt;em&gt;In September 2011 Compete reports 12.5 million unique visitors... a 187% increase in traffic&lt;/em&gt;! For a better illustration see the picture below:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://cdn.scottbartell.com/wp-content/uploads/2011/11/stumbleupon.com_uv_1y.png" alt="StumbleUpon&amp;#39;s Unique Visitors and Growth Rate Graph" title="StumbleUpon&amp;#39;s Unique Visitors and Growth Rate"&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is StumbleUpon going to be the next big social media platform?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I don’t think so but with a traffic increase this dramatic it might be worth a deeper look. StumbleUpon released an &lt;a href="http://www.scottbartell.com/stumbleupon-referral-traffic"&gt;InfoGraphic&lt;/a&gt; explaining how their platform was better than every other social media platform including both Facebook and Twitter. But I’m not to sure that StumbleUpon &lt;a href="http://www.scottbartell.com/stumbleupon-referral-traffic"&gt;provided us with all of the important data&lt;/a&gt;. What do you think?&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/9</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/stumbleupon-referral-traffic"/>
    <title>StumbleUpon: Now Generating More Traffic Then Facebook and Twitter</title>
    <content type="html">&lt;p&gt;StumbleUpon recently posted an &lt;a href="http://www.stumbleupon.com/blog/the-lifecycle-of-a-web-page-on-stumbleupon/"&gt;infographic&lt;/a&gt; comparing itself to other social media properties such as Facebook and Twitter. It claimed that between August 2011 and September 2011:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Market Share&lt;/strong&gt; – SumbleUpon had the highest market share by traffic referrals with 50.34%. With Facebook at: 37.4%. Reddit: 4.26%. Twitter: 3.23%.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;After 24 hours&lt;/strong&gt; – After 24 hours a popular website was shared with StumbleUpon it will get 80% more stumbles. Facebook will get 5% more likes. Twitter will get 0% more retweets.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Link Half-Life&lt;/strong&gt; – The half-life of a typical link at StumbleUpon is 400 hours. On Facebook: 3.2 hours. On Twitter 2.8 hours.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Average Time on Page&lt;/strong&gt; – The average time on page for a typical link on StumbleUpon is 69 seconds. Facebook and Twitter are at 23 seconds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Put bluntly, not much at all. The beauty of statistics is that they can be shaped and twisted to convey any message that you want. While all of this data might make it seem like StumbleUpon is the best choice for Social Media Marketing, it might not be. Here are a few reasons why:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The data &lt;em&gt;fails to compare the percentage of popular links to not-so-popular links&lt;/em&gt;. StumbleUpon might be comprised of only a small percentage of websites that get all of the referral traffic.&lt;/li&gt;
&lt;li&gt;The data &lt;em&gt;does not look at the type of content shared&lt;/em&gt;. All content is not treated fairly in StumbleUpon. Users seem to like highly graphical content rather than some company website.&lt;/li&gt;
&lt;li&gt;The data &lt;em&gt;fails to consider the type of users that are viewing the content&lt;/em&gt;. If StumbleUpon sends a bunch of referral traffic to a website and they are not at all interested in purchasing any products, how useful is that referral traffic when it fails to convert?&lt;/li&gt;
&lt;li&gt;Market share of referral traffic &lt;em&gt;does not consider the spread of the pageviews among pages shared in StumbleUpon&lt;/em&gt;. A lot of the referral traffic is likely to be from a small user base leading to a small amount of unique visitors.&lt;/li&gt;
&lt;li&gt;The data &lt;em&gt;ignores any other interaction with the content besides clicking on the link&lt;/em&gt;. Links that are shared on Twitter and Facebook usually come with much more than just referral traffic. Users have the ability to comment on the content or send tweets about it.&lt;/li&gt;
&lt;li&gt;The &lt;em&gt;half-life does not consider the extent of the engagement&lt;/em&gt;. While Facebook and Twitter have a much shorter period of engagement they could have overall more shares by a broader audience (because there are so many upfront).&lt;/li&gt;
&lt;/ul&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/4</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/why-every-business-needs-to-use-twitter"/>
    <title>Why Every Business Needs To Use Twitter</title>
    <content type="html">&lt;p&gt;I was pondering the importance of Twitter in business today and came up with 3 reasons why every business needs a Twitter account. Tweet me if I’m missing anything or if you think I’m wrong!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To Improve The Image of Their Brand&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Used as a Feedback Avenue&lt;/em&gt; - allows the company to reply to customer feedback in a meaningful way.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Responsiveness&lt;/em&gt; - allows the company to respond to complaints as they happen, rather than after.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Public Exposure of Remedies&lt;/em&gt; - allows for free publicity of how the company treats its customers.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Person Behind the Brand&lt;/em&gt; – allows the company to put a person behind their business creating closer relationships with customers.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Transparency&lt;/em&gt; – allows the company to be completely open and honest with customers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;To Leverage the Value of The Property&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;The Value of the Followers&lt;/em&gt; - allows the company to convey a message across an entire network of interested customers.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Getting Closer To Customers&lt;/em&gt; – allows the company to go to where their customers are rather than waiting for them to come to the company.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;To Provide Social Connectivity and Brand Exposure&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Spreading the Word&lt;/em&gt; – provides followers with the opportunity to share information about the company with their friends through the following: Retweets, Potential free celebrity endorsements, and @YourCompany showing up on millions of feeds.&lt;/li&gt;
&lt;/ul&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/10</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/what-are-touchpoints"/>
    <title>What Are TouchPoints?</title>
    <content type="html">&lt;p&gt;A touchpoint is the interaction (or the point of contact) of any product, service, or brand with any other party such as customers, non-customers, employees, companies, or organizations. This interaction can happen at any point, such as before, during, or after a transaction.&lt;/p&gt;

&lt;p&gt;Fully understanding where all of your companies touch points are and the significance of each point is critical to managing the image and perception of your business. The management of touch points can help a company position a product, service, or brand effectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A List of Example TouchPoints&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Advertising – Including print, television, radio, internet, ect.
Buying and Selling Channels&lt;/li&gt;
&lt;li&gt;Phone Communications – Including both inbound and outbound calls&lt;/li&gt;
&lt;li&gt;Social Media – Including any business run social media property such as - Facebook, Twitter, FourSquare, ect.&lt;/li&gt;
&lt;li&gt;Company Website&lt;/li&gt;
&lt;li&gt;Staff or Representatives - Including salesforce, customer service representatives, or any other staff member who communicates on behalf of the company&lt;/li&gt;
&lt;li&gt;Emails&lt;/li&gt;
&lt;li&gt;Receipts&lt;/li&gt;
&lt;li&gt;Products&lt;/li&gt;
&lt;li&gt;Services&lt;/li&gt;
&lt;li&gt;Events&lt;/li&gt;
&lt;/ul&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/11</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/managing-touch-points"/>
    <title>Managing Customer Touch Points</title>
    <content type="html">&lt;p&gt;In today’s highly competitive market it is not enough to just have certain aspects of your business excel in customer satisfaction. You need to have every single interaction with your customer exceed expectations and this starts by analyzing your &lt;a href="http://www.scottbartell.com/what-are-touchpoints"&gt;touch points&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In order for a company to effectively manage customer experience it must fully understand every &amp;quot;touch point&amp;quot; that customers have with the business. Management needs to not only determine when and where customers interact with the company but also needs accuratly measure (and &lt;a href="http://www.scottbartell.com/quantifying-customer-satisfaction-in-plain-english"&gt;quantify&lt;/a&gt;) customer experience at each touch point. With this information management should be able to identify strong and weak areas and use that information to formulate a long-term strategy that aligns with their organizational goals.&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/12</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/can-nothing-be-something"/>
    <title>Can Nothing Be Something?</title>
    <content type="html">&lt;p&gt;Note: this post is highly abstract.&lt;/p&gt;

&lt;p&gt;I poured my friend a glass of &lt;a href="http://www.zerowater.com/"&gt;ZeroWater&lt;/a&gt; today. When she took a sip of the water she excitedly remarked, &amp;quot;wow, this tastes like nothing!&amp;quot;. This response made me think: if it tastes like nothing doesn’t that mean that &amp;quot;nothing&amp;quot; is a taste and therefore nothing is something? While this might be an outlandish idea it made me relate the same idea to both business and marketing.&lt;/p&gt;

&lt;p&gt;When a company does nothing it inevitably results in something.&lt;/p&gt;

&lt;p&gt;My concern is that some businesses are stuck with the ideology that by doing nothing they have eliminated the risk that can be created by doing something. By abiding by this concept a business will avoid risk and change and begin their journey towards stagnation. Competitors will continue to take risks and their businesses will evolve and potentially become stronger while those who do nothing will go nowhere. This actually might be an understatement; while doing nothing will insure that you go nowhere it might actually force a company backwards.&lt;/p&gt;

&lt;p&gt;Take a minute and think about that old restaurant who is still using a paper system. The company undoubtably realizes that there is the technology out there that will significantly improve the efficiency of the process and their business. However, instead of taking the risk (putting up the money for the hardware, software, training, and implementation of a computer system) they choose to do nothing.&lt;/p&gt;

&lt;p&gt;The question is: by doing nothing are they going nowhere?&lt;/p&gt;

&lt;p&gt;The answer is: yes, but maybe even worse than nowhere.&lt;/p&gt;

&lt;p&gt;By choosing to do nothing this restaurant is forfeiting any benefit that this technology would have to their business and essentially giving it to their competitors. Think of a small town that is comprised entirely of 5 restaurants. They all have a paper based ticket system and everything about them is held entirely equal. What would happen if the first 4 of those restaurants went to a computer based system that allowed them to more efficiently and accurately take orders, reservations, and manage customer feedback. The 5th company, who still had a paper system, decided to do nothing and stick with what had been successful in the past, the paper system. After everything is said and done, who has the advantage? Did doing nothing leave the 5th company in the same position they were before their competitors changed? Or have their odds of success diminished significantlye for the very reason they did nothing?&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/13</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/quantifying-customer-satisfaction-in-plain-english"/>
    <title>Quantifying Customer Satisfaction – In Plain English</title>
    <content type="html">&lt;p&gt;In today’s age &lt;a href="http://en.wikipedia.org/wiki/Customer_satisfaction"&gt;customer satisfaction&lt;/a&gt; is costly. While satisfaction may seem like the desired ‘ideal’ outcome from a service provider – it’s probably not enough and it’s definitely costing you customers. So why do I say that? It’s more of a play on words than a ground breaking discovery. A customer simply being satisfied is great… But it would be exponentially better if a customer experienced euphoria from their experience. How much more likely would the chances be of a customer choosing you over the competition? How more often would a customer return to your business? How much more likely would they be to tell their friends about their experience? It’s obvious that the better the experience, the greater the likelihood of all of these scenarios becoming a reality.&lt;/p&gt;

&lt;p&gt;The question remains: how does a company improve customer satisfaction?&lt;/p&gt;

&lt;p&gt;But still the question remains: how does a company improve customer satisfaction? The answer simply put is: what can be measured can be improved. In order to improve the customer satisfaction of an organization you need to be able to quantify it. And that’s not enough, you need to quantify it correctly. Once you are able to do that – you can develop and execute a plan in order to improve customer satisfaction and you will be able to measure your progress. The measurement will allow you to not only determine which strategies will work but help you determine the strategies that are the most cost efficient and offer the greatest return.&lt;/p&gt;

&lt;p&gt;So how do you correctly quantify customer satisfaction? Now that’s the million dollar question (literally). Unfortunately, there is no single answer for this. Obviously businesses vary and with those variations different concerns must be addressed when deciding the best method for quantification. There are several factors that can be used to measure satisfaction. Keep in mind that the better measurements use multiple variables in order to gather as much data as possible and reduce the possibility of choosing a poor measurement.&lt;/p&gt;

&lt;p&gt;Only when an organization is able to determine where they stand in terms of customer satisfaction will will they be able to improve.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Possible Measurements for Customer Satisfaction:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Overall sales volume.&lt;/li&gt;
&lt;li&gt;A solid customer satisfaction survey program.&lt;/li&gt;
&lt;li&gt;The Rate of return customers.&lt;/li&gt;
&lt;li&gt;The salesforce’s perception of customer satisfaction (internal ratings).&lt;/li&gt;
&lt;li&gt;The amount and frequency of customer complaints.&lt;/li&gt;
&lt;li&gt;The rate at which customers pay (with the idea that the more over due a payment is the more unsatisfied the client is).&lt;/li&gt;
&lt;li&gt;Asking customers directly about their level of satisfaction.&lt;/li&gt;
&lt;li&gt;Asking customers through a third party about their level of satisfaction.&lt;/li&gt;
&lt;li&gt;Using social media (twitter, facebook, ect) to determine customer satisfaction.&lt;/li&gt;
&lt;li&gt;Looking on the internet for reviews, blog posts, or conversations about customer satisfaction.&lt;/li&gt;
&lt;li&gt;Each of these presented measurements can be quantified in several ways. When determining how to quantify a specific measurement it is important to make sure that it is done in constant manor that is separated from bias. Inconsistencies leads to a pretty useless measurement and assessment of progress. When bias is involved it again hinders the data and paints an unclear picture. If an organization wants to improve a consistent and honest assessment is key.&lt;/li&gt;
&lt;/ul&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/14</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/lecture-series-hire-the-right-people"/>
    <title>Hire The Right People by Carlos Brito (Anheuser-Busch)</title>
    <content type="html">&lt;p&gt;By: Carlos Brito, CEO of Anheuser-Busch InBev&lt;/p&gt;

&lt;p&gt;From: Stanford Graduate School of Business&lt;/p&gt;

&lt;p&gt;Date: November 11, 2011&lt;/p&gt;

&lt;h3&gt;Key Take Aways&lt;/h3&gt;

&lt;p&gt;Hire your own employees. Not hiring your own employees is like the coach of a baseball team having his team pick a new player.&lt;/p&gt;

&lt;h3&gt;Dream.&lt;/h3&gt;

&lt;p&gt;A dream is something that can take a company to the next step. Dreaming big and dreaming small takes the same amount of energy. You do not get punished for dreaming too big. If you know 80% how to get to your dream you can figure out the next 20% along the way. A dream can inspire people and motivate people to get to their dream. They are powerful enough to commit people. A good dream will bring the best people to your company. Think about a high jump. The higher that the bar is set, the higher you will jump. If it’s set too low there is no reason to jump higher than where it is set.&lt;/p&gt;

&lt;h3&gt;People.&lt;/h3&gt;

&lt;p&gt;Great companies are made by great people. Great people love to challenge each other almost forcing each other to be better. These people focus about what is best for the business and not themselves. Great people attract more great people. Mediocre people attract mediocre people. Mediocre people have a mindset that is centered around how ‘fun’ a job is or how easy it is and how it has low competition and low pressure.&lt;/p&gt;

&lt;p&gt;They Like: Meritocracy, Informality, Candor&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Meritocracy&lt;/em&gt;: You need to dedicate time to good people. Constructive and useful feedback helps people succeed. Make sure you apply the correct pressure to your team. Too much: people panic. Too little: people are having a great time. Great people will leave. People are at their best when they are under &amp;quot;healthy&amp;quot; pressure. Not too much and lot too little.&lt;/p&gt;

&lt;p&gt;Take people out of their confort zone. When people get too confortable, it’s bad (stale).&lt;/p&gt;

&lt;p&gt;If you can’t please everyone, please the best people you have. Poor preforming people will quit!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Informality&lt;/em&gt;: It might be a good idea to have no office space. This will mean that there is no place to hide. It is better to see what people are doing and to connect. It will allow for easy information flow and quick meetings.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Candor&lt;/em&gt;: Good people are high maintenance. They tend to ask everyday what is going on and give feedback.&lt;/p&gt;

&lt;h3&gt;Culture.&lt;/h3&gt;

&lt;p&gt;Ownership mindset. &amp;quot;This is mine!&amp;quot; A culture of ownership is key. When you own something you recognize that there are consequences for decisions. Rental car example: People treat a rental car much different than their own car. They don’t have to live with their consequences for their actions.&lt;/p&gt;

&lt;p&gt;We don’t want people to ask: &amp;quot;what if I started my own business&amp;quot;. This is your business.&lt;/p&gt;

&lt;p&gt;Consumer is the boss. An important question to ask is: would our consumers be proud if they knew how we spent the money we made from them? Ex: excessive spending vs NFL sponsorship.&lt;/p&gt;

&lt;h3&gt;Leadership.&lt;/h3&gt;

&lt;p&gt;Anybody who needs a team to get to a traget is a leader. Actions are more important than words. The best leader can see the complex world and translate it into simple things (5 actions that can be done by anyone). Much like tuning a complex engine into a car with just a gas pedel and a break to operate the complicated engine.&lt;/p&gt;

&lt;p&gt;No shortcuts. It takes time, it’s brick by brick person by person, you should’t look for shortcuts.&lt;/p&gt;

&lt;p&gt;Source: &lt;a href="http://www.youtube.com/watch?v=OSnWnqq23JU"&gt;http://www.youtube.com/watch?v=OSnWnqq23JU&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Other Posts in the Lecture Series&lt;/h4&gt;

&lt;p&gt;&lt;a href="http://www.scottbartell.com/lecture-series-conducting-effective-negotiations"&gt;Conducting Effective Negotiations&lt;/a&gt;
by Joel Peterson, Lead Director at JetBlue Airways and at Franklin Covey&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.scottbartell.com/lecture-series-joe-kennedy"&gt;Joe Kennedy&lt;/a&gt;
by Joe Kennedy, CEO of Pandora Radio&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/15</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/lecture-series-joe-kennedy"/>
    <title>A Lecture on Innovation from Joe Kennedy (Pandora)</title>
    <content type="html">&lt;p&gt;By: Joe Kennedy, CEO of Pandora Radio
From: Stanford Graduate School of Business
Date: March, 2011&lt;/p&gt;

&lt;h3&gt;My Key Take Away&lt;/h3&gt;

&lt;p&gt;Don’t think of the Internet as a new medium to deliver the same old technology.&lt;/p&gt;

&lt;p&gt;Example #1: When film first came out the movie industry thought that this new technology was a great medium to show plays. They would leave the camera stationary and act out &amp;quot;movies&amp;quot; in front of the camera. It wasn’t until later that the industry begin experimenting with moving the camera around to multiple locations, doing close ups, ect.&lt;/p&gt;

&lt;p&gt;Example #2: Pandora radio. When the radio broadcast industry began to realize how the fast the internet was developing they saw it as a great way to deliver the same radio to their customers. Pandora came to realize that this wasn’t the only way that radio could be done on the internet. They realized that the listeners could give the station feedback and the station could customize their playlist depending on what the listeners enjoy.&lt;/p&gt;

&lt;p&gt;This can be applied to almost any industry. Think about e-books. The exact same content is being sent, it’s just presented in a different medium (digital). What if the book was able to be customized depending on the individual and what appeals to them.&lt;/p&gt;

&lt;p&gt;Source: &lt;a href="http://www.youtube.com/watch?v=eRhk4IrT9FU"&gt;http://www.youtube.com/watch?v=eRhk4IrT9FU&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Other Posts in the Lecture Series&lt;/h4&gt;

&lt;p&gt;&lt;a href="http://www.scottbartell.com/lecture-series-conducting-effective-negotiations"&gt;Conducting Effective Negotiations&lt;/a&gt;
by Joel Peterson, Lead Director at JetBlue Airways and at Franklin Covey&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.scottbartell.com/lecture-series-hire-the-right-people"&gt;AB InBev’s Brito: ‘Hire the Right People’&lt;/a&gt;
by Carlos Brito, CEO of Anheuser-Busch InBev&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/16</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/lecture-series-conducting-effective-negotiations"/>
    <title>Top Business Lecture on Effective Negotiations</title>
    <content type="html">&lt;p&gt;By: Joel Peterson, Lead Director at JetBlue Airways and at Franklin Covey
From: Stanford Graduate School of Business
Date: January 31, 2007&lt;/p&gt;

&lt;h3&gt;My Key Take Away&lt;/h3&gt;

&lt;p&gt;Some obvious techniques that are commonly used: These might get a deal done but you are unlikely to get a deal that is enduring, flexible, and one that builds positive relationships.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bathroom: Feed the person a lot of food and water and talk slow.&lt;/li&gt;
&lt;li&gt;Plane: If they have a plane to catch, talk slow and drag out the meeting. When they need to leave to catch the flight bring up a key point to force a quick decision.&lt;/li&gt;
&lt;li&gt;Lock in: You’re locked into a room until you make a decision.&lt;/li&gt;
&lt;li&gt;Physically Uncomfortable: Someone tries to figure out what makes you physically uncomfortable and exploits it.&lt;/li&gt;
&lt;li&gt;Abusive Language: A person is yelling at you and getting very angry with you.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;How to overcome these techniques&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Call them out: (Yelling) Why did you do that?! Response: (calm) Why are you yelling at me?&lt;/li&gt;
&lt;li&gt;Ask questions: Gets information and cools people off.&lt;/li&gt;
&lt;li&gt;Make it ineffective: Ignore it, or plan for delay. Don’t drink water or eat food. Plan a second flight. Make the game that they are playing on you work against them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Practical Keys to Successful Negotiations:&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Negotiate with the correct party: Are you talking to the right person? Can the make a decision? Are you wasting your time?&lt;/li&gt;
&lt;li&gt;Become a trusted negotiator (function of CCP): To become trusted you need Character, Competence, Empowerment.&lt;/li&gt;
&lt;li&gt;Know your own BATNA (Best Alternative to a Negotiated Agreement): Take it one step father and try and figure out the other parties BATNA. What is it they want to achieve and what are their options. Don’t just think of your own agenda.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Internalize Fisher and Ury’s Map:&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Discern battles/wars (Elephants/Ants): Some people don’t know the elephants from the ants. Some people have to win every single deal point. You need to be willing to lose some battles to win the war.&lt;/li&gt;
&lt;li&gt;Don’t Worry (too much) about &amp;quot;techniques&amp;quot;: Don’t worry about them but you need to be aware of them. When other people use these techniques there is something in that for you (information).&lt;/li&gt;
&lt;li&gt;Understand what other party wants/values: The more you can understand what the other party wants the easier it will be to satisfy them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Video: &lt;a href="http://www.youtube.com/watch?v=rCmvMDrCWjs"&gt;http://www.youtube.com/watch?v=rCmvMDrCWjs&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Other Posts in the Lecture Series&lt;/h4&gt;

&lt;p&gt;&lt;a href="http://www.scottbartell.com/lecture-series-joe-kennedy"&gt;Joe Kennedy&lt;/a&gt; by Joe Kennedy, CEO of Pandora Radio&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.scottbartell.com/lecture-series-hire-the-right-people"&gt;AB InBev’s Brito: ‘Hire the Right People’&lt;/a&gt; by Carlos Brito, CEO of Anheuser-Busch InBev&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/17</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/google-instant-and-adwords-even-more-revene-for-google"/>
    <title>Google Instant and Adwords: Even More Revene For Google</title>
    <content type="html">&lt;p&gt;Today was, to say the least, an inspiring day for me. As I was watching Google’s seminar on YouTube I was touched with a rare feeling of evolution and innovation. Google has yet again took search to an entirely new level.  Google released Google Instant today.&lt;/p&gt;

&lt;p&gt;While I’m sure more people are panicking in the SEO world, unsure about their personal ramifications from Google Instant, my mind has yet to rest from processing all of the genius behind Google Instant.&lt;/p&gt;

&lt;p&gt;One extremely important point that I think people have missed today is that &lt;em&gt;Google Instant will allow more people to see more ads in turn increasing the potential for the searcher to click on an advertisement&lt;/em&gt;. Think about this. Instead of the normal one or two queries that people usually search (starting with a main topic and adding modifiers) people will now start seeing several searches before reaching their ideal keyword combination.&lt;/p&gt;

&lt;p&gt;For example. Say someone is looking for some ideas for wedding favors. Previously, a user would have gone to Google and typed in something like &amp;quot;wedding favor ideas&amp;quot; and Google would display 10 organic results with a few Google ads on the same page. Now, with Google Instant, when a user types in &amp;quot;wedding&amp;quot; they will notice that there will be some search results (and ads) associate with this… then maybe the user would would take glance at the results. Even if the user doesn’t scroll down the page they will be able to see some organic results along with some ads. This continues to repeat as the user adds modifiers to their search. Next they add the word &amp;quot;favors&amp;quot; to the search making the search term &amp;quot;wedding favors&amp;quot;. Now the search results will be changed and more ads will show. The point that I am trying to make is that users will see more ads and more search results and this will work to increase the likelihood of a click and likely result in more revenue for Google.&lt;/p&gt;

&lt;p&gt;If you’re still skeptical about my theory I’d like you to ask yourself a question: Do you really think that Google would introduce a product that is so game changing without testing the implications on it’s profit?&lt;/p&gt;

&lt;p&gt;Understand that Google’s main profit flow comes from Adword ads and that without this revenue stream they would be out of business. Google tests everything. They have tested Google Instant on about 1 million users. If Adwords revenue was stagnant or went down would they have  implemented this change?&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
  <entry>
    <id>tag:scottbartell.com,2005:Post/18</id>
    <published>2013-04-17T09:07:33Z</published>
    <updated>2013-04-17T09:07:33Z</updated>
    <link rel="alternate" type="text/html" href="http://scottbartell.com/calculated-risk-taking-leads-to-success"/>
    <title>Calculated Risk Taking Leads To Success</title>
    <content type="html">&lt;p&gt;Depending on how old you are and when you got into internet marketing you might remember when the internet first came about. People were unsure what this new creation would turn into. Investors were skeptical about spending cash to buy these new things called ‘domain names’ (back then domains cost a whopping $70). Very few people understood this new creation ‘the internet’ and felt very uneasy about the feature of it. Because of this overwhelming skepticism virtually every domain name was available at this time.&lt;/p&gt;

&lt;p&gt;So, my question to you is: &lt;em&gt;What did it take for someone to risk the chance of failure and fork over the money for a domain name&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;Risk is a major part of most success. People make risks every day weather it’s buying a new house that you can’t afford or making a left turn into on coming traffic. Risks are a part of everyone’s day-to-day life and we have all, at some level, become experts at choosing which risks are worth taking.&lt;/p&gt;

&lt;p&gt;In the business world risk taking is one of the most critical aspects separating successful businesses from the failures. Face it the only way to really make money is to take risks and it’s these risks that are the reason why money is made. If making money and being successful was risk-free than anybody could be successful and if everyone was successful than nobody would be. Basically what I’m trying to point out is that people are successful because the unsuccessful are afraid of taking risks. When people are afraid of risk taking it actually leaves an opportunity for someone else to undertake this risk and become successful.&lt;/p&gt;

&lt;p&gt;There’s one important aspect to risk taking which I have left out. What about poor risk taking? Think about this: You’ve received some money to invest and you’ve heard that real-estate is a sure way to earn some money. So you call a real-estate agent and you explain that you’re looking for a double to rent out. About one week later you get a call back and the agent says She’s found the perfect house. You’re all excited and can’t wait to see it. Upon arrival you’re excited about the appearance it looks beautiful; it has brand new siding and a new driveway. You do a brief walk-thru of the house and everything is perfect. The price is perfect for your budget so you get out your checkbook and write a check for $150,000. When the house becomes yours the first thing you do is try to find some tenants. The first problem arises, no one is looking for a place to rent. Keep in mind, no tenants means no income. A few months pass and your second problem arises, the market crashes. The value of your newly purchased house drops 15% overnight. But you’re still optimistic because you planed on being in this for the long term, so you move on. Now your third problem hits. It turns out the basement wasn’t inspected well enough before you purchased the home, the infrastructure is unstable and the house needs to be fixed or the house my collapse. The bill is in the tens of thousands.&lt;/p&gt;

&lt;p&gt;So what’s the lesson to be learned? You need to make risks in order to become successful and make money but those risks need to be calculated. You can’t just take a shot in the dark, it’s too risky. You need to carefully analyze the risk your about to undertake. You need to figure out the possible outcomes, both negative and positive. Then you need to weight them and determine weather or not it is a good decision. Sometimes it’s not enough to use your currant knowledge to make the decision, you may need to research prior to your decision. If in the example above the person had looked at the area to see if there were people were looking for a place to rent maybe he would have avoided this decision. If he had hired a professional to look at the house prior to the purchase maybe the professional would have talked him out of the house because of the basement problems. Research is really key to good decision making.&lt;/p&gt;
</content>
    <author>
      <name>Scott Bartell</name>
    </author>
  </entry>
</feed>
