<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>jeremyf.github.com</title>
 <link href="http://jeremyf.github.com/jeremyf.github.com/atom.xml" rel="self"/>
 <link href="http://jeremyf.github.com/jeremyf.github.com/"/>
 <updated>2009-07-22T07:30:47-07:00</updated>
 <id>http://jeremyf.github.com/jeremyf.github.com/</id>
 <author>
   <name>Dr Nic Williams</name>
   <email>jeremyfwilliams@gmail.com</email>
 </author>

 
 <entry>
   <title>Pretty Output for irb and script/console</title>
   <link href="http://jeremyf.github.com/jeremyf.github.com/2009/07/22/pretty-irb-output.html"/>
   <updated>2009-07-22T00:00:00-07:00</updated>
   <id>http://jeremyf.github.com/jeremyf.github.com/2009/07/22/pretty-irb-output</id>
   <content type="html">&lt;p&gt;Rather simple means of adding pretty output to irb&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Get the hirb gem&lt;/li&gt;
&lt;/ul&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;    &lt;span class='n'&gt;sudo&lt;/span&gt; &lt;span class='n'&gt;gem&lt;/span&gt; &lt;span class='n'&gt;install&lt;/span&gt; &lt;span class='n'&gt;cldwalker&lt;/span&gt;&lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='n'&gt;hirb&lt;/span&gt; &lt;span class='o'&gt;--&lt;/span&gt;&lt;span class='n'&gt;source&lt;/span&gt; &lt;span class='n'&gt;http&lt;/span&gt;&lt;span class='ss'&gt;:/&lt;/span&gt;&lt;span class='o'&gt;/&lt;/span&gt;&lt;span class='n'&gt;gems&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;github&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;com&lt;/span&gt;
  
&lt;/pre&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Configure ~/.irbrc&lt;/li&gt;
&lt;/ul&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;    &lt;span class='nb'&gt;require&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;rubygems&amp;#39;&lt;/span&gt;
    &lt;span class='nb'&gt;require&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;hirb&amp;#39;&lt;/span&gt;
    &lt;span class='no'&gt;Hirb&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;enable&lt;/span&gt;
    &lt;span class='kp'&gt;extend&lt;/span&gt; &lt;span class='no'&gt;Hirb&lt;/span&gt;&lt;span class='o'&gt;::&lt;/span&gt;&lt;span class='no'&gt;Console&lt;/span&gt;
  
&lt;/pre&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Look at the output&lt;/li&gt;
&lt;/ul&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;    &lt;span class='o'&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class='no'&gt;Site&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;find&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:first&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
    &lt;span class='o'&gt;+----+-----------+-----------+-----------+-----------+-----------+&lt;/span&gt;
    &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='nb'&gt;id&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='nb'&gt;name&lt;/span&gt;      &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='n'&gt;domain&lt;/span&gt;    &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='n'&gt;site_s&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;.&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='n'&gt;create&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;.&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='n'&gt;update&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;.&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt;
    &lt;span class='o'&gt;+----+-----------+-----------+-----------+-----------+-----------+&lt;/span&gt;
    &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='mi'&gt;1&lt;/span&gt;  &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='no'&gt;Web&lt;/span&gt; &lt;span class='no'&gt;Group&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='n'&gt;webgro&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;.&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='mi'&gt;1&lt;/span&gt;         &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='mi'&gt;2007&lt;/span&gt;&lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;.&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='mi'&gt;2008&lt;/span&gt;&lt;span class='o'&gt;-&lt;/span&gt;&lt;span class='mi'&gt;0&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;.&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt;
    &lt;span class='o'&gt;+----+-----------+-----------+-----------+-----------+-----------+&lt;/span&gt;
    &lt;span class='mi'&gt;1&lt;/span&gt; &lt;span class='n'&gt;row&lt;/span&gt; &lt;span class='k'&gt;in&lt;/span&gt; &lt;span class='n'&gt;set&lt;/span&gt;
    &lt;span class='o'&gt;&amp;gt;&amp;gt;&lt;/span&gt;
  
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This makes me happy. A prettier output for Ruby objects. For more information, see http://github.com/cldwalker/hirb/tree/master&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Rails Subdomain caching</title>
   <link href="http://jeremyf.github.com/jeremyf.github.com/2009/05/28/subdomain-caching.html"/>
   <updated>2009-05-28T00:00:00-07:00</updated>
   <id>http://jeremyf.github.com/jeremyf.github.com/2009/05/28/subdomain-caching</id>
   <content type="html">&lt;p&gt;Today I spent some time implementing caching in a Rails application that makes use of subdomains.&lt;br /&gt;With a quick bit of google-fu, I stumbled upon Nathaniel Bibler&amp;#8217;s &lt;a href='http://launchpad.rocketjumpindustries.com/posts/5-defining-a-dynamic-page-cache-loction-by-subdomain-in-rails'&gt;post&lt;/a&gt;.&lt;br /&gt;A very informative guide, however, the apache rewrite rules proved to be a bit more involved. In addition, the shennagans of the subdomain seemed a little unnecessary, so I opted for host instead of subdomain. The changes are below.&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;    &lt;span class='k'&gt;class&lt;/span&gt; &lt;span class='nc'&gt;ApplicationController&lt;/span&gt; &lt;span class='o'&gt;&amp;lt;&lt;/span&gt; &lt;span class='no'&gt;ActionController&lt;/span&gt;&lt;span class='o'&gt;::&lt;/span&gt;&lt;span class='no'&gt;Base&lt;/span&gt;  
      &lt;span class='kp'&gt;private&lt;/span&gt;
      &lt;span class='k'&gt;def&lt;/span&gt; &lt;span class='nf'&gt;cache_page_with_host&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;content&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='kp'&gt;nil&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;options&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='kp'&gt;nil&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;
        &lt;span class='n'&gt;path&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='k'&gt;case&lt;/span&gt; &lt;span class='n'&gt;options&lt;/span&gt;
          &lt;span class='k'&gt;when&lt;/span&gt; &lt;span class='no'&gt;Hash&lt;/span&gt;
            &lt;span class='n'&gt;url_for&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;options&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;merge&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='ss'&gt;:only_path&lt;/span&gt; &lt;span class='o'&gt;=&amp;gt;&lt;/span&gt; &lt;span class='kp'&gt;true&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='ss'&gt;:skip_relative_url_root&lt;/span&gt; &lt;span class='o'&gt;=&amp;gt;&lt;/span&gt; &lt;span class='kp'&gt;true&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='ss'&gt;:format&lt;/span&gt; &lt;span class='o'&gt;=&amp;gt;&lt;/span&gt; &lt;span class='n'&gt;params&lt;/span&gt;&lt;span class='o'&gt;[&lt;/span&gt;&lt;span class='ss'&gt;:format&lt;/span&gt;&lt;span class='o'&gt;]&lt;/span&gt;&lt;span class='p'&gt;))&lt;/span&gt;
          &lt;span class='k'&gt;when&lt;/span&gt; &lt;span class='nb'&gt;String&lt;/span&gt;
            &lt;span class='n'&gt;options&lt;/span&gt;
          &lt;span class='k'&gt;else&lt;/span&gt;
            &lt;span class='n'&gt;request&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;path&lt;/span&gt;
        &lt;span class='k'&gt;end&lt;/span&gt;
        &lt;span class='n'&gt;cache_page_without_host&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='n'&gt;content&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='no'&gt;File&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;join&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot;/&lt;/span&gt;&lt;span class='si'&gt;#{&lt;/span&gt;&lt;span class='n'&gt;request&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;host&lt;/span&gt;&lt;span class='si'&gt;}&lt;/span&gt;&lt;span class='s2'&gt;/&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt; &lt;span class='n'&gt;path&lt;/span&gt; &lt;span class='o'&gt;==&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;/&amp;quot;&lt;/span&gt; &lt;span class='p'&gt;?&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;index.html&amp;#39;&lt;/span&gt; &lt;span class='p'&gt;:&lt;/span&gt; &lt;span class='n'&gt;path&lt;/span&gt;&lt;span class='p'&gt;))&lt;/span&gt;
      &lt;span class='k'&gt;end&lt;/span&gt;
    &lt;span class='k'&gt;end&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Apache Config&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;RewriteEngine On

