<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Adam Bondurant</title>
	<link>http://www.adambondurant.com</link>
	<description>Everything/Nothing</description>
	<pubDate>Thu, 26 Jun 2008 23:18:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3</generator>
	<language>en</language>
			<item>
		<title>Sort by a list of IDs queried using MySQL&#039;s IN() function</title>
		<link>http://www.adambondurant.com/2008/06/26/sort-by-a-list-of-ids-queried-using-mysqls-in-function/</link>
		<comments>http://www.adambondurant.com/2008/06/26/sort-by-a-list-of-ids-queried-using-mysqls-in-function/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 23:08:25 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Education]]></category>

		<guid isPermaLink="false">http://www.adambondurant.com/2008/06/26/sort-by-a-list-of-ids-queried-using-mysqls-in-function/</guid>
		<description><![CDATA[
  I run into this problem from time to time, and I&#039;ve finally put enough energy into it that I want
  to commit it to memory through the blog. The most common occurrence of this in my world is when
  performing a search using something like Lucene or Sphinx. Here&#039;s what usually [...]]]></description>
			<content:encoded><![CDATA[<p>
  I run into this problem from time to time, and I&#039;ve finally put enough energy into it that I want
  to commit it to memory through the blog. The most common occurrence of this in my world is when
  performing a search using something like Lucene or Sphinx. Here&#039;s what usually happens:
</p>
<p>
  I perform a search using my engine of choice. Sphinx, for example, will give me back a hash of
  results formatted like this:
</p>
<pre>
  Array
  (
    [matches] => Array
    (
      [10546] => Array
      (
        [weight] => 3
        [attrs] => Array
        (
          [feed_id] => 624
          [published_at] => 1213713545
        )
      )
      [14154] => Array
      (
        [weight] => 3
        [attrs] => Array
        (
          [feed_id] => 583
          [published_at] => 1213801410
        )
      )
      ...
    )
    [time] => 0.000
    ...
  )
</pre>
<p>
  Since I do not store my full-text fields in my index, I then have to take the IDs from the
  <tt>matches</tt> array and query the database to get at my data. The query is simple:
</p>
<pre class="textmate-source"><span class="source source_sql"><span class="keyword keyword_other keyword_other_DML keyword_other_DML_sql">SELECT</span> <span class="keyword keyword_operator keyword_operator_star keyword_operator_star_sql">*</span> <span class="keyword keyword_other keyword_other_DML keyword_other_DML_sql">FROM</span> items <span class="keyword keyword_other keyword_other_DML keyword_other_DML_sql">WHERE</span> id <span class="keyword keyword_other keyword_other_data-integrity keyword_other_data-integrity_sql">IN</span> (<span class="constant constant_numeric constant_numeric_sql">10546</span>, <span class="constant constant_numeric constant_numeric_sql">14154</span>, &#8230;);</span></pre>
<p>
  Unfortunately, that query will not necessarily return the rows in the order I provided.
  This is an easy fix if I&#039;d like to sort my results on a column in my database, since I can
  just add a quick <tt>ORDER BY</tt> clause on say, the date the item was created. But if I
  searched the database for results sorted by relevance, the database really doesn&#039;t know
  anything about how to sort that way. I need a way to tell MySQL to sort the results in
  the order I&#039;ve supplied my IDs, which leads us to at least two functions: <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set"><tt>FIND_IN_SET</tt></a>
  and <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_field"><tt>FIELD</tt></a>.
</p>
<p>
  Both functions work the same way: Given a string (or column) as the first argument, they
  return the 1-based index &#8212; or zero if not found &#8212; of the argument in either the list of additional
  arguments (<tt>FIELD</tt>) or the second argument, a comma-delimited string (<tt>FIND_IN_SET</tt>). For
  my purposes, then, my query looks like this:
</p>
<pre class="textmate-source"><span class="source source_sql"><span class="comment comment_line comment_line_number-sign comment_line_number-sign_sql"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_sql">#</span> Using FIELD
</span><span class="keyword keyword_other keyword_other_DML keyword_other_DML_sql">SELECT</span> <span class="keyword keyword_operator keyword_operator_star keyword_operator_star_sql">*</span> <span class="keyword keyword_other keyword_other_DML keyword_other_DML_sql">FROM</span> items <span class="keyword keyword_other keyword_other_DML keyword_other_DML_sql">WHERE</span> id <span class="keyword keyword_other keyword_other_data-integrity keyword_other_data-integrity_sql">IN</span> (<span class="constant constant_numeric constant_numeric_sql">10546</span>, <span class="constant constant_numeric constant_numeric_sql">14154</span>, &#8230;) <span class="keyword keyword_other keyword_other_DML keyword_other_DML_sql">ORDER BY</span> FIELD(id, <span class="constant constant_numeric constant_numeric_sql">10546</span>, <span class="constant constant_numeric constant_numeric_sql">14154</span>, &#8230;);

<span class="comment comment_line comment_line_number-sign comment_line_number-sign_sql"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_sql">#</span> Using FIND_IN_SET
</span><span class="keyword keyword_other keyword_other_DML keyword_other_DML_sql">SELECT</span> <span class="keyword keyword_operator keyword_operator_star keyword_operator_star_sql">*</span> <span class="keyword keyword_other keyword_other_DML keyword_other_DML_sql">FROM</span> items <span class="keyword keyword_other keyword_other_DML keyword_other_DML_sql">WHERE</span> id <span class="keyword keyword_other keyword_other_data-integrity keyword_other_data-integrity_sql">IN</span> (<span class="constant constant_numeric constant_numeric_sql">10546</span>, <span class="constant constant_numeric constant_numeric_sql">14154</span>, &#8230;) <span class="keyword keyword_other keyword_other_DML keyword_other_DML_sql">ORDER BY</span> FIND_IN_SET(id, <span class="string string_quoted string_quoted_single string_quoted_single_sql"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_sql">&#039;</span>10546,14154,&#8230;&#039;</span>);</span></pre>
<p>
  Both functions will return the same results, sorted the same way. I went so far as to profile
  both, too, just to make sure I was using the best function. Granted, when I profiled this using
  MySQL&#039;s built-in profiler, my query was pretty simple (as it should be, in my opinion). Your
  mileage may vary:
</p>
<pre>
  +----------+------------+------------------------------+
  | Query_ID | Duration   | Sorting result | Query       |
  +----------+------------+------------------------------+
  |        1 | 0.01572400 | 0.001129       | FIND_IN_SET |
  |        2 | 0.00241400 | 0.00127        | FIELD       |
  |        3 | 0.00194700 | 0.00114        | FIND_IN_SET |
  |        4 | 0.00193100 | 0.001121       | FIELD       |
  |        5 | 0.00192300 | 0.001116       | FIND_IN_SET |
  |        6 | 0.00192100 | 0.001101       | FIELD       |
  +----------+------------+------------------------------+
</pre>
<p>
  Note that the query result is a hybrid between <tt>show profiles</tt> and <tt>show profile for query [id]</tt>,
  and I&#039;ve ripped out the actual query because all I care about is the sorting function being used (the query
  is the same otherwise). The duration on the whole was lower in each subsequent query because of MySQL&#039;s query cache,
  but since I really wasn&#039;t interested in that anyway &#8212; just the sorting duration &#8212; it doesn&#039;t really matter.
</p>
<p>
  The profiling I did was ridiculously contrived, but it did go to show me, based on the miniscule differences, that
  it most likely will not matter which function I use (although <tt>FIND_IN_SET</tt> ultimately won out over my
  <i>exhaustive</i> six-query profile).
</p>]]></content:encoded>
			<wfw:commentRss>http://www.adambondurant.com/2008/06/26/sort-by-a-list-of-ids-queried-using-mysqls-in-function/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Awesome recruiter email</title>
		<link>http://www.adambondurant.com/2008/06/19/awesome-recruiter-email/</link>
		<comments>http://www.adambondurant.com/2008/06/19/awesome-recruiter-email/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 18:57:47 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://www.adambondurant.com/2008/06/19/awesome-recruiter-email/</guid>
		<description><![CDATA[
  Holy hell, this is amazing:


  
    Hello Allan,
  
  
    I am vara, recruiter form Tekforcecorp.
    I saw your resume on Internet and we have a immediate requirement for PHP developer.
    please see the requirement and let me [...]]]></description>
			<content:encoded><![CDATA[<p>
  Holy hell, this is amazing:
</p>
<blockquote>
  <p>
    Hello Allan,
  </p>
  <p>
    I am vara, recruiter form Tekforcecorp.<br />
    I saw your resume on Internet and we have a immediate requirement for PHP developer.<br />
    please see the requirement and let me know if you are interested. Please get back to me with updated rseume and salary info.This is a fulltime position.<br />
  </p>
  <p>
    Responsibilities:
  </p>
  <ul>
    <li>Develop web applications and services</li>
    <li>Apply industry best-practice software standards and technology to complex business problems</li>
    <li>Help set-up and maintain development, test and production environments</li>
  </ul>
  <p>
    Qualifications:
  </p>
  <ul>
    <li>Bachelors degree in CS or related field, or equivalent experience</li>
    <li>2+ years experience in design and development of commercial web applications on multiple platforms</li>
    <li>Previous professional experience with PHP required (PHP5 preferred)</li>
    <li>Current experience with MySQL required</li>
    <li>Basic understanding of OOP principles and practices is required</li>
    <li>Experience with Java, Ruby on Rails, and/or object oriented C++ a plus</li>
    <li>Experience with AJAX a plus</li>
    <li>Ability to work on a small team, in a start-up environment</li>
    <li>Ability to handle multiple concurrent activities and have a flexible, positive attitude</li>
    <li>Excellent verbal, written and communication skills is a must</li>
    <li>Must be team-oriented, with an interest and willingness to help develop and mentor the engineering team as it grows</li>
  </ul>
  <p>
    Vara<br />
    Tekforce Corp<br />
    2420 Camino Ramon , Suite 212<br />
    San Ramon, CA 94583<br />
    925 866 8200 ext. 234<br />
    925 866 8219 Fax<br />
    vara@tekforcecorp.com<br />
  </p>
</blockquote>]]></content:encoded>
			<wfw:commentRss>http://www.adambondurant.com/2008/06/19/awesome-recruiter-email/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Make Rails&#039; Auto-linker Accept Parentheses</title>
		<link>http://www.adambondurant.com/2008/05/21/make-rails-auto-linker-accept-parentheses/</link>
		<comments>http://www.adambondurant.com/2008/05/21/make-rails-auto-linker-accept-parentheses/#comments</comments>
		<pubDate>Wed, 21 May 2008 19:06:30 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Education]]></category>

		<guid isPermaLink="false">http://www.adambondurant.com/2008/05/21/make-rails-auto-linker-accept-parentheses/</guid>
		<description><![CDATA[
  The Rails helper, auto_link is a handy way to scan a block of text,
  adding HTML links as they are found. I recognized an issue with its regular
  expression, however, when dealing with files commonly linked to on
  VerticalWire.


  The links in question look like this:
  http://www.website.com/assets/screenshotbundle(5-20-08).zip
  [...]]]></description>
			<content:encoded><![CDATA[<p>
  The Rails helper, <tt>auto_link</tt> is a handy way to scan a block of text,
  adding HTML links as they are found. I recognized an issue with its regular
  expression, however, when dealing with files commonly linked to on
  <a href="http://verticalwire.com" title="External Link: VerticalWire.com">VerticalWire</a>.
</p>
<p>
  The links in question look like this:
  <pre>http://www.website.com/assets/screenshotbundle(5-20-08).zip</pre>
  Unfortunately, Rails was creating links that looked something like this:
  <pre><a href="http://www.website.com/assets/screenshotbundle">http://www.website.com/assets/screenshotbundle</a>(5-20-08).zip</pre>
  While parentheses aren&#039;t necessarily commonplace in URLs, they&#039;re still
  acceptable; Web browsers won&#039;t balk when they&#039;re encountered. It&#039;s clear that
  we need to patch our helper to accept parentheses.
</p>
<p>
  Delving into the <tt>auto_link</tt> method in ActionView::Helpers::TextHelper,
  it&#039;s working off a rather large regular expression defined as the constant,
  <tt>AUTO_LINK_RE</tt>. To safely change this constant, you need to do so
  within the initializer block in <tt>environment.rb</tt>. If you try to define
  it by putting a file in the <tt>config/initializers</tt> directory, you&#039;ll get
  a warning that the constant has already been defined. Here&#039;s my updated
  definition:
</p>
<pre class="textmate-source"><span class="source source_ruby source_ruby_rails"><span class="support support_class support_class_ruby">Rails</span><span class="punctuation punctuation_separator punctuation_separator_other punctuation_separator_other_ruby">::</span><span class="support support_class support_class_ruby">Initializer</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>run <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do </span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span><span class="variable variable_other variable_other_block variable_other_block_ruby">config</span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span>
<span class="meta meta_module meta_module_ruby">  <span class="keyword keyword_control keyword_control_module keyword_control_module_ruby">module</span> <span class="entity entity_name entity_name_type entity_name_type_module entity_name_type_module_ruby">ActionView</span></span>
<span class="meta meta_module meta_module_ruby">    <span class="keyword keyword_control keyword_control_module keyword_control_module_ruby">module</span> <span class="entity entity_name entity_name_type entity_name_type_module entity_name_type_module_ruby">Helpers</span></span>
<span class="meta meta_rails meta_rails_helper">      <span class="keyword keyword_control keyword_control_ruby">module</span> <span class="variable variable_other variable_other_constant variable_other_constant_ruby">TextHelper</span>
        <span class="variable variable_other variable_other_constant variable_other_constant_ruby">AUTO_LINK_RE</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_regexp string_regexp_mod-r string_regexp_mod-r_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">%r{</span>
          <span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>                          <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> leading text</span>
            &lt;<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\w</span>+.*?&gt;|                <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> leading HTML tag, or</span>
            <span class="string string_regexp string_regexp_character-class string_regexp_character-class_ruby"><span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">[</span>^=!:&#039;&#034;/<span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">]</span></span>|               <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> leading punctuation, or</span>
            |                        <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> nothing</span>
          <span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>
          <span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>
            <span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>?:https?://<span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>|           <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> protocol spec, or</span>
            <span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>?:www<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\.</span><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>                <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"># www.*</span>
          <span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>
          <span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>
            <span class="string string_regexp string_regexp_character-class string_regexp_character-class_ruby"><span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">[</span>-<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\w</span><span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">]</span></span>+                   <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> subdomain or domain</span>
            <span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>?:<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\.</span><span class="string string_regexp string_regexp_character-class string_regexp_character-class_ruby"><span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">[</span>-<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\w</span><span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">]</span></span>+<span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>*            <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> remaining subdomains or domain</span>
            <span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>?::<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\d</span>+<span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>?                <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> port</span>
            <span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>?:/<span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>?:<span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>?:<span class="string string_regexp string_regexp_character-class string_regexp_character-class_ruby"><span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">[</span>~<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\w\+</span>@%=<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\(\)</span>-<span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">]</span></span>|<span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>?:<span class="string string_regexp string_regexp_character-class string_regexp_character-class_ruby"><span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">[</span>,.;:<span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">][</span>^<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\s</span>$<span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">]</span></span><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>+<span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>?<span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>* <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> path</span>
            <span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>?:<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\?</span><span class="string string_regexp string_regexp_character-class string_regexp_character-class_ruby"><span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">[</span><span class="constant constant_character constant_character_escape constant_character_escape_ruby">\w\+</span>@%&amp;=.;-<span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">]</span></span>+<span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>?    <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> query string</span>
            <span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span>?:<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\#</span><span class="string string_regexp string_regexp_character-class string_regexp_character-class_ruby"><span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">[</span><span class="constant constant_character constant_character_escape constant_character_escape_ruby">\w\-</span><span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">]</span></span>*<span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>?           <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> trailing anchor</span>
          <span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>
          <span class="string string_regexp string_regexp_group string_regexp_group_ruby"><span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">(</span><span class="string string_regexp string_regexp_character-class string_regexp_character-class_ruby"><span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">[</span>[:punct:<span class="punctuation punctuation_definition punctuation_definition_character-class punctuation_definition_character-class_ruby">]</span></span>]|<span class="constant constant_character constant_character_escape constant_character_escape_ruby">\s</span>|&lt;|$<span class="punctuation punctuation_definition punctuation_definition_group punctuation_definition_group_ruby">)</span></span>       <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> trailing text</span>
        <span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">}x</span></span>
      </span><span class="keyword keyword_control keyword_control_ruby">end</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class="keyword keyword_control keyword_control_ruby">end</span>
