<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title>Jon Allured</title>
	<link href="http://jonallured.com/atom.xml" rel="self"/>
	<link href="http://jonallured.com/"/>
	<updated>2012-02-19T10:25:08-08:00</updated>
	<id>http://jonallured.com/</id>
	<author>
		<name>Jon Allured</name>
		<email>jon@jonallured.com</email>
	</author>

	<entry>
		<title>Johnson on :before and :after in CSS; Clayton on Rails Config</title>
		<link href="http://jonallured.com/2012/02/13/johnson-on-before-and-after-in-css-clayton-on-rails-config.html"/>
		<updated>2012-02-13T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/02/13/johnson-on-before-and-after-in-css-clayton-on-rails-config</id>
		<content type="html">&lt;h1 id='johnson_on_before_and_after_in_css_clayton_on_rails_config'&gt;Johnson on :before and :after in CSS; Clayton on Rails Config&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Monday, February 13, 2012&lt;/p&gt;
&lt;p&gt;Joshua Johnson writing for Design Shack &lt;a href='http://designshack.net/articles/css/the-lowdown-on-before-and-after-in-css/'&gt;explains&lt;/a&gt; how the &lt;code&gt;:before&lt;/code&gt; and &lt;code&gt;:after&lt;/code&gt; CSS pseudo-elements work. I was confused about why he was calling them pseudo-elements and not a pseudo-class like &lt;code&gt;:hover&lt;/code&gt; or &lt;code&gt;:active&lt;/code&gt;, so it was nice that he anticipated this confusion and started out by addressing it. The difference between these two parts of CSS turns out to be pretty simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;pseudo-classes target an entire element, think &lt;code&gt;a:hover&lt;/code&gt; &amp;#8211; the entire link is styled&lt;/li&gt;

&lt;li&gt;pseudo-elements target a part of an element, think &lt;code&gt;p::first-letter&lt;/code&gt; &amp;#8211; just the first letter of the &lt;code&gt;p&lt;/code&gt; is styled&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the CSS3 spec, pseudo-elements use two colons and pseudo-classes just need one &amp;#8211; prior to this clarification both types would use just one. Johnson then tells us that he usually sees &lt;code&gt;:before&lt;/code&gt;, not &lt;code&gt;::before&lt;/code&gt; and explains that its because IE8 doesn&amp;#8217;t understand the double-colon syntax and since the single-colon version still works, most developers use that form.&lt;/p&gt;

