<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Human.  Mostly.

  var _gaq = _gaq || [];
  _gaq.push([‘_setAccount’, ‘UA-29857634-1’]);
  _gaq.push([‘_trackPageview’]);

  (function() {
    var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
    ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
    var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
  })();</description><title>Tim Morton</title><generator>Tumblr (3.0; @tmorton)</generator><link>http://timothymorton.com/</link><item><title>The Periodic Table Puzzle</title><description>&lt;p&gt;In a recent job interview, I got the following puzzle/algorithm question:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You have the standard periodic table of the elements, and a list of words (ie the OSX spell-check dictionary).  How can we find the longest word that appears in the table?  For example, &amp;#8220;NO&amp;#8221; starting at #7.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_m0oqcqsNSm1qb93ek.png"/&gt;&lt;/p&gt;
&lt;p&gt;After a bit of thought, I started sketching out an algorithm based on iterating through the table.  At each cell, we start trying to build words that start at that cell.  For example, at #1 we consider &amp;#8220;H&amp;#8221;, then &amp;#8220;HLi&amp;#8221;, etc.  For each candidate word, we consult the dictionary: is this a word?  (if so, we can consider it for the &amp;#8220;longest word&amp;#8221; prize).  Then we ask a related question: is this a prefix for a word?  That is, does any word start with this character sequence?  If not, then we can abandon this direction, and return to the current starting cell.  After considering each direction from that cell, we can move on to the next one.&lt;/p&gt;
&lt;p&gt;It turns out, the interviewer was thinking of a different algorithm.  First, sort the dictionary by word length.  Starting at the longest word, search through the table for an occurrence of that word.  Stop when we&amp;#8217;ve found a word. &lt;/p&gt;
&lt;p&gt;What followed in the interview was a lot of hand-waving about algorithmic complexity and sketched pseudocode.  Running through the table for every single word in the dictionary (until a match is found) seemed very slow to me.  With my algorithm, I can consider each candidate word in O(log n) on the size of the dictionary, by binary searching on a sorted dictionary.  With his, we&amp;#8217;re considering each candidate word against one dictionary word at a time, but doing this for each word in the dictionary.  That algorithm will end up something like O(n) on the size of the dictionary.  I&amp;#8217;m sure there are optimizations possible to both approaches, but sitting in a conference room with a whiteboard and some notebook paper, I was pretty sure that my approach was correct. &lt;/p&gt;
&lt;h2&gt;Math is hard, let&amp;#8217;s go coding&lt;/h2&gt;
&lt;p&gt;A few weeks later, I was still curious about the question: was my approach really faster?  To answer the question, I whipped up a &lt;a href="https://github.com/tmorton/word_search"&gt;prototype implementation&lt;/a&gt; in ruby.  &lt;/p&gt;
&lt;p&gt;Short answer: I was right.  Solving the puzzle with his algorithm took ~26 seconds on my machine.  My algorithm runs 1000 times in just 5.6 seconds.  Neither version is well-optimized, but I think I&amp;#8217;ve fairly represented the guts of the slower algorithm.  &lt;/p&gt;</description><link>http://timothymorton.com/post/19076773391</link><guid>http://timothymorton.com/post/19076773391</guid><pubDate>Sat, 10 Mar 2012 16:07:38 -0500</pubDate></item><item><title>Be Ruthless (but not yet)</title><description>&lt;p&gt;Earlier this week, &lt;a href="http://playswithfire.com/blog/2012/02/19/you-are-not-ruthless-enough/" title="this excellent piece"&gt;this excellent piece&lt;/a&gt; by Chris Parker made the rounds on Hacker News. &lt;/p&gt;
&lt;blockquote&gt;Here’s the thing: you are not ruthless enough. You are certainly not ruthless enough to your objects, and you probably need to be more ruthless to yourself.&lt;/blockquote&gt;
&lt;p&gt;This is true.  Be ruthless.  But not yet. Let&amp;#8217;s see how Chris continues:&lt;/p&gt;
&lt;blockquote&gt;Being ruthless to yourself means every time you say “oh, I’ll just open up this internal bit over here…” use that moment to give yourself whatever negative feedback you need to go back and write the correct interface.&lt;/blockquote&gt;
&lt;p&gt;When you have an internal bit &amp;#8220;over here&amp;#8221;, and you have a good idea about what you&amp;#8217;re trying to accomplish, then you should be absolutely ruthless. But when you&amp;#8217;re first building something new, even if it&amp;#8217;s just a new set of classes for a small feature, you should be a mild-mannered, dope-smoking, peace-loving hippy. Toss things out there. Share private internals with wild abandon.  Build the messy, cobbled-together version, just to prove that it can work. Then clean it up.&lt;/p&gt;
&lt;p&gt;Remember the &lt;a href="http://c2.com/cgi/wiki?MakeItWorkMakeItRightMakeItFast" title="old aphorism"&gt;old aphorism&lt;/a&gt;:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Make it work&lt;/li&gt;
&lt;li&gt;Make it right&lt;/li&gt;
&lt;li&gt;Make it fast&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Many people skip the second step, and they will encounter the evils that Chris explains.  But other people get stuck on the first step, seeking the correct or elegant solution before they have any sense of the real problem space.  &lt;/p&gt;
&lt;p&gt;This rhythm reoccurs at all scales of the software development process.  In minute-to-minute development, we can write a test, get it to pass, then refactor a little.  With a small feature or bugfix, often &amp;#8220;just do it&amp;#8221; is the way to start - but before committing the code, review with a critical eye.  At the week-to-week level, you need to mind your application architecture, but you also need to deliver real functionality and make sure that real users are happy with the software.    &lt;/p&gt;
&lt;p&gt;So be ruthless with code, not with ideas or concepts or half-formed architecture diagrams floating in your head.  Produce code with joy, with courage, and (occasionally) with wild abandon - before you ruthlessly shape it into something great.&lt;/p&gt;</description><link>http://timothymorton.com/post/18272462339</link><guid>http://timothymorton.com/post/18272462339</guid><pubDate>Sat, 25 Feb 2012 16:51:00 -0500</pubDate></item><item><title>Weird things you cannot do</title><description>&lt;p&gt;Don&amp;#8217;t name a capistrano namespace &amp;#8220;rake&amp;#8221;.  This breaks the db:migrate task, or any other built-in task that tries to run a rake command.  You&amp;#8217;ll get a message like this:&lt;/p&gt;
&lt;pre&gt;executing "cd (your deployment directory) &amp;amp;&amp;amp; #&amp;lt;Capistrano::Configuration::Namespaces::Namespace:0x107e01908&amp;gt; RAILS_ENV=production  db:migrate"&lt;/pre&gt;
&lt;p&gt;This error occurs with Capistrano 2.9, but does not occur with 2.5 - I&amp;#8217;m not going to bother tracking down the exact version that introduced this issue.&lt;/p&gt;</description><link>http://timothymorton.com/post/17375820864</link><guid>http://timothymorton.com/post/17375820864</guid><pubDate>Fri, 10 Feb 2012 11:52:00 -0500</pubDate><category>ruby</category><category>rails</category><category>code</category><category>tips</category></item><item><title>The origin of 20% time</title><description>&lt;p&gt;Six days shall thou hack, and deliver all thy features;&lt;/p&gt;
&lt;p&gt;but the seventh day is a sabbath unto Quality of thy Code; in it thou shall not deliver any business value, nor thy tester, nor thy project manager, thy senior developer nor thy junior developer, nor any consultant or contractor that is within thy company.&lt;/p&gt;</description><link>http://timothymorton.com/post/11522282672</link><guid>http://timothymorton.com/post/11522282672</guid><pubDate>Sun, 16 Oct 2011 09:28:35 -0400</pubDate></item><item><title>New gem: Mixable Engines</title><description>&lt;p&gt;Just published a new gem for my day job: &lt;a href="https://github.com/asee/mixable_engines"&gt;Mixable Engines&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the beginning, there was the engines plugin.  This was back before Rails 2.3, when men were men and there was no &amp;#8220;engines&amp;#8221; functionality built into rails.  The plugin would mix together the controller classes from your engines and your application.  &lt;/p&gt;
&lt;p&gt;In those days, my colleagues and I at the ASEE wrote lots of engines, and lots of apps that used those engines, and all of it depending on this mixed-together architecture.  Now as we upgrade our apps to Rails 3, this gem allows us to keep the existing code and engines working without rewriting everything. &lt;/p&gt;</description><link>http://timothymorton.com/post/9793673037</link><guid>http://timothymorton.com/post/9793673037</guid><pubDate>Sun, 04 Sep 2011 12:47:17 -0400</pubDate></item><item><title>RIP, faithful phone</title><description>&lt;p&gt;I am the least gadget-whoring programmer that I know.  As proof, I submit this fact: my recently-deceased phone was an original, 2g iPhone.  It had become annoyingly slow recently, but I was not planning on forking over the cash to replace it.  But now, sadly, it has decided that the &amp;#8220;touch screen&amp;#8221; does not care about touch, and will just be a screen.&lt;/p&gt;
&lt;p&gt;It has served me well, since the 2007 price drop a few months after launch.  &lt;/p&gt;
&lt;p&gt;Now, bring on the shiny!&lt;/p&gt;</description><link>http://timothymorton.com/post/7238196550</link><guid>http://timothymorton.com/post/7238196550</guid><pubDate>Mon, 04 Jul 2011 16:22:18 -0400</pubDate></item><item><title>Code and Money - a gap in the medium term</title><description>&lt;p&gt;In software development, we&amp;#8217;ve got tools for planning the short run.  Unit tests tell me what code to implement right now.  Daily task lists tell me what to work on today.  GTD helps to manage my week.  &lt;/p&gt;
&lt;p&gt;In planning my personal finances, I&amp;#8217;ve got a good handle on my day to day expenses.  The Mint iPhone app keeps my balances up to date.  I&amp;#8217;ve got money going into my checking account, out to various savings accounts, and paying my bills.  I know, to a good approximation, whether I can really afford an expensive latte in the morning.  &lt;/p&gt;
&lt;p&gt;Similarly, in both areas, my long term planning is about as good as it can be.  Mockups and broad product descriptions give the software project a mission.  Retirement calculators and rules-of-thumb tell me whether I&amp;#8217;ll be ok in the future.  All of these visions are fuzzy, because there&amp;#8217;s unpredictable events in the future, but the tools are there to give us the best possible answers that can we can get.  &lt;/p&gt;
&lt;p&gt;The trouble comes in the medium term.  Your customer wants a new feature for their conference in three months: can you deliver?  What other features need to be rearranged?  You need to replace your car in a year.  How much should you save?  Does that interfere with your vacation plans?  The medium term is where the art of planning gets dicey.  It&amp;#8217;s close enough that real decisions and commitments are needed, but far enough that intuitive notions of &amp;#8220;easy&amp;#8221;, &amp;#8220;hard&amp;#8221;, &amp;#8220;expensive&amp;#8221; and &amp;#8220;minor&amp;#8221; are not sufficient.  In the medium term, there are multiple projects, each with different deadlines, requirements, and priorities.  &lt;/p&gt;
&lt;p&gt;Right now I have six medium-term financial goals, all with different deadlines.  Some are flexible, both in date and amount - I could put off my vacations, or do something less expensive.  Some are not - the property taxes must be paid by the deadline, come hell or high water.  I don&amp;#8217;t have a good way to visualize how they all fit together - in fact, I&amp;#8217;m thinking of writing a tool.  Given a fixed number of dollars per paycheck, will that allow me to pay everything?  Or, given fixed amounts and deadlines, how much do I need to pay per paycheck?  &lt;/p&gt;
&lt;p&gt;Right now I have several projects in the works, some with deadlines, some without.  If the deadlines can&amp;#8217;t be met, then customers need to know as soon as possible, but none of them are overwhelming on their own.  The question is, can they all fit together into my schedule, in a way that satisfies everyone?&lt;/p&gt;</description><link>http://timothymorton.com/post/2434484483</link><guid>http://timothymorton.com/post/2434484483</guid><pubDate>Thu, 23 Dec 2010 14:44:00 -0500</pubDate></item><item><title>$30/hr Java Coders are not Photography</title><description>&lt;p&gt;In the beginning, there were painters.  They were artists and chroniclers of reality.&lt;/p&gt;
&lt;p&gt;At the RailsConf keynote, Neil Ford claimed that photography changed painting, by freeing painters from the burden of representing reality.  He then went on to claim that &amp;#8220;enterprise java&amp;#8221; development will do the same for programming - freeing us from the drudgery of faithfully copying business processes.&lt;/p&gt;
&lt;p&gt;This is sort of correct - we are (slowly) being freed from the boring and repetitive parts of our craft, but not because we&amp;#8217;re outsourcing those pieces to India and Romania.  Just like painters, we&amp;#8217;re outsourcing those pieces to machines.  Libraries, compilers, and frameworks free us from &amp;#8220;accurately&amp;#8221; representing the computers with which we&amp;#8217;re working.  More importantly, we&amp;#8217;re making progress from the other direction, taking the simplest business problems and automating them too.  Spreadsheets freed up programmers from developing simple math applications.  Google Docs Forms and similar things mean that basic form-crud will soon be a thing of the past.  These problems will be solved by the combination of machines and non-experts, just like the &amp;#8220;capture this scene&amp;#8221; problem is solved by a non-painter and his camera.&lt;/p&gt;</description><link>http://timothymorton.com/post/680438183</link><guid>http://timothymorton.com/post/680438183</guid><pubDate>Wed, 09 Jun 2010 11:37:00 -0400</pubDate><category>railsconf</category><category>programming</category><category>business</category></item><item><title>TDD Survey Results</title><description>&lt;p&gt;I gave a lightning talk at RubyNation called &amp;#8220;TDD in the real world&amp;#8221;, mostly as an excuse to poll the audience about testing practices. &lt;/p&gt;
&lt;p&gt;The most interesting question for me was - how many people follow the standard &amp;#8220;red, green, refactor&amp;#8221; cycle in their day to day development? I asked - who follows this pattern more than half the time? 70% of the time? 100% of the time? Results:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;50% - about half the audience.&lt;/li&gt;
&lt;li&gt;70% - ~40% of the audience (I&amp;#8217;m in this category)&lt;/li&gt;
&lt;li&gt;100% - 5 and a half people, including Yehuda Katz&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;A lot of people are not doing strict TDD. This is the RubyNation conference, which had &lt;a title="TATFT"&gt;TATFT&lt;/a&gt; last year. This is the Ruby community, which has a ton of experimentation and a million test frameworks. Frankly, I&amp;#8217;m kind of baffled. Are these people doing a lot of research-style code spikes? Are they writing tests after the code, but still getting decent test coverage? Or is testing just &amp;#8220;exercise and vegetables&amp;#8221; - things that people should be doing, but don&amp;#8217;t?&lt;/p&gt;
&lt;p&gt;More research is needed.&lt;/p&gt;</description><link>http://timothymorton.com/post/479738643</link><guid>http://timothymorton.com/post/479738643</guid><pubDate>Sun, 14 Jun 2009 00:00:00 -0400</pubDate></item><item><title>Engines and routes - a simple solution</title><description>&lt;p&gt;So the new Engines feature in Rails 2.3 is great, but there&amp;#8217;s one big problem with the way it handles routes. The routes in all of your engines are loaded before your application routes. This is a big problem if your engines have a catch-all default route for a CMS-type thing.&lt;/p&gt;
&lt;p&gt;The Thoughtbot guys have &lt;a title="one solution" href="http://robots.thoughtbot.com/post/159805560/tips-for-writing-your-own-rails-engine"&gt;one solution&lt;/a&gt; which involves alias_method_chain and the ActionController internals. Fortunately, there&amp;#8217;s a much simpler way.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;In your engine, rename routes.rb to my_routes.rb.&lt;/li&gt;
&lt;li&gt;At the end of your application routes.rb file, add this line:
&lt;pre&gt;ActionController::Routing::Routes.add_configuration_file(&lt;/pre&gt;
&lt;pre&gt;  "#{RAILS_ROOT}/vendor/plugins/cms/config/my_routes.rb")&lt;/pre&gt;
(&amp;#8220;cms&amp;#8221; is the engine name, replace it with your own)&lt;/li&gt;
&lt;li&gt;That line goes &lt;strong&gt;outside&lt;/strong&gt; the block that covers the rest of the routes.rb file.&lt;/li&gt;
&lt;/ul&gt;</description><link>http://timothymorton.com/post/479724714</link><guid>http://timothymorton.com/post/479724714</guid><pubDate>Mon, 25 May 2009 00:00:00 -0400</pubDate></item></channel></rss>

