<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Colin Jones' Plexus Blog</title>
    <link>http://www.plexusweb.com/staff/colin/blog</link>
    <pubDate>Sat, 26 Jul 2008 11:56:25 GMT</pubDate>
    <description>Colin Jones' Plexus Blog</description>
    <item>
      <title>Command Line Navigation: Keyboard Shortcuts</title>
      <link>http://www.plexusweb.com/staff/colin/blog/post/229/Command-Line-Navigation-Keyboard-Shortcuts</link>
      <description>&lt;p&gt;How's about some handy-dandy command-line  keyboard shortcuts for *nix? (*nix = Unix, Linux, Mac OSX, etc.)&lt;/p&gt;

&lt;p&gt;These are all based on Emacs, which I never use (I prefer Textmate for most coding and vim/vi for changes on remote servers). &lt;strong&gt;A dash (-) means hold the first button down while you press the second, and a comma (,) means press the first, release it, then press the second.&lt;/strong&gt;&lt;p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the start of the line: Ctrl-a&lt;/li&gt;
&lt;li&gt;Go to the end of the line: Ctrl-e&lt;/li&gt;
&lt;li&gt;Go back a word: Esc,b&lt;/li&gt;
&lt;li&gt;Go forward a word: Esc,f&lt;/li&gt;
&lt;li&gt;Delete everything from the cursor to the beginning of the line: Ctrl-u&lt;/li&gt;
&lt;li&gt;Delete everything from the cursor to the end of the line: Ctrl-k&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And don't forget that the up and down arrows are your friend when you want to do something again!&lt;/p&gt;

&lt;p&gt;Enjoy your extra 3 seconds per messed-up command!&lt;/p&gt;</description>
      <pubDate>Thu, 24 Jul 2008 15:26:50 GMT</pubDate>
      <guid>http://www.plexusweb.com/staff/colin/blog/post/229/Command-Line-Navigation-Keyboard-Shortcuts</guid>
      <author>Colin Jones</author>
    </item>
    <item>
      <title>rake aborted! Access denied</title>
      <link>http://www.plexusweb.com/staff/colin/blog/post/218/rake-aborted-Access-denied</link>
      <description>&lt;p&gt;This blog of mine is quickly becoming an encyclopedia of all the crazy problems that can happen if you're not careful.  I'll have   to do some more right-brained thinking for my next entry...  At any rate, if you've been using Rails with MySQL, there's a hair-pulling problem you may run across when generating a new project from scratch, now that Rails 2.0 has SQLite3 as the default database.&lt;/p&gt;

&lt;p&gt;Fire up a new rails application and add :&lt;/p&gt;
&lt;pre&gt;rails test_app&lt;/pre&gt;
&lt;p&gt;and then pop a simple migration in there:&lt;/p&gt;
&lt;pre&gt;cd test_app/
./script/generate model User login:string password:string&lt;/pre&gt;

&lt;p&gt;Now, being up on our Rails news, we know that config/database.yml is set up by default for SQLite3, so let's change it to work properly (being careful to avoid tabs---only spaces allowed in YAML).  Here's a development section as an example (please read the whole article before trying to use this, though):&lt;p&gt;

&lt;pre&gt;
development:
  adapter: mysql
  database: test_app_development
  user: test_user
  password: test_password
  host: localhost
&lt;/pre&gt;

&lt;p&gt;Now, we can just&lt;/p&gt; &lt;pre&gt;rake db:migrate&lt;/pre&gt; &lt;p&gt;and be off on our merry way, right?  Well, of course not---we know we need to create the database using mysql or mysqladmin first:&lt;/p&gt;
&lt;pre&gt;
$ mysql -p 
&gt; create test_app_development;
&gt; grant all privileges on test_app_development.* to 'test_user'@'localhost' identified by 'test_password';
&lt;/pre&gt;
&lt;p&gt;But there's still a problem somewhere!  Because you get&lt;/p&gt;
&lt;pre&gt;
rake aborted!
Access denied for user 'root'@'localhost' (using password: YES)
&lt;/pre&gt;
&lt;p&gt;when you try to rake db:migrate.  Why is it looking for 'root' when you've already specified 'test_user' in the database.yml and your config/environment.rb designates that you are indeed in development mode?!?&lt;/p&gt;