# Rewrite rule to check for host cached pages.
# This will check the file system for a cached copy, if that exists
# use the static cached page. 
# The [QSA,L] is very important. See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriteflags
RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}/index.html -f
RewriteRule ^/$ /cache/%{HTTP_HOST}/index.html [QSA,L]
RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}/%{REQUEST_URI}.html -f
RewriteRule ^(.*)$ /cache/%{HTTP_HOST}/$1.html [QSA,L]&lt;/code&gt;&lt;/pre&gt;</content>
 </entry>
 
 <entry>
   <title>First Post and in all likelihood the last.</title>
   <link href="http://jeremyf.github.com/jeremyf.github.com/2009/05/19/first-post.html"/>
   <updated>2009-05-19T00:00:00-07:00</updated>
   <id>http://jeremyf.github.com/jeremyf.github.com/2009/05/19/first-post</id>
   <content type="html">&lt;p&gt;I have begun to explore using Jekyll and Github pages. Oh github I &amp;#60;3 you.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>git add --patch file.name</title>
   <link href="http://jeremyf.github.com/jeremyf.github.com/2008/04/08/git-add.html"/>
   <updated>2008-04-08T00:00:00-07:00</updated>
   <id>http://jeremyf.github.com/jeremyf.github.com/2008/04/08/git-add</id>
   <content type="html">&lt;p&gt;I would highly recommend reading &amp;#8220;this post&amp;#8221;:http://tomayko.com/writings/the-thing-about-git, it highlights yet another awesome feature of git. Git lets you do your work how you do it, instead of how the SCM says you should. Here is a great example. I have a hopelessly muddled set of changes in file&lt;em&gt;the&lt;/em&gt;other.txt. The changes are for two (or more) different purposes, and I need to only push a portion of it. Enter &lt;code&gt;git add --patch&lt;/code&gt;. I can go through each diff element and select to put it in the queue (the Index) for what will be committed.&lt;/p&gt;
&lt;pre&gt;
  $ git add --patch file_the_other.txt 
  diff --git a/file_the_other.txt b/file_the_other.txt
  index 2120d21..e3aa90d 100644
  --- a/file_the_other.txt
  +++ b/file_the_other.txt
  @@ -1,3 +1,6 @@
  +World is here
   A file like another file, but with different content.

  -There is even more content here.
  \ No newline at end of file
  +There is even more content here.
  +
  +Hello World
  \ No newline at end of file
  Stage this hunk [y/n/a/d/s/?]?
&lt;/pre&gt;</content>
 </entry>
 
 
</feed>