</span></pre>
<p>
  <b>Update:</b> <a href="http://rails.lighthouseapp.com/projects/8994/tickets/234-make-auto_link-accept-parentheses-in-urls#ticket-234-1" title="External Link: Lighthouse">I&#039;ve created a ticket to correct this behavior</a>.
</p>]]></content:encoded>
			<wfw:commentRss>http://www.adambondurant.com/2008/05/21/make-rails-auto-linker-accept-parentheses/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Recruiters are hilarious</title>
		<link>http://www.adambondurant.com/2008/05/08/recruiters-are-hilarious/</link>
		<comments>http://www.adambondurant.com/2008/05/08/recruiters-are-hilarious/#comments</comments>
		<pubDate>Thu, 08 May 2008 19:13:07 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://www.adambondurant.com/2008/05/08/recruiters-are-hilarious/</guid>
		<description><![CDATA[I just got a call from someone (Josh? Jason?) at a recruiter. It took him a few seconds to tell me he was, in fact, a recruiter, but once he did, I realized I didn&#039;t want to talk, told him, &#034;No thanks. Bye.&#034; and hung up the phone. I could hear him keep talking on [...]]]></description>
			<content:encoded><![CDATA[I just got a call from someone (Josh? Jason?) at a recruiter. It took him a few seconds to tell me he was, in fact, a recruiter, but once he did, I realized I didn&#039;t want to talk, told him, &#034;No thanks. Bye.&#034; and hung up the phone. I could hear him keep talking on the other end as I pulled away my phone, but hung up none-the-less.

Not two seconds after I put down my phone did he call back, and as such, went to my voicemail box. I couldn&#039;t wait to hear what the message might entail. It went something like this:
<blockquote>Hey, Adam. It&#039;s [what&#039;s-his-name] again. I&#039;m going to send you a check in the mail for $1.55 for etiquette lessons, because it&#039;s obvious your mother never taught you that it&#039;s rude to hang up on someone.</blockquote>

Wah wah. Have fun at you crappy recruiting job, Jessie.

Or maybe it was Jeff?]]></content:encoded>
			<wfw:commentRss>http://www.adambondurant.com/2008/05/08/recruiters-are-hilarious/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A case for methodizing your constants</title>
		<link>http://www.adambondurant.com/2008/04/04/a-case-for-methodizing-your-constants/</link>
		<comments>http://www.adambondurant.com/2008/04/04/a-case-for-methodizing-your-constants/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 16:17:49 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Education]]></category>

		<guid isPermaLink="false">http://www.adambondurant.com/2008/04/04/a-case-for-methodizing-your-constants/</guid>
		<description><![CDATA[
  I was testing a bit of Rails code today and came across a spot where I wanted a unit test to make sure my method was going to properly handle an upper limit on associated objects. Think of it like this:

class Release &#60; ActiveRecord::Base
  has_many :tags
  
  MAX_TAGS = 15
 [...]]]></description>
			<content:encoded><![CDATA[<p>
  I was testing a bit of Rails code today and came across a spot where I wanted a unit test to make sure my method was going to properly handle an upper limit on associated objects. Think of it like this:
</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby"><span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Release<span class="entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby"> <span class="punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby">&lt;</span> ActiveRecord::Base</span></span></span>
  has_many <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>tags</span>
  
  <span class="variable variable_other variable_other_constant variable_other_constant_ruby">MAX_TAGS</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="constant constant_numeric constant_numeric_ruby">15</span>
  
  <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">associate</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">tag</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
    <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>tags <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">&lt;&lt;</span> tag <span class="keyword keyword_control keyword_control_ruby">unless</span> <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>tags<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>size <span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby">==</span> <span class="variable variable_other variable_other_constant variable_other_constant_ruby">MAX_TAGS</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>
  At 15 max tags, either I&#039;m going to clutter up my tests with dummy data, or I&#039;m going to drive myself insane creating needless fixtures. I use <a href="http://mocha.rubyforge.org/" title="External Link: Mocha">Mocha</a> to stub out methods in my tests, so I immediately asked myself, &#034;How can I stub a constant?&#034; You can go ahead and alter the constant in your test case using <tt>const_set</tt>, but that requires that you set it back at the end of your test. Another option is to methodize the constant and stub it out like you would any other method:
</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby"><span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Release<span class="entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby"> <span class="punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby">&lt;</span> ActiveRecord::Base</span></span></span>
  has_many <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>tags</span>
  
  <span class="variable variable_other variable_other_constant variable_other_constant_ruby">MAX_TAGS</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="constant constant_numeric constant_numeric_ruby">15</span>
  
  <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">self.max_tags</span></span>
    <span class="variable variable_other variable_other_constant variable_other_constant_ruby">MAX_TAGS</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>
  
  <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">associate</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">tag</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
    <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>tags <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">&lt;&lt;</span> tag <span class="keyword keyword_control keyword_control_ruby">unless</span> <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>tags<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>size <span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby">==</span> <span class="support support_class support_class_ruby">Release</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>max_tags
  <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>
  Now, in your test case, you can just stub out your new class method and, provided you&#039;re now accessing the constant in your original method through its new wrapper method, you&#039;re all set:
</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby"><span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">ReleaseTest<span class="entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby"> <span class="punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby">&lt;</span> ActiveSupport::TestCase</span></span></span>
  <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">test_associate</span></span>
    <span class="support support_class support_class_ruby">Release</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>stubs<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>max_tags</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>returns<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">1</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    
    assert_no_difference <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">&#039;</span>release(:first).tags.reload.size<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">&#039;</span></span> <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do
</span>      release<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>first</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>associate<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>tags<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>new</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">))</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>]]></content:encoded>
			<wfw:commentRss>http://www.adambondurant.com/2008/04/04/a-case-for-methodizing-your-constants/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Start Simple, End With a Flourish</title>
		<link>http://www.adambondurant.com/2008/04/03/start-simple-end-with-a-flourish/</link>
		<comments>http://www.adambondurant.com/2008/04/03/start-simple-end-with-a-flourish/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 16:00:22 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Education]]></category>

		<guid isPermaLink="false">http://www.adambondurant.com/2008/04/03/start-simple-end-with-a-flourish/</guid>
		<description><![CDATA[
  As I continue developing new sites, I find myself falling into development patterns. I&#039;m trying to foster some of them, but there&#039;s one habit in particular I&#039;m trying to break: I realize that when I began my most recent project, it was littered with JavaScript-y goodness in an effort to get the &#034;wow&#034; [...]]]></description>
			<content:encoded><![CDATA[<p>
  As I continue developing new sites, I find myself falling into development patterns. I&#039;m trying to foster some of them, but there&#039;s one habit in particular I&#039;m trying to break: I realize that when I began my most recent project, it was littered with JavaScript-y goodness in an effort to get the &#034;wow&#034; factor from users. As time has worn on, however, I&#039;ve found myself ripping out more and more of this chrome, to the point where the majority of my site now functions as a &#034;normal&#034; Web application.
</p>
<p>
  One of the first pieces of AJAX I added to this project was the ability to edit a &#034;media bar&#034; while still browsing the page it was on. You&#039;d click an &#034;edit&#034; link in a vertically floated DIV, and it would scale upwards in sort of a light box effect, while fading out its contents and fading in controls to edit those contents. Now, don&#039;t get me wrong. This control looked cool (take my word for it). I still have the code lying around in an old Subversion check-in, because I&#039;m a bit proud of it, actually.
</p>
<p>
  The problem with my editable media bar was that ultimately, it was too stylish for its own good. The novelty wore off after a few uses, and then I was stuck with a difficult-to-maintain piece of JavaScript that never seemed to fit with the rest of the site. But I had spent like three days on it! It was so cool! Which is why it had to go: I had spent so much time on it that I had tunnel vision, and when our designer actually got around to seeing it, he didn&#039;t even make a peep; it wasn&#039;t even a blip on his radar.
</p>
<p>
  Something I had to realize was that if I really wanted this element on the site, I had to also be comfortable taking it away, and reevaluating it. It may come back in a similar form in the future, but for a version 1.0 release, it wasn&#039;t worth the time I spent creating it. I&#039;ve reverted to a standard link to send users to the media bar edit page, and its functionality is as good, if not better, than my initial flashy solution.
</p>
<p>
  So I&#039;m going to be starting simple on my next project. JavaScript and AJAX can wait. It has its place on The Web, but for most everyday user interface patterns, it&#039;s just overkill, and the benefits do not outweigh the development time.
</p>]]></content:encoded>
			<wfw:commentRss>http://www.adambondurant.com/2008/04/03/start-simple-end-with-a-flourish/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bagels: Cafe Encore</title>
		<link>http://www.adambondurant.com/2008/01/26/bagels-cafe-encore/</link>
		<comments>http://www.adambondurant.com/2008/01/26/bagels-cafe-encore/#comments</comments>
		<pubDate>Sun, 27 Jan 2008 00:35:56 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Food]]></category>

		<category><![CDATA[]]></category>

		<guid isPermaLink="false">http://www.adambondurant.com/2008/01/28/bagels-cafe-encore/</guid>
		<description><![CDATA[
  
  
  View Larger Map


  I started my search for the perfect bagel near Union Square at Cafe Encore.
  This little cafe is situated on Post Street at Mason Street, about a block
  away from my office. Its sign is small and is sandwiched between two other
  [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; border: 1px solid #CCC; padding: 3px 0 3px 3px">
  <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=l&amp;hl=en&amp;geocode=17617530478859365968,37.788076,-122.409850&amp;q=cafe+encore&amp;near=san+francisco,+ca&amp;ie=UTF8&amp;om=0&amp;cid=37788076,-122409850,6570069591277087314&amp;s=AARTsJrj-f-N7EgHkLtC9TC-hGGNSZVh1A&amp;ll=37.790303,-122.408938&amp;spn=0.005935,0.00912&amp;z=16&amp;iwloc=A&amp;output=embed"></iframe>
  <br />
  <small><a href="http://maps.google.com/maps?f=l&amp;hl=en&amp;geocode=17617530478859365968,37.788076,-122.409850&amp;q=cafe+encore&amp;near=san+francisco,+ca&amp;ie=UTF8&amp;om=0&amp;cid=37788076,-122409850,6570069591277087314&amp;ll=37.790303,-122.408938&amp;spn=0.005935,0.00912&amp;z=16&amp;iwloc=A&amp;source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>
</div>
<p>
  I started my search for the perfect bagel near Union Square at Cafe Encore.
  This little cafe is situated on Post Street at Mason Street, about a block
  away from my office. Its sign is small and is sandwiched between two other
  signs, so if you&#039;re coming from the East, you might miss it.
</p>
<p>
  The cafe itself is small with a few places to sit, a juice fridge, ATM, and a
  menu with a healthy assortment of both breakfast and lunch options. The two
  women I&#039;ve seen working there are very friendly and are willing to chat with
  the customers. There is a sign behind the register that advises, &#034;No soup for
  you! (We&#039;re temporarily sold out, sorry)&#034; and people seem to get a kick out of
  it.
</p>
<p>
  Regarding the bagels, I should start by saying that I&#039;m looking at four
  things with these reviews:
  <ul>
    <li>Appearance</li>
    <li>Price</li>
    <li>Bagel bread</li>
    <li>Cream cheese</li>
  </ul>
  All bagels will be toasted, plain, with plain cream cheese. Now, onto the
  review for Cafe Encore.
</p>
<ul>
  <li>
    <b>Appearance:</b> The bagel doesn&#039;t really look good at all. It&#039;s smooshed,
    and reminds me of Lender&#039;s bagels. Even when toasted, I feel like it&#039;s just
    going to ooze cream cheese and not have that crunch I love so much when
    bitten into.
  </li>
  <li>
    <b>Price:</b> The bagel costs $2.50. I&#039;m used to a $2.06 bagel, but I&#039;ve
    come to accept that most everything costs more in Union Square, so I&#039;m not
    too concerned. I will say that $2.50 is on the high end of what I expect to
    pay for my bagel, though, and anything more than that will just disappoint,
    unless it&#039;s God&#039;s gift to bagels.
  </li>
  <li>
    <b>Bagel bread:</b> The appearance says it all: the bread is squishy and
    lacks character. There&#039;s nothing like biting into a fresh, toasted piece of
    bread, but this comes nowhere close to perfection.
  </li>
  <li>
    <p>
      <b>Cream cheese:</b> The coverage on the bagel is spotty at best. I pulled
      off one quarter of the bagel only to realize that 95% of the cream cheese
      came with it, leaving the other piece beneath it with very little. I&#039;m not
      looking forward to eating a piece of bagel with almost no cream cheese.
    </p>
    <p>
      Another problem is that the cream cheese is really warm and gooey. I like
      a firm, cold cream cheese to contrast the toasted bagel, but this stuff
      doesn&#039;t hold up to the heat and threatens to turn into a drippy mess.
    </p>
  </li>
</ul>
<p>
  While I enjoy the cafe itself, I&#039;m going to have to avoid Cafe Encore&#039;s bagels
  from now on. There are too many things wrong with them to keep going back.
</p>]]></content:encoded>
			<wfw:commentRss>http://www.adambondurant.com/2008/01/26/bagels-cafe-encore/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A new gym</title>
		<link>http://www.adambondurant.com/2008/01/23/a-new-gym/</link>
		<comments>http://www.adambondurant.com/2008/01/23/a-new-gym/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 15:21:47 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Random]]></category>

		<category><![CDATA[]]></category>

		<guid isPermaLink="false">http://www.adambondurant.com/2008/01/23/a-new-gym/</guid>
		<description><![CDATA[
  I&#039;m starting a new gym. It&#039;s actually going to be a chain of gyms, but I&#039;m
  getting ahead of myself. My new gym is fabulous. It&#039;s exclusionary. It&#039;s
  better than any gym you&#039;ve ever been to.


  My gym does not accept membership during the months of November, December, 
  [...]]]></description>
			<content:encoded><![CDATA[<p>
  I&#039;m starting a new gym. It&#039;s actually going to be a chain of gyms, but I&#039;m
  getting ahead of myself. My new gym is fabulous. It&#039;s exclusionary. It&#039;s
  better than any gym you&#039;ve ever been to.
</p>
<p>
  <b>My gym does not accept membership during the months of November, December, 
  January, nor February.</b>
</p>
<p>
  Moreso, my gym&#039;s card scanning system looks at your account during those four
  months and if it&#039;s been more than 8 months, you&#039;re politely but firmly told to
  come back in March. I understand how frustrated members may become, but as I
  said before, my gym is fabulous, it is exclusionary, and it does not
  accommodate resolutionists.
</p>]]></content:encoded>
			<wfw:commentRss>http://www.adambondurant.com/2008/01/23/a-new-gym/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails Cookie Testing Notes</title>
		<link>http://www.adambondurant.com/2008/01/16/rails-cookie-testing-notes/</link>
		<comments>http://www.adambondurant.com/2008/01/16/rails-cookie-testing-notes/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 00:15:09 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Education]]></category>

		<category><![CDATA[]]></category>

		<guid isPermaLink="false">http://www.adambondurant.com/2008/01/17/rails-cookie-testing-notes/</guid>
		<description><![CDATA[
  I ran into a few gotchas I wanted to document about testing and cookies in
  Rails while developing a user persistence system for a site. The
  implementation isn&#039;t really important, but the nuances of cookie accessing is
  what I really wanted to focus on.


  In a functional test (and [...]]]></description>
			<content:encoded><![CDATA[<p>
  I ran into a few gotchas I wanted to document about testing and cookies in
  Rails while developing a user persistence system for a site. The
  implementation isn&#039;t really important, but the nuances of cookie accessing is
  what I really wanted to focus on.
</p>
<p>
  In a functional test (and possibly an integration test, but I don&#039;t really
  touch those), you can set pre-populated cookie variables like so:
</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">test_cookie</span></span>
  <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>request</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>cookies<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>persist</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">&#039;</span>secret<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">&#039;</span></span>
  get <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>index</span>
  assert_response <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>success</span>
<span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>
  The above code will set a cookie named &#034;persist&#034; to the value &#034;secret.&#034; The
  subsequent request (<tt>get :index</tt> in this case) will have that cookie
  available to it during the action&#039;s lifecycle.
</p>
<p>
  One thing to note, however, is that the <tt>cookies</tt> hash in a functional
  test is populated <b>after</b> a request has been made, and is <b>only</b>
  populated with cookies that were set <b>during</b> the request. What does this
  mean for us? It means this code will not work (assuming the index page does
  not set any cookies for us):
</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">test_cookie</span></span>
  <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>request</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>cookies<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>persist</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">&#039;</span>secret<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">&#039;</span></span>
  get <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>index</span>
  assert_equal <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">&#039;</span>secret<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">&#039;</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> cookies<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">&#039;</span>persist<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">&#039;</span></span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span> <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> This will fail as the cookies hash is empty
</span><span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>
  The reason the <tt>cookies</tt> hash is empty is because no cookies were set
  during the call to the index action. Think of the <tt>cookies</tt> hash as you
  would the <tt>assigns</tt> hash: It&#039;s only filled if you fill it during the
  request.
</p>
<p>
  Another issue I ran into was testing for the deletion of a cookie. It&#039;s a
  simple fix, but it&#039;s something none-the-less:
</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">test_cookie</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">  <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> This action deletes the &#034;persist&#034; cookie via cookies.delete(:persist)
</span>  delete <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>destroy</span>
  assert_nil cookies<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">&#039;</span>persist<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">&#039;</span></span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span> <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> This will fail as the value is actually empty, not nil
</span>  assert cookies<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">&#039;</span>persist<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">&#039;</span></span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>empty? <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> This will succeed
</span><span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>
  Finally, unlike the <tt>assigns</tt> hash, you cannot access the
  <tt>cookies</tt> hash after a request using a symbol. You must identify the
  cookie&#039;s key by string, even if you set the cookie&#039;s key in your action as a
  symbol. There&#039;s a patch for this
  (<a href="http://dev.rubyonrails.org/ticket/5924">Ticket #5924</a>) but
  nothing is really being done about it.
</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">test_cookie</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">  <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> This action sets the &#034;persist&#034; cookie to &#039;1&#039;
</span>  post <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>create</span>
  assert_equal <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">&#039;</span>1<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">&#039;</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> cookies<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>persist</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span> <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> This will fail
</span>  assert_equal <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">&#039;</span>1<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">&#039;</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> cookies<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">&#039;</span>persist<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">&#039;</span></span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span> <span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> This will succeed
</span><span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>
  So there you go. A few issues you might run into when testing with cookies.
</p>]]></content:encoded>
			<wfw:commentRss>http://www.adambondurant.com/2008/01/16/rails-cookie-testing-notes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New Job, New Food</title>
		<link>http://www.adambondurant.com/2008/01/16/new-job-new-food/</link>
		<comments>http://www.adambondurant.com/2008/01/16/new-job-new-food/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 03:00:00 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Food]]></category>

		<guid isPermaLink="false">http://www.adambondurant.com/2008/01/16/new-job-new-food/</guid>
		<description><![CDATA[
  I started a new job on January 2nd of this year. I&#039;m now working for an
  incubator of Web applications at a PR firm in San Francisco. The job is going
  really well, but what I&#039;m really concerned about is the lack of good breakfast
  food in my new location, [...]]]></description>
			<content:encoded><![CDATA[<p>
  I started a new job on January 2nd of this year. I&#039;m now working for an
  incubator of Web applications at a PR firm in San Francisco. The job is going
  really well, but what I&#039;m really concerned about is the lack of good breakfast
  food in my new location, Union Square. Granted, I could go to any number of
  restaurants in the area and get a nice sit-down meal for about $8.00, but I&#039;m
  really just addicted to bagels.
</p>
<p>
  When I was growing up, my dad used to get a salt-encrusted bagel as often as
  he could. When his cholesterol started getting too high, my mom made him make
  us a deal that any bagel he bought would count $5 towards the purchase of a
  new Super Nintendo game. I think he realized it was a win/win situation,
  having happy sons and an equally happy stomach, so the plan didn&#039;t work very
  well&#8211;at least, not for mom&#8211;my brothers and I got at least two games out of
  it.
</p>
<p>
  There was only one good place to get bagels in Dublin: The Bagel Bakery. I&#039;m
  glad my dad did the legwork to figure out the best place to buy bagels in my
  hometown. I think ultimately what made him stop getting so many was the change
  in ownership. My dad was a people person, and outward image counted a lot
  towards his coming back to a store. When the new owners were described as, &#034;a
  little cranky,&#034; the bagels stopped coming.
</p>
<p>
  While I understand the downsides of bagels, especially a bagel every morning,
  I just don&#039;t want to give them up. After a lot of searching around SOMA at my
  old job, I found Cafe Centro in South Park. They have, hands down, <i>the</i>
  best bagels in SOMA. The bagels themselves are crisp when lightly toasted. The
  real winner, though, is the cream cheese. A nice, firm cheese is key to a good
  bagel, and these guys understand that.
</p>
<p>
  My goal in the next few weeks is to document my findings regarding bagels in
  my new area. I can only hope to find something comparable to The Bagel Bakery
  and Cafe Centro.
</p>]]></content:encoded>
			<wfw:commentRss>http://www.adambondurant.com/2008/01/16/new-job-new-food/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