&lt;p&gt;Well, I was dismayed to find out that the hours I spent researching this problem were because of a typo in config/database.yml above:&lt;/p&gt;
&lt;pre&gt;
  user: test_user
&lt;/pre&gt;
&lt;h2&gt;NO!&lt;/h2&gt;
&lt;pre&gt;
  username: test_user
&lt;/pre&gt;
&lt;h2&gt;YES!&lt;/h2&gt;

&lt;p&gt;So, long story short, if you get the dreaded &lt;/p&gt;&lt;pre&gt;Access denied for user 'root'@'localhost'&lt;/pre&gt;&lt;p&gt; using rake db:migrate or anything else in rails, and you have the database created and the user there matches the user in database.yml, PLEASE check well for typos in database.yml, because it's finicky and Rails won't let you know if there's a problem.  &lt;/p&gt;

</description>
      <pubDate>Fri, 27 Jun 2008 02:25:50 GMT</pubDate>
      <guid>http://www.plexusweb.com/staff/colin/blog/post/218/rake-aborted-Access-denied</guid>
      <author>Colin Jones</author>
    </item>
    <item>
      <title>Arrays: Iterating + Deleting = BAD</title>
      <link>http://www.plexusweb.com/staff/colin/blog/post/214/Arrays-Iterating--Deleting--BAD</link>
      <description>&lt;p&gt;Going through some legacy Ruby code that I'm updating for a client, I came across a seemingly random problem where some elements of an array weren't being removed properly. Here's a simplified version.  Can you see the problem?&lt;/p&gt;
&lt;pre&gt;
@example_array = ["a","b","c","d","e","f"]
@example_array.each do |example_element|         
  @example_array.delete(example_element)
end
&lt;/pre&gt;
&lt;p&gt;The element &lt;em&gt;after&lt;/em&gt; each element that got deleted successfully doesn't get  deleted.  Why?  The &lt;strong&gt;delete&lt;/strong&gt; call re-indexes the array in place before the iterator comes around again.  The same is true, incidentally, of the insert method, which in the same context could continue infinitely.
&lt;/p&gt;
&lt;p&gt;Moral of the story: don't mess with the number of items in an enumerable as you're iterating through it.  If you need this functionality, maybe just make a copy and modify &lt;em&gt;that&lt;/em&gt;:&lt;/p&gt;
&lt;pre&gt;
@example_array = ["a","b","c","d","e","f"]
@example_array_copy = @example_array.dup
@example_array.each do |example_element|         
  @example_array_copy.delete(example_element)
end
@example_array = @example_array_copy
&lt;/pre&gt;</description>
      <pubDate>Fri, 20 Jun 2008 01:54:10 GMT</pubDate>
      <guid>http://www.plexusweb.com/staff/colin/blog/post/214/Arrays-Iterating--Deleting--BAD</guid>
      <author>Colin Jones</author>
    </item>
    <item>
      <title>Engines vs. Rails, Part the Second</title>
      <link>http://www.plexusweb.com/staff/colin/blog/post/206/Engines-vs-Rails-Part-the-Second</link>
      <description>&lt;p&gt;So we're upgrading to Rails 2.0 for our new sites, and I found a problem with the way Engines (even the latest version as of today) interacts with Rails 2.0.&lt;/p&gt;
&lt;p&gt;First load of my Rails Engines page (in a development site):&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[machine] Everything works great!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Second load:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[machine] A copy of ApplicationController has been removed from the module tree but is still active!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[me] Crap.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Enter some help from the interwebs: &lt;a href="http://www.ruby-forum.com/topic/137733"&gt;http://www.ruby-forum.com/topic/137733&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;[me] Hooray!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Basically, I just had to add this to the init.rb file in each Engines plugin:&lt;/p&gt;
&lt;pre&gt;
load_paths.each do |path|
  Dependencies.load_once_paths.delete(path)
