<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>See John CodeSee John Code</title>
	<atom:link href="http://www.seejohncode.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.seejohncode.com</link>
	<description>Ramblings by John Crepezzi</description>
	<lastBuildDate>Mon, 07 Jan 2013 13:44:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>Changing User-Agent in Google Chrome</title>
		<link>http://www.seejohncode.com/2012/10/16/changing-user-agent-in-google-chrome/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=changing-user-agent-in-google-chrome</link>
		<comments>http://www.seejohncode.com/2012/10/16/changing-user-agent-in-google-chrome/#comments</comments>
		<pubDate>Tue, 16 Oct 2012 18:38:55 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[user-agent]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=812</guid>
		<description><![CDATA[<p>Here&#8217;s a Google Chrome pro-tip for you.  It&#8217;s easy to change the user-agent in Google Chrome dev builds with no extensions necessary: Open the inspector &#8211; by right clicking on any page and clicking &#8220;Inspect element&#8221; In the bottom right click the &#8220;Settings&#8221; gear Click into the &#8220;Overrides&#8221; tab Check user-agent, and select the one [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/10/16/changing-user-agent-in-google-chrome/">Changing User-Agent in Google Chrome</a></p>]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s a Google Chrome pro-tip for you.  It&#8217;s easy to change the user-agent in Google Chrome dev builds with no extensions necessary:</p>
<ol>
<li>Open the inspector &#8211; by right clicking on any page and clicking &#8220;Inspect element&#8221;</li>
<li>In the bottom right click the &#8220;Settings&#8221; gear</li>
<li>Click into the &#8220;Overrides&#8221; tab</li>
<li>Check user-agent, and select the one you want</li>
</ol>
<p>Awesome time-saver, especially for those like me who hate installing extensions.</p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/10/16/changing-user-agent-in-google-chrome/">Changing User-Agent in Google Chrome</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/10/16/changing-user-agent-in-google-chrome/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Proper Escaping of Single-quotes</title>
		<link>http://www.seejohncode.com/2012/10/16/proper-escaping-of-single-quotes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=proper-escaping-of-single-quotes</link>
		<comments>http://www.seejohncode.com/2012/10/16/proper-escaping-of-single-quotes/#comments</comments>
		<pubDate>Tue, 16 Oct 2012 17:26:17 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=807</guid>
		<description><![CDATA[<p>If you&#8217;ve ever tried building up a command programatically, you may have run into some issues around proper quoting of arguments. To solve most problems, you can just throw everything inside of a set single quotes. The shell won&#8217;t touch anything inside and you&#8217;ll be all good. Then the one remaining question is what to do [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/10/16/proper-escaping-of-single-quotes/">Proper Escaping of Single-quotes</a></p>]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;ve ever tried building up a command programatically, you may have run into some issues around proper quoting of arguments.</p>
<p>To solve most problems, you can just throw everything inside of a set single quotes. The shell won&#8217;t touch anything inside and you&#8217;ll be all good.</p>
<pre class="brush: bash; title: ; notranslate">
$ echo &quot;$hello world&quot; # &quot; world&quot; # or something worse
$ echo '$hello world' # &quot;$hello world&quot;
</pre>
<p>Then the one remaining question is what to do if you want to include a single quote? Your first inclination may be to escape it with a backslash:</p>
<pre class="brush: bash; title: ; notranslate">
$ echo '$hello \' world' # incomplete
</pre>
<p>But that&#8217;s not how it works :( The way you actually have to go about this is to stop the single-quote pair, escape a single quote, and then start it back up. Here it is:</p>
<pre class="brush: bash; title: ; notranslate">
$ echo '$hello '\'' world' # &quot;hello ' world&quot;
</pre>
<p>&#8212;</p>
<p>As a bonus, if you try to do this substitution in Ruby, you may try something like:</p>
<pre class="brush: ruby; title: ; notranslate">
var = 'hello \' world'
var.gsub('\'', '\'\\\'\'') # &quot;hello ' world' world&quot;
</pre>
<p>Wat!? That&#8217;s not what you wanted! Read that documentation!  Let&#8217;s try again</p>
<pre class="brush: ruby; title: ; notranslate">
var.gsub('\'') { '\'\\\'\'' } # &quot;hello '\\'' world&quot;
</pre>
<p>There we go! Make it a little prettier even:</p>
<pre class="brush: ruby; title: ; notranslate">
var.gsub(&quot;'&quot;) { %q{'\'} }
</pre>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/10/16/proper-escaping-of-single-quotes/">Proper Escaping of Single-quotes</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/10/16/proper-escaping-of-single-quotes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dependency Injection in JavaScript Tests</title>
		<link>http://www.seejohncode.com/2012/09/09/dependency-injection-in-javascript-tests/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dependency-injection-in-javascript-tests</link>
		<comments>http://www.seejohncode.com/2012/09/09/dependency-injection-in-javascript-tests/#comments</comments>
		<pubDate>Sun, 09 Sep 2012 14:00:41 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=792</guid>
		<description><![CDATA[<p>When you&#8217;re writing tests in Node, its often useful to be able to stub out modules which are included by the object you&#8217;re attempting to test.  Unfortunately due to the way that the module system is structured, its not straightforward to do this in a single test (as opposed to globally). There are a few [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/09/09/dependency-injection-in-javascript-tests/">Dependency Injection in JavaScript Tests</a></p>]]></description>
				<content:encoded><![CDATA[<p>When you&#8217;re writing tests in Node, its often useful to be able to stub out modules which are included by the object you&#8217;re attempting to test.  Unfortunately due to the way that the module system is structured, its not straightforward to do this in a single test (as opposed to globally).</p>
<p>There are a few solution for this dependency injection problem around, namely <a href="https://github.com/felixge/node-sandboxed-module">node-sandboxed-module</a> and <a href="https://github.com/nathanmacinnes/injectr">injectr</a>.  These modules use node&#8217;s <a href="http://nodejs.org/api/vm.html">vm module</a> to create a new context that they run the test inside of, and in that context they use the mock instead of the original when calling `require`.  This is a nice solution, but unfortunately by bringing the code into a new context, you also break code analysis tools like mocha&#8217;s <a title="Setting up Mocha &amp; JSCoverage" href="http://www.seejohncode.com/2012/03/13/setting-up-mocha-jscoverage/">html-cov</a>.</p>
<p>A few days ago, <a href="http://mlmorg.com/">Matt Morgan</a> released a module called <a href="https://github.com/mlmorg/mockit">mockit</a>, which approaches the problem instead by temporarily replacing `require` when requiring the dependency the test needs (as opposed to trying to replace it for the duration of the test).</p>
<p>Imagine you had a `Downloader` class, and you wanted to use it in your tests, but have it so that when `Downloader` called `require(&#8216;http&#8217;);`, it got a mock instead of node&#8217;s http class.  You could do that with one call to mockit:</p>
<pre class="brush: jscript; title: ; notranslate">
var Downloader = mockit('../lib/downloader', {
  http: mockHttp
});
</pre>
<p>I think this is a really nice solution to this problem &#8211; totally unobtrusive and uses node&#8217;s existing `require` functionality when no mock exists. Check it out!</p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/09/09/dependency-injection-in-javascript-tests/">Dependency Injection in JavaScript Tests</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/09/09/dependency-injection-in-javascript-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Callstacks</title>
		<link>http://www.seejohncode.com/2012/09/04/javascript-callstacks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=javascript-callstacks</link>
		<comments>http://www.seejohncode.com/2012/09/04/javascript-callstacks/#comments</comments>
		<pubDate>Tue, 04 Sep 2012 14:00:38 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=782</guid>
		<description><![CDATA[<p>Today I&#8217;m going to share a cool method for generating a JavaScript callstack from any point in your code.  JavaScript doesn&#8217;t offer this functionality, but we can tease it out pretty easily, especially in V8 (very useful for Node programmers). The closest thing JavaScript has to a callstack is the 10-frame backtrace that comes along [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/09/04/javascript-callstacks/">JavaScript Callstacks</a></p>]]></description>
				<content:encoded><![CDATA[<p>Today I&#8217;m going to share a cool method for generating a JavaScript callstack from any point in your code.  JavaScript doesn&#8217;t offer this functionality, but we can tease it out pretty easily, <em>especially</em> in V8 (very useful for Node programmers).</p>
<p>The closest thing JavaScript has to a callstack is the 10-frame backtrace that comes along whenever an error is generated.  So we can use that to our advantage, by generating an error on-demand, catching the response, and examining the #stack attribute of the thrown error object:</p>
<pre class="brush: jscript; title: ; notranslate">
function callstack() {
  try { capture.error } catch (e) {
    return e.stack;
  }
}
</pre>
<p>Normally we&#8217;d have to stop there, and if we wanted to access that data programatically we&#8217;d have to parse the pre-formatted String that comes back.  But with V8 we have a better option!  V8 gives us access to the method that prepares the preformatted response, so by temporarily replacing it &#8211; we can return the original data instead.  Check it out, here&#8217;s a small node.js module:</p>
<pre class="brush: jscript; title: ; notranslate">
var replacementPreparer = function (error, trace) {
  return trace;
};

module.exports = function () {
  var capture;
  var oldPreparer = Error.prepareStackTrace;
  Error.prepareStackTrace = replacementPreparer;
  try { capture.error } catch (e) {
    capture = e.stack;
  }
  Error.prepareStackTrace = oldPreparer;
  return capture;
};
</pre>
<p>And the usage:</p>
<pre class="brush: jscript; title: ; notranslate">
var callstack = require('./path/to/callstack/js');
for (var i = 0; i &lt; 1000; i++) {
  callstack(); // use this anywhere in your code
}
</pre>
<p>When you call `callstack`, you&#8217;ll get back an array of CallSite objects upon which you can call methods from the V8 API to get at all the juicy details: <a href="http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi">http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi</a></p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/09/04/javascript-callstacks/">JavaScript Callstacks</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/09/04/javascript-callstacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Gotcha: single line conditionals</title>
		<link>http://www.seejohncode.com/2012/07/31/ruby-gotcha-single-line-conditionals/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ruby-gotcha-single-line-conditionals</link>
		<comments>http://www.seejohncode.com/2012/07/31/ruby-gotcha-single-line-conditionals/#comments</comments>
		<pubDate>Tue, 31 Jul 2012 14:12:53 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[gotcha]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=769</guid>
		<description><![CDATA[<p>I&#8217;ve touched on this gotcha briefly in the past when discussing the Wat video, but I thought a few examples of when single-line conditionals can bite you would be fun. In Ruby, we can write a conditional containing a single expression that normally takes up three lines: on a single line to save space: And [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/07/31/ruby-gotcha-single-line-conditionals/">Ruby Gotcha: single line conditionals</a></p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve touched on this gotcha briefly in the past when <a title="Ruby: WAT?" href="http://www.seejohncode.com/2012/02/03/ruby-wat/">discussing the Wat video</a>, but I thought a few examples of when single-line conditionals can bite you would be fun.</p>
<p>In Ruby, we can write a conditional containing a single expression that normally takes up three lines:</p>
<pre class="brush: ruby; title: ; notranslate">
unless condition
  something
end
</pre>
<p>on a single line to save space:</p>
<pre class="brush: ruby; title: ; notranslate">
something unless condition
</pre>
<p>And that is all well and good &#8211; these two are pretty much the same.  But they&#8217;re not identical in practice. There are a few weird things about to come up.</p>
<p>Our first example will be using <code>defined?</code> to conditionally print a variable</p>
<pre class="brush: ruby; title: ; notranslate">
if defined?(var1)
  puts var1 # never runs
end

var1 # NameError: undefined local variable
</pre>
<p>So that works just as we&#8217;d expect. The conditional never runs because <code>defined?(var1)</code> returns <code>nil</code>. After the conditional, access the undefined <code>var1</code> gives us a <code>NameError</code> because (appropriately) its not defined. Let&#8217;s modify that a little bit and put an assignment inside of the conditional.</p>
<pre class="brush: ruby; title: ; notranslate">
if defined?(var2)
  var2 = 5 # never runs
end

var2 # nil
defined?(var2) # &quot;local-variable&quot;
</pre>
<p>So that might look a bit odd.  We never ran the conditional, so <code>var2</code> never gets set &#8211; that makes sense.  But after the block, <code>var2</code> doesn&#8217;t throw a <code>NameError</code> when accessed anymore. This is because the Ruby parser makes room and defines <code>var2</code> when it sees it on the lefthand side of an expression (even though its inside of a conditional that doesn&#8217;t run).</p>
<p>Let&#8217;s write the same on one line though:</p>
<pre class="brush: ruby; title: ; notranslate">
var3 = 5 if defined?(var3)

var3 # 5
</pre>
<p>Even more interesting &#8211; an undefined variable written this way will become defined and assigned when run.  The first thing that happens is that the parser comes along and defines <code>var3</code> which it sees on the lefthand side of a conditional.  <em>Then</em> <code>defined?</code> runs, which this time evaluates to <code>"local-variable"</code>, causing the conditional to pass, and <code>5</code> to be assigned to <code>var3</code>.  In cases like this, the single-line conditional will produce an entirely different result than block conditionals.</p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/07/31/ruby-gotcha-single-line-conditionals/">Ruby Gotcha: single line conditionals</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/07/31/ruby-gotcha-single-line-conditionals/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MessagePack &amp; JSON</title>
		<link>http://www.seejohncode.com/2012/07/27/messagepack-json/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=messagepack-json</link>
		<comments>http://www.seejohncode.com/2012/07/27/messagepack-json/#comments</comments>
		<pubDate>Fri, 27 Jul 2012 15:13:05 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[messagepack]]></category>
		<category><![CDATA[msgpack]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=746</guid>
		<description><![CDATA[<p>Yesterday I had lunch with Paul Dix, and he mentioned a serialization library called MessagePack that could serialize and deserialize data the same as JSON, but with a much smaller footprint in to the way that it encodes it data.  So I started digging in.. JSON stores data in sets of enclosing braces that are extremely readable, but [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/07/27/messagepack-json/">MessagePack &#038; JSON</a></p>]]></description>
				<content:encoded><![CDATA[<p>Yesterday I had lunch with <a href="http://www.pauldix.net/">Paul Dix</a>, and he mentioned a serialization library called <a href="http://msgpack.org/">MessagePack</a> that could serialize and deserialize data the same as JSON, but with a much smaller footprint in to the way that it encodes it data.  So I started digging in..</p>
<p>JSON stores data in sets of enclosing braces that are extremely readable, but not really optimal computer to read.  MessagePack gets its optimizations by putting all of the data needed to know the size of a data structure at the front of it.</p>
<p>So JSON thinks like:</p>
<pre class="brush: bash; title: ; notranslate">
[ # square brace - i'm about to read an array
  &quot;one&quot;, # read until the end &quot;, then saw a comma - there must be more elements
  &quot;two&quot;  # read until the end &quot;, no comma
] # square brance - i'm done reading an array
</pre>
<p>And MessagePack thinks like:</p>
<pre class="brush: bash; title: ; notranslate">
\x92 # a dictionary is coming with 2 elements
\xA3 # the first element is a string with 3 letters
one  # 3-letter string
\xA3 # the second element is a string with 3 letters
two  # 3-letter string
</pre>
<p>So that&#8217;s really cool &#8211; and there are implementation for a lot of languages. But I couldn&#8217;t stop. How much smaller does MessagePack makes things practically &#8211; and how much faster is it?</p>
<h2>Length</h2>
<p>I figured I&#8217;d compare a few common structures with the two libraries and see how things came out.  I was also very interested to see how each library&#8217;s output compressed with gzip.</p>
<p>So I started off with a Facebook profile &#8211; Its a large Dictionary/Array mix of data with generous amounts of integers and strings mixed in.  A great test subject for a common case.</p>
<pre>== Full facebook profile ====
MessagePack length: <strong>1990*</strong> (973 compressed  - 49%)
JSON length:        2441  (<strong>955*</strong> compressed - 39%)</pre>
<p>So on *this* data, although MessagePack is smaller, it didn&#8217;t compress by the same amount and thus the JSON compressed version was smaller.  This is extremely interesting, but not entirely surprising if you think about the amount of information that&#8217;s repeated over and over in JSON (specifically common patterns like &#8220;},{&#8221; which MessagePack doesn&#8217;t have.  That against the fact that MessagePack has an large number of identifiers that mean &#8220;Array&#8221; because the identifier mixes in information about the length of the structure.</p>
<p>A friends list from Facebook would be an interesting subject too &#8211; since its a large array of 2-element arrays.</p>
<pre>== Facebook friends list ====
MessagePack length: <strong>21848</strong> (9482 compressed - 43%)
JSON length:        27653 (<strong>9149</strong>compressed - 33%)</pre>
<p>As predicted, MessagePack does a better job compressing data like this &#8211; because its identifier for Array also contains the length of the array about to come.  JSON is still smaller compressed here &#8211; but let&#8217;s push this further.  Let&#8217;s throw a structure at each that is a 100-element array of 100 7-letter words.</p>
<pre>== 100 groups of 100 7-letter words ====
MessagePack length: <strong>80303</strong> (<strong>49152</strong> compressed - 61%)
JSON length: 100201 (51726 compressed - 52%)</pre>
<p>MessagePack compressed just as we thought &#8211; and now has edged out JSON.  Let&#8217;s do the same with arrays of 7-digit numbers (just for fun)</p>
<pre>== 100 groups of 100 7-digit numbers ====
MessagePack length: <strong>50303</strong> (<strong>36585</strong> compressed - %73)
JSON length:        80201 (36898 compressed - %46)</pre>
<h2>Speed</h2>
<p>For me, Speed is where I&#8217;m really excited about what MessagePack could be capable of.  So I started comparing the performance of the <a href="http://rubygems.org/gems/msgpack">Ruby MessagePack library</a> (written as a C extension) to <a href="https://github.com/brianmario/yajl-ruby/">YAJL</a> (also with C bindings to YAJL).</p>
<p>On the same Facebook profile as above, I benchmarked encoding and decoding over 100,000 runs each.</p>
<pre>== Encoding ====
user system total real
json 6.360000 0.120000 6.480000 ( 6.468930)
<strong>msg 4.480000 0.010000 4.490000 ( 4.481516)</strong>

== Decoding ====
user system total real
json 15.040000 0.270000 15.310000 ( 15.290871)
<strong>msg 13.180000 1.530000 14.710000 ( 37.719052)</strong></pre>
<h2>Conclusion</h2>
<p>I will absolutely be using MessagePack when storing data either uncompressed, or with large amount of repeated structure sizes.  It obviously won&#8217;t work for anywhere you&#8217;d like the data to be human-readable, but is an amazingly brilliant idea with great execution.</p>
<p>Check it out!</p>
<p>The code used to generate these numbers: <a href="https://gist.github.com/3188573">https://gist.github.com/3188573</a></p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/07/27/messagepack-json/">MessagePack &#038; JSON</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/07/27/messagepack-json/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Brewster</title>
		<link>http://www.seejohncode.com/2012/07/18/brewster/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=brewster</link>
		<comments>http://www.seejohncode.com/2012/07/18/brewster/#comments</comments>
		<pubDate>Wed, 18 Jul 2012 17:20:35 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[brewster]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=743</guid>
		<description><![CDATA[<p>For the past year and a half, I&#8217;ve been very quiet about a project I&#8217;ve been working on.  So much so that I haven&#8217;t even said the name, actually.  But this past Thursday, Brewster was finally made public.  The reaction so far has been overwhelmingly positive, with write-ups all over the web from the New York [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/07/18/brewster/">Brewster</a></p>]]></description>
				<content:encoded><![CDATA[<p>For the past year and a half, I&#8217;ve been very quiet about a project I&#8217;ve been working on.  So much so that I haven&#8217;t even said the name, actually.  But this past Thursday, <a href="https://www.brewster.com/">Brewster</a> was finally made public.  The reaction so far has been overwhelmingly positive, with write-ups all over the web from the <a href="http://bits.blogs.nytimes.com/2012/07/12/brewster-a-mobile-app-wants-to-transform-your-address-book/">New York Times</a> to <a href="http://gizmodo.com/5926431/brewster-merge-all-your-contacts-from-every-medium-in-one-spot">Gizmodo</a> and <a href="http://allthingsd.com/20120712/qa-behind-brewster-the-buzzy-new-modern-address-book/">AllThingsD</a>.</p>
<p>Brewster is a personalized address book for iPhone.  It takes all of your contacts from the social networks you&#8217;re part of and mixes them with contacts from more traditional places like your address book and your Google Contacts.  It gives you an amazing unified view of the people you know, and how you know them.  You can search across all of your contacts, sort them into lists, and gain insight into how they&#8217;re connected.</p>
<p>If you haven&#8217;t checked it out yet &#8211; head over to the website and <a href="https://www.brewster.com/">download the app today</a>!</p>
<ul>
<li><a href="http://https://twitter.com/brewsterapp">Brewster on Twitter</a></li>
<li><a href="http://https://www.facebook.com/brewsterapp">Brewster on Facebook</a></li>
</ul>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/07/18/brewster/">Brewster</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/07/18/brewster/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lazy Attributes in JavaScript</title>
		<link>http://www.seejohncode.com/2012/06/02/lazy-attributes-in-javascript/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=lazy-attributes-in-javascript</link>
		<comments>http://www.seejohncode.com/2012/06/02/lazy-attributes-in-javascript/#comments</comments>
		<pubDate>Sat, 02 Jun 2012 22:47:40 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=726</guid>
		<description><![CDATA[<p>A while back, I released a tiny library called laze for making the use of lazy attributes easy in JavaScript. I thought I&#8217;d do a post to provide some more context of how laze fits into my workflow in a node.js project.  There are definitely some terrible things you can do with this library, but hopefully this [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/06/02/lazy-attributes-in-javascript/">Lazy Attributes in JavaScript</a></p>]]></description>
				<content:encoded><![CDATA[<p>A while back, I released a tiny library called <a href="https://github.com/seejohnrun/laze">laze</a> for making the use of lazy attributes easy in JavaScript.</p>
<p>I thought I&#8217;d do a post to provide some more context of how laze fits into my workflow in a <a href="http://nodejs.org/">node.js</a> project.  There are definitely some terrible things you can do with this library, but hopefully this post will outline the intended use and convince you to try it out.</p>
<p>Imagine I want to create a new server, and then start listening on a given port.  I start out with some really tightly coupled code:</p>
<pre class="brush: jscript; title: ; notranslate">
Server.prototype = {
  start: function () {
    var host = this.config.host || '127.0.0.1';
    var port = this.config.port || 8080;
    var server = http.createServer();
    server.on('request', this.handleRequest.bind(this));
    server.listen(port, host);
  }
};
</pre>
<p>This code works well, but in my opinion it just does way too much.  In here, we have logic for:</p>
<ol>
<li>Handling how to pull the host and port out of our config &#8211; and what to do if they&#8217;re not set</li>
<li>Creating a new server</li>
<li>Binding our server to another function for requests</li>
<li>Starting the server listening on the given host and port</li>
</ol>
<p>Imagine we want to start splitting this function up a bit.  We&#8217;ll start with pulling the host/port configuration out.</p>
<pre class="brush: jscript; title: ; notranslate">
Server.prototype = {
  getHost: function () {
    return this.config.host || '127.0.0.1';
  },
  getPort: function () {
    return this.config.port || 8080;
  },
  start: function () {
    var server = http.createServer();
    server.on('request', this.handleRequest.bind(this));
    server.listen(this.getPort(), this.getHost());
  }
};
</pre>
<p>So this works pretty well actually &#8211; but if somewhere else in this object we&#8217;d like to have access to the host and port, we&#8217;re re-running the logic inside of `getHost` and `getPort`.  Not a big deal for these quick functions, but something that did a bit more would make that approach just wasteful.</p>
<p>So we could proceed in one of two ways:</p>
<h2>Call getHost and getPort from the constructor</h2>
<pre class="brush: jscript; title: ; notranslate">
var Server = function () {
  this.host = this.getHost();
  this.port = this.getPort();
};
</pre>
<p>If we call the two methods from the constructor, we can have properties set that contain the proper host and port.  This is nice &#8211; but crowding our constructor with calls to methods that aren&#8217;t needed *unless* start gets called.  You can see that if these were time-intensive tasks &#8211; we&#8217;d end up wasting time for methods that may not be called at all.</p>
<h2>Call getHost and getPort from `start`</h2>
<pre class="brush: jscript; title: ; notranslate">
Server.prototype.start = function () {
  this.host = this.getHost();
  this.port = this.getPort();
  var server = http.createServer();
  server.on('request', this.handleRequest.bind(this));
  server.listen(this.port, this.host);
};
</pre>
<p>This approach is good &#8211; its made our start function a bit more complicated but the separation is correct.  The one remaining problem with this approach is that if another method wants to access `host` or `port` before `start` has been called &#8211; they&#8217;ll both be undefined.</p>
<h2>Another Option: Lazy Attributes</h2>
<p>Laze uses `defineProperty` to give us another option.  We can define properties that won&#8217;t be set until they are used.  Then we get the best of all worlds.  The host or port can be called at any time and have the proper values.  And &#8211; once they&#8217;re called one time, they&#8217;ll hold onto their value for the next time without recomputing it.  Let&#8217;s take a look at the code:</p>
<pre class="brush: jscript; title: ; notranslate">
Server.prototype = {
  start: function () {
    var server = http.createServer();
    server.on('request', this.handleRequest.bind(this));
    server.listen(this.port, this.host);
  }
};

laze.defineAll(Server.prototype, {
  port: function () {
    return this.config.port || 8080;
  },
  host: function () {
    return this.config.host || '127.0.0.1';
  }
});
</pre>
<p>If you want to &#8211; you could take this whole thing another step, and make the creation of the server lazy too.</p>
<pre class="brush: jscript; title: ; notranslate">
Server.prototype = {
  this.server.listen(this.port, this.host);
};

laze.defineAll(Server.prototype, {
  port: function () {
    return this.config.port || 8080;
  },
  host: function () {
    return this.config.host || '127.0.0.1';
  },
  server: function () {
    var server = http.createServer();
    server.on('request', this.handleRequest.bind(this));
    return server;
  }
});
</pre>
<p>I hope this post gave a good overview of using lazy attributes in JavaScript with laze &#8211; if you&#8217;re interested in reading how it works check out the <a href="https://github.com/seejohnrun/laze/blob/master/lib/laze.js">code</a> (which is pretty simple), or go straight to the github page.</p>
<p>You can also install laze via npm:</p>
<pre class="brush: bash; title: ; notranslate">
npm install laze
</pre>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/06/02/lazy-attributes-in-javascript/">Lazy Attributes in JavaScript</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/06/02/lazy-attributes-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Streaks</title>
		<link>http://www.seejohncode.com/2012/05/04/streaks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=streaks</link>
		<comments>http://www.seejohncode.com/2012/05/04/streaks/#comments</comments>
		<pubDate>Sat, 05 May 2012 02:15:26 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=719</guid>
		<description><![CDATA[<p>Yesterday, my 124-day blogging and open-source coding streak came to an end.  I&#8217;ll continue to keep the same goals, and am sad to see it go &#8211; but hopefully we&#8217;ll build it back up</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/05/04/streaks/">Streaks</a></p>]]></description>
				<content:encoded><![CDATA[<p>Yesterday, my 124-day blogging and open-source coding streak came to an end.  I&#8217;ll continue to keep the same goals, and am sad to see it go &#8211; but hopefully we&#8217;ll build it back up</p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/05/04/streaks/">Streaks</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/05/04/streaks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Do It.</title>
		<link>http://www.seejohncode.com/2012/05/02/do-it/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=do-it</link>
		<comments>http://www.seejohncode.com/2012/05/02/do-it/#comments</comments>
		<pubDate>Thu, 03 May 2012 01:43:26 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=713</guid>
		<description><![CDATA[<p># of People who do nothing is greater than # of People who make excuses to not do something is greater than # of People who talk about doing something is greater than # of People who attempt to do something is greater than # of People who do something</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/05/02/do-it/">Do It.</a></p>]]></description>
				<content:encoded><![CDATA[<p># of People who do nothing <strong>is greater than</strong></p>
<p># of People who make excuses to not do something <strong>is greater than</strong></p>
<p># of People who talk about doing something <strong>is greater than</strong></p>
<p># of People who attempt to do something <strong>is greater than</strong></p>
<p># of People who do something</p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/05/02/do-it/">Do It.</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/05/02/do-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git Bash Completion and Detail</title>
		<link>http://www.seejohncode.com/2012/05/01/git-bash-completion-and-detail/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=git-bash-completion-and-detail</link>
		<comments>http://www.seejohncode.com/2012/05/01/git-bash-completion-and-detail/#comments</comments>
		<pubDate>Tue, 01 May 2012 22:40:46 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=695</guid>
		<description><![CDATA[<p>One of the things I can&#8217;t live without is git bash integration in my $PS1.  This gives me feedback on the branch and status of my current directory.  Here&#8217;s an example screenshot: So how do you get this set up?  Here&#8217;s how I do it (in ~/.bash_profile): And then you can just include the git [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/05/01/git-bash-completion-and-detail/">Git Bash Completion and Detail</a></p>]]></description>
				<content:encoded><![CDATA[<p>One of the things I can&#8217;t live without is git bash integration in my $PS1.  This gives me feedback on the branch and status of my current directory.  Here&#8217;s an example screenshot:</p>
<p><a href="http://www.seejohncode.com/wp-content/uploads/2012/05/shot.jpg"><img class="alignnone size-full wp-image-696" title="shot" src="http://www.seejohncode.com/wp-content/uploads/2012/05/shot.jpg" alt="" width="599" height="128" /></a></p>
<p>So how do you get this set up?  Here&#8217;s how I do it (in ~/.bash_profile):</p>
<pre class="brush: bash; title: ; notranslate">
GIT_COMPLETION_PATH=/etc/bash_completion.d/git
if [ -f $GIT_COMPLETION_PATH ]; then
  . $GIT_COMPLETION_PATH
  GIT_PS1_SHOWDIRTYSTATE=true # */+ for dirty
  GIT_PS1_SHOWSTASHSTATE=true # $ for stashes
  GIT_PS1_SHOWUNTRACKEDFILES=true # % for untracked
fi
</pre>
<p>And then you can just include the git completion function in your $PS1 where you want it. My $PS1 is super simple, and just has this and the current path (and some nice colors):</p>
<pre class="brush: bash; title: ; notranslate">
export PS1=&quot;\e[0;33m\w\e[0;91m\$(__git_ps1 ' (%s)')\e[0;96m \$\e[0m &quot;
</pre>
<p>Note: the location of your git bash_completion directory may be different (especially if you installed git via homebrew).  I like to solve that with a symbolic link, instead of changing this configuration (I just find it cleaner that way &#8211; much nicer for upgrades too):</p>
<p><em>git -&gt; /usr/local/Cellar/git/1.7.9.6/etc/bash_completion.d/git-completion.bash</em></p>
<p>If you like this &#8211; read more of <a title="My dotfiles" href="http://www.seejohncode.com/2012/02/13/my-dotfiles/">my dotfiles</a></p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/05/01/git-bash-completion-and-detail/">Git Bash Completion and Detail</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/05/01/git-bash-completion-and-detail/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Git Tip: Viewing a Git Stash</title>
		<link>http://www.seejohncode.com/2012/04/30/git-tip-viewing-a-git-stash/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=git-tip-viewing-a-git-stash</link>
		<comments>http://www.seejohncode.com/2012/04/30/git-tip-viewing-a-git-stash/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 23:20:42 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=692</guid>
		<description><![CDATA[<p>I use `git stash` very often to set some code aside while I work temporarily in another branch.  Sometimes, I want to peek at what I have stashed instead of taking it out.  You can do that very easily with `git stash show`:</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/30/git-tip-viewing-a-git-stash/">Git Tip: Viewing a Git Stash</a></p>]]></description>
				<content:encoded><![CDATA[<p>I use `git stash` very often to set some code aside while I work temporarily in another branch.  Sometimes, I want to peek at what I have stashed instead of taking it out.  You can do that very easily with `git stash show`:</p>
<pre class="brush: bash; title: ; notranslate">
git stash show -p  # view a diff
</pre>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/30/git-tip-viewing-a-git-stash/">Git Tip: Viewing a Git Stash</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/04/30/git-tip-viewing-a-git-stash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: Testing Multipart Uploads with RSpec</title>
		<link>http://www.seejohncode.com/2012/04/29/quick-tip-testing-multipart-uploads-with-rspec/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=quick-tip-testing-multipart-uploads-with-rspec</link>
		<comments>http://www.seejohncode.com/2012/04/29/quick-tip-testing-multipart-uploads-with-rspec/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 01:50:27 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[spec]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=687</guid>
		<description><![CDATA[<p>I couldn&#8217;t find this practically anywhere, so I thought I&#8217;d write a quick post on how to test multi-part uploads with RSpec.  The problem is that if you try to write something like: You&#8217;ll actually be sending the string &#8220;&#60;File:&#8230;&#62;&#8221; down as a request parameter.  What you actually want is a bit more obscure, but [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/29/quick-tip-testing-multipart-uploads-with-rspec/">Quick Tip: Testing Multipart Uploads with RSpec</a></p>]]></description>
				<content:encoded><![CDATA[<p>I couldn&#8217;t find this practically anywhere, so I thought I&#8217;d write a quick post on how to test multi-part uploads with RSpec.  The problem is that if you try to write something like:</p>
<pre class="brush: ruby; title: ; notranslate">
post :photo, :file =&gt; File.open(path)
</pre>
<p>You&#8217;ll actually be sending the string &#8220;&lt;File:&#8230;&gt;&#8221; down as a request parameter.  What you actually want is a bit more obscure, but works perfectly:</p>
<pre class="brush: ruby; title: ; notranslate">
post :photo, :file =&gt; Rack::Test::UploadedFile.new(path, mime_type) # text/jpg
</pre>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/29/quick-tip-testing-multipart-uploads-with-rspec/">Quick Tip: Testing Multipart Uploads with RSpec</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/04/29/quick-tip-testing-multipart-uploads-with-rspec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Roku</title>
		<link>http://www.seejohncode.com/2012/04/28/roku/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=roku</link>
		<comments>http://www.seejohncode.com/2012/04/28/roku/#comments</comments>
		<pubDate>Sun, 29 Apr 2012 02:33:31 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=684</guid>
		<description><![CDATA[<p>I got a Roku box a few days ago &#8211; to replace my Google TV in my living room.  The Roku is definitely less powerful, can&#8217;t browse the web quite as well &#8211; but has been pretty enjoyable.  For the things it does, the Roku outperforms.  Netflix, Amazon Prime, and Hulu all felt pretty hacked [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/28/roku/">Roku</a></p>]]></description>
				<content:encoded><![CDATA[<p>I got a Roku box a few days ago &#8211; to replace my Google TV in my living room.  The Roku is definitely less powerful, can&#8217;t browse the web quite as well &#8211; but has been pretty enjoyable.  For the things it does, the Roku outperforms.  Netflix, Amazon Prime, and Hulu all felt pretty hacked into Google TV, but the Roku gives them a much more solid feel.</p>
<p>TV is a pretty exciting space, looking forward to what&#8217;s coming next &#8211; seems like it may be one of the next big battlegrounds as we head towards making computers even more ubiquitous.</p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/28/roku/">Roku</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/04/28/roku/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sopatrack Update</title>
		<link>http://www.seejohncode.com/2012/04/27/sopatrack-update/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sopatrack-update</link>
		<comments>http://www.seejohncode.com/2012/04/27/sopatrack-update/#comments</comments>
		<pubDate>Sat, 28 Apr 2012 01:42:34 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[cispa]]></category>
		<category><![CDATA[pipa]]></category>
		<category><![CDATA[sopa]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=680</guid>
		<description><![CDATA[<p>With this whole CISPA mess heating up, I thought it&#8217;d be good to write an update post (here&#8217;s the original) about a recent update that was made to Randy&#8217;s site, Sopatrack. With the new update, comes a lot more data to view, and the expansion (despite the name) beyond SOPA to other bills in Congress. [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/27/sopatrack-update/">Sopatrack Update</a></p>]]></description>
				<content:encoded><![CDATA[<p>With this whole <a href="http://www.washingtonpost.com/business/technology/cispa-whos-for-it-whos-against-it-and-how-it-could-affect-you/2012/04/27/gIQA5ur0lT_story.html">CISPA mess</a> heating up, I thought it&#8217;d be good to write an update post (<a href="http://www.seejohncode.com/2012/01/16/stop-sopa-and-pipa/">here&#8217;s the original</a>) about a recent update that was made to Randy&#8217;s site, <a href="http://sopatrack.com/">Sopatrack</a>.</p>
<p>With the new update, comes a lot more data to view, and the expansion (despite the name) beyond SOPA to other bills in Congress.  The re-design really helps to make the raw data more clear.  My favorite page is the <a href="http://sopatrack.com/bills">bills page</a>, which breaks down funding on supporting and opposing sides for each bill.</p>
<p>Check it out, and keep your <a href="http://sopatrack.com/congresspeople">congresspeople</a> responsible!</p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/27/sopatrack-update/">Sopatrack Update</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/04/27/sopatrack-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino: Combination Lock Opener</title>
		<link>http://www.seejohncode.com/2012/04/26/arduino-combination-lock-opener/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=arduino-combination-lock-opener</link>
		<comments>http://www.seejohncode.com/2012/04/26/arduino-combination-lock-opener/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 02:21:59 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[arduino]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=676</guid>
		<description><![CDATA[<p>So I&#8217;ve started in on my first Arduino project &#8211; an automatic combination lock opener.  It&#8217;ll automatically turn and guess the combination for a Master lock like this.  It&#8217;ll have a screen to display its current combination attempt, and will spin the dial itself.  I thought for a while about it, and I think I [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/26/arduino-combination-lock-opener/">Arduino: Combination Lock Opener</a></p>]]></description>
				<content:encoded><![CDATA[<p>So I&#8217;ve started in on my first Arduino project &#8211; an automatic combination lock opener.  It&#8217;ll automatically turn and guess the combination for a Master lock <a href="http://www.northerntool.com/images/product/images/17856_lg.jpg">like this</a>.  It&#8217;ll have a screen to display its current combination attempt, and will spin the dial itself.  I thought for a while about it, and I think I have some really neat ideas to make it more interesting:</p>
<ol>
<li>An optimization can be made by taking advantage of the lock&#8217;s imperfect positioning, and instead of trying every number, trying every other number first.</li>
<li>Based on where 1 spin ends, you can make the next move you choose to make start close to the end position of your last move.</li>
<li>The last turn, you can spin the lock and continually attempt opening, without re-trying the combinations.</li>
</ol>
<p>So, my hopes are that with these optimizations, I can go from:</p>
<ul>
<li>1st dial &#8211; 40 possibilities</li>
<li>2nd dial &#8211; 40 possibilities</li>
<li>3rd dial &#8211; 40 possibilities</li>
<li>40 * 40 * 40 = 64000 combinations</li>
</ul>
<p>To:</p>
<ul>
<li>1st dial &#8211; 20 possibilities</li>
<li>2nd dial &#8211; 20 possibilities</li>
<li>3rd dial &#8211; spinning as I go</li>
<li>20 * 20 * 1 = 400 combinations</li>
</ul>
<p>I&#8217;ll post here updates as I have them, and hopefully soon we&#8217;ll have a cool combination lock unlocker.</p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/26/arduino-combination-lock-opener/">Arduino: Combination Lock Opener</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/04/26/arduino-combination-lock-opener/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Async.js is Boss</title>
		<link>http://www.seejohncode.com/2012/04/25/async-js-is-boss/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=async-js-is-boss</link>
		<comments>http://www.seejohncode.com/2012/04/25/async-js-is-boss/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 03:47:42 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=672</guid>
		<description><![CDATA[<p>A JavaScript library I really like is async by caolan.  It makes common tasks for multiple async operations really natural, which is especially useful for Node programming. Check it out!</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/25/async-js-is-boss/">Async.js is Boss</a></p>]]></description>
				<content:encoded><![CDATA[<p>A JavaScript library I really like is <a href="https://github.com/caolan/async">async by caolan</a>.  It makes common tasks for multiple async operations really natural, which is especially useful for Node programming.</p>
<p>Check it out!</p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/25/async-js-is-boss/">Async.js is Boss</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/04/25/async-js-is-boss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding the Caller in Ruby</title>
		<link>http://www.seejohncode.com/2012/04/24/finding-the-caller-in-ruby/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=finding-the-caller-in-ruby</link>
		<comments>http://www.seejohncode.com/2012/04/24/finding-the-caller-in-ruby/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 23:59:55 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=667</guid>
		<description><![CDATA[<p>In Ruby, it can be really useful to know, in the flow of execution, the call stack within a certain method.  For that we have Kernel#caller. #caller returns an Array representing the current call stack, where each element is a String like &#8220;file:line in &#8216;name&#8217;&#8221;.  Here&#8217;s an example: which will output: ex.rb:8:in `do_it' ex.rb:11:in `&#60;main&#62;'</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/24/finding-the-caller-in-ruby/">Finding the Caller in Ruby</a></p>]]></description>
				<content:encoded><![CDATA[<p>In Ruby, it can be really useful to know, in the flow of execution, the call stack within a certain method.  For that we have Kernel#caller.</p>
<p>#caller returns an Array representing the current call stack, where each element is a String like &#8220;file:line in &#8216;name&#8217;&#8221;.  Here&#8217;s an example:</p>
<pre class="brush: ruby; title: ; notranslate">
def actually_do_it
  caller.join(&quot;\n&quot;)
end

def do_it
  actually_do_it
end

puts do_it
</pre>
<p>which will output:</p>
<pre>ex.rb:8:in `do_it'
ex.rb:11:in `&lt;main&gt;'</pre>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/24/finding-the-caller-in-ruby/">Finding the Caller in Ruby</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/04/24/finding-the-caller-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Path Dependencies with Bundler</title>
		<link>http://www.seejohncode.com/2012/04/23/path-dependencies-with-bundler/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=path-dependencies-with-bundler</link>
		<comments>http://www.seejohncode.com/2012/04/23/path-dependencies-with-bundler/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 00:14:16 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[bundler]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=665</guid>
		<description><![CDATA[<p>I&#8217;m a big fan of splitting up applications into separate pieces whenever possible.  This is especially convenient in Ruby with tools like bundler &#38; rubygems to make modularization a breeze. Often when I turn something into a gem, I want to work on my application and its dependency at the same time.  For that reason, [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/23/path-dependencies-with-bundler/">Path Dependencies with Bundler</a></p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m a big fan of splitting up applications into separate pieces whenever possible.  This is especially convenient in Ruby with tools like bundler &amp; rubygems to make modularization a breeze.</p>
<p>Often when I turn something into a gem, I want to work on my application and its dependency at the same time.  For that reason, bundler let&#8217;s you declare dependencies by path, instead of rebuilding:</p>
<p>If a normally line in your Gemfile looks like:</p>
<pre class="brush: ruby; title: ; notranslate">
gem 'autodoc'
</pre>
<p>you can specify a path as an argument to `gem` like:</p>
<pre class="brush: ruby; title: ; notranslate">
gem 'autodoc', :path =&gt; '/Users/john/Development/autodoc'
</pre>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/23/path-dependencies-with-bundler/">Path Dependencies with Bundler</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/04/23/path-dependencies-with-bundler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vim: Git Plugin</title>
		<link>http://www.seejohncode.com/2012/04/22/vim-git-plugin/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vim-git-plugin</link>
		<comments>http://www.seejohncode.com/2012/04/22/vim-git-plugin/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 03:04:29 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.seejohncode.com/?p=662</guid>
		<description><![CDATA[<p>Another vim plugin I love enough to feature here is git-vim which gives you convenient access to git commands from inside of vim.  I only use a few of them (and only in their base form) &#8211; but I find them pretty indispensable: :GitLog Will open a git log in a new buffer of the changes to [...]</p><p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/22/vim-git-plugin/">Vim: Git Plugin</a></p>]]></description>
				<content:encoded><![CDATA[<p>Another vim plugin I love enough to feature here is <a href="https://github.com/motemen/git-vim">git-vim</a> which gives you convenient access to git commands from inside of vim.  I only use a few of them (and only in their base form) &#8211; but I find them pretty indispensable:</p>
<p><strong>:GitLog</strong></p>
<p>Will open a git log in a new buffer of the changes to the current file</p>
<p><strong>:GitBlame</strong></p>
<p>Will open a vertical buffer containing the line-by-line blame of the current file</p>
<p><strong>:GitDiff</strong></p>
<p>Will open a buffer next to the existing buffer, with its current diff</p>
<p><hr>

Read this post on <a href="http://www.seejohncode.com/2012/04/22/vim-git-plugin/">Vim: Git Plugin</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.seejohncode.com/2012/04/22/vim-git-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