&lt;p&gt;So, with these distinction out of the way, Johnson goes into what &lt;code&gt;:before&lt;/code&gt; and &lt;code&gt;:after&lt;/code&gt; are. They allow one to add content either before or after an element without having to actually add this content to the markup. You use this selector and then use the &lt;code&gt;content&lt;/code&gt; property, like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;.phoneNumber:before {
  content: &amp;quot;&amp;amp;#9742;&amp;quot;;
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This would add the phone glyph (&amp;#9742;) before any element with the &lt;code&gt;phoneNumber&lt;/code&gt; class.&lt;/p&gt;

&lt;p&gt;And then &lt;code&gt;:after&lt;/code&gt; is the same way. This is a neat example that gives a simple idea of why one would use the pseudo-elements, but then his next example shows how fancy one can get with this technique by styling a button with just the barest amount of markup. The button example actually seems a little crazy to me but its impressive nonetheless.&lt;/p&gt;

&lt;p&gt;Johnson finishes up by showing a couple obscure uses of &lt;code&gt;:before&lt;/code&gt; and &lt;code&gt;:after&lt;/code&gt;. First, using them to clear floats and second, to create pure-CSS shapes. This was a good write up and I appreciated the time he took to find out a little more about these selectors.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I&amp;#8217;ve recently been thinking about configuring Rails apps mostly because I&amp;#8217;m tired of having a file full of environment variables for all the apps I run locally that has to be loaded in my shell to match those at Heroku. What I wanted to move to was a setup where the config file for each environment could decide if it should use environment variables (production) or just parse them out of a YAML file not checked into the repo (development).&lt;/p&gt;

&lt;p&gt;So, when I saw &lt;a href='http://robots.thoughtbot.com/post/16466303962/inject-that-rails-configuration-dependency?a408c0a0'&gt;the post&lt;/a&gt; Josh Clayton did on injecting Rails configuration into tests the thing that stood out most was actually how he was using the config:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Doit::Application.config.default_creator&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I&amp;#8217;ve been doing this same thing another way &amp;#8211; using the &lt;code&gt;Rails&lt;/code&gt; object, so like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Rails.configuration.default_creator&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Reading Josh&amp;#8217;s post I realized these are both ways to accomplish the same thing.&lt;/p&gt;

&lt;p&gt;But his point was more about testing with these configuration settings. What Clayton is saying is that you shouldn&amp;#8217;t be stubbing at the application config level, instead inject a dependency on this information into your model and then test that. There are some good examples and I liked how he approached this.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Marston on Sinatra's Halt; Jones on Sinatra vs. Rails; Bernhardt on Learning Vim</title>
		<link href="http://jonallured.com/2012/02/08/marston%E2%80%93on-sinatras-halt-jones-on-sinatra-vs-rails-bernhardt-on-learning-vim.html"/>
		<updated>2012-02-08T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/02/08/marston–on-sinatras-halt-jones-on-sinatra-vs-rails-bernhardt-on-learning-vim</id>
		<content type="html">&lt;h1 id='marston_on_sinatras_halt_jones_on_sinatra_vs_rails_bernhardt_on_learning_vim'&gt;Marston on Sinatra&amp;#8217;s Halt; Jones on Sinatra vs. Rails; Bernhardt on Learning Vim&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Wednesday, February 8, 2012&lt;/p&gt;
&lt;p&gt;Myron Marston did a quick write up on &lt;a href='http://myronmars.to/n/dev-blog/2012/01/why-sinatras-halt-is-awesome'&gt;why &lt;code&gt;halt&lt;/code&gt; is so awesome in Sinatra&lt;/a&gt;. I&amp;#8217;ve actually used it before, but its been a while, so this was a good reminder. Also, the way he demonstrated it with the different status codes depending on the error that happened was pretty sweet.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Darren Jones writing for Ruby Source &lt;a href='http://rubysource.com/rails-or-sinatra-the-best-of-both-worlds/'&gt;explores&lt;/a&gt; the differences and similarities of Sinatra and Rails by asking around and writing up what people say. Having used both and experienced the pain of choosing Sinatra and regretting it later when things got more complex, many of the comments rang true. My main take away from this post and my own experience is that Sinatra can be a great tool to build an API or do a quick prototype, but as the scope and complexity increase you&amp;#8217;ll quickly want some of the niceties of Rails.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Watched &lt;a href='https://www.destroyallsoftware.com/screencasts/catalog/some-vim-tips'&gt;Destroy All Software 30: Some Vim Tips&lt;/a&gt; and really enjoyed it. Gary Bernhardt goes through some things that he thinks might help someone learn Vim and some strategies for pushing yourself to get better. One of his first pieces of advice is to look at the keyboard and find keys where you can&amp;#8217;t name what they do in Vim and then find out. Go from the keys themselves to shifted keys to controlled keys.&lt;/p&gt;

&lt;p&gt;He also talks about trying to train yourself to recognize when you are repeating yourself and practice pausing to think of a better way. I&amp;#8217;m definitely guilty of repeating myself, I usually do press &amp;#8220;j&amp;#8221; over and over to move down a page, so I need to work on that.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Making URLs Pretty; Uncle Bob on SRP; Grimm on ActiveRecord Associations; Heilmann on classList</title>
		<link href="http://jonallured.com/2012/02/07/making-urls-pretty-uncle-bob-on-srp-grimm-on-activerecord-associations-heilmann-on-classlist.html"/>
		<updated>2012-02-07T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/02/07/making-urls-pretty-uncle-bob-on-srp-grimm-on-activerecord-associations-heilmann-on-classlist</id>
		<content type="html">&lt;h1 id='making_urls_pretty_uncle_bob_on_srp_grimm_on_activerecord_associations_heilmann_on_classlist'&gt;Making URLs Pretty; Uncle Bob on SRP; Grimm on ActiveRecord Associations; Heilmann on classList&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Tuesday, February 7, 2012&lt;/p&gt;
&lt;p&gt;Watched &lt;a href='http://railscasts.com/episodes/314-pretty-urls-with-friendlyid'&gt;RailsCasts 314: Pretty URLs with FriendlyId&lt;/a&gt; and learned that Rails uses a method on its Models called &lt;code&gt;#to_param&lt;/code&gt; to decide what to put in a show path. This means you can override it and use something besides an id:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class Post &amp;lt; ActiveRecord::Base
  def to_param
    post.title.parameterize
  end
end

# gives you this path:
/posts/title-of-post&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But if you leave off the id, then your &lt;code&gt;ActiveRecord#find&lt;/code&gt; is going to be a pain &amp;#8211; this is where &lt;a href='https://github.com/norman/friendly_id'&gt;&lt;code&gt;friendly_id&lt;/code&gt;&lt;/a&gt; comes in. You &lt;code&gt;extend&lt;/code&gt; your model with &lt;code&gt;FriendlyId&lt;/code&gt; and then you can use the &lt;code&gt;friendly_id&lt;/code&gt; method to set which column to use in the url.&lt;/p&gt;

&lt;p&gt;There&amp;#8217;s an option to create slugs for your objects that will make your friendly urls even more friendly by taking that column and applying some formatting rules to it. You can also store the history of a slug&amp;#8217;s value so that when you change it the old values will still work.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I was reading &lt;a href='http://blog.8thlight.com/uncle-bob/2012/02/01/Service-Oriented-Agony.html'&gt;Uncle Bob&amp;#8217;s post&lt;/a&gt; about running a retrospective on an app that&amp;#8217;s partitioned into services. Its an interesting walk through of what happened and how it caused pain for the developers. He gets to a point where he&amp;#8217;s reminding us about what the Single Responsibility Principle means. I usually think about that principle when I&amp;#8217;m looking at a Class that does more than one thing, but as I was reading his definition I realized that there&amp;#8217;s another side to it: grouping together things that change together. Kind of an &amp;#8220;ah-ha&amp;#8221; moment for me: I was only internalizing half of the principle.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Avdi Grimm &lt;a href='http://avdi.org/devblog/2012/01/19/activerecord-default-association-extensions/'&gt;reminds us&lt;/a&gt; of just how awesome &lt;code&gt;#scoped&lt;/code&gt; is, this time in the context of wanting to define a method on a collection of ActiveRecord associations. Pretty neat.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Learned about the HTML &lt;code&gt;classList&lt;/code&gt; property from a &lt;a href='http://hacks.mozilla.org/2012/01/hidden-gems-of-html5-classlist/'&gt;write up&lt;/a&gt; by Chris Heilmann. Its not implemented in every browser, IE being the glaring problem, but its still interesting.&lt;/p&gt;

&lt;p&gt;This property is an array-like object with the classes on a given DOM node and it comes with a handful of helpful functions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;element.classList&lt;/code&gt;: returns an array of classes&lt;/li&gt;

&lt;li&gt;&lt;code&gt;element.classList.add(&amp;#39;some-class&amp;#39;)&lt;/code&gt;: add &amp;#8216;some-class&amp;#8217; to &lt;code&gt;element&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;&lt;code&gt;element.classList.remove(&amp;#39;another-class&amp;#39;)&lt;/code&gt;: remove &amp;#8216;another-class&amp;#8217; from &lt;code&gt;element&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;&lt;code&gt;element.classList.contains(&amp;#39;some-class&amp;#39;)&lt;/code&gt;: does &lt;code&gt;element&lt;/code&gt; have class &amp;#8216;some-class&amp;#8217; (returns boolean)&lt;/li&gt;

&lt;li&gt;&lt;code&gt;element.classList.toggle(&amp;#39;some-class&amp;#39;)&lt;/code&gt;: either add or remove &amp;#8216;some-class&amp;#8217; on &lt;code&gt;element&lt;/code&gt;, depending on whether its already on there&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hadn&amp;#8217;t heard of this one before, so it was fun to play around with it in the console, works much better than the days of managing classes by hand!&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Klabnik on Moving from Sinatra to Rails and Acceptance vs. Integration Tests</title>
		<link href="http://jonallured.com/2012/02/06/klabnik-on-moving-from-sinatra-to-rails-and-acceptance-vs-integration-tests.html"/>
		<updated>2012-02-06T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/02/06/klabnik-on-moving-from-sinatra-to-rails-and-acceptance-vs-integration-tests</id>
		<content type="html">&lt;h1 id='klabnik_on_moving_from_sinatra_to_rails_and_acceptance_vs_integration_tests'&gt;Klabnik on Moving from Sinatra to Rails and Acceptance vs. Integration Tests&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Monday, February 6, 2012&lt;/p&gt;
&lt;p&gt;I recently had a conversation with fellow Rocketeer &lt;a href='https://twitter.com/higgaion'&gt;Brian Dunn&lt;/a&gt; about the difference between Acceptance and Integration testing. I&amp;#8217;ve always been a little fuzzy about what the two terms meant, but Steve Klabnik&amp;#8217;s post about &lt;a href='http://blog.steveklabnik.com/posts/2012-01-17-moving-from-sinatra-to-rails'&gt;moving from Sinatra to Rails&lt;/a&gt; prompted me to finally bring it up.&lt;/p&gt;

&lt;p&gt;What he helped me see is that Acceptance and Integration tests are similar in that they are written at a higher level than a Unit test, but Acceptance tests aren&amp;#8217;t meant to interact with code at all. When you use Cucumber for this level of testing, that means an Integration test might look like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Given a translator that has been assigned a task
When I navigate to the assignement list
Then I should see an assignment for that task and translator&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And the maybe its defined with something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Given &amp;#39;a translator that has been assigned a task&amp;#39; do
  @translator = Fabricate :translator
  @task = Fabricate :task
  @translator.assign @task
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That would be a reasonable Integration test for this step, but wouldn&amp;#8217;t cut it if we were writing an Acceptance test. For that type of test, we&amp;#8217;d need to create the Translator, the Task and then assign it using only the interface, maybe something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Given I create a new translator
And I fill out the translator creation form
And I create a new task
And I fill out the task creation form
And I create a new assignment
And I fill out the assignment form
When I navigate to the assignement list
Then I should see an assignment for that task and translator&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And then you&amp;#8217;d have a bunch of work to do to define these steps using only Capybara.&lt;/p&gt;

&lt;p&gt;Or something like that, anyway &amp;#8211; the point is that what is one easy step in an Integration test turns into a lot of steps taking nothing for granted in an Acceptance test.&lt;/p&gt;

&lt;p&gt;Its no surprise that in the context of moving from Sinatra to Rails, Klabnik tells us that our Acceptance tests are our most valuable tool to make sure our code works the way we intend for it to work. In fact, he suggests evaluating how well your Acceptance tests cover the app and writing a few more of this type of test where you see spotty coverage.&lt;/p&gt;

&lt;p&gt;He mentions that he normally writes only happy path Acceptance tests and then uses a term I hadn&amp;#8217;t heard before: the sad path. Can&amp;#8217;t believe I hadn&amp;#8217;t run into that before.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m very much a fan of this idea that you should get quick wins and use that momentum to get to bigger problems later. I always find myself wanting to do the hardest stuff last and then when I get to it, I&amp;#8217;ve built up a head of steam and I feel like I get it done better than if I had started it first.&lt;/p&gt;

&lt;p&gt;Another thing that jumped out was his note about how Rails and Sinatra have different redirection methods &amp;#8211; I&amp;#8217;ve always been annoyed by this.&lt;/p&gt;

&lt;p&gt;Klabnik advises us to resist the urge to simultaneously move code over and convert it to the Rails style &amp;#8211; he&amp;#8217;d rather see you move it over with as few modifications as possible, get it working and then refactor.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve never had to make the move from Sinatra to Rails, but I think his ideas are pretty sound and would try this approach if this did come up in my work.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Hagemann on Testing Rake Tasks; SPDY in FireFox 11; RVM Using Git Flow</title>
		<link href="http://jonallured.com/2012/02/05/hagemann-on-testing-rake-tasks-spdy-in-firefox-11-rvm-using-git-flow.html"/>
		<updated>2012-02-05T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/02/05/hagemann-on-testing-rake-tasks-spdy-in-firefox-11-rvm-using-git-flow</id>
		<content type="html">&lt;h1 id='hagemann_on_testing_rake_tasks_spdy_in_firefox_11_rvm_using_git_flow'&gt;Hagemann on Testing Rake Tasks; SPDY in FireFox 11; RVM Using Git Flow&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Sunday, February 5, 2012&lt;/p&gt;
&lt;p&gt;Stephan Hagemann had a good &lt;a href='http://pivotallabs.com/users/shagemann/blog/articles/1967-test-your-rake-tasks-'&gt;post on testing Rake tasks&lt;/a&gt;. What I liked about it was the &amp;#8220;before/after&amp;#8221; structure of the post &amp;#8211; first he shows the anti-pattern and then he describes the approach he prefers. This is a good model for technical posts of this nature and I will try to remember it for my own writing.&lt;/p&gt;

&lt;p&gt;The content was great too &amp;#8211; I&amp;#8217;ve always been a little lost when it comes to testing Rake tasks, but Hagemann&amp;#8217;s suggestions seem like good ones.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;SPDY just &lt;a href='http://hacks.mozilla.org/2012/02/spdy-brings-responsive-and-scalable-transport-to-firefox-11/'&gt;landed in FireFox 11&lt;/a&gt;. SPDY is a protocol for transporting web content. You&amp;#8217;ve probably heard of HTTP, another protocol for transporting web content, so what makes SPDY different? Its the way it prioritizes and multiplexes the downloading of web page elements such that only one connection is made to the server. The exact technical details are over my head, but this is good work that could make some headaches for web developers a little easier. I&amp;#8217;m especially excited about it for mobile devices where server connections aren&amp;#8217;t cheap over lousy 3G connections.&lt;/p&gt;

&lt;p&gt;I first heard about it on &lt;a href='http://5by5.tv/hypercritical/36'&gt;an episode of Hypercritical&lt;/a&gt; and thought it was neat but maybe just a wacky Google experiment that would never go anywhere, so I was fairly surprised to see that Mozilla took a run at it for their Browser.&lt;/p&gt;

&lt;p&gt;Its not an official spec yet, but its going that way &amp;#8211; it will be interesting to see if its implemented by Opera, Microsoft or Apple, but I think its something to watch.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;The RVM team switched to using the &lt;a href='http://nvie.com/posts/a-successful-git-branching-model/'&gt;Git Flow&lt;/a&gt; approach to structuring their project and have &lt;a href='http://www.engineyard.com/blog/2012/rvm-stable-and-more'&gt;finished the transition&lt;/a&gt;, so now you can run:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rvm get stable&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And you&amp;#8217;ll stay on the stable branch. Neato. Check that post for a few other changes to the behavior of RVM.&lt;/p&gt;

&lt;p&gt;I had heard of Git Flow before, but took this as an opportunity to read up about it. After reading Vincent Driessen&amp;#8217;s original post about Git Flow (above), I found Jeff Kreeftmeijer&amp;#8217;s post on &lt;a href='http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/'&gt;why he likes this approach so much&lt;/a&gt;. He talks about using the &lt;a href='https://github.com/nvie/gitflow'&gt;git extensions&lt;/a&gt; and how he uses them in various situations. I enjoyed thinking about another workflow and would be interested in trying this system in a future project.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>The Simpleton Pattern; When to Include, When to Extend</title>
		<link href="http://jonallured.com/2012/01/31/the-simpleton-pattern-when-to-include-when-to-extend.html"/>
		<updated>2012-01-31T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/31/the-simpleton-pattern-when-to-include-when-to-extend</id>
		<content type="html">&lt;h1 id='the_simpleton_pattern_when_to_include_when_to_extend'&gt;The Simpleton Pattern; When to Include, When to Extend&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Monday, January 30, 2012&lt;/p&gt;
&lt;p&gt;After &lt;a href='http://jonallured.com/2012/01/27/brown-on-the-singleton-in-ruby.html'&gt;my post on the Singleton pattern&lt;/a&gt;, fellow Rocketeer &lt;a href='http://twitter.com/voxdolo'&gt;Stephen Caudill&lt;/a&gt; directed me towards Steve Yegge&amp;#8217;s post on the &lt;a href='https://sites.google.com/site/steveyegge2/singleton-considered-stupid'&gt;Simpleton Pattern&lt;/a&gt;. Its a fairly snarky post, but there&amp;#8217;s real insight to be had. I think his main point is that the Singleton pattern is overused and that its usually bad design to use it because of its global nature.&lt;/p&gt;

&lt;p&gt;Yegge says that the Singleton is actually a throwback to non OO programming, that it is an escape hatch one can use when OO gets too intense. He talks about how he loved this pattern and used it quite a bit until he realized that all he was doing was using these classes as namespaces for global functions. Its great to read criticism like this, helps me have a more well-rounded view of things.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I haven&amp;#8217;t had much experience with writing Modules in Ruby and so I&amp;#8217;ve always been a little confused about the difference between &lt;code&gt;include&lt;/code&gt; and &lt;code&gt;extend&lt;/code&gt;, but Aaron Lasseigne&amp;#8217;s &lt;a href='http://ficate.com/explaining-include-and-extend'&gt;write up on the topic&lt;/a&gt; was really helpful. He starts out by giving us the common definition of when you use one or the other:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You &lt;strong&gt;include&lt;/strong&gt; a module to add instance methods to a class and &lt;strong&gt;extend&lt;/strong&gt; to add class methods.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;He goes on to explain why this isn&amp;#8217;t the whole story, staring with how instance and class methods are stored. So, given this class:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class Klass
  def foo; end
  def self.bar; end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can find &lt;code&gt;#foo&lt;/code&gt; and &lt;code&gt;.bar&lt;/code&gt; like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Klass.new.methods - methods # =&amp;gt; [:foo]
Klass.methods - Object.methods # =&amp;gt; [:bar]
Klass.singleton_methods # =&amp;gt; [:bar]&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I had never seen &lt;code&gt;Object#singleton_methods&lt;/code&gt; before and I got curious what else was out there, so I jumped over to &lt;code&gt;irb&lt;/code&gt; and ran:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Object.methods.select {|method| method.to_s =~ /single/}
# =&amp;gt; [:singleton_class, :singleton_methods, :define_singleton_method]&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And this is when I remembered some conversations &lt;a href='http://twitter.com/higgaion'&gt;Brian Dunn&lt;/a&gt; (another Rocketeer) and I have had about the eigenclass. I went hunting for more information to make sure I was putting this together correctly and found a &lt;a href='http://blog.madebydna.com/all/code/2011/06/24/eigenclasses-demystified.html'&gt;write up&lt;/a&gt; from Andrea Singh that confirmed it.&lt;/p&gt;

&lt;p&gt;When &lt;code&gt;.bar&lt;/code&gt; is defined for Klass, its actually being defined on the eigenclass of Klass, thus the &lt;code&gt;singleton_methods&lt;/code&gt; method inspects this for methods and that&amp;#8217;s what its returning.&lt;/p&gt;

&lt;p&gt;Lasseigne then defines &lt;code&gt;include&lt;/code&gt; and &lt;code&gt;extend&lt;/code&gt; with this information in mind:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;include:&lt;/strong&gt; adds methods from the provided Module to the object&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;extend:&lt;/strong&gt; calls include on the singleton class (eigenclass) of the object&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Reading these two posts and their diagrams really helped clarify that the Eigenclass is just another name for the Singleton class that&amp;#8217;s created when you define methods on an object and the relationship between Module instance methods and class methods with the thing that&amp;#8217;s getting them mixed in.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Brown on Creational Design Patterns in Ruby</title>
		<link href="http://jonallured.com/2012/01/30/brown-on-creational-design-patterns-in-ruby.html"/>
		<updated>2012-01-30T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/30/brown-on-creational-design-patterns-in-ruby</id>
		<content type="html">&lt;h1 id='brown_on_creational_design_patterns_in_ruby'&gt;Brown on Creational Design Patterns in Ruby&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Monday, January 30, 2012&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve read Gregory Brown&amp;#8217;s post on &lt;a href='http://jonallured.com/2012/01/20/brown-on-structural-design-patterns-in-ruby.html'&gt;structural design patterns&lt;/a&gt; in Ruby and I&amp;#8217;ve also spent some time with a couple of his write ups focusing on just &lt;a href='http://jonallured.com/2012/01/27/brown-on-the-singleton-in-ruby.html'&gt;the Singleton pattern&lt;/a&gt;. Next I wanted to finish the rest of the &lt;a href='http://blog.rubybestpractices.com/posts/gregory/059-issue-25-creational-design-patterns.html'&gt;creational patterns&lt;/a&gt; - as in the post on structural patterns, his aim is not to explain each pattern as much as it is to show some examples of the patterns in real Ruby code.&lt;/p&gt;

&lt;h2 id='multiton'&gt;Multiton&lt;/h2&gt;

&lt;p&gt;This pattern shares some similarities with the Singleton, if fact its really just a Singleton where you want to have unique instances for each key used. The example Brown uses from Prawn was pretty clear and I was able to see the pattern shine through.&lt;/p&gt;

&lt;p&gt;I hadn&amp;#8217;t run into &lt;code&gt;Hash.update&lt;/code&gt; before - its called on a hash and passed another hash and it combines them with the key/value pairs from the argument overriding those of the hash its called on.&lt;/p&gt;

&lt;h2 id='factory_method'&gt;Factory Method&lt;/h2&gt;

&lt;p&gt;To help describe this pattern, Brown starts by walking us through some code a student of his was writing. This code started as a typical Ruby class that had a boolean as an argument. It was quickly suggested that instead of this, a hash be used:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# starts this way
class AdjacencyMatrix
  def initialize(data, directed=false)
    # some code
  end
end

undirected_matrix = AdjacencyMatrix.new(data)
directed_matrix   = AdjacencyMatrix.new(data, true)

# refactored with an options hash
class AdjacencyMatrix
  def initialize(data, options)
    directed = options[:directed]
    # some code
  end
end

undirected_matrix = AdjacencyMatrix.new(data)
directed_matrix   = AdjacencyMatrix.new(data, :directed =&amp;gt; true)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Having an options hash like this is a good start, but in this case it made sense to use the Factory pattern:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class AdjacencyMatrix
  class &amp;lt;&amp;lt; self
    def undirected(data)
      new(data)
    end

    def directed(data)
      new(data,true)
    end

    private :new
  end

  def initialize(data, directed=false)
    #...
  end
end

undirected_matrix = AdjacencyMatrix.undirected(data)
directed_matrix   = AdjacencyMatrix.directed(data)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So the &lt;code&gt;#undirected&lt;/code&gt; and &lt;code&gt;#directed&lt;/code&gt; class methods are builder methods. Rather than calling &lt;code&gt;#new&lt;/code&gt;, you call one of these and they instantiate your object in the desired state.&lt;/p&gt;

&lt;h2 id='abstract_factory'&gt;Abstract Factory&lt;/h2&gt;

&lt;p&gt;This one was harder to deal with. From what Brown says, this pattern doesn&amp;#8217;t really make that much sense in Ruby because of &amp;#8220;the flexible nature of Ruby’s type system&amp;#8221;, whatever that means. All I really got from this one is that I probably don&amp;#8217;t need to worry about it and that&amp;#8217;s fine by me.&lt;/p&gt;

&lt;h2 id='builder'&gt;Builder&lt;/h2&gt;

&lt;p&gt;The Builder pattern is another one where Brown feels Ruby&amp;#8217;s dynamic nature means its not necessary for some formal construct. Instead there&amp;#8217;s a spirit of the Builder pattern that can be used:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;[C]reate an abstract blueprint describing the steps of creating an object, and then allow many different implementations to actually carry out that process as long as they provide the necessary steps.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;He gives us an example from code he&amp;#8217;s written and it made sense, but didn&amp;#8217;t really jump out at me as something I&amp;#8217;ve had to deal with in my own code.&lt;/p&gt;

&lt;h2 id='prototype'&gt;Prototype&lt;/h2&gt;

&lt;p&gt;The last pattern is another one where Brown doesn&amp;#8217;t have much concrete to say. He talks about it in a theoretical way, but admits that he can&amp;#8217;t come up with a meaningful example where it might be helpful in Ruby.&lt;/p&gt;

&lt;h2 id='reflections'&gt;Reflections&lt;/h2&gt;

&lt;p&gt;With that Brown goes into some notes about writing this post and what he&amp;#8217;s taken away from it. He talks about how he feels design patterns are an advanced topic that can be challenging for beginner and intermediate developers. I don&amp;#8217;t know how Brown would judge me, but I felt like some of the patterns are pretty easy to get and others are vague and hard to get much out of.&lt;/p&gt;

&lt;p&gt;For me the main thing is to be exposed to this stuff so that when it comes up on conversation with other developers, we have the same vocabulary with which to discuss design and Brown seems to agree with this.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Brown on the Singleton in Ruby</title>
		<link href="http://jonallured.com/2012/01/27/brown-on-the-singleton-in-ruby.html"/>
		<updated>2012-01-27T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/27/brown-on-the-singleton-in-ruby</id>
		<content type="html">&lt;h1 id='brown_on_the_singleton_in_ruby'&gt;Brown on the Singleton in Ruby&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Friday, January 27, 2012&lt;/p&gt;
&lt;p&gt;&lt;a href='http://jonallured.com/2012/01/20/brown-on-structural-design-patterns-in-ruby.html'&gt;I read the second post&lt;/a&gt; Gregory Brown did on design patterns in Ruby first, but I wanted to go back and read &lt;a href='http://blog.rubybestpractices.com/posts/gregory/059-issue-25-creational-design-patterns.html'&gt;the first one on creational patterns&lt;/a&gt;. I ended up spending a lot of time working through just the Singleton pattern because he updated his thoughts there with &lt;a href='http://practicingruby.com/articles/shared/jleygxejeopq'&gt;another write up&lt;/a&gt; that was equally insightful and thorough.&lt;/p&gt;

&lt;p&gt;A singleton is used when you only need one instance of a class. There is official support for this pattern in Ruby with &lt;a href='http://ruby-doc.org/stdlib-1.9.3/libdoc/singleton/rdoc/Singleton.html'&gt;the Singleton module&lt;/a&gt; in standard lib. I took a look there and saw this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class Klass; include Singleton; end
a, b = Klass.instance, Klass.instance
a == b # =&amp;gt; true
Klass.new # =&amp;gt; NoMethodError - new is private ...&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This shows what it means to be a Singleton in Ruby - once &lt;code&gt;#instance&lt;/code&gt; is called and an instance of &lt;code&gt;Klass&lt;/code&gt; is created, then all variables pointing to it are pointing at the same thing and you can&amp;#8217;t new up another one. Note that when you call &lt;code&gt;#instance&lt;/code&gt; the first time, &lt;code&gt;#initialize&lt;/code&gt; gets called as if you had called &lt;code&gt;#new&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Brown notes two main benefits of using the Singleton module:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;instantiation is lazy evaluated&lt;/li&gt;

&lt;li&gt;Ruby enforces the single instance limitation for you&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And explains them:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The former provides a potential performance and memory bonus when the object never ends up getting used, and the latter helps prevent accidental object creation. Both of these things are nice to have, and it only takes a bit of extra effort make them happen.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I get the benefit of letting Ruby prevent you from accidentally creating another instance, but I don&amp;#8217;t really see how there&amp;#8217;s much to be gained from &amp;#8220;a potential performance and memory bonus&amp;#8221;. Seems like one object isn&amp;#8217;t going to affect performance or memory that much and if it would, then maybe that&amp;#8217;s a smell that you&amp;#8217;re doing something wrong.&lt;/p&gt;

&lt;p&gt;Next Brown talks about how he likes to implement this pattern in Ruby. He thinks the Singleton module is fine, but also maybe too literal; he prefers to just use a module and then define methods off of it.&lt;/p&gt;

&lt;p&gt;Had to be reminded about what he was doing on line 2, with &lt;code&gt;extend self&lt;/code&gt; - this is just a shortcut like &lt;code&gt;class &amp;lt;&amp;lt; self&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class Klass
  class &amp;lt;&amp;lt; self
    def foo; :bear; end
  end
end

Klass.foo # =&amp;gt; :bear

module Mod
  extend self

  def foo; :bear; end
end

Mod.foo # =&amp;gt; :bear&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So, both &lt;code&gt;class &amp;lt;&amp;lt;  self&lt;/code&gt; and &lt;code&gt;extend self&lt;/code&gt; are doing the same thing: we can write our Classes and Modules without having to preface our method definition with &lt;code&gt;self&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Brown finishes up this section by reminding us that the Singleton pattern should be used sparingly because of its global nature:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;[A Singleton&amp;#8217;s global nature] makes them more difficult to test, easier to corrupt, and harder to isolate when it comes time to debug issues with them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then, after all that I went back and read his &lt;a href='http://practicingruby.com/articles/shared/jleygxejeopq'&gt;updated thoughts on Singletons&lt;/a&gt;. In this write up he explores seven ways to implement the pattern:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using the Singleton module provided by the standard library&lt;/li&gt;

&lt;li&gt;Using a class consisting of only class methods&lt;/li&gt;

&lt;li&gt;Using a module consisting of only module methods&lt;/li&gt;

&lt;li&gt;Using a module with module_function&lt;/li&gt;

&lt;li&gt;Using a module with extend self&lt;/li&gt;

&lt;li&gt;Using a bare instance of Object&lt;/li&gt;

&lt;li&gt;Using a hand-rolled construct&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I&amp;#8217;ve discussed the first method above. Methods 3, 4 and 5 are close to the other method I described above with 2 being a slight variation on it. But then he goes into a couple strange areas, like using a bare instance of an Object or hand-rolling a new Ruby construct. My takeaway is actually that I prefer the 5th method, the one described second above: defining methods right on a Module and then just using it directly. It was a fun thought experiment to contemplate his Universe construct, but being that its purely theoretical, doesn&amp;#8217;t really offer any practical help with Singletons.&lt;/p&gt;

&lt;p&gt;Brown&amp;#8217;s comments on avoiding Singletons and his reflections on writing about this pattern were very insightful. He talks about how there&amp;#8217;s actually very little practical difference between these fancy approaches to Singletons and just newing up an instance of a normal Class and that really rings true to me. Seems like unless I&amp;#8217;m in a very particular situation, I&amp;#8217;ll probably just write a class and use an instance of it. If I need more than that, I&amp;#8217;ll probably try the Module with extend self approach and see how far that gets me.&lt;/p&gt;

&lt;p&gt;Oh and he describes modules like &lt;code&gt;Math&lt;/code&gt; module as &amp;#8220;Function bags&amp;#8221;, which actually made me laugh out loud.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Helms on Imprecise Floats; Carroll on Services</title>
		<link href="http://jonallured.com/2012/01/24/helms-on-imprecise-floats-carroll-on-services.html"/>
		<updated>2012-01-24T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/24/helms-on-imprecise-floats-carroll-on-services</id>
		<content type="html">&lt;h1 id='helms_on_imprecise_floats_carroll_on_services'&gt;Helms on Imprecise Floats; Carroll on Services&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Tuesday, January 24, 2012&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve heard about Floating point numbers being flaky and I knew there was a perfectly logical reason for it, but I&amp;#8217;ve never really groked it until reading &lt;a href='http://www.rails-troubles.com/2011/12/ruby-float-quirks.html'&gt;Clemens Helms&amp;#8217; write up&lt;/a&gt; on the topic. I really like how he articulates this concept: Float numbers are a binary format, implemented right on the processor of your computer, this is why they&amp;#8217;re so fast. When you use this format with a decimal number, its going to be converted from base 10 to base 2. This conversion can produce imprecise numbers in the same way that some decimal numbers aren&amp;#8217;t precise.&lt;/p&gt;

&lt;p&gt;And by precise numbers I&amp;#8217;m talking about the difference between 1/3 and .3333 - the former is a number that can&amp;#8217;t precisely be represented as a decimal, its an infinitely repeating series of the number three, but we usually just round it to some number of them, say four. So, to understand why Float isn&amp;#8217;t always precise, you just have to remember that when some decimal numbers are converted to Float, they result in an imprecise binary number that&amp;#8217;s going to get rounded.&lt;/p&gt;

&lt;p&gt;Helm then goes on to give us a couple ideas about what to do when you need precision, one way is to pick a delta you can live with and another is to use &lt;a href='http://www.ruby-doc.org/stdlib-1.9.3/libdoc/bigdecimal/rdoc/BigDecimal.html'&gt;&lt;code&gt;BigDecimal&lt;/code&gt;&lt;/a&gt;, another number format in Ruby&amp;#8217;s standard lib. I took a look at BigDecimal and in the documentation there&amp;#8217;s a really easy way to see how Float can break:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;(1.2 - 1.0) == 0.2 # =&amp;gt; false&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But this would return true if BigDecimal was used instead of Float.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;a href='http://blog.carbonfive.com/2012/01/10/does-my-rails-app-need-a-service-layer/'&gt;Jared Carroll explores&lt;/a&gt; services and a service layer in Rails. He concludes that services can be helpful, but service layers are really only necessary when you need to support clients other than HTTP. I had never heard about these things, so I found the topic interesting, he starts out by reviewing what he means by a service:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;[A] service is an action, not a thing. And instead of forcing the operation into an existing object, we should encapsulate it in a separate, stateless service.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are three kinds of services, taken from what Eric Evans says in &lt;a href='http://domaindrivendesign.org/books/evans_2003'&gt;Domain-Driven Design&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Application Service: A service that provides non-infrastructure related operations that wouldn’t come up when discussing the domain model outside the context of software, i.e., in its natural environment.&lt;/li&gt;

&lt;li&gt;Domain Service: A domain service scripts a use-case involving multiple domain objects. Forcing this logic into a domain object is awkward because these use-cases often involve rules outside the responsibility of any single object.&lt;/li&gt;

&lt;li&gt;Infrastructure Service: An infrastructure service encapsulates access to an external system. Infrastructure services are often used by application and domain services.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Application Services are things like a report being generated - this code would be properly extracted to a service object and I&amp;#8217;ve just this. I always wondered if there was a idiomatic way of doing this, what I&amp;#8217;ve done is just call the object something like &amp;#8220;Exporter&amp;#8221; or &amp;#8220;Reporter&amp;#8221; and then hang methods off of that object that corresponded to the different exports or reports.&lt;/p&gt;

&lt;p&gt;The Domain Service stood out to me as something that I&amp;#8217;ve grappled with quite a bit in my own work. There are those times when what you&amp;#8217;re working on involves different objects and the action doesn&amp;#8217;t belong to any of these individual objects. At times I&amp;#8217;ve just picked one and stuck the stuff there anyway, but more recently I&amp;#8217;ve been creating a new object to deal with them and I guess those were services.&lt;/p&gt;

&lt;p&gt;The two examples Carroll gives for the Infrastructure Service are emailing and message queueing, so had me thinking about &lt;a href='http://guides.rubyonrails.org/action_mailer_basics.html'&gt;ActionMailer&lt;/a&gt; and &lt;a href='https://github.com/collectiveidea/delayed_job'&gt;Delayed Job&lt;/a&gt;. This pattern type seems closest to a service layer, which is where we go next:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;[A] service layer as an application&amp;#8217;s boundary and set of available operations from the perspective of interfacing client layers. In other words, it&amp;#8217;s your application&amp;#8217;s API.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Carroll points to HTTP and JSON as the standard ways of communicating and feels that unless you need some other method of communication, you really don&amp;#8217;t need a service layer. I know I was having a hard time thinking of a case where you&amp;#8217;d need another method, so I&amp;#8217;m just going to believe him.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Kellum on Pixels; Shaughnessy on Shared Strings</title>
		<link href="http://jonallured.com/2012/01/23/kellum-on-pixels-shaughnessy-on-shared-strings.html"/>
		<updated>2012-01-23T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/23/kellum-on-pixels-shaughnessy-on-shared-strings</id>
		<content type="html">&lt;h1 id='kellum_on_pixels_shaughnessy_on_shared_strings'&gt;Kellum on Pixels; Shaughnessy on Shared Strings&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Monday, January 23, 2012&lt;/p&gt;
&lt;p&gt;Scott Kellum &lt;a href='http://www.alistapart.com/articles/a-pixel-identity-crisis/'&gt;explores&lt;/a&gt; how devices where a pixel is not always a pixel are making the lives of designers even harder than they already were. He starts out by establishing some vocabulary:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The truth is that there are two different definitions of pixels: they can be the smallest unit a screen can support (a hardware pixel) or a pixel can be based on an optically consistent unit called a “reference pixel.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;[A &lt;strong&gt;hardware pixel&lt;/strong&gt; is] the smallest point a screen can physically display and is usually comprised of red, green, and blue sub-pixels&amp;#8230;it cannot be stretched, skewed, or subdivided.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;The w3c currently defines the &lt;strong&gt;reference pixel&lt;/strong&gt; as the standard for all pixel-based measurements. This new pixel should look exactly the same in all viewing situations.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Hardware pixels were clear to me, but I had a harder time understanding reference pixels until I took a look at Figure 1. A hardware pixel is the actual pixel bounded by the physical pixel square on the device while a reference pixel is used by the hardware pixels to draw things.&lt;/p&gt;

&lt;p&gt;Next he talks about how you can use the &lt;code&gt;device-pixel-ratio&lt;/code&gt; media query to identify devices with scaled pixels. He is able to use some media query magic to normalize two devices with the same number of hardware pixels, but different scaled pixels. Pretty neat and also, I&amp;#8217;m glad I don&amp;#8217;t have to deal with this stuff.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Pat Shaughnessy &lt;a href='http://patshaughnessy.net/2012/1/18/seeing-double-how-ruby-shares-string-values'&gt;discusses&lt;/a&gt; how the Ruby interpreter uses an optimization called &amp;#8220;copy on write&amp;#8221; by diving deep into its code.&lt;/p&gt;

&lt;p&gt;He starts off by outlining an example he used in &lt;a href='http://jonallured.com/2012/01/09/shaughnessy-explores-strings-klabnik-on-whats-wrong-with-mvc.html'&gt;another post he did on Ruby and Strings&lt;/a&gt; and shows us using a debug script that Ruby will try not to duplicate a string if it doesn&amp;#8217;t need to. He is able to get down to the hexadecimal values and show the relationship between two Ruby variables that point to the same RString structure that itself points to one Heap String.&lt;/p&gt;

&lt;p&gt;Then he shows how &lt;code&gt;Object#dup&lt;/code&gt; will make two RString structures that are pointing to one Heap String. This is what a &amp;#8220;Shared String&amp;#8221; really is, so if you have this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;str = &amp;quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit&amp;quot;
str2 = String.dup(str)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then &lt;code&gt;str&lt;/code&gt; and &lt;code&gt;str2&lt;/code&gt; both point to different RString structures and those in turn point to the same Heap String. But the RString structure that &lt;code&gt;str2&lt;/code&gt; points to is actually different from the RString &lt;code&gt;str&lt;/code&gt; points to. The former has a pointer to the latter. So far, so good.&lt;/p&gt;

&lt;p&gt;Next he goes into what happens when you start modifying that duplicate string. Turns out when you modify &lt;code&gt;str2&lt;/code&gt; the first thing that happens is that Ruby creates a copy of the heap data and removes the pointer connecting the two RString structures. Once that&amp;#8217;s done, then it performs the modification. This is true for a modification like &lt;code&gt;upcase&lt;/code&gt;, but it also applies to &lt;code&gt;slice&lt;/code&gt; - it will create new heap data for the substring.&lt;/p&gt;

&lt;p&gt;But this isn&amp;#8217;t always true: if your slice is less than 24 characters long then you&amp;#8217;ll get an Embedded String. Also, if your substring is longer than 24 characters, but includes all of the remaining characters, then Ruby does something else cool. Say you do this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;str = &amp;quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit&amp;quot;
str2 = str[1..-1]&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then &lt;code&gt;str2&lt;/code&gt; will point to a different RString structure, but that structure will point to the same heap data, its just that its &lt;code&gt;ptr&lt;/code&gt; value will be advanced one position.&lt;/p&gt;

&lt;p&gt;He concludes by reminding us that in most cases, Ruby developers shouldn&amp;#8217;t worry too much about these details, that the interpreter is there to do this stuff for us. Its interesting to know what&amp;#8217;s going on behind the scenes and in certain edge cases, this knowledge could help you write faster programs, but mostly this feels like an academic exercise and its one that I really enjoyed.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>JavaScript Everywhere; The Value of Thinking Aloud; 3D With Just the DOM; Bernhardt on Unix</title>
		<link href="http://jonallured.com/2012/01/21/javascript-everywhere-value-of-thinking-aloud-3d-with-the-dom-bernhardt-on-unix.html"/>
		<updated>2012-01-21T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/21/javascript-everywhere-value-of-thinking-aloud-3d-with-the-dom-bernhardt-on-unix</id>
		<content type="html">&lt;h1 id='javascript_everywhere_the_value_of_thinking_aloud_3d_with_just_the_dom_bernhardt_on_unix'&gt;JavaScript Everywhere; The Value of Thinking Aloud; 3D With Just the DOM; Bernhardt on Unix&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Saturday, January 21, 2012&lt;/p&gt;
&lt;p&gt;Luke Wroblewski does a great job &lt;a href='http://www.lukew.com/ff/entry.asp?1482'&gt;articulating why JavaScript is so hot right now&lt;/a&gt;. It didn&amp;#8217;t occur to me that MongoDB is really just JavaScript, but that&amp;#8217;s the &amp;#8220;J&amp;#8221; in JSON, right? Reading this really makes me want to work on something with Node.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Nielsen talks about the &lt;a href='http://www.useit.com/alertbox/thinking-aloud-tests.html'&gt;value of thinking alound&lt;/a&gt; and reiterates something he&amp;#8217;s said before:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Thinking aloud may be the single most valuable usability engineering method.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I know in my work, encouraging people to think aloud while they test something for me has always gleaned a lot of insight into things like positioning of elements on the page or flow of screens or even just labels that might not make sense. I&amp;#8217;m a big believer in this idea. Here&amp;#8217;s Nielsen&amp;#8217;s official definition:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In a thinking aloud test, you ask test participants to use the system while continuously thinking out loud — that is, simply verbalizing their thoughts as they move through the user interface.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;He goes on to note that its not always very natural for people to keep up a monologue of what they&amp;#8217;re doing and helping them do this is one of the jobs of a test facilitator. I&amp;#8217;ve actually seen this is action and can attest to both the truth of that assertion and the value of a good facilitator.&lt;/p&gt;

&lt;p&gt;This is a fantastic write up on one of my favorite techniques for getting feedback on a project.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Steven Wittens does a &lt;a href='http://acko.net/blog/making-love-to-webkit/'&gt;write up for his blog&amp;#8217;s most recent redesign&lt;/a&gt; and the tech he used to achieve the most bad-ass header I&amp;#8217;ve seen in quite a while. But before I got to that, I had to look up a solid definition of parallax:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Parallax is a displacement or difference in the apparent position of an object viewed along two different lines of sight, and is measured by the angle or semi-angle of inclination between those two lines.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As with most visual things, its easier to see the definition than to read it, so check out the sweet animated gif on the &lt;a href='http://en.wikipedia.org/wiki/Parallax'&gt;Wikipedia page for parallax&lt;/a&gt; where this definition comes from.&lt;/p&gt;

&lt;p&gt;Ok, so some of the details are over my head, but basically Witten wrote a &lt;a href='http://acko.net/editor.html'&gt;CSS 3D Editor&lt;/a&gt; that he uses to create 3D effects with nothing but native HTML elements and some JavaScript, no WebGL required. Its cray-cray - go play around with the CSS 3D Editor he built (click and drag to move around, keyboard controls defined in the write up).&lt;/p&gt;

&lt;p&gt;Oh, and if you have both Safari and Chrome, check out the page in both and see if you can detect a performance difference, I sure could.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Watched a &lt;a href='http://confreaks.net/videos/615-cascadiaruby2011-the-unix-chainsaw'&gt;great presentation from Gary Bernhardt&lt;/a&gt; on Unix where he talks about how to compose the command line. The first thing that jumped out at me was this great quote:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Half-assed is OK when you only need half of an ass.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here he&amp;#8217;s letting us off the hook on completely solving problems that aren&amp;#8217;t our concern.&lt;/p&gt;

&lt;p&gt;Then he goes into talking about what it means to be a programmable system and throws another quote at us:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The language used at each level of a stratified design has &lt;strong&gt;primatives, means of combination and means of abstraction&lt;/strong&gt; appropriate to that level of detail.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, there are three things needed for a truly programmable system and in the case of Unix, these break down like this:&lt;/p&gt;

&lt;p&gt;Primatives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Files&lt;/li&gt;

&lt;li&gt;Binaries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Means of Composition:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pipes&lt;/li&gt;

&lt;li&gt;Loops&lt;/li&gt;

&lt;li&gt;Subshells&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Means of Abstraction:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Functions&lt;/li&gt;

&lt;li&gt;Scripts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;He walks through each giving examples and talking about how this all ties together. Made me think about the command line in a whole different way.&lt;/p&gt;

&lt;p&gt;Something that I picked up was how Bernhardt was making shell functions and I didn&amp;#8217;t know you could do that. I searched and found a &lt;a href='http://tldp.org/LDP/abs/html/functions.html'&gt;write up&lt;/a&gt; that talks about shell functions:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ bamf { echo &amp;#39;still alive?&amp;#39;; }
$ bamf # =&amp;gt; still alive?&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So, that&amp;#8217;s pretty cool and kind of obvious, but I never knew it before.&lt;/p&gt;

&lt;p&gt;Back to the talk - after Bernhardt finishes going through the three sections on what makes up a programmable shell, he gives us a couple things to avoid:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tar pit of immediacy&lt;/li&gt;

&lt;li&gt;Proficiency fatalism&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The tar pit is about getting stuck doing something one way and never reevaluating whether its the best way to go. He offers pair-programming as a way to keep you from getting stuck in this way.&lt;/p&gt;

&lt;p&gt;Proficiency fatalism is where you see someone that&amp;#8217;s great at something and think that you could never do what they can. This one is something that I&amp;#8217;ve experienced and struggle with. Heck watching Bernhardt&amp;#8217;s &lt;a href='https://www.destroyallsoftware.com/screencasts'&gt;Destroy All Software&lt;/a&gt; series is an example of something that causes me to feel this way. But looking back helps me - I think about where I was at before I taught myself Rails and got serious about web development and its clear that I can pick this stuff up and there isn&amp;#8217;t anything intrinsically different between me and someone that knows more than I do. Its actually quite liberating.&lt;/p&gt;

&lt;p&gt;Then he gives us two things we should do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use more pipes and functions&lt;/li&gt;

&lt;li&gt;Pay attention to how much ass you need&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first is about how sometimes its worth writing stupid lines just to learn and sear into your brain better ways of composing the shell. Maybe not appropriate while doing billable work, but on your own, try to come up with wacky one-liners because it will get you better at the shell.&lt;/p&gt;

&lt;p&gt;The second is about quality and completeness, which he affectionately refers to as &amp;#8220;ass&amp;#8221; and I think its a great point. He talks about how there is actually a spectrum of quality, with something like the &lt;a href='http://manifesto.softwarecraftsmanship.org/'&gt;Software Craftsmanship&lt;/a&gt; movement on one side and something like &lt;a href='http://theleanstartup.com/'&gt;Lean Startup&lt;/a&gt; on the other. Neither are right or wrong, but its up to us to know where we should be on this spectrum for the project we&amp;#8217;re working on, or even just the problem in front of us at the moment.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Brown on Structural Design Patterns in Ruby</title>
		<link href="http://jonallured.com/2012/01/20/brown-on-structural-design-patterns-in-ruby.html"/>
		<updated>2012-01-20T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/20/brown-on-structural-design-patterns-in-ruby</id>
		<content type="html">&lt;h1 id='brown_on_structural_design_patterns_in_ruby'&gt;Brown on Structural Design Patterns in Ruby&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Friday, January 20, 2012&lt;/p&gt;
&lt;p&gt;Gregory Brown considers &lt;a href='http://blog.rubybestpractices.com/posts/gregory/060-issue-26-structural-design-patterns.html'&gt;how the classic design patterns pertain to Ruby&lt;/a&gt; and explores how one could interpret them by giving some examples. This is the second part of a two-part series, this time focusing on the structural patterns. I&amp;#8217;ve heard of the &lt;a href='http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612'&gt;Design Patterns&lt;/a&gt; book, we have a copy at the office, but I&amp;#8217;ve not read it. And I&amp;#8217;ve read a little about the patterns, but I took this post as an opportunity to get a little better acquainted with them.&lt;/p&gt;

&lt;h2 id='adapter'&gt;Adapter&lt;/h2&gt;

&lt;p&gt;This pattern made sense right away and had me thinking of places where I&amp;#8217;ve seen. The example was really clear: there are a bunch of different Markdown libraries for Ruby, Mitko Kostov wrote &lt;a href='https://github.com/mytrile/marky'&gt;Marky&lt;/a&gt; to sit in between them and your code. What you get is the ability to change which Markdown processor you use under the hood without actually needing to change any of your code. Marky abstracts away the details of each Markdown library&amp;#8217;s implementation and instead you just write to the Adapter.&lt;/p&gt;

&lt;p&gt;If you look at Marky&amp;#8217;s README, there&amp;#8217;s a list of &amp;#8220;Adapters&amp;#8221;, just pick one and you can convert some Markdown to html like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Marky.adapter = :maruku
Marky.to_html(&amp;quot;Hello, Marky&amp;quot;)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Easy, but it seems strange to me that Marky calls Maruku an adapter. Its Marky itself that&amp;#8217;s the Adapter and Maruku is the library it sits in front of. I would have expected to see a list of Processors and would pick one like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Marky.processor = :maruku
Marky.to_html(&amp;quot;Hello, Marky&amp;quot;)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Either way, this is a neat little gem that serves as a nice example when explaining the Adapter pattern.&lt;/p&gt;

&lt;p&gt;I was thinking about this pattern from the point of view of someone writing an Adapter and it occurred to me that this pattern has a side-effect: it encourages an Adapter author to only support the super-set of library features. If you have five libraries, but only two of them implement a certain feature, then it would be natural to ignore it when writing an Adapter for these libraries. Either they&amp;#8217;ve all got a feature and your Adapter exposes it, or they don&amp;#8217;t and you ignore it.&lt;/p&gt;

&lt;p&gt;The other approach would be to only let clients of your Adapter who&amp;#8217;ve picked a library with that feature use it. You&amp;#8217;d have to maintain some code that knows which libraries support which features and &lt;code&gt;raise&lt;/code&gt; when a client tries to do something that&amp;#8217;s not implemented. This seems counter to the spirit of an Adapter to me.&lt;/p&gt;

&lt;p&gt;Which leaves me thinking that the sane way to design an Adapter is to support only the super-set of features. That means that when you choose to use an Adapter rather than picking one of its underlying libraries, you should probably be doing it because you really need the ability to switch out the underlying library. If that&amp;#8217;s not important to you, then its possible that just picking a library with the features you need would actually be better.&lt;/p&gt;

&lt;h2 id='bridge'&gt;Bridge&lt;/h2&gt;

&lt;p&gt;I think its funny that Brown describes a bridge using the word &amp;#8220;physically&amp;#8221; - how exactly does a programming pattern &lt;em&gt;physically&lt;/em&gt; do anything? Anyway&amp;#8230;&lt;/p&gt;

&lt;p&gt;I got far less out of this one. The &lt;a href='http://sourcemaking.com/design_patterns/bridge'&gt;SourceMaking article&lt;/a&gt; he linked to had a bit about describing a bridge by making a comparison about light switches and that did help build a mental model for this.&lt;/p&gt;

&lt;p&gt;Then he goes on to give an example he feels is contrived and complain that its hard to figure out a purpose for this pattern in Ruby. Didn&amp;#8217;t get much out of this one.&lt;/p&gt;

&lt;h2 id='composite'&gt;Composite&lt;/h2&gt;

&lt;p&gt;I was unsatisfied with the example here. As Brown said towards the end of this section, the example was pretty intense and I couldn&amp;#8217;t see the pattern properly. I searched for another example and found &lt;a href='http://onestepback.org/index.cgi/Tech/Ruby/ThinkingInRuby.red'&gt;a write up&lt;/a&gt; from Jim Weirich that gave an example that was much easier to wrap my head around.&lt;/p&gt;

&lt;p&gt;Weirich uses Robert Martin&amp;#8217;s programming problem called &amp;#8220;Mark IV Coffee Maker&amp;#8221; to help define the Composite pattern. He describes how a Boiler object is a composite of both a Heater and a Relief Valve. Then he says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The Boiler becomes a single object to the brewer which just issues on/off commands to the boiler. The boiler is responsible for making sure all its subcomponents (the heater and the relief valve) are properly operated.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So the Brewer can just issue its on/off commands to our Boiler composite object, then the Boiler can handle the grunt work of figuring out how to talk to the objects that make it up.&lt;/p&gt;

&lt;p&gt;This one is really interesting and I&amp;#8217;ll be on the lookout for places where I can use it in my own work.&lt;/p&gt;

&lt;h2 id='proxy'&gt;Proxy&lt;/h2&gt;

&lt;p&gt;As with the Adapter pattern, Brown gives us an example for this pattern from Rails and as such it wasn&amp;#8217;t too hard to understand. A Proxy object sits in front of another object and in this way its similar to an Adapter. But this pattern implies that the Proxy can do some mutating where an Adapter is just abstracting the implementation.&lt;/p&gt;

&lt;p&gt;The example here is how ActiveRecord does association collections, like &lt;code&gt;has_many&lt;/code&gt;. So if a post has many comments, then you can do:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;post.comments # =&amp;gt; array of post&amp;#39;s comments
post.comments.class # =&amp;gt; Array&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But you can also do:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;post.comments.create(author: user, body: &amp;quot;Great post!&amp;quot;)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And &lt;code&gt;Array&lt;/code&gt; definitely does not implement &lt;code&gt;#create&lt;/code&gt;, so what&amp;#8217;s going on here is that &lt;code&gt;#comments&lt;/code&gt; is actually a Proxy. It acts like an &lt;code&gt;Array&lt;/code&gt; when it needs to, but is also able to do its own thing.&lt;/p&gt;

&lt;p&gt;Brown shows us a couple ways to implement this pattern, the first uses &lt;a href='http://www.ruby-doc.org/stdlib-1.9.3/libdoc/delegate/rdoc/Delegator.html'&gt;delegate&lt;/a&gt; from standard lib and the second uses &lt;code&gt;method_missing&lt;/code&gt;. He prefers using delegate, but wonders if Rails uses the &lt;code&gt;method_missing&lt;/code&gt; approach.&lt;/p&gt;

&lt;p&gt;I took a little dive into the Rails code and found ActiveRecord&amp;#8217;s &lt;a href='https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/has_many_association.rb'&gt;&lt;code&gt;HasManyAssociation&lt;/code&gt;&lt;/a&gt;, which ends up using a &lt;a href='https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/collection_proxy.rb'&gt;&lt;code&gt;CollectionProxy&lt;/code&gt;&lt;/a&gt; and sure enough, you&amp;#8217;ll see &lt;code&gt;method_missing&lt;/code&gt; implemented in there. Its worth reading through that code a little and seeing the trickery that gets these Proxies all their magic.&lt;/p&gt;

&lt;h2 id='decorator'&gt;Decorator&lt;/h2&gt;

&lt;p&gt;These are similar to Proxies, but are typically used to add or extend the behavior of the object. Decorators are hot right now with gems like &lt;a href='https://github.com/jcasimir/draper'&gt;Draper&lt;/a&gt; and are something I have already been thinking about. Since Brown basically skips this one, I will too.&lt;/p&gt;

&lt;h2 id='facade'&gt;Facade&lt;/h2&gt;

&lt;p&gt;The Facade pattern is used when you want to abstract something to act like something else. So, he uses &lt;code&gt;open_uri&lt;/code&gt; as his example because it acts as a Facade for File; its aim is to abstract working with a url into feeling like working with a file. I really liked this line:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It’s worth keeping in mind that pretty much every DSL you encounter is a Facade of some form or another.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This pattern also made sense right away and seems pretty easy to grok.&lt;/p&gt;

&lt;h2 id='flyweight'&gt;Flyweight&lt;/h2&gt;

&lt;p&gt;This pattern seems to be about optimizing memory. You can use this one to store what seems like a lot of data in a lighter weight way. The example given was about storing the font information for each letter separately and then when creating a string just look up each letter&amp;#8217;s font info by the letter instead of re-creating it.&lt;/p&gt;

&lt;p&gt;So given a string like &amp;#8220;Hello World&amp;#8221;, the font information for &amp;#8220;l&amp;#8221; would only be stored once, but the lighter weight character &amp;#8220;l&amp;#8221; appears three times. Brown concedes that this might not fit Flyweight exactly, but that its a good way to think about the higher level concepts.&lt;/p&gt;

&lt;h2 id='reflections'&gt;Reflections&lt;/h2&gt;

&lt;p&gt;Brown&amp;#8217;s reflections talk about how design patterns should help us have a common vocabulary when we&amp;#8217;re talking about code, but that it might not be possible without creating new ones specifically for Ruby. I know that when I hear people talking about patterns, I often feel like the hardest part is making sure we&amp;#8217;re talking about the same things. The ideas aren&amp;#8217;t the hard part, its the communicating about them that can be difficult.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Delayed Job hits 3.0; Marston on Deprecating Legacy Code</title>
		<link href="http://jonallured.com/2012/01/12/delayed-job-hits-3-marston-on-deprecating-legacy-code.html"/>
		<updated>2012-01-12T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/12/delayed-job-hits-3-marston-on-deprecating-legacy-code</id>
		<content type="html">&lt;h1 id='delayed_job_hits_30_marston_on_deprecating_legacy_code'&gt;Delayed Job hits 3.0; Marston on Deprecating Legacy Code&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Thursday, January 12, 2012&lt;/p&gt;
&lt;p&gt;Delayed Job &lt;a href='http://collectiveidea.com/blog/archives/2012/01/04/the-big-three-oh/'&gt;went 3.0 recently&lt;/a&gt; with two major changes: named queues and callbacks on the lifecycle of a job. They also changed it so that the ActiveRecord backend is provided by a gem, which means one could provide another backend if they were so inclined.&lt;/p&gt;

&lt;p&gt;I think the named queues are the only thing I&amp;#8217;d use. This could give you a way to segment jobs and assign a different number of workers based on the importance of the jobs. Maybe you&amp;#8217;d have a &amp;#8220;normal&amp;#8221; queue and an &amp;#8220;important&amp;#8221; queue and have more workers per job on the important one. Looks easy to use:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;object.delay(:queue =&amp;gt; &amp;#39;important&amp;#39;).method&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then if you&amp;#8217;re using rake to work your jobs, just start your worker like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ QUEUE=important rake jobs:work&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;They also fixed a couple bugs, but none of them were familiar to me.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Really &lt;a href='http://myronmars.to/n/dev-blog/2011/12/deprecating-a-legacy-subsystem-in-rails'&gt;excellent write-up&lt;/a&gt; of Myron Marston&amp;#8217;s experience refactoring some legacy code. He gives us some great insight into the techniques they used, which were totally new to me. I love this idea that you could add a field to your user indicating if they should be using the old or new code and then the surprisingly few places in Rails where they needed to use this flag. Very clean and organized.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Blocks in JavaScript; HATEOAS in Rails; Davey's turbux; watchr for Ruby Koans; Using a Single Ampersand</title>
		<link href="http://jonallured.com/2012/01/11/blocks-in-javascript-hateoas-in-rails-daveys-turbux-watchr-for-ruby-koans-using-a-single-ampersand.html"/>
		<updated>2012-01-11T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/11/blocks-in-javascript-hateoas-in-rails-daveys-turbux-watchr-for-ruby-koans-using-a-single-ampersand</id>
		<content type="html">&lt;h1 id='blocks_in_javascript_hateoas_in_rails_daveys_turbux_watchr_for_ruby_koans_using_a_single_ampersand'&gt;Blocks in JavaScript; HATEOAS in Rails; Davey&amp;#8217;s turbux; watchr for Ruby Koans; Using a Single Ampersand&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Wednesday, January 11, 2012&lt;/p&gt;
&lt;p&gt;If Yehuda Katz has it his way, &lt;a href='http://yehudakatz.com/2012/01/10/javascript-needs-blocks'&gt;JavaScript would get blocks&lt;/a&gt; and he supports his position with some examples.&lt;/p&gt;

&lt;p&gt;A lot of this was over my head because the most interesting things I&amp;#8217;ve done with JavaScript mostly involve DOM manipulation and some effects. I&amp;#8217;ve never needed to work with JavaScript prototypes and have just a little experience with making an Object to encapsulate functionality. Still, this was an interesting read.&lt;/p&gt;

&lt;p&gt;Actually the thing that stood out the most here was the use of &lt;code&gt;try...finally&lt;/code&gt; in JavaScript - never knew you could do that! &lt;a href='https://developer.mozilla.org/en/JavaScript/Reference/Statements/try...catch'&gt;Looked it up&lt;/a&gt; and this clause works just like the &lt;code&gt;ensure&lt;/code&gt; in Ruby&amp;#8217;s &lt;code&gt;begin...rescue&lt;/code&gt; statements.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Klabnik &lt;a href='http://blog.steveklabnik.com/posts/2012-01-06-implementing-hateoas-with-presenters'&gt;demonstrates how to implement HATEOAS&lt;/a&gt; in a Rails app using the Draper gem for the Presenter Pattern.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Fellow Rocketeer &lt;a href='https://twitter.com/joshuadavey'&gt;Josh Davey&lt;/a&gt; just &lt;a href='https://github.com/jgdavey/vim-turbux'&gt;released turbux&lt;/a&gt; and &lt;a href='http://joshuadavey.com/post/15619414829/faster-tdd-feedback-with-tmux-tslime-vim-and'&gt;wrote up a post announcing it&lt;/a&gt; - with a video and everything! We&amp;#8217;ve been using this for a while in the office and I really like this workflow. If you use tmux this is a must-have.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Another Rocketeer &lt;a href='https://twitter.com/adam_lowe'&gt;Adam Lowe&lt;/a&gt; reminded me about &lt;a href='https://github.com/mynyml/watchr'&gt;watchr&lt;/a&gt; and at the same time &lt;a href='http://blog.adamlowe.com/2012/01/fast-focused-ruby-koans.html'&gt;points out&lt;/a&gt; that its use would make doing the &lt;a href='https://github.com/edgecase/ruby_koans'&gt;Ruby Koans&lt;/a&gt; much more pleasant. Good call.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Pan Thomakos &lt;a href='http://ablogaboutcode.com/2012/01/04/the-ampersand-operator-in-ruby/'&gt;explores the uses of the single ampersand operator&lt;/a&gt;, divided into two categories: the Binary Ampersand and the Unary Ampersand.&lt;/p&gt;

&lt;p&gt;For the Binary Ampersand, most of the uses he reviews are weird and seem pretty theoretical. Not sure where one would use most of them. But the second example was pretty neat:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[1, 2, 3, 4, 5] &amp;amp; [1, 2, 6] # =&amp;gt; [1, 2]&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So, this returns a collection of the common elements between the two collections. Its just defined on &lt;code&gt;Array&lt;/code&gt;, but I guess I never noticed it.&lt;/p&gt;

&lt;p&gt;Then shit gets pretty real with the Unary Ampersand. He actually starts by describing Blocks and Procs in a way that I found really easy to understand. Again, some of this was pretty heady for me, but I did find something that I though was really cool. If you have a thing that you&amp;#8217;re doing as a map you can use a &lt;code&gt;Proc&lt;/code&gt; with the Unary Ampersand to reduce duplication:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# this
[1,2,3].map{ |x| x*2 }
[4,5,6].map{ |x| x*2 }

# can refactor to this
multiply = Proc.new{ |x| x*2 }
[1,2,3].map(&amp;amp;multiply)
[4,5,6].map(&amp;amp;multiply)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So that&amp;#8217;s pretty cool. You can also define &lt;code&gt;to_proc&lt;/code&gt; on an object and then pass that object.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Releases for Both Rspec and Rails</title>
		<link href="http://jonallured.com/2012/01/10/releases-for-both-rspec-and-rails.html"/>
		<updated>2012-01-10T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/10/releases-for-both-rspec-and-rails</id>
		<content type="html">&lt;h1 id='releases_for_both_rspec_and_rails'&gt;Releases for Both Rspec and Rails&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Tuesday, January 10, 2012&lt;/p&gt;
&lt;p&gt;Rspec recently got &lt;a href='http://blog.davidchelimsky.net/2012/01/04/rspec-28-is-released/'&gt;bumped to 2.8&lt;/a&gt;, a minor version release with some cool stuff.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rspec-core&lt;/code&gt; now has an option where you can run things in a random order:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rspec --order rand&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This option &amp;#8220;tells RSpec to run the groups in a random order, and then run the examples within each group in random order&amp;#8221;.&lt;/p&gt;

&lt;p&gt;We also get an init:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rspec -init&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which makes a &lt;code&gt;.rspec&lt;/code&gt; file, a folder called &amp;#8220;spec&amp;#8221; and a helper file: &amp;#8220;spec/spec_helper.rb&amp;#8221;, so that&amp;#8217;s neat.&lt;/p&gt;

&lt;p&gt;Then the next day rspec-rails &lt;a href='http://blog.davidchelimsky.net/2012/01/05/rspec-rails-281-is-released/'&gt;got a patch&lt;/a&gt; for a bug in Rails 3.2.0.rc2.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Speaking of which, Rails 3.2.0.rc2 &lt;a href='http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released'&gt;was released&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What caught my eye here was that Rails 2.3-style plugins are being depreciated and will be removed from Rails 4.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Shaughnessy Explores Strings; Klabnik on What's Wrong With MVC</title>
		<link href="http://jonallured.com/2012/01/09/shaughnessy-explores-strings-klabnik-on-whats-wrong-with-mvc.html"/>
		<updated>2012-01-09T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/09/shaughnessy-explores-strings-klabnik-on-whats-wrong-with-mvc</id>
		<content type="html">&lt;h1 id='shaughnessy_explores_strings_klabnik_on_whats_wrong_with_mvc'&gt;Shaughnessy Explores Strings; Klabnik on What&amp;#8217;s Wrong With MVC&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Monday, January 9, 2012&lt;/p&gt;
&lt;p&gt;Pat Shaughnessy spent some time exploring how MRI actually processes strings and &lt;a href='http://patshaughnessy.net/2012/1/4/never-create-ruby-strings-longer-than-23-characters'&gt;wrote up those results&lt;/a&gt;. He found that under the hood there are actually three types of Strings used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Heap Strings&lt;/li&gt;

&lt;li&gt;Shared Strings&lt;/li&gt;

&lt;li&gt;Embedded Strings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A Heap String is one where the Ruby Interpreter saves the actual value of the string in something called &amp;#8220;The Heap&amp;#8221;. A Shared String is easy, its created when you do something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;string_one = &amp;quot;Some awesome string&amp;quot;
string_two = string_one&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Ruby is smart enough to know that when you create &lt;code&gt;string_two&lt;/code&gt; you really have the same string value as &lt;code&gt;string_one&lt;/code&gt;, so rather than creating a new Heap String, it just points the second variable to the first Heap String.&lt;/p&gt;

&lt;p&gt;The third type of string, the Embedded String is different from the first two because it avoids &amp;#8220;The Heap&amp;#8221; and instead embeds the value of the string right in the C Struct using a character array. But there&amp;#8217;s a limit set for the size of this character array - the value stored can be no larger than 23 characters.&lt;/p&gt;

&lt;p&gt;When a Heap String is created, a call to &lt;code&gt;malloc&lt;/code&gt; happens and this is far slower than the creation of a character array, so Embedded Strings are faster than Heap Strings. Shared Strings are faster than either because all they are is a pointer to another string.&lt;/p&gt;

&lt;p&gt;He&amp;#8217;s got some benchmark data with nifty graphs, but that&amp;#8217;s about it. He also acknowledges that it would be ridiculous to optimize any code for this quirk. Mostly I think he just enjoyed learning more about the internals of the Ruby Interpreter and I loved reading about his exploration.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Steve Klabnik takes a look at a few Rails components and &lt;a href='http://blog.steveklabnik.com/posts/2011-12-30-active-record-considered-harmful'&gt;shares his views&lt;/a&gt; about how they can mess up someone&amp;#8217;s understanding of good Object-Oriented programming. He sees a few problems and discusses each in a different section.&lt;/p&gt;

&lt;h3 id='activerecord'&gt;ActiveRecord&lt;/h3&gt;

&lt;p&gt;Here he&amp;#8217;s talking about how clunky it is to separate a Model name and its table name in the database. He points out that this coupling means that its &amp;#8220;impossible to de-couple your persistence mechanism from your domain logic&amp;#8221;.&lt;/p&gt;

&lt;p&gt;The thing that jumped out at me in this section was the bit about how it took him a couple years to realize that you could have a model in your app that didn&amp;#8217;t inherit from ActiveRecord - me too!&lt;/p&gt;

&lt;h3 id='actioncontroller'&gt;ActionController&lt;/h3&gt;

&lt;p&gt;The bad habits pointed out here are instance variables and logic in templates. I wonder what he&amp;#8217;d think about how &lt;a href='https://github.com/voxdolo/decent_exposure'&gt;decent exposure&lt;/a&gt; doesn&amp;#8217;t litter instance variables anywhere, is that better? I know I like it better.&lt;/p&gt;

&lt;p&gt;Also, I&amp;#8217;m not sure its fair to criticize ActionController for having 200 line method when you just said that ActiveRecord has encouraged skinny-controller, fat-model. This doesn&amp;#8217;t seem like a strong argument to me because I don&amp;#8217;t think anyone is arguing for 200 line methods in the controller.&lt;/p&gt;

&lt;h3 id='actionview'&gt;ActionView&lt;/h3&gt;

&lt;p&gt;I didn&amp;#8217;t think there was support for logic in templates - I thought we were all trying to minimize this as much as possible. Maybe what he&amp;#8217;s really talking about is going even further and getting more Decorators in your code? Not sure what he&amp;#8217;s talking about here, I think he had point, but didn&amp;#8217;t spend enough time fleshing it out.&lt;/p&gt;

&lt;h3 id='mvc'&gt;MVC&lt;/h3&gt;

&lt;p&gt;At this point he&amp;#8217;s hit each initial in the MVC acronym, so really he&amp;#8217;s unhappy with the whole.&lt;/p&gt;

&lt;p&gt;Steve closes by reaffirming his love of Rails and saying that its because of this love that he feels compelled to criticize it. He acknowledges that his post is light on examples and promises more on the topic which is awesome because I&amp;#8217;d like to know more about what he&amp;#8217;s thinking here.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Preston-Werner at RubyConf 2011 on GitHub Flavored Ruby</title>
		<link href="http://jonallured.com/2012/01/06/preston-werner-at-rubyconf-2011-on-github-flavored-ruby.html"/>
		<updated>2012-01-06T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/06/preston-werner-at-rubyconf-2011-on-github-flavored-ruby</id>
		<content type="html">&lt;h1 id='prestonwerner_at_rubyconf_2011_on_github_flavored_ruby'&gt;Preston-Werner at RubyConf 2011 on GitHub Flavored Ruby&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Friday, January 6, 2012&lt;/p&gt;
&lt;p&gt;I just watched the video of Tom Preston-Werner at &lt;a href='http://confreaks.net/events/rubyconf2011'&gt;RubyConf 2011&lt;/a&gt;. His video was called &amp;#8220;GitHub Flavored Ruby&amp;#8221; and it was broken down into five parts that I took notes on individually.&lt;/p&gt;

&lt;h2 id='relentless_modularization'&gt;Relentless Modularization&lt;/h2&gt;

&lt;p&gt;Here Tom&amp;#8217;s talking about keeping your software small and the benefits this provides. One benefit that stood out was smaller software is cheaper to change. This is something that I&amp;#8217;ve been struggling with on the project I&amp;#8217;m currently on, so I enjoyed thinking about how this could resolve some of the things causing pain on that project.&lt;/p&gt;

&lt;p&gt;When you sense that a component of your system might make an interesting open source library, extract it. Even if you have no intention of open-sourcing the library. This is de-coupling.&lt;/p&gt;

&lt;h2 id='readme_driven_development'&gt;Readme Driven Development&lt;/h2&gt;

&lt;p&gt;Cowboy coding: the answer to Waterfall! Both approaches can produce software that doesn&amp;#8217;t solve the problems they were created to solve.&lt;/p&gt;

&lt;p&gt;Tom&amp;#8217;s middle-ground for this is writing the README first, &lt;a href='http://tom.preston-werner.com/2010/08/23/readme-driven-development.html'&gt;Readme Driven Development&lt;/a&gt;. What this technique does is force you to think about the end user of your library before you write any code so that you can make good decisions about its design. You&amp;#8217;ll find yourself thinking about how it will work in code first, then you write that code.&lt;/p&gt;

&lt;p&gt;So as to not confuse anyone, one thing you can do is to pick a point where your Readme.md looks pretty fleshed out and then move its contents to Spec.md. Then, as you actually code portions of the project, you can move content from the Spec file to the Readme file. This helps the person who comes to your half-implemented project see what&amp;#8217;s done and what&amp;#8217;s still left to do. Very interesting ideas. I had read Tom&amp;#8217;s initial post on this linked above, but I enjoyed hearing him talk about what he likes about this approach.&lt;/p&gt;

&lt;h2 id='rakegem'&gt;RakeGem&lt;/h2&gt;

&lt;p&gt;A dependency-free template for making gems. Gives you some rake tasks that solve common needs of gem authors. What&amp;#8217;s nice is that its just code in your repo, so you can change whatever you want about it.&lt;/p&gt;

&lt;h2 id='tomdoc'&gt;TomDoc&lt;/h2&gt;

&lt;p&gt;He talks about the four levels of documentation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;line&lt;/li&gt;

&lt;li&gt;code (methods and classes)&lt;/li&gt;

&lt;li&gt;API&lt;/li&gt;

&lt;li&gt;book&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A distinction is made between documentation at the code level and at the API level. The audiences of each are different; the former is aimed at those in your code and latter is aimed at those trying to use this project.&lt;/p&gt;

&lt;p&gt;TomDoc is code-level documentation.&lt;/p&gt;

&lt;p&gt;Things to document:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what params does this method expected and what type are they&lt;/li&gt;

&lt;li&gt;what does this method return&lt;/li&gt;

&lt;li&gt;examples&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I like these ideas, but I wish TomDoc was called something else&amp;#8230;&lt;/p&gt;

&lt;h2 id='semantic_versioning'&gt;Semantic Versioning&lt;/h2&gt;

&lt;p&gt;The goal of &lt;a href='http://semver.org/'&gt;Semantic Versioning&lt;/a&gt; is for the three numbers representing each release of your software to communicate something about what was changed. For example, say you have version 1.2.3, then each number is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1: Major&lt;/li&gt;

&lt;li&gt;2: Minor&lt;/li&gt;

&lt;li&gt;3: Patch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you look at what you have to release, use this guide to decide how to increment your version number:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Major: backwards incompatible, big changes&lt;/li&gt;

&lt;li&gt;Minor: backwards compatible, new functionality, big internal changes, may contain bug fixes&lt;/li&gt;

&lt;li&gt;Patch: backwards compatible, bug fixes only&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;He called &lt;code&gt;~&amp;gt;&lt;/code&gt; the &amp;#8220;spermy operator&amp;#8221;, then clarified how it works, so if you have this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gem fabrication ~&amp;gt; &amp;#39;1.2&amp;#39;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then you&amp;#8217;re saying that you require version 1.2 and any version up to but NOT including 2.0. If gem authors stuck to Semantic Versioning, then you&amp;#8217;d know that your code wouldn&amp;#8217;t break because any minor change should be backwards compatible and not change the methods you rely on. Those types of changes would be major and thus require a bump that your Gemfile wouldn&amp;#8217;t allow.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Rails 4.0 Will Drop Ruby 1.8.7; Croak Evaluates Decorators</title>
		<link href="http://jonallured.com/2012/01/03/rails-4-will-drop-ruby-187-croak-evaluates-decorators.html"/>
		<updated>2012-01-03T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/03/rails-4-will-drop-ruby-187-croak-evaluates-decorators</id>
		<content type="html">&lt;h1 id='rails_40_will_drop_ruby_187_croak_evaluates_decorators'&gt;Rails 4.0 Will Drop Ruby 1.8.7; Croak Evaluates Decorators&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Tuesday, January 3, 2012&lt;/p&gt;
&lt;p&gt;Rails will stop supporting Ruby 1.8.7 with &lt;a href='http://weblog.rubyonrails.org/2011/12/20/rails-master-is-now-4-0-0-beta'&gt;the 4.0 series&lt;/a&gt;. DHH notes, however, that they intend to keep to a 2-year release cycle, thus don&amp;#8217;t look for 4.0 any time soon.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I watched Jeff Casimir&amp;#8217;s &lt;a href='http://vimeo.com/27361482'&gt;talk on Decorators&lt;/a&gt;, then read about them a couple more times, but I really enjoyed Dan Croak&amp;#8217;s &lt;a href='http://robots.thoughtbot.com/post/14825364877/evaluating-alternative-decorator-implementations-in'&gt;evaluation on the topic&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;He does a roundup of the four different types of Decorator implementations and that was helpful for getting a clearer idea of what exactly we&amp;#8217;re talking about when we refer to the &amp;#8220;Decorator Pattern&amp;#8221;.&lt;/p&gt;

&lt;p&gt;I also loved the places where Dan shares how he&amp;#8217;s thinking about this area of Rails. In his conclusion he goes as far as outlining his plan for when to use which types of Decorators. He also notes other questions he&amp;#8217;s still struggling with, like if we&amp;#8217;re going to embrace Decorators, is there a use-case for classic Rails view helpers anymore?&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Kosman on Better jQuery Code</title>
		<link href="http://jonallured.com/2012/01/02/kosman-on-better-jquery-code.html"/>
		<updated>2012-01-02T00:00:00-08:00</updated>
		<id>http://jonallured.com/2012/01/02/kosman-on-better-jquery-code</id>
		<content type="html">&lt;h1 id='kosman_on_better_jquery_code'&gt;Kosman on Better jQuery Code&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Monday, January 2, 2012&lt;/p&gt;
&lt;p&gt;24 Ways had one on &lt;a href='http://24ways.org/2011/your-jquery-now-with-less-suck'&gt;writing less sucky jQuery&lt;/a&gt; and in the intro Scott Kosman talks about how its really easy to use jQuery to write spaghetti code. I&amp;#8217;ve heard this term before, but never really knew what it meant other than the obvious implication that its something to avoid.&lt;/p&gt;

&lt;p&gt;Wikipedia had this to say about &lt;a href='http://en.wikipedia.org/wiki/Spaghetti_code'&gt;spaghetti code&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Spaghetti code is a pejorative term for source code that has a complex and tangled control structure, especially one using many GOTOs, exceptions, threads, or other &amp;#8220;unstructured&amp;#8221; branching constructs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There&amp;#8217;s also an example there written in BASIC that shows an &lt;code&gt;IF&lt;/code&gt; statement and a &lt;code&gt;GOTO&lt;/code&gt; being used where a &lt;code&gt;FOR&lt;/code&gt; loop makes much more sense. So the term spaghetti code is really just talking about hard to follow control flow.&lt;/p&gt;

&lt;p&gt;With this distraction resolved, I got back to the article and learned some cool shit.&lt;/p&gt;

&lt;p&gt;There are two ways of writing jQuery selectors that are always much faster than other ways:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$(&amp;#39;#id&amp;#39;);
$(&amp;#39;p&amp;#39;);&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Under the hood these selectors are able to rely on native Javascript functions and thus are super quick. The former uses &lt;code&gt;document.getElementById()&lt;/code&gt; and the latter uses &lt;code&gt;document.getElementsByTagName()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;$(&amp;#39;.class&amp;#39;);&lt;/code&gt; selector is going to be slow in browsers that don&amp;#8217;t support &lt;code&gt;document.getElementsByClassName()&lt;/code&gt;, so that&amp;#8217;s IE8 and below. Use it when you are free to be a browser snob.&lt;/p&gt;

&lt;p&gt;There&amp;#8217;s more to it that Scott goes into, but my take-away was: try to write selectors that find your elements using native Javascript functions. If you can&amp;#8217;t, at least try to use these faster selectors to get at a parent element and then throw a &lt;code&gt;.find()&lt;/code&gt; on that to drill down further.&lt;/p&gt;

&lt;p&gt;Oh and he reminds us that these selectors return a jQuery object that can be &amp;#8220;cached&amp;#8221; by setting it to a variable. So don&amp;#8217;t be a dick and write the same selector three times causing three DOM lookups, either chain your actions on the first lookup or save the first lookup in a variable and use it instead.&lt;/p&gt;

&lt;p&gt;Then he goes into his second topic, Event Delegation. Here he demonstrates how one might use delegation to improve performance by reducing 100 event listeners to 1 with the &lt;code&gt;.on()&lt;/code&gt; event listener method introduced in jQuery 1.7. Cool stuff.&lt;/p&gt;

&lt;p&gt;Finally, he goes into DOM Manipulation and we get a reminder on a much more performant way to iterate through a collection of image urls, create an element and append it to the DOM.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Edit Files in TextMate from a Remote Server</title>
		<link href="http://jonallured.com/2011/12/24/edit-files-in-textmate-from-a-remote-server.html"/>
		<updated>2011-12-24T00:00:00-08:00</updated>
		<id>http://jonallured.com/2011/12/24/edit-files-in-textmate-from-a-remote-server</id>
		<content type="html">&lt;h1 id='edit_files_in_textmate_from_a_remote_server'&gt;Edit Files in TextMate from a Remote Server&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Saturday, December 24, 2011&lt;/p&gt;
&lt;p&gt;TextMate 2 now includes a &lt;a href='http://blog.macromates.com/2011/mate-and-rmate/'&gt;Ruby script&lt;/a&gt; that will allow one to edit files on a remote box locally in TextMate. The script needs to be installed on that server and then you need to do some configuration locally. I don&amp;#8217;t know, seems like a lot of bullshit to go through.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Cowboying Some Code</title>
		<link href="http://jonallured.com/2011/12/22/cowboying-some-code.html"/>
		<updated>2011-12-22T00:00:00-08:00</updated>
		<id>http://jonallured.com/2011/12/22/cowboying-some-code</id>
		<content type="html">&lt;h1 id='cowboying_some_code'&gt;Cowboying Some Code&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Thursday, December 22, 2011&lt;/p&gt;
&lt;p&gt;Just watched &lt;a href='BAMF'&gt;Destroy All Software 23: Spiking and Continuous Spiking&lt;/a&gt;, or as I&amp;#8217;ll now refer to it, The One About Cowboying.&lt;/p&gt;

&lt;p&gt;I liked his advice about knowing when to stop spiking. His suggestion is to choose a constraint like number of lines in the file and hold yourself to that. When you go over the number of lines, force yourself to throw something away and TDD the implementation from scratch.&lt;/p&gt;

&lt;p&gt;Later he says something about how its fun to Cowboy some code and I totally agree. TDD is very satisfying, but so is just writing the damn thing.&lt;/p&gt;

&lt;p&gt;Another choice bit was when he identified that spiking can help you know where to go next when you hit a spot in your loops where the next step is unclear.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Rails 3.2; Command Reuse; Fixed Position on Mobile; Ruby Metaprogramming</title>
		<link href="http://jonallured.com/2011/12/20/rails-3-2-command-reuse-mobile-fixed-position-metaprogramming.html"/>
		<updated>2011-12-20T00:00:00-08:00</updated>
		<id>http://jonallured.com/2011/12/20/rails-3-2-command-reuse-mobile-fixed-position-metaprogramming</id>
		<content type="html">&lt;h1 id='rails_32_command_reuse_fixed_position_on_mobile_ruby_metaprogramming'&gt;Rails 3.2; Command Reuse; Fixed Position on Mobile; Ruby Metaprogramming&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Tuesday, December 20, 2011&lt;/p&gt;
&lt;p&gt;DHH &lt;a href='http://weblog.rubyonrails.org/2011/12/20/rails-3-2-rc1-faster-dev-mode-routing-explain-queries-tagged-logger-store'&gt;announced Rails 3.2, RC1&lt;/a&gt; and highlighted a few of the cool new things that landed. What stood out to me was the bit about Active Record Store. More details please!&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Jakob Nielsen reviews why command reuse or overloading a command is often &lt;a href='http://www.useit.com/alertbox/overloaded-commands.html'&gt;confusing to users&lt;/a&gt;. The example about two search fields on the same page is something I&amp;#8217;ve actually seen first-hand in user studies and worked very hard to eliminate at Allured.&lt;/p&gt;

&lt;p&gt;I also found the part about confusion in Android with the home and back buttons pretty compelling. He gives the example of a magazine app that has a home button that will send you back to the app&amp;#8217;s list of issues and another home button at the system-level that takes you back to your phone&amp;#8217;s home screen.&lt;/p&gt;

&lt;p&gt;This is exactly why I never liked Android, the best things about iOS is that when you&amp;#8217;re in an app, the whole screen is for that app and the only way out is the one and only hardware button. This design side-steps lots of confusion and lets the app be in total control of what a user sees.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;PPK does a nice little &lt;a href='http://www.quirksmode.org/blog/archives/2011/12/position_fixed.html'&gt;roundup&lt;/a&gt; of &lt;code&gt;position: fixed&lt;/code&gt; implementations, with video! I&amp;#8217;m not sure how I feel about this, but I do know its getting better. It wasn&amp;#8217;t that long ago that you&amp;#8217;d git a site with one of those goofy &amp;#8216;toolbars&amp;#8217; that would just sit there covering up part of the screen.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;I recently found out about the dynamic &lt;code&gt;find_by&lt;/code&gt; methods from the great &lt;a href='https://twitter.com/mattpolito'&gt;Matt Polito&lt;/a&gt;, and while reading a post by Pat Shaughnessy, I found out about the &lt;code&gt;scoped_by&lt;/code&gt; dynamic methods.&lt;/p&gt;

&lt;p&gt;There was more in his &lt;a href='http://patshaughnessy.net/2011/12/20/learning-from-the-masters-part-2-three-metaprogramming-best-practices'&gt;article about metaprogramming&lt;/a&gt;, for instance, I saw &lt;code&gt;Enumerable#zip&lt;/code&gt; and didn&amp;#8217;t know what it was, so I found out: it can merge two arrays:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[:a, :b].zip([:c, :d]) # =&amp;gt; [[:a, :c], [:b, :d]]&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So that&amp;#8217;s neat. Worth a read also for his reminder about how to metaprogram so that &amp;#8216;future-you&amp;#8217; wont be pissed at &amp;#8216;present-you&amp;#8217;.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Multiple Carets in TextMate 2.0; Default Scope</title>
		<link href="http://jonallured.com/2011/12/19/multiple-carets-in-textmate-2-default-scope.html"/>
		<updated>2011-12-19T00:00:00-08:00</updated>
		<id>http://jonallured.com/2011/12/19/multiple-carets-in-textmate-2-default-scope</id>
		<content type="html">&lt;h1 id='multiple_carets_in_textmate_20_default_scope'&gt;Multiple Carets in TextMate 2.0; Default Scope&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Monday, December 19, 2011&lt;/p&gt;
&lt;p&gt;Don&amp;#8217;t get me wrong, I&amp;#8217;m quickly learning to love VIM since that&amp;#8217;s all we use at Hashrocket, but TextMate will always be the first text editor that I loved. I haven&amp;#8217;t been following the Alpha that closely, but I did read about the new &lt;a href='http://blog.macromates.com/2011/multiple-carets/'&gt;Multiple Caret features&lt;/a&gt; and I&amp;#8217;m really excited about it, I think it looks pretty great.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Found out about &lt;code&gt;default_scope&lt;/code&gt; on &lt;a href='https://www.destroyallsoftware.com/screencasts/catalog/coupling-and-abstraction'&gt;Destroy All Software 21: Coupling and Abstraction&lt;/a&gt;. When you do:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;User.all&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And you&amp;#8217;ve got:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class User &amp;lt; ActiveRecord::Base
  default_scope where(active: true)
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then the &lt;code&gt;all&lt;/code&gt; method will use that default and only return active users. Pretty neat.&lt;/p&gt;

&lt;p&gt;Gregory warns though, that you can easily become coupled to this behavior in a bad way and advises that if you actually want to use this default, you might want to try using an alias instead:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class User &amp;lt; ActiveRecord::Base
  default_scope where(active: true)

  class &amp;lt;&amp;lt; self
    alias_method :all_active_users, :all
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And then you can use &lt;code&gt;User.all_active_users&lt;/code&gt; instead. What&amp;#8217;s nice about this approach is that if you later want to change the default scope, you&amp;#8217;ll notice that the &lt;code&gt;all_active_users&lt;/code&gt; is using it and can make a better choice about your change.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Bigg on Debugging; Shaughnessy on Rails Commits; OmniAuth 1.0; Videos from Windy City Rails 2011</title>
		<link href="http://jonallured.com/2011/12/18/debugging-rails-commits-omniauth-1-windy-city-rails-videos.html"/>
		<updated>2011-12-18T00:00:00-08:00</updated>
		<id>http://jonallured.com/2011/12/18/debugging-rails-commits-omniauth-1-windy-city-rails-videos</id>
		<content type="html">&lt;h1 id='bigg_on_debugging_shaughnessy_on_rails_commits_omniauth_10_videos_from_windy_city_rails_2011'&gt;Bigg on Debugging; Shaughnessy on Rails Commits; OmniAuth 1.0; Videos from Windy City Rails 2011&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Sunday, December 18, 2011&lt;/p&gt;
&lt;p&gt;Watched this great &lt;a href='http://ryanbigg.com/2011/11/screencast-wrong-argument-type/'&gt;screencast from Ryan Bigg on debugging&lt;/a&gt;. He goes through his steps to find the source of a &lt;code&gt;TypeError: wrong argument type Module (expected Class)&lt;/code&gt; error and I really enjoyed watching it.&lt;/p&gt;

&lt;p&gt;The first thing I picked up was a reminder that a &lt;code&gt;Class&lt;/code&gt; cannot inherit from a &lt;code&gt;Module&lt;/code&gt;, so this doesn&amp;#8217;t work:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;module Foo
end

class Bar &amp;lt; Foo
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That exception mentioned above will get thrown. It was interesting watching Ryan find this problem and I learned a little about how Rails works along the way.&lt;/p&gt;

&lt;p&gt;Another cool thing I took away was that you can do &lt;code&gt;bundle show [gemname]&lt;/code&gt; and &lt;a href='http://gembundler.com/'&gt;Bundler&lt;/a&gt; will spit back a path to that gem. This is a handy way to open the source for a gem in your editor. Try something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;vim `bundle show fabrication`&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And you can follow a stack trace or try messing with something in the gem, whatever. Really easy.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Pay Shaughnessy takes us through some of his &lt;a href='http://patshaughnessy.net/2011/12/6/learning-from-the-masters-some-of-my-favorite-rails-commits'&gt;favorite Rails commits&lt;/a&gt;, trying to point out some things to keep in mind as you work on projects. I found Jose&amp;#8217;s commit the most interesting, I really liked seeing this peek at how he approaches deprecation.&lt;/p&gt;

&lt;p&gt;Oh, and we see that DHH loves us and added Array.preprend and Array.append to ActiveSupport, which is also cool.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;a href='http://www.omniauth.org/'&gt;OmniAuth&lt;/a&gt; recently went 1.0 and Ryan Bates takes us on a tour of using the &lt;a href='http://railscasts.com/episodes/304-omniauth-identity'&gt;Identity strategy&lt;/a&gt; for an app. You&amp;#8217;d support this strategy when you want to provide users a way to log into your app separate from other providers. Maybe you&amp;#8217;ve got a user that doesn&amp;#8217;t have or doesn&amp;#8217;t want to use their Twitter, Facebook or Google account with your app - this strategy allows them to just create an account with your app.&lt;/p&gt;

&lt;p&gt;It occurred to me while watching this screencast that when I see ERB view templates now, they look really noisy and I actually have a hard time reading them. HAML has completely spoiled me.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Went through a few of the &lt;a href='http://vimeo.com/channels/wcr11'&gt;Windy City Rails 2011 talks&lt;/a&gt;. Watched a bit of the presentation &lt;a href='https://twitter.com/martinisoft'&gt;Aaron&lt;/a&gt; gave about Regex and saw that he did a good job and was well received by the audience.&lt;/p&gt;

&lt;p&gt;Then I watched most of Steve Klabnik&amp;#8217;s talk about Literate Code and pulled out this quote:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&amp;#8220;It seems like every time I type &amp;#8216;git blame&amp;#8217; the asshole that wrote that terrible function is me.&amp;#8221;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thought that was funny. But I really did love his point that when we write software we have four audiences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the computer&lt;/li&gt;

&lt;li&gt;ourselves&lt;/li&gt;

&lt;li&gt;the other (the person who will later maintain our code)&lt;/li&gt;

&lt;li&gt;the user&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the fact that we have these different audiences with different needs means that we aren&amp;#8217;t free to focus on and optimize for just one of them.&lt;/p&gt;

&lt;p&gt;As an aside, I liked the bit where he was talking about how a definition of technical debit could be &amp;#8220;screwing with future you&amp;#8221;. I have definitely cursed &amp;#8220;past-Jon&amp;#8221; for some garbage he wrote that was in my way at the time. &amp;#8220;Present-Jon&amp;#8221; tends to think &amp;#8220;past-Jon&amp;#8221; is a lazy asshole and too often he&amp;#8217;s right.&lt;/p&gt;

&lt;p&gt;I liked the part where he talked about how much people who make websites have to know. He mentioned all the things we have to know as developers: HTML, CSS, JS, Ruby, CoffeeScript, LESS. Validates my feelings that the web is just a really interesting place to be working right now.&lt;/p&gt;

&lt;p&gt;Another quote I liked was:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you&amp;#8217;re doing reg-green-refactor, you fail thousands of times a day.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;He was talking about how terminology can trip you up. The example he gave was working with some English Academics and their take vs a developer&amp;#8217;s take on code being &amp;#8220;broken&amp;#8221;. I&amp;#8217;ve seen this while working in the Publishing industry as a developer, but the thing I liked was how deftly he articulated something that&amp;#8217;s interesting to consider: developers that test are used to failure and have, in fact, embraced it as a means to write good code. There&amp;#8217;s something poetic about that.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Notes Help You Learn; Changing Directories</title>
		<link href="http://jonallured.com/2011/12/17/notes-help-you-learn-changing-directories.html"/>
		<updated>2011-12-17T00:00:00-08:00</updated>
		<id>http://jonallured.com/2011/12/17/notes-help-you-learn-changing-directories</id>
		<content type="html">&lt;h1 id='notes_help_you_learn_changing_directories'&gt;Notes Help You Learn; Changing Directories&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Saturday, December 17, 2011&lt;/p&gt;
&lt;p&gt;I read about &lt;a href='http://swombat.com/2011/12/11/taking-notes'&gt;the value of taking notes&lt;/a&gt; and was inspired to try taking notes while I read. This topic reminded me of that part of Junior High where we were taught note taking styles. One thing I remember was folding a paper in half and then writing stuff on one side or the other.&lt;/p&gt;

&lt;p&gt;I struggle with retaining all the shit I read, so if this help, then great. And I&amp;#8217;m going to post these notes here.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;During my audition week at &lt;a href='http://www.hashrocket.com'&gt;Hashrocket&lt;/a&gt; I saw someone type this at the command line:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cd ..; cd -&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;They were working with RVM and they had just cloned down a repo, but the &lt;code&gt;--create&lt;/code&gt; flag wasn&amp;#8217;t in the &lt;a href='http://beginrescueend.com/workflow/rvmrc/'&gt;.rvmrc file&lt;/a&gt; so they had the right Ruby, but no Gemset. You can fix this by creating the Gemset, but its better to add the flag to the rc file. Once you&amp;#8217;ve done that, you can run the command above and you&amp;#8217;ll cd up a level and then back down and trigger the .rvmrc file again. I could look at it and know that&amp;#8217;s probably what it did, but I never really knew what that last bit was all about.&lt;/p&gt;

&lt;p&gt;But to take a small step back, the first thing to know is that &lt;code&gt;;&lt;/code&gt; can be used to input a series of commands to run in sequence. Then, while reading a &lt;a href='http://www.commandlinefu.com/commands/browse/sort-by-votes'&gt;list of unix commands&lt;/a&gt; I noticed the last bit. The &lt;code&gt;cd -&lt;/code&gt; command returns you to the previous working directory. Mystery solved.&lt;/p&gt;

&lt;p&gt;There were some other interesting things in there, have a look!&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Playing Around with Content Editable in Rails</title>
		<link href="http://jonallured.com/2011/11/28/playing-around-with-content-editable-in-rails.html"/>
		<updated>2011-11-28T00:00:00-08:00</updated>
		<id>http://jonallured.com/2011/11/28/playing-around-with-content-editable-in-rails</id>
		<content type="html">&lt;h1 id='playing_around_with_content_editable_in_rails'&gt;Playing Around with Content Editable in Rails&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Monday, November 28, 2011&lt;/p&gt;
&lt;p&gt;I recently tried working with the &lt;code&gt;contenteditable&lt;/code&gt; attribute on an internal project at &lt;a href='http://hashrocket.com'&gt;Hashrocket&lt;/a&gt; with my pair &lt;a href='http://twitter.com/daveisonthego'&gt;Dave Lyon&lt;/a&gt; and wanted to share what I thought about the experience. Our use case was simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In order to remember things about a Project&lt;br /&gt;As a Project Manager on the list of Projects page&lt;br /&gt;I want to make or edit a Note&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Said another way, we&amp;#8217;ve got a Project list page, each Project can have a Note and we want to be able to create a Note for a given project or edit an existing Note. For such a case you might make a bunch of &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt; tags and then wrap them in forms or maybe bind to &lt;code&gt;blur&lt;/code&gt; and either create or update a Note all AJAXey.&lt;/p&gt;

&lt;p&gt;But this was an internal project and we wanted to try something different. We went through a couple different ideas, starting with something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;p contenteditable=&amp;quot;true&amp;quot; class=&amp;quot;note&amp;quot;&amp;gt;Note content here!&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We created an event handler to fire on &lt;code&gt;blur&lt;/code&gt; and sent the content of the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag to the server. But it wasn&amp;#8217;t long before we hit enter while editing that &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag and found that new &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; tags were being created. That didn&amp;#8217;t work like we wanted, so then we wrapped the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; with a &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt;, like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;section contenteditable=&amp;quot;true&amp;quot; class=&amp;quot;note&amp;quot;&amp;gt;
  &amp;lt;p&amp;gt;Note content here!&amp;lt;/p&amp;gt;
&amp;lt;/section&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This way when you hit enter and create more &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tags, they&amp;#8217;d be contained inside the parent and we could send the content of &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt; to the server. That was closer, but didn&amp;#8217;t feel quite right. Next we had the idea to just use a &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt;, like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;ul contenteditable=&amp;quot;true&amp;quot; class=&amp;quot;note&amp;quot;&amp;gt;
  &amp;lt;li&amp;gt;Note content here!&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We liked this because then we&amp;#8217;d just store the &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; tags in the database and it was nice and clean. I threw together a little &lt;a href='http://files.jonallured.com/content-editable/demo.html'&gt;demo page&lt;/a&gt; you can use to play around with our different approaches.&lt;/p&gt;

&lt;p&gt;My take away here is that &lt;code&gt;contenteditable&lt;/code&gt; is really only suitable for cases where you actually want HTML nodes to be created. Its perfect for something like a WYSIWYG editor or the &lt;a href='http://railscasts.com/episodes/296-mercury-editor'&gt;Mercury Editor&lt;/a&gt;, things that aim to allow editing of a page right in the page. But for something like what we were doing, I think it was overkill.&lt;/p&gt;

&lt;p&gt;Also, I&amp;#8217;m not completely comfortable with its cross-browser support. I don&amp;#8217;t have access to IE anymore, but I was able to experiment with Chrome, Safari and FireFox. From what I could tell the two WebKit browsers were fairly consistent in how they implemented the details of this attribute, but FireFox does some different things. For instance, &lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt; tags seem to be added at the end of everything.&lt;/p&gt;

&lt;p&gt;Still, &lt;code&gt;contenteditable&lt;/code&gt; is a cool attribute and I was glad to learn a little more about it. Give &lt;a href='http://files.jonallured.com/content-editable/demo.html'&gt;that demo&lt;/a&gt; a whirl and consider it the next time you need something like this.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Keeping a Live Website in Sync with a Local Version, Part Two</title>
		<link href="http://jonallured.com/2011/08/08/keeping-a-live-website-in-sync-with-a-local-version-part-two.html"/>
		<updated>2011-08-08T00:00:00-07:00</updated>
		<id>http://jonallured.com/2011/08/08/keeping-a-live-website-in-sync-with-a-local-version-part-two</id>
		<content type="html">&lt;h1 id='keeping_a_live_website_in_sync_with_a_local_version_part_two'&gt;Keeping a Live Website in Sync with a Local Version, Part Two&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Monday, August 8, 2011&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This part covers the technical aspects of a project I worked on to keep a live website in sync with a local version, &lt;a href='/2011/08/08/keeping-a-live-website-in-sync-with-a-local-version-part-one.html'&gt;the first part&lt;/a&gt; covers it from a business-level perspective.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I created a system for keeping a live version of a website in sync with a local one. I use a Ruby script activated by Cron to compare and sync the two versions and then get this out to everyone using the site by sharing a DropBox folder. A xml file, dubbed a Castlist, is used to compare last updated dates.&lt;/p&gt;

&lt;h2 id='the_castlist_file'&gt;The Castlist File&lt;/h2&gt;

&lt;p&gt;In order for the Ruby script to be able to compare assets in the live and local versions of the site, I used an XML file - here&amp;#8217;s an example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;
&amp;lt;castlist&amp;gt;
	&amp;lt;templates&amp;gt;
		&amp;lt;template id=&amp;quot;223349&amp;quot; updated_at=&amp;quot;2011-04-27 16:05:03.0&amp;quot; name=&amp;quot;dmk_bottom&amp;quot; /&amp;gt;
		&amp;lt;template id=&amp;quot;224294&amp;quot; updated_at=&amp;quot;2011-06-09 11:04:20.0&amp;quot; name=&amp;quot;dmk_castlist&amp;quot; /&amp;gt;
		... [ more templates ] ...
	&amp;lt;/templates&amp;gt;
	&amp;lt;assets&amp;gt;
		&amp;lt;asset content_type=&amp;quot;html&amp;quot; id=&amp;quot;100466409&amp;quot; updated_at=&amp;quot;2011-04-28 12:29:30.0&amp;quot; path=&amp;quot;http://mediakit.skininc.com/index.html&amp;quot; /&amp;gt;
		&amp;lt;asset content_type=&amp;quot;html&amp;quot; id=&amp;quot;102168174&amp;quot; updated_at=&amp;quot;2010-11-04 08:45:03.0&amp;quot; path=&amp;quot;http://mediakit.skininc.com/about/index.html&amp;quot; /&amp;gt;
		&amp;lt;asset content_type=&amp;quot;html&amp;quot; id=&amp;quot;100467204&amp;quot; updated_at=&amp;quot;2011-06-14 10:44:22.0&amp;quot; path=&amp;quot;http://mediakit.skininc.com/advertising/index.html&amp;quot; /&amp;gt;
		&amp;lt;asset content_type=&amp;quot;css&amp;quot; id=&amp;quot;020&amp;quot; updated_at=&amp;quot;2007-07-07 02:00:00.0&amp;quot; path=&amp;quot;http://s3.amazonaws.com/abm-assets/css/base.css&amp;quot; /&amp;gt;
		&amp;lt;asset content_type=&amp;quot;css&amp;quot; id=&amp;quot;021&amp;quot; updated_at=&amp;quot;2007-07-07 02:00:00.0&amp;quot; path=&amp;quot;http://s3.amazonaws.com/abm-assets/css/si-brand-mini.css&amp;quot; /&amp;gt;
		&amp;lt;asset content_type=&amp;quot;js&amp;quot; id=&amp;quot;026&amp;quot; updated_at=&amp;quot;2007-07-07 02:00:00.0&amp;quot; path=&amp;quot;http://s3.amazonaws.com/abm-assets/js/dmk/behavior.js&amp;quot; /&amp;gt;
		... [ more assets ] ...
	&amp;lt;/assets&amp;gt;
&amp;lt;/castlist&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There are two types of things I need to compare - templates and assets. Assets are the html, css and js files that make up the site, but the templates are a little more complicated. If I only had to compare the assets, then I actually wouldn&amp;#8217;t need the XML file at all, I could probably use the Last-Modified html header and be good to go.&lt;/p&gt;

&lt;p&gt;The problem is that I don&amp;#8217;t want to rely on my CMS for anything, I want my solution to be independent from anything I haven&amp;#8217;t written. I can&amp;#8217;t write Java (its a Java-based platform) or anything fancy like that, but I can use their templating engine to report on the state of the templates themselves, so that&amp;#8217;s what I did. The Castlist file serves as the API of the CMS so that the script knows where things stand.&lt;/p&gt;

&lt;h2 id='ruby_gems_used'&gt;Ruby Gems Used&lt;/h2&gt;

&lt;p&gt;To write the Ruby script I used just two gems: &lt;a href='https://github.com/tenderlove/nokogiri'&gt;Nokogiri&lt;/a&gt; and &lt;a href='https://github.com/RISCfuture/dropbox'&gt;Dropbox&lt;/a&gt;. Nokogiri to make parsing the XML castlist files easy and Dropbox to work with the &lt;a href='https://www.dropbox.com/developers'&gt;Dropbox API&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id='script_overview'&gt;Script Overview&lt;/h2&gt;

&lt;p&gt;The main classes are &lt;code&gt;Comparer&lt;/code&gt;, &lt;code&gt;Syncer&lt;/code&gt; and &lt;code&gt;Fixer&lt;/code&gt;. The overall flow of the script goes something like this: initialize a &lt;code&gt;Comparer&lt;/code&gt; and a &lt;code&gt;Syncer&lt;/code&gt; and see if there&amp;#8217;s a major change. A major change is something at the template level (like maybe something in navigation or a header image) that would require all pages to be refreshed. If not, then just look for stale or new pages.&lt;/p&gt;

&lt;p&gt;Then the &lt;code&gt;Syncer&lt;/code&gt; we initialized earlier makes a &lt;code&gt;Fixer&lt;/code&gt; object and uploads fixed files through the DropBox API.&lt;/p&gt;

&lt;p&gt;Finally, we use the &lt;code&gt;Comparer&lt;/code&gt; to update the local Castlist as a record of what&amp;#8217;s been changed (so we don&amp;#8217;t do the same thing over and over).&lt;/p&gt;

&lt;h2 id='the_comparer_method'&gt;The Comparer Method&lt;/h2&gt;

&lt;p&gt;When the &lt;code&gt;Comparer&lt;/code&gt; class is initialized it sets two instance variables called &lt;code&gt;live&lt;/code&gt; and &lt;code&gt;local&lt;/code&gt; to Nokogiri documents representing the live and local version of the Castlist files. These attributes are used by other instance methods to detect major changes, stale files and new files. The &lt;code&gt;major_change?&lt;/code&gt; method is the first that&amp;#8217;s called and it looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def major_change?
  @live.root.css(&amp;quot;template&amp;quot;).detect do |live_node|
    local_node = @local.root.css(&amp;quot;template##{live_node.attributes[&amp;#39;id&amp;#39;]}&amp;quot;).first
    live_node.attributes[&amp;#39;updated_at&amp;#39;].to_s != local_node.attributes[&amp;#39;updated_at&amp;#39;].to_s
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So, we just iterate over the live Nokogiri document looking for templates that don&amp;#8217;t have matching &lt;code&gt;updated_at&lt;/code&gt; dates. If one is found, then we have a major change and need to drop all the content and crawl the live site all over again. We use the &lt;code&gt;live\_urls&lt;/code&gt; method for that:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def live_urls
  @live.root.css(&amp;quot;asset&amp;quot;).map { |node| node.attributes[&amp;#39;path&amp;#39;].to_s }
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Not too much here, we&amp;#8217;re just finding all the assets in the live Castlist and then using &lt;code&gt;map&lt;/code&gt; to convert them to a list of urls, which is what we&amp;#8217;ll be passing off to &lt;code&gt;Syncer&lt;/code&gt; later.&lt;/p&gt;

&lt;p&gt;But normally we wont have a major change, so then the next things to look for are stale files (files whose live version is newer than its local version) and new files that aren&amp;#8217;t in the local version. The &lt;code&gt;stale_urls&lt;/code&gt; method looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def stale_urls
  stale_nodes = @live.root.css(&amp;#39;asset&amp;#39;).select do |live_node|
    local_node = @local.root.css(&amp;quot;asset##{live_node.attributes[&amp;#39;id&amp;#39;]}&amp;quot;).first
    if local_node
      live_node.attributes[&amp;#39;updated_at&amp;#39;].to_s != local_node.attributes[&amp;#39;updated_at&amp;#39;].to_s
    else
      false
    end
  end

  stale_nodes.map { |node| node.attributes[&amp;#39;path&amp;#39;].to_s }
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We&amp;#8217;re iterating over the live Nokogiri document once again and as in &lt;code&gt;major\_change&lt;/code&gt; we&amp;#8217;re interested in the difference between the live and local version &lt;code&gt;updated\_at&lt;/code&gt; dates. The files where these don&amp;#8217;t match are thrown into &lt;code&gt;stale_nodes&lt;/code&gt; which we then &lt;code&gt;map&lt;/code&gt; to just the paths.&lt;/p&gt;

&lt;p&gt;Last thing to check for are new urls, here&amp;#8217;s that method:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def new_urls
  new_nodes = @live.root.css(&amp;#39;asset&amp;#39;).select do |live_node|
    @local.root.css(&amp;quot;asset##{live_node.attributes[&amp;#39;id&amp;#39;]}&amp;quot;).count == 0
  end

  new_nodes.map { |node| node.attributes[&amp;#39;path&amp;#39;].to_s }
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Similar to the above methods: we&amp;#8217;re iterating over that same list of Nokogiri documents and once we find the elements we want, we use &lt;code&gt;map&lt;/code&gt; to get just the paths of the files we&amp;#8217;re interested in. The only difference here is that we&amp;#8217;re using the result of the Nokogiri css method to decide if this file already exists. If not, then its picked.&lt;/p&gt;

&lt;p&gt;So, these four methods are used to come up with an array of urls that need to be updated. In the case of a major change, this is really all of them and in the other cases, its just a subset of them.&lt;/p&gt;

&lt;h2 id='the_syncer_method'&gt;The Syncer Method&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;Syncer&lt;/code&gt; class is what connects to DropBox through their API and actually does the uploading. Upon initialization, it creates a instance variable called &lt;code&gt;session&lt;/code&gt; that uses &lt;code&gt;Dropbox::Session.deserialize&lt;/code&gt; to reestablish the connection. Once connected, we wait for &lt;code&gt;Comparer&lt;/code&gt; to feed us a list of urls and then the &lt;code&gt;upload_files&lt;/code&gt; method gets to work:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def upload_files(urls)
  fixer = Fixer.new

  urls.each do |url|
    file_path, filename, extension = /com(.*\/)([\w\-]+\.(\w+))/.match(url).captures
    clean_data = fixer.clean(url, extension)
    upload_file(clean_data, @local_path + file_path, filename)
  end

  fixer.found_files.each do |url|
    file_path, filename, extension = /com(.*\/)([\w\-]+\.(\w+))/.match(url).captures
    clean_data = fixer.clean(url, extension)
    upload_file(clean_data, @local_path + file_path, filename)
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I&amp;#8217;ll get into &lt;code&gt;Fixer&lt;/code&gt; in the next section, but for now just know that it takes our data and spits it back out cleaned up. The other thing that Fixer does is look for more files that will need to be uploaded. This is important, so I&amp;#8217;ll go into that more now.&lt;/p&gt;

&lt;p&gt;The Castlist is a manifest of sorts. Its a list of the assets that make up a website, but its not exhaustive and it shouldn&amp;#8217;t be. If we were limited to only those assets that appear in the Castlist, then every time a new image is needed, we&amp;#8217;d need to add this to the Castlist. On a brochure website meant to sell ads, this would make running the site too slow. Further the people working on the content of the site are not programmers and know nothing about how CAST operates. All they know is how to edit pages in the CMS to make changes on the live websites.&lt;/p&gt;

&lt;p&gt;And that&amp;#8217;s all they should care about. The Castlist is kept to just the elements of the site that are fairly stable. Things like the webpages and the css and js files that make it up. The exact elements on those pages can change without any affect on how CAST works. To support this, CAST must crawl the pages that make up the site and that&amp;#8217;s what &lt;code&gt;fixer.found_files&lt;/code&gt; is all about.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;upload_files&lt;/code&gt; method is merely a controller here - it instantiates a &lt;code&gt;Fixer&lt;/code&gt;, iterates over the urls it gets from the &lt;code&gt;Comparer&lt;/code&gt; and the urls &lt;code&gt;Fixer&lt;/code&gt; finds and then gets this content uploaded. The actual work happens in the &lt;code&gt;Fixer&lt;/code&gt; class.&lt;/p&gt;

&lt;h2 id='the_fixer_method'&gt;The Fixer Method&lt;/h2&gt;

&lt;p&gt;Since we can&amp;#8217;t rely on the Castlist to be a complete list of all assets on the site, we have to crawl pages and look for new things to download. But while we&amp;#8217;re crawling we should also change all absolute paths to relative ones. These are the two things the &lt;code&gt;Fixer&lt;/code&gt; class does - we&amp;#8217;ll start with a method used to fix paths.&lt;/p&gt;

&lt;p&gt;The path problem is pretty straightforward: on the live website, I make all paths absolute so that CAST can take the URL and retrieve the asset, but that&amp;#8217;s not going to work on the local copy where you don&amp;#8217;t have an internet connection, so the asset needs to be downloaded and the path needs to be altered to be relative. To do this I wrote the &lt;code&gt;find_relative_path&lt;/code&gt; method:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def find_relative_path(url)
  steps = url.gsub(/http:\/\/mediakit.\w+.com\//, &amp;#39;&amp;#39;).split(&amp;#39;/&amp;#39;).count - 1
  &amp;#39;../&amp;#39; * steps
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We take the url of the file we&amp;#8217;re working with, remove the host and then count how many slashes we see. Subtract one from that number and use the juicy string multiplication we get in Ruby to return a string that&amp;#8217;s just a bunch of path changes. This is then used while we crawl.&lt;/p&gt;

&lt;p&gt;When &lt;code&gt;Fixer&lt;/code&gt; is instantiated it creates an instance variable called &lt;code&gt;found_files&lt;/code&gt; that&amp;#8217;s going to be where we put assets we find while crawling. The crawling starts with the &lt;code&gt;clean&lt;/code&gt; method:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def clean(url, ext)
  data = Net::HTTP.get URI.parse(url)
	
  case ext
  when &amp;#39;css&amp;#39;
    scan_for_images(data)
  when &amp;#39;html&amp;#39;
    relative_path = self.find_relative_path(url)
    data.gsub!(/(http:\/\/mediakit\.\w+\.com\/|https:\/\/s3\.amazonaws\.com\/)/, relative_path)
    scan_for_files(data, relative_path)
  end

  return data
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;clean&lt;/code&gt; method is acting as a controller here - its job is to fetch the data using &lt;code&gt;url&lt;/code&gt; and then call the right crawling method based on what type of file it is. Along the way we address paths using the relative path we found earlier.&lt;/p&gt;

&lt;p&gt;Since our crawling is going to be slightly different depending on which type of file we&amp;#8217;re working with, we fork the code here using the file extension. For a file that&amp;#8217;s html, we use the &lt;code&gt;scan_for_files&lt;/code&gt; method to crawl:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def scan_for_files(data, relative_path)
  while data =~ /(href|src)\=\&amp;quot;(http:\/\/media.\w+.com\/([\w\-\/\.]+))\&amp;quot;/ do
    @found_files &amp;lt;&amp;lt; $2 unless @found_files.include?($2)
    data.sub!($2, relative_path + $3)
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The idea here is to find all nodes with a href or src attribute, add that attribute&amp;#8217;s value to our &lt;code&gt;found_files&lt;/code&gt; array and then update the path using our relative path.&lt;/p&gt;

&lt;p&gt;If we&amp;#8217;re working with a css file, then we use the &lt;code&gt;scan_for_images&lt;/code&gt; method:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def scan_for_images(data)
  data.lines do |line|
    if line =~ /url\(\&amp;quot;\.\.([\w\-\/\.]+)\&amp;quot;\)/
      url = &amp;#39;http://s3.amazonaws.com/abm-assets&amp;#39; + $1
      @found_files &amp;lt;&amp;lt; url unless @found_files.include?(url)
    end
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As with the other scan method, we&amp;#8217;re looking for assets we don&amp;#8217;t already know about but in the CSS we&amp;#8217;re using relative paths already, so we just have to add them to the &lt;code&gt;found_files&lt;/code&gt; array.&lt;/p&gt;

&lt;h2 id='deploying_the_script'&gt;Deploying the Script&lt;/h2&gt;

&lt;p&gt;While writing this script, I would just jump into Terminal and run it as I needed to check something, but once I was ready to actually start depending on this thing, I needed a way to run it on a schedule.&lt;/p&gt;

&lt;p&gt;We happened to have a spare MacMini in the office that wasn&amp;#8217;t being used for anything important, so I commandeered it to serve as our CAST server. After a quick install of Git and RVM, I just cloned the repo, installed the couple Gem dependencies and got Ruby 1.9.2 installed.&lt;/p&gt;

&lt;p&gt;For running the script on a schedule, I turned to my old frenemy Cron. I had never attempted something like this, so after some research (Googling), I found that I could run Bash commands as easily as anything else I&amp;#8217;ve done with Cron and you could even run a series of commands by separating them with semicolons. Here&amp;#8217;s how I&amp;#8217;ve got Cron running this script:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;0 * * * * /bin/bash -l -c &amp;#39;rvm 1.9.2-p180@cast; cd /Users/jon/Projects/abm/cast/; ruby cast.rb &amp;gt; logs/result.log&amp;#39;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Every hour, on the hour with results logged to a log file that just keeps over-writing itself, all within the comfy confines of RVM with a suitable Gemset for this project. Easy in retrospect, but quite a pain to figure out at the time!&lt;/p&gt;

&lt;h2 id='fire_and_forget'&gt;Fire and Forget&lt;/h2&gt;

&lt;p&gt;This project went through one re-write about a year in, but has mostly been a fire-and-forget type of project. I remote into the MacMini every once in a while to run Software Update, but other than that its very hands off.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you&amp;#8217;re interested in finding out more about the business-level strategy about this project, please read &lt;a href='/2011/08/08/keeping-a-live-website-in-sync-with-a-local-version-part-one.html'&gt;Part One&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Keeping a Live Website in Sync with a Local Version, Part One</title>
		<link href="http://jonallured.com/2011/08/08/keeping-a-live-website-in-sync-with-a-local-version-part-one.html"/>
		<updated>2011-08-08T00:00:00-07:00</updated>
		<id>http://jonallured.com/2011/08/08/keeping-a-live-website-in-sync-with-a-local-version-part-one</id>
		<content type="html">&lt;h1 id='keeping_a_live_website_in_sync_with_a_local_version_part_one'&gt;Keeping a Live Website in Sync with a Local Version, Part One&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Monday, August 8, 2011&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This part covers a project I worked on to keep a live website in sync with a local version from a business-level perspective, &lt;a href='/2011/08/08/keeping-a-live-website-in-sync-with-a-local-version-part-two.html'&gt;the second part&lt;/a&gt; covers the technical aspects of the project.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Each year Publishing companies produce something called a Media Kit (also called a Media Planner) - its an important tool salesreps use to help them sell advertising. Its a marketing piece that is responsible for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;conveying the brand&lt;/li&gt;

&lt;li&gt;establishing credibility&lt;/li&gt;

&lt;li&gt;describing the audience reached&lt;/li&gt;

&lt;li&gt;laying out all the brand&amp;#8217;s products&lt;/li&gt;

&lt;li&gt;giving price information&lt;/li&gt;

&lt;li&gt;detailing some ad material requirements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A Media Kit&amp;#8217;s audience is both long-time customers and those that have never done business with the company. It should serve as a document that can be reviewed with a customer in person or mailed out to a prospect. It should be attractive and full of calls to action. Its one of the most important documents to come out of the Marketing Department and its typically quite expensive both to print and to mail.&lt;/p&gt;

&lt;p&gt;&lt;a href='http://www.allured.com'&gt;Allured Business Media&lt;/a&gt; wanted to take a different approach for their 2011 Media Kit - they wanted to take the content of the Media Kit and create a brochure-style website that reps could use just the same way they&amp;#8217;ve used the physical Media Kit. They wanted to digitize their printed Media Kit.&lt;/p&gt;

&lt;h2 id='the_hidden_requirement'&gt;The Hidden Requirement&lt;/h2&gt;

&lt;p&gt;The digitizing process was started by deconstructing the piece and building an Information Architecture. We identified that good content always seems to get cut from the printed Media Kit due to size or money constraints and thought about what made sense to add back in now we no longer had these types of constraints.&lt;/p&gt;

&lt;p&gt;A card sort helped us think about how different pieces of content were related and revealed what primary navigation to use. Wireframes were developed and final content was written, edited, and rewritten. What we ended up with was a great brochure site managed by our existing &lt;a href='http://www.clickability.com'&gt;CMS system&lt;/a&gt;. Easy.&lt;/p&gt;

&lt;p&gt;But during the planning phase we discovered a hidden requirement: reps don&amp;#8217;t always have an internet connection when they need to show their Media Kit to customers. Take tradeshows as an example: wireless internet access is often expensive and flaky when its offered at all, especially internationally. But tradeshows are an excellent opportunity to interact with customers, so not having something to work with in this situation wasn&amp;#8217;t acceptable. It was imperative that whatever we ended up with was available without an internet connection.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s dig into this requirement a little, we needed this site to be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;available when the internet isn&amp;#8217;t&lt;/li&gt;

&lt;li&gt;updated along with the live version&lt;/li&gt;

&lt;li&gt;as transparent as possible to both the salesrep who uses the site and the Marketing team who updates the content&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What I came up with to solve this problem was really two things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a Ruby script that crawls the live version of the site and once the site is uploaded, continues to ping the live version looking for changes&lt;/li&gt;

&lt;li&gt;a shared DropBox folder that accepts these uploads using &lt;a href='https://www.dropbox.com/developers'&gt;their API&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id='a_cast_system'&gt;A CAST System&lt;/h2&gt;

&lt;p&gt;I call this solution CAST - Compare and Sync Tool. It compares the live and local version of a site and keeps them in sync. To facilitate the comparing I came up with a type of file called a Castlist. A Castlist is just XML and is a list of the assets on a site with the last updated date of each. Consider the Castlist an external API from the CMS meant to be consumed by the Ruby script.&lt;/p&gt;

&lt;p&gt;The Ruby script parses the Castlist from the live site and compares it to a Castlist that represents the current state of the local copy. When it detects that these lists are out of sync, it grabs the updates, posts them to the &lt;a href='http://www.dropbox.com/help/19'&gt;shared Dropbox folder&lt;/a&gt; and updates the local Castlist. Then whenever any DropBox user that&amp;#8217;s included in that shared folder connects to the internet, these updates are automatically downloaded to their computer and their local copy of the site is updated as well.&lt;/p&gt;

&lt;h2 id='a_seamless_experience'&gt;A Seamless Experience&lt;/h2&gt;

&lt;p&gt;The reps love the fact that when on the road they have access to this backup site. They don&amp;#8217;t always know what they are walking into when they arrive at a customer&amp;#8217;s office, but they know that even if they aren&amp;#8217;t going to be able to connect to the internet, they&amp;#8217;ll be able to go over their Media Kit website.&lt;/p&gt;

&lt;p&gt;Its a very seamless experience for reps and those in Marketing and I haven&amp;#8217;t had a single compliant - it just works.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you&amp;#8217;re interested in more of the technical details, please read &lt;a href='/2011/08/08/keeping-a-live-website-in-sync-with-a-local-version-part-two.html'&gt;Part Two&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Using Devise for Admin Accounts</title>
		<link href="http://jonallured.com/2011/04/30/using-devise-for-admin-accounts.html"/>
		<updated>2011-04-30T00:00:00-07:00</updated>
		<id>http://jonallured.com/2011/04/30/using-devise-for-admin-accounts</id>
		<content type="html">&lt;h1 id='using_devise_for_admin_accounts'&gt;Using Devise for Admin Accounts&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Saturday, April 30, 2011&lt;/p&gt;
&lt;p&gt;I use &lt;a href='https://github.com/plataformatec/devise'&gt;Devise&lt;/a&gt; on almost every Rails project I work on and wanted to share some things I&amp;#8217;ve learned about using it - specifically, how I use it for Admin accounts. Devise is a gem that creates user models and handles all the authentication that goes along with them. It also does things like password retrieval and account confirmations and it does all this in a very friendly, modular way where you can pick which parts your app needs. The team working on it has done a fabulous job with not only the code but also the documentation. I can&amp;#8217;t recommend it highly enough or thank them enough for what they&amp;#8217;ve contributed to the Rails community.&lt;/p&gt;

&lt;p&gt;One thing you&amp;#8217;ll probably run into while building a typical app using this gem is needing a way to protect screens so that only administrators can get to them. Many CRUD screens, reports and anything related to the content are all prime candidates to get some admin love. There&amp;#8217;s a &lt;a href='https://github.com/plataformatec/devise/wiki/How-To:-Add-an-Admin-role'&gt;page on the Devise wiki&lt;/a&gt; explaining two techniques you can use to create Admin accounts and you should start by reading that.&lt;/p&gt;

&lt;h2 id='you_really_need_an_admin_model'&gt;You Really Need an Admin Model&lt;/h2&gt;
&lt;p class='listHeading'&gt;The two techniques described are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;create a separate Admin model&lt;/li&gt;

&lt;li&gt;add an admin boolean to your existing User model&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are always exceptions and I&amp;#8217;m glad they mention the second approach, but I find it completely unrealistic. Your project doesn&amp;#8217;t have to get very complicated before you&amp;#8217;ll wish that you had your own model.&lt;/p&gt;

&lt;p&gt;Its clean to start with something like &lt;code&gt;if current_user.admin?&lt;/code&gt; and I think that clarity and the ease of just running a quick migration could be attractive to someone starting out, but its not long before you find yourself with a mess like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if current_user.admin? and !current_user.reports_only? and current_user.edit_content?&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;My advice is to take the plunge and do an Admin model right off the bat. You might feel like its a waste, like its more than you need, but if requirements change (don&amp;#8217;t they always?) and a little more complexity is introduced, you&amp;#8217;ll be glad you have a separate model.&lt;/p&gt;

&lt;h2 id='you_might_need_a_permission_library'&gt;You Might Need a Permission Library&lt;/h2&gt;

&lt;p&gt;This piece talks about light permission needs - I&amp;#8217;m talking about like three cases here, nothing crazy. If you have really complicated permission needs, you&amp;#8217;ll want to pursue other options, something like &lt;a href='https://github.com/ryanb/cancan'&gt;CanCan&lt;/a&gt;. There&amp;#8217;s even a &lt;a href='https://github.com/plataformatec/devise/wiki/How-To:-Use-CanCan-+-Devise,-The-easy-way'&gt;page on the Devise wiki&lt;/a&gt; to help you get started, so check that out.&lt;/p&gt;

&lt;p&gt;But here, we&amp;#8217;re just talking about basic permission needs.&lt;/p&gt;

&lt;h2 id='different_kinds_of_admin'&gt;Different Kinds of Admin&lt;/h2&gt;

&lt;p&gt;Its just going to happen, you&amp;#8217;re going to end up with different kinds of Admin accounts. It happens because there will be people that should have access to one thing but not another. You&amp;#8217;ll have people in the Marketing department that need to edit content, but they shouldn&amp;#8217;t see your CRUD screens for managing User objects or maybe you&amp;#8217;ve got raw scaffold pages for some objects that expose ids or something like that.&lt;/p&gt;

&lt;p&gt;You&amp;#8217;ll have someone from Accounting that just needs to run a report every month or a manager that wants to see a list of new accounts and they shouldn&amp;#8217;t be let anywhere near content, not to mention your screens.&lt;/p&gt;

&lt;p&gt;You&amp;#8217;ll continue to create screens that are easier than the command line for things you do frequently and you aren&amp;#8217;t going to want anyone messing around in there besides people that know what they are doing.&lt;/p&gt;
&lt;p class='listHeading'&gt;You could create a different Devise user type of each of these, but I find that approach ends up being too much. And when there are overlaps about who can see what, its weird to code. Before we move on, lets summarize:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;its important to have an Admin model so that as things get more complex you have something to hang some logic on&lt;/li&gt;

&lt;li&gt;there are different kinds of admin users, but don&amp;#8217;t go crazy and create a model for each type&lt;/li&gt;

&lt;li&gt;the easiest type of admin is the business person who just has access to run reports&lt;/li&gt;

&lt;li&gt;then you&amp;#8217;ve got you: you have access to everything&lt;/li&gt;

&lt;li&gt;finally, you&amp;#8217;ve got the normal admin, they don&amp;#8217;t see your screens, but they can edit some content and run reports too&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id='generating_your_admin'&gt;Generating Your Admin&lt;/h2&gt;

&lt;p&gt;This is the Rails Generator command I use:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rails g devise Admin god_mode:boolean reports_only:boolean&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I use &lt;code&gt;god_mode&lt;/code&gt; to indicate that its me or another programmer and I use &lt;code&gt;reports_only&lt;/code&gt; to indicate a user that shouldn&amp;#8217;t be editing stuff, just running reports. If an Admin has false for both of these then they are the normal Admin that can edit content and run reports but don&amp;#8217;t have access to programmer stuff. Easy.&lt;/p&gt;

&lt;h2 id='the_admin_model'&gt;The Admin Model&lt;/h2&gt;

&lt;p&gt;The suggestion from the wiki is to use the &lt;code&gt;:trackable&lt;/code&gt;, &lt;code&gt;:timeoutable&lt;/code&gt; and &lt;code&gt;:lockable&lt;/code&gt; modules, which I think its too much, but review each and see what&amp;#8217;s right for your project. Choices like this are what&amp;#8217;s great about Devise - if you have a need for these things, then you can easily mix them in.&lt;/p&gt;

&lt;p&gt;But for me, I end up with a model that looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class Admin &amp;lt; ActiveRecord::Base
  devise :database_authenticatable, :rememberable
  attr_accessible :email, :password, :password_confirmation, :god_mode, :reports_only
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So, I do add the &lt;code&gt;:rememberable&lt;/code&gt; module because I like it and more importantly the Marketing and Accounting people like it.&lt;/p&gt;

&lt;p&gt;I think its important to point out something here: we&amp;#8217;re not including the &lt;code&gt;:registerable&lt;/code&gt; module, which means routes like /admins/sign_up aren&amp;#8217;t going to work. This is one of the ways you are protecting yourself. Admin accounts can only be created from the command line with a command like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; Admin.create(:email =&amp;gt; &amp;#39;user@domain.com&amp;#39;, :password =&amp;gt; &amp;#39;shhhhh&amp;#39;, :god_mode =&amp;gt; true, :reports_only =&amp;gt; false)&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='the_admin_migration'&gt;The Admin Migration&lt;/h2&gt;

&lt;p&gt;Almost there, but before we run the migration that the Generator created for us, the wiki guides us to remove a few things. I like to add defaults for the two booleans, so my migration looks like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class DeviseCreateAdmins &amp;lt; ActiveRecord::Migration
  def self.up
    create_table(:admins) do |t|
      t.database_authenticatable :null =&amp;gt; false
      t.rememberable
      t.boolean :god_mode, :default =&amp;gt; false
      t.boolean :reports_only, :default =&amp;gt; false
      t.timestamps
    end
  end

  def self.down
    drop_table :admins
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With your migration updated, you should be all set to run a &lt;code&gt;rake db:migrate&lt;/code&gt; and then go to the console and create an Admin account for yourself.&lt;/p&gt;

&lt;h2 id='you_will_need_views'&gt;You Will Need Views&lt;/h2&gt;

&lt;p&gt;Just a couple more things to finish. I like to go verify that Devise added the route correctly and actually I usually end up shifting things around because I like to see the Admin route right next to the User route. Not a big deal, just make sure everything&amp;#8217;s cool in your routes.rb file.&lt;/p&gt;

&lt;p&gt;Next its time to talk about views. Lets assume you&amp;#8217;re reading this before you implement, that&amp;#8217;ll mean that you haven&amp;#8217;t generated any views yet and you can issue a command like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rails g devise:views admins&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;a href='https://github.com/plataformatec/devise/blob/master/README.rdoc'&gt;Devise README&lt;/a&gt; covers this under the aptly named Configuring Views heading - go read all the juicy details. What you want is for all your User views to live under /app/views/users and all your Admin views to live under /app/views/admins.&lt;/p&gt;

&lt;p&gt;If you are reading this while in the middle of development and you&amp;#8217;ve already generated views for your User model, they will be under /app/views/devise, but that&amp;#8217;s ok, you can still issue the above command and you&amp;#8217;ll get your Admin views under /app/views/admins - just remember where each set of views lives and you&amp;#8217;ll be all good.&lt;/p&gt;

&lt;h2 id='now_use_it'&gt;Now Use It&lt;/h2&gt;

&lt;p&gt;The obvious way to use all this is to add the default Devise before filter:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;before_filter :authenticate_admin!&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Any controller protected that way will redirect to the sign in page unless an Admin is logged in. You can always use either the &lt;code&gt;only&lt;/code&gt; or the &lt;code&gt;except&lt;/code&gt; keywords to pick out controller actions that aren&amp;#8217;t Admin only. This level of protection lets Marketing, Accounting and you all in.&lt;/p&gt;

&lt;p&gt;For your stuff you could add another before filter like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;before_filter :ensure_god_mode

def ensure_god_mode
  redirect_to admin_root_path unless current_admin.god_mode?
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That&amp;#8217;ll make sure only you and your fellow programmers have access.&lt;/p&gt;

&lt;p&gt;For the Accounting people, I tend to use a different approach. For them, I end up blocking things at the view level. I&amp;#8217;ll have an Admin dashboard kind of page that lists things Admin can do and this is how I block them:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;p&amp;gt;Here are the things you can do:&amp;lt;/p&amp;gt;
&amp;lt;ul&amp;gt;
  &amp;lt;li&amp;gt;[something every admin can do]&amp;lt;/li&amp;gt;
  &amp;lt;% unless current_admin.reports_only %&amp;gt;
  &amp;lt;li&amp;gt;[something business people shouldn&amp;#39;t mess with, maybe a link to edit content?]&amp;lt;/li&amp;gt;
  &amp;lt;% end %&amp;gt;
  &amp;lt;li&amp;gt;[another thing any admin can do, maybe a report?]&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There are lots of ways to use your Admin model and the booleans, theses are just a couple patterns I&amp;#8217;ve seen myself using.&lt;/p&gt;

&lt;h2 id='one_last_fun_thing'&gt;One Last Fun Thing&lt;/h2&gt;

&lt;p&gt;Hopefully these notes will help someone figure out how to create Admin accounts that work for their project, I know I&amp;#8217;ve been happy with this approach. I like to keep things fun with my code, so the last thing I wanted to share is an addition I make to the application layout file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;%= &amp;quot;&amp;lt;p id=\&amp;quot;godModeNotice\&amp;quot;&amp;gt;GOD MODE ACTIVE!&amp;lt;/p&amp;gt;&amp;quot;.html_safe if current_admin.god_mode? %&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You&amp;#8217;ll need to tuck it into an &lt;code&gt;if admin_signed_in?&lt;/code&gt; block, but it should get a snort of appreciation from the programmer sitting next to you when he sees it. And its fun when normal Admins see it too.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Quicksilver on Snow Leopard</title>
		<link href="http://jonallured.com/2009/12/30/quicksilver-on-snow-leopard.html"/>
		<updated>2009-12-30T00:00:00-08:00</updated>
		<id>http://jonallured.com/2009/12/30/quicksilver-on-snow-leopard</id>
		<content type="html">&lt;h1 id='quicksilver_on_snow_leopard'&gt;Quicksilver on Snow Leopard&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Wednesday, December 30, 2009&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve been lost and sad ever since I upgraded to Snow Leopard and couldn&amp;#8217;t run &lt;a href='http://docs.blacktree.com/quicksilver/what_is_quicksilver'&gt;Quicksilver&lt;/a&gt;, so I spent a little time today poking around and found &lt;a href='http://groups.google.com/group/blacktree-quicksilver/browse_thread/thread/8432fc6538d2d778'&gt;this post&lt;/a&gt; in Quicksilver&amp;#8217;s Google Group that talks about how you can get it to work. Looks like all you have to do is run a beta version and the post identifies a particular preference file that you should delete - I had to actually delete the entire Quicksilver folder (~/Library/Application Support/Quicksilver) in order to even get it to open. This was the trick for me. I had installed this version before, but when I fired it up, nothing would happen. I had to actually delete this entire folder before it would do anything.&lt;/p&gt;

&lt;p&gt;But now Quicksilver is back and running on my machine and I&amp;#8217;m very happy! Quicksilver is such an important part of my UI that I was really annoyed that I couldn&amp;#8217;t run it anymore and really disheartened to find out that Blacktree hasn&amp;#8217;t addressed this issue. In fact, from what I can tell, they aren&amp;#8217;t actively developing Quicksilver anymore and its been taken over by a group of developers that have moved it over to a &lt;a href='http://github.com/tiennou/blacktree-alchemy'&gt;GitHub repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you&amp;#8217;ve never used Quicksilver, I strongly encourage you to check it out - its a really nice application launcher that goes way beyond that one feature to change how you interact with your computer. If you prefer to keep your hands off the mouse and on the keyboard, you&amp;#8217;ll love Quicksilver.&lt;/p&gt;</content>
	</entry>

	<entry>
		<title>Finding the Mouse Position When an Event Fires</title>
		<link href="http://jonallured.com/2009/12/25/finding-the-mouse-position-when-an-event-fires.html"/>
		<updated>2009-12-25T00:00:00-08:00</updated>
		<id>http://jonallured.com/2009/12/25/finding-the-mouse-position-when-an-event-fires</id>
		<content type="html">&lt;h1 id='finding_the_mouse_position_when_an_event_fires'&gt;Finding the Mouse Position When an Event Fires&lt;/h1&gt;
&lt;p id='articleDate'&gt;published Friday, December 25, 2009&lt;/p&gt;
&lt;p&gt;We recently had a project where we needed to find out where the mouse was (its coordinates) when an event fired (hover). I wanted to create a little &lt;a href='http://files.jonallured.com/examples/mouse_position.html'&gt;example page&lt;/a&gt; that I could play around with to see how this worked.&lt;/p&gt;

&lt;p&gt;The markup is really simple and just creates four divs in red - on &lt;code&gt;over&lt;/code&gt; their background color is changed to green and then its changed back on &lt;code&gt;out&lt;/code&gt;. We&amp;#8217;re using jQuery here, so the syntax is based on the &lt;a href='http://docs.jquery.com/Events/hover'&gt;hover documentation&lt;/a&gt; and the solution as inspired by their &lt;a href='http://docs.jquery.com/Tutorials:Mouse_Position'&gt;Mouse Position tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The magic is really just the bit where you define the hover functions and then the &lt;code&gt;pageX&lt;/code&gt; and &lt;code&gt;pageY&lt;/code&gt; attributes of &lt;code&gt;e&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$(&amp;#39;div.block&amp;#39;).hover(
   function (e) {
      ...
      var msg = &amp;#39;ON! x=&amp;#39; + e.pageX + &amp;#39;, y=&amp;#39; + e.pageY;
      ...
   },
   function (e) {
      ...
      var msg = &amp;#39;OFF! x=&amp;#39; + e.pageX + &amp;#39;, y=&amp;#39; + e.pageY;
      ...
   }
);&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you pass the hover functions a variable, it will give you access to the &lt;a href='http://docs.jquery.com/Events/jQuery.Event'&gt;event object&lt;/a&gt; through which you can determine the mouse&amp;#8217;s position by using its &lt;code&gt;pageX&lt;/code&gt; and &lt;code&gt;pageY&lt;/code&gt; attributes - slick, huh?&lt;/p&gt;

&lt;p&gt;So, I really liked this and wanted to see it in action - I thought &lt;a href='http://getfirebug.com/console.html'&gt;logging the info to the FireBug console&lt;/a&gt; would be a nice way to see it, but later I realized that I wanted to run this code in other browsers (IE), so I made my own console div and then wrote the coordinates to it.&lt;/p&gt;

&lt;p&gt;When I tested this out, however, I didn&amp;#8217;t like that I had to keep scrolling the div to the bottom, so I found a &lt;a href='http://radio.javaranch.com/pascarello/2005/12/14/1134573598403.html'&gt;nice technique&lt;/a&gt; to keep it at the bottom:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function (e) {
   ...
   var consoleDiv = document.getElementById(&amp;#39;console&amp;#39;);
   consoleDiv.scrollTop = consoleDiv.scrollHeight;
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;div&lt;/code&gt; element&amp;#8217;s &lt;code&gt;scrollTop&lt;/code&gt; is set to its &lt;code&gt;scrollHeight&lt;/code&gt; so that it will remain scrolled to the bottom as its size grows. I had never heard of these attributes, but they are nicely documented in Mozilla&amp;#8217;s Developer Center: &lt;a href='https://developer.mozilla.org/en/DOM/element.scrollTop'&gt;scrollTop&lt;/a&gt;, &lt;a href='https://developer.mozilla.org/en/DOM/element.scrollHeight'&gt;scrollHeight&lt;/a&gt;.&lt;/p&gt;</content>
	</entry>

</feed>