end
&lt;/pre&gt;</description>
      <pubDate>Tue, 18 Mar 2008 18:54:32 GMT</pubDate>
      <guid>http://www.plexusweb.com/staff/colin/blog/post/206/Engines-vs-Rails-Part-the-Second</guid>
      <author>Colin Jones</author>
    </item>
    <item>
      <title>undefined method `last' for {}:Hash</title>
      <link>http://www.plexusweb.com/staff/colin/blog/post/196/undefined-method-last-for-Hash</link>
      <description>&lt;p&gt;Sometimes you hate the things that make your life so easy, because you have some problems with those things that make it temporarily more difficult.  But then you fix the problems, and everything's back to being cool again.&lt;/p&gt;

&lt;p&gt;In this case, I'm using Engines with Ruby on Rails, and there seems to be a conflict between my version of rake and my version of engines.  So I did a rake db:migrate and got the ugly-looking:&lt;/p&gt;
&lt;pre&gt;undefined method `last' for {}:Hash&lt;/pre&gt;
&lt;p&gt;on line 10 of the rakefile.  Well, after some Googling and clicking through, I found that all I needed to do was update a few lines of the engines code. In /vendor/plugins/engines/tasks/engines.rake, change the redefine_task method to read as follows:&lt;/p&gt;
&lt;pre&gt;
def redefine_task(task_class, args, &amp;block)
   task_name, deps = (RAKEVERSION &gt;= '0.8.0') ? resolve_args([args]) : resolve_args(args)
   task_name = task_class.scope_name(@scope, task_name)
   deps = [deps] unless deps.respond_to?(:to_ary)
   deps = deps.collect {|d| d.to_s }
   task = @tasks[task_name.to_s] = task_class.new(task_name, self)
   task.application = self
   if RAKEVERSION &gt;= '0.8.0'
     task.add_description(@last_description)
     @last_description = nil
   else
     task.add_comment(@last_comment)
     @last_comment = nil
   end
   task.enhance(deps, &amp;block)
   task
end
&lt;/pre&gt;</description>
      <pubDate>Fri, 22 Feb 2008 20:20:39 GMT</pubDate>
      <guid>http://www.plexusweb.com/staff/colin/blog/post/196/undefined-method-last-for-Hash</guid>
      <author>Colin Jones</author>
    </item>
    <item>
      <title>Valid XHTML - How to Lose the Non-SGML Characters</title>
      <link>http://www.plexusweb.com/staff/colin/blog/post/147/Valid-XHTML---How-to-Lose-the-Non-SGML-Characters</link>
      <description>&lt;p&gt;Here at Plexus, we pride ourselves on our use of Web standards, which lead to greater usability and searchability, in addition to better preparation for future browsers and other Web technology.  We proudly display links to validation services at w3.org for our XHTML 1.0 Strict and CSS, and they show that we're writing valid code.&lt;/p&gt;

&lt;p&gt;On our sites that allow users to enter content, however, we sometimes encounter validation errors such as: &lt;/p&gt;

&lt;code&gt;This page is &lt;strong&gt;not&lt;/strong&gt; Valid XHTML 1.0 Strict&lt;br /&gt; Error  Line 60 column 118: non SGML character number 128.&lt;/code&gt;
&lt;p&gt;[the problem here was a left quote pasted in from Microsoft Word]&lt;/p&gt;

&lt;p&gt;We've looked at writing scripts that convert each "non SGML character" to ones that will pass XHTML validation, but it ends up being very difficult to track down each individual invalid character.&lt;/p&gt;

