<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Addicted To New</title>
	
	<link>http://addictedtonew.com</link>
	<description>Historically more coding heavy but lately filled up mostly with just thoughts.</description>
	<pubDate>Wed, 26 Aug 2009 11:56:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/johnnunemaker" /><feedburner:info uri="johnnunemaker" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><geo:lat>41.650672</geo:lat><geo:long>-86.160028</geo:long><image><link>http://www.addictedtonew.com/</link><url>http://addictedtonew.com/images/black100.jpg</url><title>Addicted To New Logo</title></image><feedburner:emailServiceId>johnnunemaker</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:browserFriendly>Coding, Photography and Life by John Nunemaker</feedburner:browserFriendly><item>
		<title>JavaScript Array Max and Equal Height Columns</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/zpbWzW-9rkY/</link>
		<comments>http://addictedtonew.com/archives/482/javascript-array-max-and-equal-height-columns/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 11:00:10 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[Coding]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=482</guid>
		<description>JavaScript has a Math.max function that allows you get the maximum between two numbers. That is cool, and all, but I rarely want to compare two numbers. More often, I&amp;#8217;m looking for the maximum number of an array. For example, on a recent project, I wanted all children of an elements to be the same [...]</description>
			<content:encoded><![CDATA[<p>JavaScript has a Math.max function that allows you get the maximum between two numbers. That is cool, and all, but I rarely want to compare two numbers. More often, I&#8217;m looking for the maximum number of an array. For example, on a recent project, I wanted all children of an elements to be the same height. I didn&#8217;t want to deal with Faux columns and I was ok with relying on JavaScript this time.</p>
<p>The best way to set columns to an equal height is to just grab all the heights, get the max, and then set each element height to the max. I did a bit of search around and found an example of adding max to Array&#8217;s prototype. I wrapped that in an if statement that checks if max is currently defined, that way if max gets added to Array in the future, my version won&#8217;t conflict.</p>
<pre><code class="javascript">if (typeof Array.prototype['max'] == 'undefined') {
  Array.prototype.max = function() {
    return Math.max.apply({},this);
  }
}</code></pre>
<p>The trick in the code above is that using apply on the built in function allows max to receive an unlimited number of arguments. This allows me to do the following:</p>
<pre><code class="javascript">[1,2,3].max() // => 3</code></pre>
<p>In this instance (making equal height columns), I ended up with the following solution. </p>
<pre><code class="javascript">$.fn.equalHeightChildren = function() {
  return this.each(function() {
    var children = $(this).children();

    var tallest  = $.map(children, function(child) {
      return $(child).height();
    }).max();

    children.each(function() {
      var padding = parseInt($(this).css('padding-top')) +
                    parseInt($(this).css('padding-bottom'));
      $(this).height(tallest - padding);
    });
  });
}</code></pre>
<p>I use $.map to loop through the children and return an array of their heights. At the end of map, I call max() to return the greatest height. The nice thing about this solution is that it even takes into account padding and the box model.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=f5zzAzkZ"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=WEWhFsBk"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=xbzBGPVQ"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=xbzBGPVQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/zpbWzW-9rkY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/482/javascript-array-max-and-equal-height-columns/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/482/javascript-array-max-and-equal-height-columns/</feedburner:origLink></item>
		<item>
		<title>Logging for the Lazy</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/Jkf4NQU9UDk/</link>
		<comments>http://addictedtonew.com/archives/473/logging-for-the-lazy/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 22:24:25 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[Coding]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=473</guid>
		<description>They say that laziness is a virtue in programmers. That is a good sign for me as I am the laziest of them all. When debugging JavaScript in Firefox or Safari, I use console.log all the time. There are two things about console.log that bother me.
Firstly, it is 11 characters. When I just want to [...]</description>
			<content:encoded><![CDATA[<p>They say that laziness is a virtue in programmers. That is a good sign for me as I am the laziest of them all. When debugging JavaScript in Firefox or Safari, I use console.log all the time. There are two things about console.log that bother me.</p>
<p>Firstly, it is 11 characters. When I just want to output something really quick, it really annoys me that it takes 11 characters just for the function name, not including whatever it is that I want to print out.</p>
<p>Secondly, console.log only takes one argument at a time. More often than not, I&#8217;m outputting the values of a few things, which means I have to type (or copy and paste) those 11 characters a lot. What I&#8217;ve started doing recently, is adding this simple log function to my projects.</p>
<pre><code class="javascript">function log() {
  if (window &amp;&amp; window.console &amp;&amp; window.console.log)
    for(var i=0, len = arguments.length; i &lt; len; i++)
      console.log(arguments[i]);
}</code></pre>
<p>This simple function allows me to do the following:</p>
<pre><code class="javascript">log(some_var)
log(one_var, two_var, three_var)</code></pre>
<p>It is only 3 characters and allows me to print out as many objects to the console as my heart desires. Nothing fancy, but it gets the job done and saves me some time and thought.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=HyrklDYj"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=f3ElueiC"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=Y70f6L5z"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=Y70f6L5z" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/Jkf4NQU9UDk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/473/logging-for-the-lazy/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/473/logging-for-the-lazy/</feedburner:origLink></item>
		<item>
		<title>Creating a Network Bar with jQuery</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/WNvRKibGmvw/</link>
		<comments>http://addictedtonew.com/archives/462/creating-a-network-bar-with-jquery/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 16:17:29 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[Coding]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=462</guid>
		<description>Network bars are making the rounds on a lot of sites. If you aren&amp;#8217;t familiar with the term, it is usually a bar at the top of a site with links to other sites that are in the same network. Brandon, one of my friends, has a network bar on Open Soul that has links [...]</description>
			<content:encoded><![CDATA[<p>Network bars are making the rounds on a lot of sites. If you aren&#8217;t familiar with the term, it is usually a bar at the top of a site with links to other sites that are in the same network. Brandon, one of my friends, has a network bar on <a href="http://opensoul.org">Open Soul</a> that has links to his two other co-workers and to a few products and services they provide. Another great example is all of the sites created by <a href="http://sidebarcreative.com/">Sidebar</a>, such as <a href="http://mymilemarker.com/">My Mile Marker</a>, <a href="http://overheard.it/">Overheard.it</a>, and <a href="http://djangoplugables.com/">Django Pluggables</a>.</p>
<p><a href="http://addictedtonew.com/archives/450/new-blog-about-blogging/">Not too long ago</a>, I created my second tips site, <a href="http://blawgtips.com/">BlawgTips</a>. I wanted to drive traffic back and forth between BlawgTips and <a href="http://railstips.org/">RailsTips</a>, so I created a network bar that sits at the top of each of those. I was shocked at how easy it was. I only wanted it to be one request, so I included the styles inline in a style tag instead of calling another external stylesheet. Below is the code.</p>
<pre><code class="javascript">jQuery(document).ready(function($) {
  var styles = '&lt;style type="text/css"&gt;' +
    "#network_bar                 {float:left; display:inline; width:100%; margin:0; padding:0; background:#222; color:#ccc;}" +
    "#network_bar ul              {float:left; display:inline; margin:0; padding:0;}" +
    "#network_bar ul li           {float:left; display:inline; margin:0; padding:0; border-right:1px solid #333; list-style-type:none;}" +
    "#network_bar ul li a         {float:left; display:block; margin:0; padding:6px 10px; color:#aaa; font:11px/11px helvetica, arial, sans-serif !important; text-decoration:none; text-align:center;}" +
    "#network_bar ul li a:hover   {color:#fff;}" +
    "#network_bar ul li a.current {color:#fff;}" +
  '&lt;/style&gt;';

  var html = '&lt;div id="network_bar"&gt;' +
    '&lt;ul&gt;' +
      '&lt;li&gt;&lt;a href="http://blawgtips.com" title="Over-analyzing the simple art of blogging"&gt;BlawgTips&lt;/a&gt;&lt;/li&gt;' +
      '&lt;li&gt;&lt;a href="http://railstips.org" title="One man feverishly posting everything he learns"&gt;RailsTips&lt;/a&gt;&lt;/li&gt;' +
    '&lt;/ul&gt;' +
  '&lt;/div&gt;';

  $('head').append(styles);
  $('body').prepend(html);

  // to ensure that there is clearage after network bar
  $('#network_bar').next().css({clear: 'both'});

  $('#network_bar a').each(function() {
    var link = $(this);
    var is_current = new RegExp(link.attr('href')).match(window.location.href);
    if (is_current) {
      link.addClass('current');
    }
  });
});</code></pre>
<p>I define a style tag and some html. I then append the styles to the head and prepend the html to the body. I also add a clear:both to the element following the html added just to ensure things get cleared. I probably could switch that to css. Finally, I loop through the a tags in the network bar and add a class of current to the link that represents the current site a visitor is on. </p>
<p>That is it. <strong>The jQuery that actually does the work is less than 10 lines</strong>. Now I can put this in an external script and include it on multiple sites to get the exact same network bar on each of those sites. When I add a new site to the network, I simply update this one script and all the sites update with it. Pretty cool.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=oY64QG1m"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=d5MHTT2N"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=DfHzzthG"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=DfHzzthG" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/WNvRKibGmvw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/462/creating-a-network-bar-with-jquery/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/462/creating-a-network-bar-with-jquery/</feedburner:origLink></item>
		<item>
		<title>New Blog about Blogging</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/r4neGaY546I/</link>
		<comments>http://addictedtonew.com/archives/450/new-blog-about-blogging/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 15:12:58 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[blogging]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=450</guid>
		<description>I have spent a lot of time over the past few months growing RailsTips, one of my other blogs. From October to December, I doubled my traffic and almost doubled my feed subscribers (16k to 30k and 2.5k to 4k).
All the tweaks and changes I have been doing over there has left me wanting an [...]</description>
			<content:encoded><![CDATA[<p>I have spent a lot of time over the past few months growing <a href="http://railstips.org">RailsTips</a>, one of my other blogs. From October to December, I doubled my traffic and almost doubled my feed subscribers (16k to 30k and 2.5k to 4k).</p>
<p>All the tweaks and changes I have been doing over there has left me wanting an outlet to share them. Last week, I whipped <a href="http://blawgtips.com">the site</a> together (with the same simple theme as RailsTips) and invited my friend <a href="http://grundyhome.com">Chas Grundy</a> to co-author it with me.</p>
<p><a href="http://blawgtips.com"><img class="image" src="http://addictedtonew.com/wp-content/uploads/2009/01/blawgtips.jpg" alt="Blawgtips Screenshot" /></a></p>
<p>We both enjoy sharing the things we learn and really hope this project will be useful to those interested in blogging for more professional reasons (make money, project leads, make a name for yourself, etc.). We&#8217;ve kicked it off with a few articles, that I&#8217;ll list here, so you can get an idea of the content going forward.</p>
<ul>
<li> <a title="It's the Little Things" href="http://blawgtips.com/2009/1/11/its-the-little-things">It&#8217;s the Little Things</a></li>
<li> <a title="Does Blogging Matter?" href="http://blawgtips.com/2009/1/11/does-blogging-matter">Does Blogging Matter?</a></li>
<li> <a title="Gardening Your Blog" href="http://blawgtips.com/2009/1/6/gardening-your-blog">Gardening Your Blog</a></li>
<li> <a title="If You Post It, They Will Come" href="http://blawgtips.com/2009/1/6/if-you-post-it-they-will-come">If You Post It, They Will Come</a></li>
<li> <a title="Make Your Post Title Count" href="http://blawgtips.com/2009/1/6/make-your-post-title-count">Make Your Post Title Count</a></li>
<li> <a title="Ribbon Cutting" href="http://blawgtips.com/2009/1/6/ribbon-cutting">Ribbon Cutting</a></li>
</ul>
<p>Head on over and <a href="http://blawgtips.com">subscribe</a> if you want to stay in the loop. Also, we are sure there are other bloggers out there with stuff to say, so if you would like to guest author a post, let me know.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=poLVcsPT"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=C87nQRDA"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=80R6wI0s"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=80R6wI0s" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/r4neGaY546I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/450/new-blog-about-blogging/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/450/new-blog-about-blogging/</feedburner:origLink></item>
		<item>
		<title>Refactoring Tip: Move Functions into Objects</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/wXeG98s4HFc/</link>
		<comments>http://addictedtonew.com/archives/444/refactoring-tip-move-functions-into-objects/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 04:22:03 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[Coding]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=444</guid>
		<description>On the last project that I worked on, we were spending a lot of time learning and the code started to get out of control. Towards the end, I made a few passes through and started moving stuff around. Take the following two functions for example.
function addChat(name, room_jid, person_jid) {
  // add chat stuff
}

function [...]</description>
			<content:encoded><![CDATA[<p>On the last project that I worked on, we were spending a lot of time learning and the code started to get out of control. Towards the end, I made a few passes through and started moving stuff around. Take the following two functions for example.</p>
<pre><code class="javascript">function addChat(name, room_jid, person_jid) {
  // add chat stuff
}

function showChat(room) {
  // show chat stuff
}</code></pre>
<p>There is nothing wrong with the functions above but you can see the similarities. Both have chat in the name and both are operating on chat based stuff. What I did on the project is move them into a simple Chat object like this.</p>
<pre><code class="javascript">var Chat = {
  add: function(name, room_jid, person_jid) {
    // add chat stuff
  },

  show: function(room) {
    // show chat stuff
  }
}</code></pre>
<p>Now I don&#8217;t have to remember whether I named the function addChat or chatAdd. It is much easier to remember that we have a Chat object and that it has add and show methods. I&#8217;m obviously not going to have an Add object with a chat method. Catch my drift? I think this is one of the reasons I got so frustrated with PHP back in the day. The function names were a pain to remember and the parameter order was even worse. </p>
<p>Moving things to an object like this makes them easier to remember and allows your code to grow. If, for example, I wanted to keep track of the current chat with a variable or the number of active chats, I could simply add those to the Chat object. Using functions, your only option would be to have a global variable of sorts, and trust me, those lead to the path of ruin. :)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=IU4hgYoH"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=CoPKodaA"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=fLJYsLQJ"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=fLJYsLQJ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/wXeG98s4HFc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/444/refactoring-tip-move-functions-into-objects/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/444/refactoring-tip-move-functions-into-objects/</feedburner:origLink></item>
		<item>
		<title>Refactoring Tip: Introduce Explaning Variables</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/KxqoxE_5VE8/</link>
		<comments>http://addictedtonew.com/archives/434/refactoring-tip-introduce-explaning-variables/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 17:38:11 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[Coding]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[patterns]]></category>

		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=434</guid>
		<description>I am not one to latch on to fancily named patterns, nor have I read the book on it (I did give it a skim). That said, I have managed to learn a few and today I&amp;#8217;ll share one of my favorites. You often hear people say that comments are code smell. &amp;#8220;You should be [...]</description>
			<content:encoded><![CDATA[<p>I am not one to latch on to fancily named patterns, nor have I read <a href="http://www.refactoring.com/">the book on it</a> (I did give it a skim). That said, I have managed to learn a few and today I&#8217;ll share one of my favorites. You often hear people say that comments are code smell. &#8220;You should be able to tell what code is doing by just looking at the code,&#8221; they say from their perch on high. Well, I hate to break it to you, but they are kind of right. <strong>Your code should be the comments</strong>. Take the following snippet of JavaScript code:</p>
<pre><code class="javascript">// if google.com or www.google.com add http:// to the href
if (typeof(scheme) == 'undefined' || scheme == 'www.') { url = 'http://' + url; }
</code></pre>
<p>This code is from some JavaScript I&#8217;m working on that performs auto-linking of urls and email addresses. Note that there is a comment and if you read the comment you get an idea of what the code is doing. Now I just stated that comments possibly smell, so what can we do to remove the comment and yet retain the intent of the code?</p>
<pre><code class="javascript">var no_scheme  = typeof(scheme) == 'undefined',
    www_scheme = scheme == 'www.';
if (no_scheme || www_scheme) { url = 'http://' + url; }
</code></pre>
<p>We just used a pattern, namely that of <a href="http://www.refactoring.com/catalog/introduceExplainingVariable.html">introducing explaining variables</a>. The pattern probably seems obvious now that you see it, but how often do we code like the first example. In the example above, the explaining variables are introduced with the act of replacing the, not so obvious, conditions in the if statement, with variables that are named based on the intent of the condition. Our two lines of code are now three, but I guarantee the next programmer (which might even be yourself a few months later) in our code will appreciate that extra line. Everyone knows code gets changed quite often and comments rarely do which leads to confusing and out of date comments.</p>
<p>Next time you start busting out conditional statements or chaining methods together, consider how you could introduce an explaning variable that might make the code intent more clear.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=4JY7putx"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=9fJos6bk"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=mU1OP6qC"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=mU1OP6qC" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/KxqoxE_5VE8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/434/refactoring-tip-introduce-explaning-variables/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/434/refactoring-tip-introduce-explaning-variables/</feedburner:origLink></item>
		<item>
		<title>Creating A jQuery Plugin From Scratch</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/687-ya64zJY/</link>
		<comments>http://addictedtonew.com/archives/414/creating-a-jquery-plugin-from-scratch/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 18:19:44 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[Coding]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=414</guid>
		<description>The first few jQuery plugins I created were basically my attempt at doing prototype in jQuery. They were not idiomatic jQuery. I did a bit of googling and found some good examples and decided to write a really basic jQuery plugin just to cement the format in my head. I figured I would post it [...]</description>
			<content:encoded><![CDATA[<p>The first few jQuery plugins I created were basically my attempt at doing prototype in jQuery. They were not idiomatic jQuery. I did a bit of googling and found some good examples and decided to write a really basic jQuery plugin just to cement the format in my head. I figured I would post it here both to further cement it and as a way for you to learn if you want. If you only want to see the end result, <a href="http://github.com/jnunemaker/javascripts/tree/master/jquery.toggler.js">you can find it on GitHub</a>. </p>
<h2>Cross Library Safety</h2>
<p>The first thing I do is create a wrapper function which allows me to use $ and not cause conflicts with other JavaScript frameworks that may be included. It is simple and looks like this:</p>
<pre><code class="javascript">(function($) {
  // safe to use $ here and not cause conflicts
})(jQuery);</code></pre>
<h2>Create and Name Your Plugin Function</h2>
<p>Next, I created the function inside which my plugin will reside. Whatever you name this function will be how you and others use your plugin.</p>
<pre><code class="javascript">(function($) {
  $.fn.<strong>toggler</strong> = function() {
    // the plugin functionality goes in here
  }
})(jQuery);</code></pre>
<p>I have emboldened the function name in the code above to make it obvious. This means that to use the plugin I am creating, someone would have to do <code>$('#some_selector').toggler()</code>.</p>
<h2>Allow chainability</h2>
<p>The next thing to keep in mind is that because jQuery takes any selector, you could be dealing with one or more objects. This means you need to be sure that your plugin loops through each element matched by the selector and applies the plugin functionality.</p>
<pre><code class="javascript">(function($) {
  $.fn.toggler = function() {
    <strong>return this.each(function() {</strong>
      // apply plugin functionality to each element
    });
  }
})(jQuery);</code></pre>
<p>The other thing you will notice about the addition above is that I use return. One of the cool things about jQuery is the chainability (ie: <code>$('#some_div').hide().remove()</code>). Returning the <code>this.each</code> iteration allows your plugin to be chained with other jQuery operations and plugins.</p>
<h2>Start Building Plugin Functionality</h2>
<p>The goal of the plugin I was creating was to allow saying that a particular link is a toggler. So what is a toggler you ask? A toggler is a link that toggles the visibility of another element on the page. The connection of the link to the element is by using the href. By setting the link&#8217;s href to anchor to the id of another element, we get two things for free. First, if JavaScript is not enabled, the link will still anchor to the element on the page. Second, we know which element the link is suppose to toggle display for. Take the following html for example:</p>
<pre><code class="html">&lt;p&gt;&lt;a href="#foo" class="toggler"&gt;Toggler&lt;/a&gt;&lt;/p&gt;
&lt;div id="foo"&gt;Togglee&lt;/div&gt;</code></pre>
<p>The default behavior of the toggler link is to anchor to the Togglee div wherever it is on the page. We will then use the jQuery plugin we are making to hide the togglee div on page load and then toggle its display each time the toggler link is clicked. First, let&#8217;s hide the togglee div and add the click observer to the toggler link.</p>
<pre><code class="javascript">(function($) {
  $.fn.toggler = function() {
    return this.each(function() {
      <strong>this.togglee = $($(this).attr('href')).hide();
      $(this).click(onClick);</strong>
    });
  }
})(jQuery);</code></pre>
<p>The first bold line sets a togglee attribute on the toggler that is equal to the togglee jQuery element. Note the <code>$(this).attr('href')</code>. Using the html from above, this would return #foo. <code>$('#foo')</code> is equivalent to a jQuery object of the togglee div. We call <code>hide()</code> to hide the div by default. Because jQuery allows chaining, the hide() call returns the togglee jQuery object and we save a line of code. The long hand way of writing that line would be something like this:</p>
<pre><code class="javascript">this.togglee = $($(this).attr('href'));
this.togglee.hide();</code></pre>
<p>Because jQuery allows chaining, lines like the ones above can be combined and in my opinion remain readable. Chaining too many things together can lower readability and the obviousness of intent though, so always practice safe chaining.</p>
<h2>Observing Clicks</h2>
<p>The <code>$(this).click(onClick);</code> line above tells the toggler (which is <code>$(this)</code>) to run the function <code>onClick</code> whenever it gets clicked. We haven&#8217;t yet created the onClick function so let&#8217;s do that now.</p>
<pre><code class="javascript">(function($) {
  $.fn.toggler = function() {
    return this.each(function() {
      this.togglee = $($(this).attr('href')).hide();
      $(this).click(onClick);
    });

    <strong>function onClick() {
      this.togglee.toggle()
      return false;
    }</strong>
  }
})(jQuery);</code></pre>
<p><code>this</code> is automatically set to the element that fired the <code>onClick</code>, by jQuery, which is our toggler link. Because we assigned the togglee attribute to the toggler link, we can simple call <code>this.togglee.toggle() </code>and it will toggle the display of the togglee div. The <code>return false</code> tells the togglee link to not actually fire the normal event, which would append #foo to the window location.</p>
<h2>Allowing For Options</h2>
<p>At this point, we could be done but why not allow some options for our plugin. In this case, we&#8217;ll add the option to make the togglee div animate with a slide instead of simply showing and hiding. Check out the bold lines in the cold sample below to see what is needed to add options.</p>
<pre><code class="javascript">(function($) {
  $.fn.toggler = function(options) {

    <strong>var opts = $.extend({}, $.fn.toggler.defaults, options);</strong>

    return this.each(function() {
      this.togglee = $($(this).attr('href')).hide();
      $(this).click(onClick);
    });

    function onClick() {
      <strong>this.togglee[opts.animate ? 'slideToggle' : 'toggle']();</strong>
      return false;
    }
  }

  <strong>$.fn.toggler.defaults = {animate: false}</strong>
})(jQuery);</code></pre>
<p>The first bold line sets the opts variable and uses <a href="http://docs.jquery.com/Utilities/jQuery.extend">jQuery&#8217;s extend function</a> to do so. Basically, <code>$.extend</code> is a merge tool. In plain english here is what happens: it merges <code>$.fn.toggler.defaults</code> on top of <code>{}</code> and then merges <code>options</code> on top of the first merge. It guarantees that our <code>opts</code> variable will be a hash (<code>{}</code>), will have some defaults (<code>$.fn.toggler.defaults</code>) and yet can be overridden on a per case basis with options passed in by you, the developer (<code>options</code>).</p>
<p>In the second bold line, we tell togglee to call <code>slideToggle</code> if <code>opts.animate</code> is true, otherwise just call <code>toggle</code>. This uses the ternary operator and some cool JavaScript functionality. If <code>opts.animate</code> is true, it returns <code>'slideToggle'</code>, otherwise it returns <code>'toggle'</code>. This means if <code>opts.animate</code> is true, you would end up with <code>this.togglee['slideToggle']()</code>, which is the sweet functionality I referenced above that JavaScript natively provides. <code>this.togglee['slideToggle']</code> is a reference to the <code>slideToggle</code> function and when you apply the parenthesis it will invoke the <code>slideToggle</code> function. I feel this way is more succinct, is still readable and again, it saves you a few lines and an if/else statement. Not a big deal, but worth it in this case.</p>
<p>The third and final emboldened line just sets the defaults that get used in the first line if no options are provided by you when you call <code>toggler</code> on some elements.</p>
<h2>Example Uses With/Without Options</h2>
<p>Now that we have options, you can call the toggler function any of the following ways and it will work.</p>
<pre><code class="javascript">// will do simple toggle on click
$('a.toggler').toggler();

// will use slideToggle instead of simple toggle on click
$('a.toggler.animate').toggler({animate:true});</code></pre>
<p>That is pretty much it. You can now create a jQuery plugin that is jQuery-ish and has the ability to have options that can be adjusted on the fly, by you and the people who use your amazing plugin. The only other thing I would mention is most people seem to name their plugins jquery.{plugin name}.js. For example, I named this plugin jquery.toggler.js.</p>
<p>Overall, I am intrigued with jQuery. It doesn&#8217;t come with everything that Prototype does out of the box, but it is probably enough for most. Even if you do not switch to jQuery, I think it is important to give it a good run as it will help you think through JavaScript in a bit different light. As always, if I missed anything or I was unclear or wrong anywhere in the post, feel free to let me know and I will update.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=VhheW7aL"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=l10A9CpJ"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=w9oh6c1N"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=w9oh6c1N" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/687-ya64zJY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/414/creating-a-jquery-plugin-from-scratch/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/414/creating-a-jquery-plugin-from-scratch/</feedburner:origLink></item>
		<item>
		<title>An Idea Idea</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/lSXOOJOkAHA/</link>
		<comments>http://addictedtonew.com/archives/403/an-idea-idea/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 22:08:14 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[ideas]]></category>

		<category><![CDATA[thoughts]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=403</guid>
		<description>I have a lot of ideas lately. I think the main reason I have had so many is because I have been trying to come up with ideas. Contrary to popular belief, ideas do not spring out of nowhere. Idea generation is like exercising. The more you exercise, the stronger you get. Likewise, the more you [...]</description>
			<content:encoded><![CDATA[<p>I have a lot of ideas lately. I think the main reason I have had so many is because I have been trying to come up with ideas. Contrary to popular belief, ideas do not spring out of nowhere. Idea generation is like exercising. The more you exercise, the stronger you get. Likewise, <strong>the more you sit there and think of ideas, the more ideas you generate</strong>. Be prepared. When your idea muscle grows strong, it will create an overwhelming flood.</p>
<h2>Track Your Ideas</h2>
<p>If you are going to try to generate more ideas, you have to get them out of your brain as they happen. The more ideas you keep in your brain the less ideas you will have. Carry a <a href="http://www.moleskine.com">Moleskine</a>, sign up for a note app, <a href="http://tadalist.com">create a list</a> or buy a voice recorder. Whatever you do, as soon as you get an idea, get it out of your head. You do not have to instantly go do the idea, just record it.</p>
<h2>Develop Your Ideas</h2>
<p>As you become more disciplined at tracking your ideas, more ideas will come to. Some of those ideas will be improvements to original ideas. Over time you will start to see certain a really cool transformation of some ideas. You will create ideas that you would have never been capable of originally, but <strong>due to increased attention and thought, they have developed into something great</strong>.</p>
<h2>Share Your Ideas</h2>
<p>Share your ideas. Do not just track your ideas and forcefully try to come up with new ones. Also bring others into the fold. Share your ideas with them and you will be surprised at how differently they think through them, which will in turn help you think differently. <strong>Sharing an idea with someone is one of the best ways to really develop it. </strong></p>
<h2>Pick One and Do It</h2>
<p>So now you are tracking your ideas, generating more ideas, and sharing them with people which in turn is generating more ideas and mutating previous ones. Pick one. <strong>Pick the idea that meets at the crossroads of interesting and profitable</strong>. Design it. Build it. Market it. Do not stop there though. Keep generating more ideas. It is possible that the idea you pick will not be successful. If that is the case, you only need to worry if you have at some point stopped your creative process.</p>
<h2>The Idea Idea</h2>
<p>Today I had an idea on how to better share ideas. You will never have time to build all your ideas, but that does not mean that the ones you do not pick are not solid. Try to get someone else to work on the solid idea and consult with them. <strong>Sharing ownership and seeing an idea take shape is better than letting it rot</strong>.</p>
<p>My idea was a blog where I share ideas that I do not have time to fully own, but that I would still like to see created. Each time I decide I do not want to focus on an idea, I could release it as a blog post. Anyone else would then be free to take the idea and run. All I would ask for is the opportunity to help with the idea at some point because chances are I would want to use it and I believe I could be helpful along the way.</p>
<p><strong>The blog idea almost immediately morphed into something else</strong>. I think it would be cool to have a site online where you could store your ideas and annotate them with thoughts, links, screenshots and scribbles. If you decide you do not want to devote time to the idea, you can make it public and allow someone else to work on it. That person can take the idea and run with it, and even more wisely, involve you in the process.</p>
<p>That is the idea. It&#8217;s an idea idea. Anyone who stumbles across this can feel free to take that idea and run with it. I cannot guarantee profitability but I think it is cool. I would love to help bring this into fruition, but I have already <a href="http://orderedlist.com/tags/harmony">chosen an idea</a> to run with, leaving me with no time.</p>
<p>How to you store your ideas? What are some good ones that you will never do?</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=4ITtRzs4"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=yQVLk5yo"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=i3BnYb8s"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=i3BnYb8s" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/lSXOOJOkAHA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/403/an-idea-idea/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/403/an-idea-idea/</feedburner:origLink></item>
		<item>
		<title>4 Weight Lifting Tips</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/XIkNVHTyuxE/</link>
		<comments>http://addictedtonew.com/archives/377/4-weight-lifting-tips/#comments</comments>
		<pubDate>Sat, 01 Nov 2008 04:05:43 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[exercise]]></category>

		<category><![CDATA[health]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=377</guid>
		<description>I started lifting weights again and it feels great. I have lifted weights off and on since college and have picked up a few things that I thought I would share. 
1. Negative Can Be Positive
In order to present my tips I first have to explain one thing. In weight lifting, each exercise has a positive [...]</description>
			<content:encoded><![CDATA[<p>I started lifting weights again and it feels great. I have lifted weights off and on since college and have picked up a few things that I thought I would share. </p>
<h2>1. Negative Can Be Positive</h2>
<p>In order to present my tips I first have to explain one thing. In weight lifting, <strong>each exercise has a positive and negative motion</strong>. The positive motion is when you exert. On bench press, the positive motion would be when you push the bar off your chest. The opposite of positive motion is obviously negative motion. Negative motion, on bench press, would be when you lower the bar to your chest. </p>
<p>Positive motion always seems the most difficult but <strong>negative can actually work your muscles more</strong>. Sometimes when you hit a wall at a certain weight level a purely negative workout (with a good spotter) can help you break through.</p>
<h2>2. Breathe!!!</h2>
<p>Breathing is really important in weight lifting. Grunting, contrary to popular belief is not, but rather it is the fact that grunting is kind of a way of exhaling, which is similar to breathing and thus is more helpful than not grunting but less helpful than actually exhaling. Anyway, <strong>always exhale during positive motion</strong> (when you exert effort) and inhale during negative motion. You don&#8217;t have to inhale and exhale each time but never inhale during positive and never exhale during negative. </p>
<h2>3. Vary Your Speed</h2>
<p>Related to the motions and breathing is timing. Typically, <strong>positive motions should be half the time of their negative counter parts</strong>. On bench press, this would mean slowly lowering the bar to your chest (3-4 seconds, negative motion), followed by a burst of power to raise it back up (1-2 seconds, positive motion). </p>
<p>To sum up the first three, inhale during negative motions, and do them slowly (think balance) and exhale during positive motions and do them quickly (think power). </p>
<h2>4. Bigger to Smaller</h2>
<p>Always, always, <strong>always work larger muscles first</strong> and work your way down to smaller muscles. Take your legs for example: first work out your quadriceps and hamstrings, then work out your calf muscles. If you work out your calf muscles first, you will not be able to properly work out your upper legs. The same is true with ams vs. chest/back. Do your chest or back first, before working out your biceps or triceps. </p>
<h2>My Workout Schedule</h2>
<p>I do not have set days or set exercises that I do, but rather have set muscle groups that I rotate through on whatever days I end up working out. I <strong>always work out chest with triceps, back with biceps and legs with shoulders</strong>. In each workout I start with the larger muscle group and work to the smaller ones. I also try to do abs 3 to 4 days a week. Abs can take a beating, typically.</p>
<p>So why am I not ripped and a physical specimen? I believe I just dished some good advice, but I am pretty undisciplined at following it for more than 3 months in a given year. The other 9 months? I use them to make up for all the hard work during the 3 good months. :)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=w2W0VQDi"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=WTaBxlKT"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=SkbIegmm"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=SkbIegmm" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/XIkNVHTyuxE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/377/4-weight-lifting-tips/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/377/4-weight-lifting-tips/</feedburner:origLink></item>
		<item>
		<title>Do It For Mom</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/sLUK2NMaqL8/</link>
		<comments>http://addictedtonew.com/archives/384/do-it-for-mom/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 05:02:44 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[thoughts]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=384</guid>
		<description>Mom. Mom. Mom. Moooom. Mooooooooom. Mom, mom, mom. Remember those days? Remember when you only cared what mom thought of what you were doing? Those were the good days. Then, out of nowhere, you are no longer doing it for mom. You are doing it for your boss or your co-worker or your client. Make [...]</description>
			<content:encoded><![CDATA[<p>Mom. Mom. Mom. Moooom. Mooooooooom. Mom, mom, mom. Remember those days? Remember when you only cared what mom thought of what you were doing? Those were the good days. Then, out of nowhere, you are no longer doing it for mom. You are <strong>doing it for your boss</strong> or <strong>your co-worker</strong> or <strong>your client</strong>. Make the logo bigger. Get this done ASAP.  </p>
<p>I might be weird but I still do stuff for my mom. Heck, I even have a tumblr account dedicated to her, aptly named &#8220;<a href="http://forjohnsmom.tumblr.com">For John&#8217;s Mom</a>.&#8221; Anytime I post to one of my many blogs (or blawgs as she pronounces it, yes you do mom, don&#8217;t deny it), tweet or find something funny on the internet my mom knows about it.</p>
<p>Often times when I am working on something I will send her an email or give her a call and tell her about it. She could tell you my favorite programming language (and my favorite framework for said language). She knows that each Friday I spend time on an app I am building, and <a href="http://orderedlist.com/tags/harmony">that its name is Harmony</a>. </p>
<p><strong>The next work project you do, do it for your mom.</strong> Put <a href="http://addictedtonew.com/archives/366/effort-and-time/">everything you have</a> into it and show it to your mom when you are done. Explain to her why it is cool and how hard you worked at it. She will be proud. You will be proud.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=6ILa0E0H"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=tDW426wI"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=QyQZS6sR"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=QyQZS6sR" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/sLUK2NMaqL8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/384/do-it-for-mom/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/384/do-it-for-mom/</feedburner:origLink></item>
		<item>
		<title>Effort and Time</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/dk6V7XQmOyc/</link>
		<comments>http://addictedtonew.com/archives/366/effort-and-time/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 05:19:53 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[consistency]]></category>

		<category><![CDATA[effort]]></category>

		<category><![CDATA[thoughts]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=366</guid>
		<description>I have been saying that to people a lot lately. Success takes effort and time. Now that I think about it, effort and time could probably be considered the definition of consistency. Though now that I think about that, consistency is possible without effort, as you could consistently sit on the couch. Most likely that [...]</description>
			<content:encoded><![CDATA[<p>I have been saying that to people a lot lately. <strong>Success takes effort and time.</strong> Now that I think about it, effort and time could probably be considered the definition of consistency. Though now that I think about that, consistency is possible without effort, as you could consistently sit on the couch. Most likely that would not lead to much success.  </p>
<p>I guess the point I am trying to get across is often people start off fired up about something, but over time it fades and they stop putting effort into it. Lately, I have put a lot of effort into blogging at <a href="http://railstips.org">RailsTips</a> and I have noticed results. Pageviews have increased. Comments have increased. <strong>You can have a spike of success through great effort over short period of time, but if you do not consistently put forth effort, it will remain just that, a spike</strong>. Spikes in success are exciting but with effort and time, one day you will look back and that spike will seem pretty small.</p>
<p>I guess the kind of funny thing about me saying that success takes time and effort (see how I changed the order, just noting that) is that it assumes that I have known success. You might not think of me as that successful but <strong>I would respond that success is relative</strong>. Always aim high, but never feel discouraged by the fact that there are bigger dogs out there. Likewise, you should never feel over confident about the smaller dogs.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=7dXV5G9i"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=LXmoIPOh"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=Ax1AOMvG"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=Ax1AOMvG" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/dk6V7XQmOyc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/366/effort-and-time/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/366/effort-and-time/</feedburner:origLink></item>
		<item>
		<title>Gary V on Personal Branding</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/L5WiSDfHZhs/</link>
		<comments>http://addictedtonew.com/archives/359/gary-vaynerchuck-on-personal-branding/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 04:08:33 +0000</pubDate>
		<dc:creator>jnunemaker</dc:creator>
		
		<category><![CDATA[Media]]></category>

		<category><![CDATA[branding]]></category>

		<category><![CDATA[passion]]></category>

		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=359</guid>
		<description>Below is an embedded video of Gary Vaynerchuck&amp;#8217;s Web 2.0 keynote. I&amp;#8217;m a big fan of Gary and this talk is a good example of why. There is some foul language so if that offends you, consider yourself warned. The video is about 15 minutes long, but well worth it.

He is a really charismatic speaker [...]</description>
			<content:encoded><![CDATA[<p>Below is an embedded video of <a href="http://garyvaynerchuk.com/2008/09/23/my-web-20-keynote-in-nyc/">Gary Vaynerchuck&#8217;s Web 2.0 keynote</a>. I&#8217;m a big fan of Gary and this talk is a good example of why. There is some foul language so if that offends you, consider yourself warned. The video is about 15 minutes long, but well worth it.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/EhqZ0RU95d4&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/EhqZ0RU95d4&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>He is a really charismatic speaker and extremely passionate. Below is one of my favorite excerpts from the keynote:</p>
<blockquote><p>&#8220;Look yourself in the mirror and ask yourself what do I want to do I want to do everyday for the rest of my life. Do that! I promise you can monitize that s***.&#8221;</p>
</blockquote>
<p>Gary if you stumble across this, keep it up. You are inspiring.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=zzUl4xpT"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=VNbJlCFQ"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=I1ggUoI3"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=I1ggUoI3" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/L5WiSDfHZhs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/359/gary-vaynerchuck-on-personal-branding/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/359/gary-vaynerchuck-on-personal-branding/</feedburner:origLink></item>
		<item>
		<title>Rails and Mint</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/X1HsNeJqY4M/</link>
		<comments>http://addictedtonew.com/archives/356/rails-and-mint/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 04:26:46 +0000</pubDate>
		<dc:creator>John Nunemaker</dc:creator>
		
		<category><![CDATA[Software]]></category>

		<category><![CDATA[analytics]]></category>

		<category><![CDATA[mint]]></category>

		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=356</guid>
		<description>Mint is a fabulous analytics application that you install on your own server. It requires PHP and MySQL and the license key is tied to your domain. This led me to believe that I needed to have Mint installed on the same server as the website or application I wanted to track. Fact is, you [...]</description>
			<content:encoded><![CDATA[<p><a href="http://haveamint.com">Mint</a> is a fabulous analytics application that you install on your own server. It requires PHP and MySQL and the license key is tied to your domain. This led me to believe that I needed to have Mint installed on the same server as the website or application I wanted to track. Fact is, you can put Mint on a subdomain and then just link to that in your site or application. </p>
<h2>The Problem</h2>
<p>How about an example so this makes sense? Railstips uses Mephisto, which is written in Ruby On Rails. It is kind of bad form to install Rails and PHP on the same server (some would say it is bad form to install PHP at all, but I digress). When I switched Railstips to use mod_rails, I lost my rewrites that told requests for /mint to go to mint instead of Rails (as mod_rails recommends turning mod_rewrite off). The solution, though not obvious at first, was simple. </p>
<h2>The Solution</h2>
<p>I setup mint.railstips.org on a PHP server and installed mint there. Then on Railstips.org, which uses mod_rails, I simply linked to the full mint install url in the tracking code, ie:</p>
<pre><code class="html">&lt;script src="http://mint.railstips.org/mint/?js" type="text/javascript"&gt;&lt;/script&gt;</code></pre>
<p>I swear originally when Mint came out you couldn&#8217;t do that, but Shaun must have made a change. I actually noticed that this was possible from the <a href="http://haveamint.com/faqs/compatibility/from_another_server">FAQ&#8217;s on the Mint website</a>. </p>
<p>So, in the future, if you want to use Inman&#8217;s awesome analytics software, all you need to do is setup PHP on a server somewhere and install Mint. It doesn&#8217;t need to be on the same server/domain as the site or application you wish to track.</p>
<p><strong>Note:</strong> Be sure that whatever domain Mint is installed at matches the domain on your Mint license. For example, if Mint is installed at mint.railstips.org, be sure that your mint license is for mint.railstips.org. If it isn&#8217;t, login at <a href="http://haveamint.com">HaveAMint.com</a> and transfer the license to where you intend to install Mint.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=OQqq7IRW"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=fELfSFig"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=HklAijp1"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=HklAijp1" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/X1HsNeJqY4M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/356/rails-and-mint/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/356/rails-and-mint/</feedburner:origLink></item>
		<item>
		<title>How To Make Coffee</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/4Vb-7MY6hgg/</link>
		<comments>http://addictedtonew.com/archives/354/how-to-make-coffee/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 16:44:46 +0000</pubDate>
		<dc:creator>John Nunemaker</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=354</guid>
		<description>Making your own coffee from the bean is really easy. Maybe it&amp;#8217;s because I&amp;#8217;m inept at most kitchen related activities (other than eating) but I remember thinking that making coffee (other than drip or instant) seemed a bit intimidating at first. Below is my surefire guide to good coffee.
Boil Water
If you have some other way [...]</description>
			<content:encoded><![CDATA[<p>Making your own coffee from the bean is really easy. Maybe it&#8217;s because I&#8217;m inept at most kitchen related activities (other than eating) but I remember thinking that making coffee (other than drip or instant) seemed a bit intimidating at first. Below is my surefire guide to good coffee.</p>
<h2>Boil Water</h2>
<p>If you have some other way of acquiring hot water, you can skip this step. :)</p>
<p><a href="http://www.flickr.com/photos/johnnunemaker/2821253849/" title="Boil Water by jnunemaker, on Flickr"><img src="http://farm4.static.flickr.com/3104/2821253849_450d15c842.jpg" class="image full" style="width:460px;" alt="Boil Water" /></a></p>
<h2>Select Coffee</h2>
<p>I&#8217;m finishing off a bag of Ethiopia Sidamo. I don&#8217;t know much about the different kinds but I typically like bolder coffees. My next bag is a House Blend which is more of a medium. <strong>Whatever you do, don&#8217;t get pre-ground coffee.</strong> Once a bean is ground, the flavor begins to go. For the best coffee, always grind when you are ready for the cup, not in advance.</p>
<p><a href="http://www.flickr.com/photos/johnnunemaker/2821254373/" title="Pick Coffee by jnunemaker, on Flickr"><img src="http://farm4.static.flickr.com/3149/2821254373_50e836967d.jpg" class="image full" alt="Pick Coffee" /></a></p>
<h2>Put Beans in Grinder</h2>
<p>I use a blade grinder. You can purchase them online (think ebay) or at <a href="http://www.starbucks.com/retail/grinders.asp">any Starbucks</a> (other stores too I&#8217;m sure).</p>
<p><a href="http://www.flickr.com/photos/johnnunemaker/2822092638/" title="Put beans in grinder by jnunemaker, on Flickr"><img src="http://farm4.static.flickr.com/3254/2822092638_768124de92.jpg" class="image full" alt="Put beans in grinder" /></a></p>
<h2>Grind Beans</h2>
<p>Because we are using a press and making coffee (not espresso), you want the beans to be pretty chunky. Don&#8217;t grind them up too fine.</p>
<p><a href="http://www.flickr.com/photos/johnnunemaker/2821255631/" title="Grind beans by jnunemaker, on Flickr"><img src="http://farm4.static.flickr.com/3167/2821255631_70f5686628.jpg" class="image full" alt="Grind beans" /></a></p>
<h2>Put Beans and Water into Press</h2>
<p>I always put the ground beans in and then pour the boiling water on top. Also, note the small size of my press. I can make myself a cup of coffee and I don&#8217;t have a whole pot to dump out later. It makes about two normal coffee cups or one of the cups I have pictured below.</p>
<p><a href="http://www.flickr.com/photos/johnnunemaker/2822093760/" title="Put beans in press by jnunemaker, on Flickr"><img src="http://farm4.static.flickr.com/3145/2822093760_b137de4001.jpg" class="image full" style="width:460px;" alt="Put beans in press" /></a></p>
<p><a href="http://www.flickr.com/photos/johnnunemaker/2821256869/" title="Put boiling water in press by jnunemaker, on Flickr"><img src="http://farm4.static.flickr.com/3012/2821256869_c054ddedaf.jpg" class="image full" style="width:460px;" alt="Put boiling water in press" /></a></p>
<h2>Stir and Steep</h2>
<p>Once you&#8217;ve got the ingredients poured in, stir it up and let the coffee steep for 4 or 5 minutes.</p>
<p><a href="http://www.flickr.com/photos/johnnunemaker/2822095076/" title="Stir and let steep for 4 minutes by jnunemaker, on Flickr"><img src="http://farm4.static.flickr.com/3043/2822095076_06733c4e50.jpg" class="image full" style="width:460px;" alt="Stir and let steep for 4 minutes" /></a></p>
<h2>Press</h2>
<p>Press the coffee grinds down. This is probably the easiest step.</p>
<p><a href="http://www.flickr.com/photos/johnnunemaker/2822095528/" title="Press the coffee by jnunemaker, on Flickr"><img src="http://farm4.static.flickr.com/3143/2822095528_82d1869152.jpg" class="image full" style="width:460px;" alt="Press the coffee" /></a></p>
<h2>Pour Into Cup</h2>
<p>I lied, this is probably the easiest step. I&#8217;m a big fan of the cup pictured. Never gets hot on the outside but keeps the coffee very warm on the inside. Also, the top is really nice and seals well.</p>
<p><a href="http://www.flickr.com/photos/johnnunemaker/2821258697/" title="Get a cool cup by jnunemaker, on Flickr"><img src="http://farm4.static.flickr.com/3080/2821258697_a9a8778f79.jpg" class="image full" style="width:460px;" alt="Get a cool cup" /></a></p>
<p><a href="http://www.flickr.com/photos/johnnunemaker/2822097010/" title="Pour into cup and enjoy by jnunemaker, on Flickr"><img src="http://farm4.static.flickr.com/3117/2822097010_63349f42fa.jpg" class="image full" style="width:460px;" alt="Pour into cup and enjoy" /></a></p>
<h2>Recap</h2>
<p>All you need is hot water, coffee beans, grinder, press and cup. The whole process takes 5-10 minutes, of which most is spent waiting and not actually doing anything. As far as cost, the grinder and press can be purchased for around $50 total and the beans are typically $5-$10 per bag. <strong>The benefit of this process is great coffee and you can claim to be a coffee snob.</strong> </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=edIj3Rh9"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=e5ARBdLI"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=6oNLMgwj"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=6oNLMgwj" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/4Vb-7MY6hgg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/354/how-to-make-coffee/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/354/how-to-make-coffee/</feedburner:origLink></item>
		<item>
		<title>Favorite 2008 Olympic Moments</title>
		<link>http://feedproxy.google.com/~r/johnnunemaker/~3/xZ1lE68Y7DE/</link>
		<comments>http://addictedtonew.com/archives/352/favorite-2008-olympic-moments/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 03:49:48 +0000</pubDate>
		<dc:creator>John Nunemaker</dc:creator>
		
		<category><![CDATA[Media]]></category>

		<guid isPermaLink="false">http://addictedtonew.com/?p=352</guid>
		<description>I&amp;#8217;ve had this post half written in my &amp;#8220;to blog&amp;#8221; bin for a week now so I figured it was time to finish it or delete it. Considering how much I enjoyed the Olympics this year, I knew deleting it wasn&amp;#8217;t an option. Below are a few of the moments that inspired me from the [...]</description>
			<content:encoded><![CDATA[<p>I&#8217;ve had this post half written in my &#8220;to blog&#8221; bin for a week now so I figured it was time to finish it or delete it. Considering how much I enjoyed the Olympics this year, I knew deleting it wasn&#8217;t an option. Below are a few of the moments that inspired me from the games.</p>
<h2>Michael Phelps</h2>
<p><strong>The 4&#215;100 relay where Jason Lezak caught the French</strong> from behind was absolutely amazing. Steph and I were high-fiving and jumping around. I get excited pretty easily but it has been along time since I&#8217;ve had that kind of adrenaline pumping through my programmer veins.</p>
<p><img src="http://addictedtonew.com/wp-content/uploads/2008/09/phelps-4x100relay.jpg" alt="phelps_4x100relay.jpg" class="image full" /></p>
<p><strong>Phelps 7th gold medal was won by a fingertip</strong> that only a high speed camera could catch (and an electronic touch pad). I didn&#8217;t get to see this until a few days after but it was still amazing. His 8th gold medal was also moving but I decided I could only put so many Michael Phelps photos in one blog post.</p>
<p><img src="http://addictedtonew.com/wp-content/uploads/2008/09/phelps-finger-tip.jpg" alt="phelps_finger_tip.jpg" class="image full" style="width:460px;" /></p>
<h2>Redeem Team Wins Gold</h2>
<p>Don&#8217;t get me started on the NBA. Over the past 10 years I&#8217;ve went from super fan to super critic, but the redeem team was fun to watch. They hustled on defense (something which never happens in the NBA these days) and were unselfish on the offensive side.</p>
<p><img src="http://addictedtonew.com/wp-content/uploads/2008/09/redeem-team-wins-gold.jpg" alt="redeem_team_wins_gold.jpg" class="image full" /></p>
<h2>Usain Bolt 200m</h2>
<p>Phelps was amazing but Usain Bolt&#8217;s 200m victory sent chills down my spine. He crushed the competition and defeated a sacred world record. </p>
<p><img src="http://addictedtonew.com/wp-content/uploads/2008/09/usain-bolt-200m.jpg" alt="usain_bolt_200m.jpg" class="image full" style="width:460px;" /></p>
<h2>May/Walsh Repeat as Gold Medalists</h2>
<p>108 straight matches and two gold medals. Only one word comes to mind: Domination. The amazing part is how grounded they seem. </p>
<p><img src="http://addictedtonew.com/wp-content/uploads/2008/09/may-walsh-gold.jpg" alt="may_walsh_gold.jpg" class="image full" /></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/johnnunemaker?a=VcdCD6R3"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=43" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=wccZ5JyM"><img src="http://feeds.feedburner.com/~f/johnnunemaker?d=50" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/johnnunemaker?a=9wd0ynHi"><img src="http://feeds.feedburner.com/~f/johnnunemaker?i=9wd0ynHi" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/johnnunemaker/~4/xZ1lE68Y7DE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://addictedtonew.com/archives/352/favorite-2008-olympic-moments/feed/</wfw:commentRss>
		<feedburner:origLink>http://addictedtonew.com/archives/352/favorite-2008-olympic-moments/</feedburner:origLink></item>
	</channel>
</rss>