&lt;p&gt;The better solution (assuming you're like us and have been using ISO-8859-1 encoding) is to just change the character encoding UTF-8.  That is, drop a META tag in your document template like this: &lt;/p&gt;
&lt;code&gt;&amp;lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;&lt;/code&gt;

&lt;p&gt;And you should be home free, so now you can feel confident about your code still passing XHTML 1.0 Strict validation even though you're letting clients paste Microsoft characters in.&lt;/p&gt;

</description>
      <pubDate>Thu, 31 May 2007 19:03:34 GMT</pubDate>
      <guid>http://www.plexusweb.com/staff/colin/blog/post/147/Valid-XHTML---How-to-Lose-the-Non-SGML-Characters</guid>
      <author>Colin Jones</author>
    </item>
    <item>
      <title>Reduce PDF File Size</title>
      <link>http://www.plexusweb.com/staff/colin/blog/post/123/Reduce-PDF-File-Size</link>
      <description>&lt;p&gt;If you're like me and have struggled for hours trying to figure out how to shrink someone else's PDF files without access to the original, you're in luck (as long as you're running Mac OSX):&lt;/p&gt;

&lt;ol&gt;

&lt;li&gt;Just open the offending PDF in Preview, save as JPEG (slide the quality down to "Least" for greater reduction in file size)&lt;/li&gt;

&lt;li&gt;Save your new JPEG as a PDF (also with Preview).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You're basically just flattening the PDF into an image, rather than unembedding fonts and "optimizing" images like Adobe Acrobat's PDF Optimizer does.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt; Big drop in file size; free; fast &amp;amp; easy&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt; You'll lose editable forms; you may also lose resolution, depending on how low you slide the quality when you save as JPEG&lt;/p&gt;

&lt;p&gt;Hope it helps somebody!&lt;/p&gt;</description>
      <pubDate>Mon, 02 Apr 2007 14:52:35 GMT</pubDate>
      <guid>http://www.plexusweb.com/staff/colin/blog/post/123/Reduce-PDF-File-Size</guid>
      <author>Colin Jones</author>
    </item>
    <item>
      <title>Merge PDFs without Acrobat</title>
      <link>http://www.plexusweb.com/staff/colin/blog/post/104/Merge-PDFs-without-Acrobat</link>
      <description>&lt;p&gt;Several times in the last few months, I've needed a way to combine two PDF files into one. I don't have the full version of Acrobat on my machine, and using Photoshop to do it is more hassle than it's worth, so I found this freeware utility that does the job handily:&lt;/p&gt;

&lt;p style="margin-left: 15px; font-size: 1.2em;"&gt;&lt;a href="http://www.accesspdf.com/pdftk/"&gt;pdftk&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 19 Dec 2006 19:25:56 GMT</pubDate>
      <guid>http://www.plexusweb.com/staff/colin/blog/post/104/Merge-PDFs-without-Acrobat</guid>
      <author>Colin Jones</author>
    </item>
    <item>
      <title>Need a background-image on a table row?</title>
      <link>http://www.plexusweb.com/staff/colin/blog/post/95/Need-a-background-image-on-a-table-row</link>
      <description>&lt;p&gt;Don't do it the intuitive way...&lt;/p&gt;
&lt;div style="background-color: #000;color: #FFF;padding: 10px;width: 95%;font-size:.9em;"&gt;
&amp;lt;table&amp;gt;&lt;br&gt;
  &amp;emsp;&amp;lt;tr style="background: url(/images/tr-background.gif) no-repeat 0 0;"&amp;gt;&lt;br&gt;
    &amp;emsp;&amp;emsp;&amp;lt;td&amp;gt;Row 1&amp;lt;/td&amp;gt;&lt;br&gt;
    &amp;emsp;&amp;emsp;&amp;lt;td&amp;gt;Row 2&amp;lt;/td&amp;gt;&lt;br&gt;
    &amp;emsp;&amp;emsp;&amp;lt;td&amp;gt;Row 3&amp;lt;/td&amp;gt;&lt;br&gt;
  &amp;emsp;&amp;lt;/tr&amp;gt;&lt;br&gt;
&amp;lt;/table&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;...because it doesn't work in IE6 or Safari, even if you set the &amp;lt;td&amp;gt; background element to 'transparent' or 'none'. &lt;/p&gt;

&lt;p&gt;But you can still make it happen with just the one image:&lt;/p&gt;
&lt;div style="background-color: #000;color: #FFF;padding: 10px;width: 95%;font-size:.9em;"&gt;
&amp;lt;table&amp;gt;&lt;br&gt;
  &amp;emsp;&amp;lt;tr&amp;gt;&lt;br&gt;
    &amp;emsp;&amp;emsp;&amp;lt;td style="background: url(/images/tr-background.gif) no-repeat 0 0;"&amp;gt;Row 1&amp;lt;/td&amp;gt;&lt;br&gt;
    &amp;emsp;&amp;emsp;&amp;lt;td style="background: url(/images/tr-background.gif) no-repeat 50% 0;"&amp;gt;Row 2&amp;lt;/td&amp;gt;&lt;br&gt;
    &amp;emsp;&amp;emsp;&amp;lt;td style="background: url(/images/tr-background.gif) no-repeat 100% 0;"&amp;gt;Row 3&amp;lt;/td&amp;gt;&lt;br&gt;
  &amp;emsp;&amp;lt;/tr&amp;gt;&lt;br&gt;
&amp;lt;/table&amp;gt;
&lt;/div&gt;
&lt;p&gt;You're just altering the background-position of the image, so that what should be on the left goes on the left (at 0), the middle part goes to the middle (50% horizontally), and the last part goes at the end (100%).  Remember that values in the background-position element are ordered horizontal, then vertical, unlike the margin and padding elements.&lt;/p&gt;

&lt;p&gt;And, of course, you'll want to separate presentation from content by putting the CSS elsewhere and classing the td's.&lt;/p&gt;</description>
      <pubDate>Fri, 17 Nov 2006 22:00:25 GMT</pubDate>
      <guid>http://www.plexusweb.com/staff/colin/blog/post/95/Need-a-background-image-on-a-table-row</guid>
      <author>Colin Jones</author>
    </item>
    <item>
      <title>Gentlemen, start your search engines!</title>
      <link>http://www.plexusweb.com/staff/colin/blog/post/65/Gentlemen-start-your-search-engines</link>
      <description>&lt;p&gt;I've been learning a lot recently about optimizing sites for search engine rankings, which is clearly one of the most important business components of any website. If a customer can't find your store, how can they buy what you're selling? Think about your own experiences with &lt;a href="http://www.google.com"&gt;Google&lt;/a&gt; or other search engines (there are others?!?)---would you look through more than 2-3 pages of search results if you found anything decent on the first page of results? I wouldn't, and you can bet the average customer wouldn't.&lt;/p&gt;

&lt;p&gt;You can see for yourself what a difference search engine optimization can make by &lt;a href="http://www.google.com/search?q=colin+jones"&gt;googling my name&lt;/a&gt;. You'll find it eventually, at #26, on my Plexus staff page. Before I worked here, I can remember going through the list pretty far past 10 pages (10 links each), and not seeing the &lt;strong&gt;real&lt;/strong&gt; CoJo at all.   At first, I thought that this increase in my internet fame was just due to the number of incoming links to the Plexus domain, but after a little digging in the source code, I had an epiphany: the word "colin" is littered throughout in URLs because we use &lt;a href="http://www.rubyonrails.org"&gt;Ruby on Rails&lt;/a&gt;, and "colin" is part of a route we&#65533;ve mapped to all the pages that have to do with me.  So you end up with URLs like this: &lt;/p&gt;
&lt;ul&gt;
&lt;li style="list-style-type: none;"&gt;http://www.plexusweb.com/staff/&lt;strong&gt;colin&lt;/strong&gt;/blog&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This colin-ized route appears in tons of link tags in the markup, and search engines are finding each instance (and ranking accordingly).  Yet another reason to let us build your site with Ruby on Rails.&lt;/p&gt;</description>
      <pubDate>Wed, 23 Aug 2006 22:40:17 GMT</pubDate>
      <guid>http://www.plexusweb.com/staff/colin/blog/post/65/Gentlemen-start-your-search-engines</guid>
      <author>Colin Jones</author>
    </item>
  </channel>
</rss>
