<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Compulsivo</title>
	
	<link>http://www.compulsivoco.com</link>
	<description>Ruby on Rails web application design, development and consulting</description>
	<pubDate>Mon, 29 Jun 2009 22:13:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Compulsivo" type="application/rss+xml" /><feedburner:emailServiceId>Compulsivo</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Easy Rails API Authentication Using restful-authentication</title>
		<link>http://feedproxy.google.com/~r/Compulsivo/~3/kXgOmc1WwaY/</link>
		<comments>http://www.compulsivoco.com/2009/05/rails-api-authentication-using-restful-authentication/#comments</comments>
		<pubDate>Sat, 16 May 2009 22:06:35 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.compulsivoco.com/?p=224</guid>
		<description><![CDATA[You&#8217;ve got a Rails application and you&#8217;d like to add an API.  This tutorial assumes you are using restful-authentication.
Creating the API key

  You&#8217;ll need to add a new column, api_key, to your users table.  This field will store the unique API key used for authentication.


./script/generate migration AddApiKeyToUsers


class AddApiKeyToUsers &#60; ActiveRecord::Migration
  def [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve got a Rails application and you&#8217;d like to add an API.  This tutorial assumes you are using <a href="http://github.com/technoweenie/restful-authentication/tree/master" target="_blank">restful-authentication</a>.</p>
<h2>Creating the API key</h2>
<p>
  You&#8217;ll need to add a new column, api_key, to your users table.  This field will store the unique API key used for authentication.
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>script<span style="color: #000000; font-weight: bold;">/</span>generate migration AddApiKeyToUsers</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> AddApiKeyToUsers <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    add_column <span style="color:#ff3333; font-weight:bold;">:users</span>, <span style="color:#ff3333; font-weight:bold;">:api_key</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>, <span style="color:#ff3333; font-weight:bold;">:limit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">40</span>, <span style="color:#ff3333; font-weight:bold;">:default</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    remove_column <span style="color:#ff3333; font-weight:bold;">:users</span>, <span style="color:#ff3333; font-weight:bold;">:api_key</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>
  The API key is a simple SHA hash based on the current time and a random number &#8212; we need this to be unique.  We&#8217;re not going to enable the API for a user by default, though you could easily do this using <em>before_create</em>.  Instead, we&#8217;ll let the user enable or disable the API using the API Keys Controller, which we&#8217;ll create next.
</p>
<p>
  Make the following changes to your <em>app/models/user.rb</em> file:
</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> User <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> enable_api!
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">generate_api_key</span>!
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> disable_api!
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">update_attribute</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:api_key</span>, <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> api_is_enabled?
    !<span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">api_key</span>.<span style="color:#9900CC;">empty</span>?
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  protected
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> secure_digest<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>args<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#6666ff; font-weight:bold;">Digest::SHA1</span>.<span style="color:#9900CC;">hexdigest</span><span style="color:#006600; font-weight:bold;">&#40;</span>args.<span style="color:#9900CC;">flatten</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'--'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> generate_api_key!
      <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">update_attribute</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:api_key</span>, secure_digest<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span>, <span style="color:#006600; font-weight:bold;">&#40;</span>1..10<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#CC0066; font-weight:bold;">rand</span>.<span style="color:#5A0A0A; font-weight:bold;">to_s</span> <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>
  Now, let&#8217;s create the API Keys Controller, which we&#8217;ll use to allow the user to create, re-generate, and delete their API Key.  This effectively allows the user to enable and disable API access to their account.
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>script<span style="color: #000000; font-weight: bold;">/</span>generate controller APIKeys</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> APIKeysController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController
  <span style="color:#5A0A0A; font-weight:bold;">before_filter</span> <span style="color:#ff3333; font-weight:bold;">:login_from_cookie</span>
  <span style="color:#5A0A0A; font-weight:bold;">before_filter</span> <span style="color:#ff3333; font-weight:bold;">:login_required</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Create or re-generate the API key</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> create
    current_user.<span style="color:#9900CC;">enable_api</span>!
&nbsp;
    <span style="color:#5A0A0A; font-weight:bold;">respond_to</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>format<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#5A0A0A; font-weight:bold;">redirect_to</span> edit_user_path<span style="color:#006600; font-weight:bold;">&#40;</span>current_user<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Delete the API key</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#5A0A0A; font-weight:bold;">destroy</span>
    current_user.<span style="color:#9900CC;">disable_api</span>!
&nbsp;
    <span style="color:#5A0A0A; font-weight:bold;">respond_to</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>format<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">html</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#5A0A0A; font-weight:bold;">redirect_to</span> edit_user_path<span style="color:#006600; font-weight:bold;">&#40;</span>current_user<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>
  Add the resource to <em>config/routes.rb</em>
</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">map.<span style="color:#9900CC;">resource</span> <span style="color:#ff3333; font-weight:bold;">:api_key</span></pre></div></div>

<p>
  You&#8217;ll need to allow the user to enable and disable the API, as well as re-generate their API key if they feel it&#8217;s been compromised.  Add something like this to <em>app/views/users/edit.html.erb</em>:
</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">api_is_enabled</span>? <span style="color:#006600; font-weight:bold;">%&gt;</span>
  &lt;p&gt;
    Your API Key: 
    (<span style="color:#006600; font-weight:bold;">&lt;%</span>= link_to <span style="color:#996600;">&quot;re-generate&quot;</span>, api_key_path, <span style="color:#ff3333; font-weight:bold;">:method</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:post</span> <span style="color:#006600; font-weight:bold;">%&gt;</span> | <span style="color:#006600; font-weight:bold;">&lt;%</span>= link_to <span style="color:#996600;">&quot;disable&quot;</span>, api_key_path, <span style="color:#ff3333; font-weight:bold;">:method</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:delete</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>)
  &lt;/p&gt;
  &lt;p&gt;
    &lt;strong&gt;<span style="color:#006600; font-weight:bold;">&lt;%</span>= <span style="color:#0066ff; font-weight:bold;">@user</span>.<span style="color:#9900CC;">api_key</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>&lt;/strong&gt;
  &lt;/p&gt;
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">else</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  &lt;p&gt;	
    You'll need a unique key to make calls to the API.  Remember to keep this key a secret as it can be used to access your account.
  &lt;/p&gt;
  &lt;p&gt;
    <span style="color:#006600; font-weight:bold;">&lt;%</span>= link_to<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Get a key&quot;</span>, api_key_path, <span style="color:#ff3333; font-weight:bold;">:method</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:post</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  &lt;/p&gt;
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<h2>Authenticating the API Key</h2>
<p>
  Add the following to <em>lib/authenticated_system.rb</em>:
</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> login_from_api_key
  <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">current_user</span> = User.<span style="color:#9900CC;">find_by_api_key</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:api_key</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>
  Modify <em>lib/authenticated_system.rb</em> to add <em>login_from_api_key</em> as follows:
</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> current_user
  <span style="color:#0066ff; font-weight:bold;">@current_user</span> <span style="color:#006600; font-weight:bold;">||</span>= <span style="color:#006600; font-weight:bold;">&#40;</span>login_from_session <span style="color:#006600; font-weight:bold;">||</span> login_from_api_key <span style="color:#006600; font-weight:bold;">||</span> login_from_basic_auth <span style="color:#006600; font-weight:bold;">||</span> login_from_cookie<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#0066ff; font-weight:bold;">@current_user</span> == <span style="color:#0000FF; font-weight:bold;">false</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>
  Optionally, if you&#8217;d also like to support access to the API via HTTP Basic Authentication using the API key in addition to a user&#8217;s login and password, you can make the following change to <em>app/models/user.rb</em>:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">authenticate</span><span style="color:#006600; font-weight:bold;">&#40;</span>login, password<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">nil</span> <span style="color:#9966CC; font-weight:bold;">if</span> login.<span style="color:#9900CC;">blank</span>? <span style="color:#006600; font-weight:bold;">||</span> password.<span style="color:#9900CC;">blank</span>?
  <span style="color:#9966CC; font-weight:bold;">if</span> password.<span style="color:#9900CC;">downcase</span> == <span style="color:#996600;">&quot;x&quot;</span>
    <span style="color:#008000; font-style:italic;"># This is an API request</span>
    u = find_by_api_key<span style="color:#006600; font-weight:bold;">&#40;</span>login<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">else</span>
    u = find_by_login<span style="color:#006600; font-weight:bold;">&#40;</span>login.<span style="color:#9900CC;">downcase</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    u <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> u.<span style="color:#9900CC;">authenticated</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>password<span style="color:#006600; font-weight:bold;">&#41;</span> ? u : <span style="color:#0000FF; font-weight:bold;">nil</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>
  When prompted to log in using HTTP Basic Authentication, use the API Key as the login and &#8216;X&#8217; as the password.
</p>
<h2>Testing it Out</h2>
<p>
  Assuming you have a RESTful resource called Items, you should be able to use curl as so:
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">curl http:<span style="color: #000000; font-weight: bold;">//</span>www.yoursite.com<span style="color: #000000; font-weight: bold;">/</span>items<span style="color: #000000; font-weight: bold;">/</span>1.xml?<span style="color: #007800;">api_key</span>=356a192b</pre></div></div>

<img src="http://feeds.feedburner.com/~r/Compulsivo/~4/kXgOmc1WwaY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.compulsivoco.com/2009/05/rails-api-authentication-using-restful-authentication/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.compulsivoco.com/2009/05/rails-api-authentication-using-restful-authentication/</feedburner:origLink></item>
		<item>
		<title>God Init.d Script for CentOS</title>
		<link>http://feedproxy.google.com/~r/Compulsivo/~3/lO272-8m2RU/</link>
		<comments>http://www.compulsivoco.com/2009/05/god-initd-script-for-centos/#comments</comments>
		<pubDate>Fri, 15 May 2009 21:00:31 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.compulsivoco.com/?p=319</guid>
		<description><![CDATA[
This is the /etc/init.d/god script we are using for God on CentOS 5.

Get God

sudo gem install god

Create a Default Config File

sudo touch /etc/god.conf

Create the Init Script
Put this in /etc/init.d/god

#!/bin/bash
#
# God
#
# chkconfig: - 85 15
# description: start, stop, restart God
#              
&#160;
RETVAL=0
&#160;
case &#34;$1&#34; in
 [...]]]></description>
			<content:encoded><![CDATA[<p>
This is the <em>/etc/init.d/god</em> script we are using for <a href="http://god.rubyforge.org" target="_blank">God</a> on CentOS 5.
</p>
<h2>Get God</h2>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">sudo gem install god</pre></div></div>

<h2>Create a Default Config File</h2>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">sudo touch /etc/god.conf</pre></div></div>

<h2>Create the Init Script</h2>
<p>Put this in <em>/etc/init.d/god</em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># God</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># chkconfig: - 85 15</span>
<span style="color: #666666; font-style: italic;"># description: start, stop, restart God</span>
<span style="color: #666666; font-style: italic;">#              </span>
&nbsp;
<span style="color: #007800;">RETVAL</span>=<span style="color: #000000;">0</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>god <span style="color: #660033;">-P</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>god.pid <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>god.log
      <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>god load <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>god.conf
      <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
    stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>god.pid<span style="color: #000000; font-weight: bold;">`</span>
      <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
    restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>god.pid<span style="color: #000000; font-weight: bold;">`</span>
      <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>god <span style="color: #660033;">-P</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>god.pid <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>god.log
      <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>god load <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>god.conf
      <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
    status<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #007800;">RETVAL</span>=<span style="color: #007800;">$?</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: god {start|stop|restart|status}&quot;</span>
      <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
  <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>      
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$RETVAL</span></pre></div></div>

<h2>Make it Executable</h2>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">sudo chmod a+x /etc/init.d/god</pre></div></div>

<h2>Ensure God Launches on System Boot</h2>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">sudo chkconfig --add god
sudo chkconfig --level 345 god on</pre></div></div>

<h2>Fire it Up</h2>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">sudo /etc/init.d/god start</pre></div></div>

<img src="http://feeds.feedburner.com/~r/Compulsivo/~4/lO272-8m2RU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.compulsivoco.com/2009/05/god-initd-script-for-centos/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.compulsivoco.com/2009/05/god-initd-script-for-centos/</feedburner:origLink></item>
		<item>
		<title>Private, Authenticated RSS Feeds in Rails</title>
		<link>http://feedproxy.google.com/~r/Compulsivo/~3/guvg9V33lvs/</link>
		<comments>http://www.compulsivoco.com/2009/02/private-secure-authenticated-rss-feeds-in-rails/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 04:09:19 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.compulsivoco.com/?p=247</guid>
		<description><![CDATA[So, you want to allow your users to access a RSS feed of private data in their account.  Something like,
http://subdomain.yoursite.com/comments/123abc/feed.rss, where &#8220;123abc&#8221; is a secret token.
Here&#8217;s how to do this in Rails 2.1.2, though it will most likely work in other versions of Rails.  In this example, each Account has_many Comments, and we&#8217;d like to [...]]]></description>
			<content:encoded><![CDATA[<p>So, you want to allow your users to access a RSS feed of private data in their account.  Something like,</p>
<p>http://subdomain.yoursite.com/comments/123abc/feed.rss, where &#8220;123abc&#8221; is a secret token.</p>
<p>Here&#8217;s how to do this in Rails 2.1.2, though it will most likely work in other versions of Rails.  In this example, each Account has_many Comments, and we&#8217;d like to get a RSS feed of comments.</p>
<p>1.  Create a route for the feed in your routes.rb file.</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;">map.<span style="color:#9900CC;">resources</span> <span style="color:#ff3333; font-weight:bold;">:accounts</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>account<span style="color:#006600; font-weight:bold;">|</span>
  account.<span style="color:#9900CC;">comments_feed</span> <span style="color:#996600;">'comments/:token/feed.:format'</span>, <span style="color:#ff3333; font-weight:bold;">:controller</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'comments'</span>, <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'feed'</span>, <span style="color:#ff3333; font-weight:bold;">:token</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">nil</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>2.  Create a new migration and add the feed_token to the Account.</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> AddFeedTokenToAccount <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span>
    add_column <span style="color:#ff3333; font-weight:bold;">:accounts</span>, <span style="color:#ff3333; font-weight:bold;">:feed_token</span>, <span style="color:#ff3333; font-weight:bold;">:string</span>, <span style="color:#ff3333; font-weight:bold;">:limit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">40</span>, <span style="color:#ff3333; font-weight:bold;">:default</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span>
    remove_column <span style="color:#ff3333; font-weight:bold;">:accounts</span>, <span style="color:#ff3333; font-weight:bold;">:feed_token</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>3.  When a new Account is created, create the feed_token.  We&#8217;ll just use a standard SHA1 hash of the current time and the account id.  This should be unique enough.  Let&#8217;s also create a method to validate the feed token.  All of this goes in app/models/account.rb</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> Account <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  <span style="color:#5A0A0A; font-weight:bold;">before_create</span> <span style="color:#ff3333; font-weight:bold;">:create_feed_token</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> valid_feed_token?<span style="color:#006600; font-weight:bold;">&#40;</span>token<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">feed_token</span> == token
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  protected
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> create_feed_token
    <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">feed_token</span> = <span style="color:#6666ff; font-weight:bold;">Digest::SHA1</span>.<span style="color:#9900CC;">hexdigest</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span>.<span style="color:#5A0A0A; font-weight:bold;">to_s</span> <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">id</span>.<span style="color:#5A0A0A; font-weight:bold;">to_s</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>4.  Add a new feed method to your Comments controller.  This goes in app/controllers/comments_controller.rb</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> feed
  <span style="color:#0066ff; font-weight:bold;">@account</span> = Account.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span>account_id<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#0066ff; font-weight:bold;">@comments</span> = <span style="color:#0066ff; font-weight:bold;">@account</span>.<span style="color:#9900CC;">comments</span>
  <span style="color:#0066ff; font-weight:bold;">@token</span> = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:token</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
  <span style="color:#5A0A0A; font-weight:bold;">respond_to</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>format<span style="color:#006600; font-weight:bold;">|</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@account</span>.<span style="color:#9900CC;">valid_feed_token</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>@token<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">rss</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#5A0A0A; font-weight:bold;">render</span> <span style="color:#ff3333; font-weight:bold;">:layout</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#CC0066; font-weight:bold;">format</span>.<span style="color:#9900CC;">rss</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#5A0A0A; font-weight:bold;">render</span> <span style="color:#ff3333; font-weight:bold;">:nothing</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>, <span style="color:#ff3333; font-weight:bold;">:status</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#ff3333; font-weight:bold;">:forbidden</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>5.  Create the file app/views/comments/feed.rss.builder.  This is what generates the RSS feed.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">xml.instruct! :xml, :version =&gt; &quot;1.0&quot;
xml.rss :version =&gt; &quot;2.0&quot; do
  xml.channel do
    xml.title &quot;Comments&quot;
    xml.description &quot;A bunch of comments&quot;
    xml.link account_comments_url(@account)
&nbsp;
    for comment in @comments
      xml.item do
        xml.title comment.title
        xml.description comment.body
        xml.pubDate comment.created_at.to_s(:rfc822)
        xml.link account_comments_url(@account)
      end
    end
  end
end</pre></div></div>

<p>6.  Link to the comments RSS feed somewhere on your site.  For example, somewhere in app/views/comments/index.html.erb place the following link:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;%= link_to 'Subscribe', account_comments_feed_path(@account, :format =&gt; :rss, :token =&gt; @account.feed_token)) %&gt;</pre></div></div>

<img src="http://feeds.feedburner.com/~r/Compulsivo/~4/guvg9V33lvs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.compulsivoco.com/2009/02/private-secure-authenticated-rss-feeds-in-rails/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.compulsivoco.com/2009/02/private-secure-authenticated-rss-feeds-in-rails/</feedburner:origLink></item>
		<item>
		<title>A Private Web Beta in Seconds with Prefinery</title>
		<link>http://feedproxy.google.com/~r/Compulsivo/~3/FcX9zZbSUcc/</link>
		<comments>http://www.compulsivoco.com/2009/02/manage-private-web-beta-with-prefinery/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 20:41:32 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Prefinery]]></category>

		<guid isPermaLink="false">http://www.compulsivoco.com/?p=225</guid>
		<description><![CDATA[Don&#8217;t write it yourself
You&#8217;ve got some slick new Web site and you&#8217;d like to run a private beta.  Maybe this is because you&#8217;re convinced your site is so awesome you&#8217;re going to get more traffic than your ready for.  Or, maybe you&#8217;d just like to work out the bugs with a small, select group of [...]]]></description>
			<content:encoded><![CDATA[<h2>Don&#8217;t write it yourself</h2>
<p>You&#8217;ve got some slick new Web site and you&#8217;d like to run a private beta.  Maybe this is because you&#8217;re convinced your site is so awesome you&#8217;re going to get more traffic than your ready for.  Or, maybe you&#8217;d just like to work out the bugs with a small, select group of users.  Either way, you need a process for collecting the e-mail addresses for people who are interested in signing up, generating unique invitation codes, and sending an e-mail invitation.</p>
<p>This process is a pain in the ass, and not something core to your awesome new web site.  Heck, you&#8217;ll probably only be in private beta for a few months so you&#8217;ll end up throwing away all the code you write to manage the private beta.</p>
<p><a title="Create a private beta for your web site in seconds with Prefinery." href="http://www.prefinery.com" target="_blank">Prefinery</a> can manage this entire process for you.  Here&#8217;s how it works &#8230;</p>
<h3>1.  Sign up for a free Prefinery account</h3>
<p>You specify what contact information (name, email, address, phone, etc.) must be gathered when users request an invitation code.</p>
<h3>2.  Install the invitation widget</h3>
<p>This is as easy as copying and pasting a few lines of Javascript.</p>
<h3>3.  Users visit your web site and request an invitation code</h3>
<p>The Prefinery invitation widget gets launched when a user clicks a link or image on your site.  Your users never leave your web site!</p>
<h3>4.  Poof, an invitation code is generated</h3>
<p>You log into Prefinery where you see the thousands of people who are begging to use your awesome new site.  Approving access is as easy as clicking a button.  Once access is approved, an e-mail (from your address, of course) is sent to the user.</p>
<h3>5.  Users sign up on your site</h3>
<p>We give you the secret formula so that you can decode a Prefinery invitation code when users sign up on your site. We provide code samples in various languages, including Ruby, PHP, and Python.  In most cases this process is as simple as one line of source code.</p>
<h2>Learn more</h2>
<p>You can learn more about Prefinery by taking the <a title="Take a tour of Prefinery for private web betas." href="http://www.prefinery.com/tour" target="_self">tour</a>, checking out the <a title="View screenshots of Prefinery for private web betas." href="http://www.prefinery.com/tour/web" target="_self">screenshots</a>, or signing up for a <a title="Sign up for a free Prefinery account and create a private web beta in seconds." href="http://www.prefinery.com/signup/web/free" target="_self">free account</a>.</p>
<img src="http://feeds.feedburner.com/~r/Compulsivo/~4/FcX9zZbSUcc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.compulsivoco.com/2009/02/manage-private-web-beta-with-prefinery/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.compulsivoco.com/2009/02/manage-private-web-beta-with-prefinery/</feedburner:origLink></item>
		<item>
		<title>Backup Your WordPress Blog to Amazon S3 using Ruby</title>
		<link>http://feedproxy.google.com/~r/Compulsivo/~3/_DR5o53FkNQ/</link>
		<comments>http://www.compulsivoco.com/2009/01/backup-your-wordpress-blog-to-amazon-s3-using-ruby/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 21:54:14 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.compulsivoco.com/?p=218</guid>
		<description><![CDATA[I&#8217;ve been running this blog for months without a backup solution.  Mostly because I didn&#8217;t really care for any of the existing solutions which required me to do too many manual steps.  I wanted something completely hands-off (automatically run every night), secure and reliable (store the backups on Amazon&#8217;s S3).
So, enjoy wordpress-s3-backup.  Use it to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been running this blog for months without a backup solution.  Mostly because I didn&#8217;t really care for any of the existing solutions which required me to do too many manual steps.  I wanted something completely hands-off (automatically run every night), secure and reliable (store the backups on Amazon&#8217;s S3).</p>
<p>So, enjoy <a title="WordPress S3 Backups with Ruby" href="http://github.com/jbritten/wordpress-s3-backup/tree/master" target="_blank">wordpress-s3-backup</a>.  Use it to backup your WordPress blog &#8212; both the database and the site.  It&#8217;s a Ruby Rake script and you&#8217;ll need the AWS-S3 gem.  Stick it in your crontab to run nightly and move on with your life.</p>
<p><a title="WordPress S3 Backups with Ruby" href="http://github.com/jbritten/wordpress-s3-backup/tree/master" target="_blank">Get it here</a>.</p>
<img src="http://feeds.feedburner.com/~r/Compulsivo/~4/_DR5o53FkNQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.compulsivoco.com/2009/01/backup-your-wordpress-blog-to-amazon-s3-using-ruby/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.compulsivoco.com/2009/01/backup-your-wordpress-blog-to-amazon-s3-using-ruby/</feedburner:origLink></item>
		<item>
		<title>How to Set an Expires Header in Apache</title>
		<link>http://feedproxy.google.com/~r/Compulsivo/~3/h5PA8eDP6ZM/</link>
		<comments>http://www.compulsivoco.com/2008/12/how-to-set-an-expires-header-in-apache/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 20:40:48 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.compulsivoco.com/?p=197</guid>
		<description><![CDATA[Setting an Expires (or Cache-Control) header in Apache will help speed up your Web site.  We&#8217;re running Apache 2.x, and define an expires header for all of our static assets (images, stylesheets, and scripts).
Just add the following to your &#60;VirtualHost&#62; section of your Apache configuration:
ExpiresActive On
ExpiresByType image/png &#8220;now plus 365 days&#8221;
ExpiresByType image/jpeg &#8220;now plus 365 [...]]]></description>
			<content:encoded><![CDATA[<p>Setting an Expires (or Cache-Control) header in Apache will help speed up your Web site.  We&#8217;re running Apache 2.x, and define an expires header for all of our static assets (images, stylesheets, and scripts).</p>
<p>Just add the following to your &lt;VirtualHost&gt; section of your Apache configuration:</p>
<p style="padding-left: 60px;">ExpiresActive On<br />
ExpiresByType image/png &#8220;now plus 365 days&#8221;<br />
ExpiresByType image/jpeg &#8220;now plus 365 days&#8221;<br />
ExpiresByType image/gif &#8220;now plus 365 days&#8221;<br />
ExpiresByType application/javascript &#8220;now plus 365 days&#8221;<br />
ExpiresByType application/x-javascript &#8220;now plus 365 days&#8221;<br />
ExpiresByType text/javascript &#8220;now plus 365 days&#8221;<br />
ExpiresByType text/css &#8220;now plus 365 days&#8221;</p>
<p>You can read all about expires headers by reading Yahoo!&#8217;s <a href="http://developer.yahoo.com/performance/rules.html#expires" target="_blank">Best Practices for Speeding Up Your Website </a>guide.</p>
<p>Also, be sure to check out our post on how to speed up your Website by <a href="http://www.compulsivoco.com/2008/12/apache-gzip-configuration">Configuring Apache to Gzip Your Components</a>.</p>
<img src="http://feeds.feedburner.com/~r/Compulsivo/~4/h5PA8eDP6ZM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.compulsivoco.com/2008/12/how-to-set-an-expires-header-in-apache/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.compulsivoco.com/2008/12/how-to-set-an-expires-header-in-apache/</feedburner:origLink></item>
		<item>
		<title>How to Configure Apache to Gzip Your Components</title>
		<link>http://feedproxy.google.com/~r/Compulsivo/~3/vkzXJOtMM1Y/</link>
		<comments>http://www.compulsivoco.com/2008/12/apache-gzip-configuration/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 20:40:42 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.compulsivoco.com/?p=207</guid>
		<description><![CDATA[Compressing your Web components will help speed up your Website.  The majority of your visitors will benefit as most all Web browsers support gzip compression.  You&#8217;ll want to compress all text, which includes html, css, javascript, xml, json, etc.
Apache 2.x uses mod_deflate, and all you need to do is add the following to your &#60;VirtualHost&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Compressing your Web components will help speed up your Website.  The majority of your visitors will benefit as most all Web browsers support gzip compression.  You&#8217;ll want to compress all text, which includes html, css, javascript, xml, json, etc.</p>
<p>Apache 2.x uses mod_deflate, and all you need to do is add the following to your &lt;VirtualHost&gt; section of your Apache configuration:</p>
<p style="padding-left: 60px;">AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript<br />
BrowserMatch ^Mozilla/4 gzip-only-text/html<br />
BrowserMatch ^Mozilla/4\.0[678] no-gzip<br />
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html</p>
<p>All you truly need is the first line.  The BrowserMatch lines are there to handle issues with old browsers.</p>
<p>You can read all about gzipping by reading Yahoo!&#8217;s <a href="http://developer.yahoo.com/performance/rules.html#gzip" target="_blank">Best Practices for Speeding Up Your Website</a> guide.</p>
<p>Also, be sure to check out our post on <a href="http://www.compulsivoco.com/2008/12/how-to-set-an-expires-header-in-apache">How to Set an Expires Header in Apache</a>, which will also help speed up your Website.</p>
<img src="http://feeds.feedburner.com/~r/Compulsivo/~4/vkzXJOtMM1Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.compulsivoco.com/2008/12/apache-gzip-configuration/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.compulsivoco.com/2008/12/apache-gzip-configuration/</feedburner:origLink></item>
		<item>
		<title>Announcing Major Enhancements for Prefinery</title>
		<link>http://feedproxy.google.com/~r/Compulsivo/~3/mGXiOvYRkPY/</link>
		<comments>http://www.compulsivoco.com/2008/11/major-enhancements-for-prefinery-beta-management-software/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 17:50:43 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Prefinery]]></category>

		<guid isPermaLink="false">http://www.compulsivoco.com/?p=177</guid>
		<description><![CDATA[Some major enhancements are coming to Prefinery on December 10, 2008.  Here&#8217;s the complete run-down:
Personalized subdomains
Every company account gets a free, personalized subdomain.  In addition to giving you the opportunity to add a bit of branding to the URL, you will now log in to administer your betas using this new subdomain.  For example, if [...]]]></description>
			<content:encoded><![CDATA[<p>Some major enhancements are coming to Prefinery on December 10, 2008.  Here&#8217;s the complete run-down:</p>
<h2 style="padding-left: 30px;">Personalized subdomains</h2>
<p style="padding-left: 30px;">Every company account gets a free, personalized subdomain.  In addition to giving you the opportunity to add a bit of branding to the URL, you will now log in to administer your betas using this new subdomain.  For example, if your subdomain is &#8220;adobe&#8221; you will now log in at http://adobe.prefinery.com/admin</p>
<h2 style="padding-left: 30px;">Separate administrator and tester areas</h2>
<p style="padding-left: 30px;">As an administrator of a beta program, you will log into Prefinery using your personalized subdomain (e.g., http://adobe.prefinery.com/admin) and will interact with a management console.  Testers will access your beta at a separate location and view a unique set of pages that you have customized.</p>
<h2 style="padding-left: 30px;">Complete user interface redesign</h2>
<p style="padding-left: 30px;">The first thing you&#8217;ll notice when you log in is that Prefinery has received a major facelift.  We&#8217;re not talking a nip here and a tuck there.  We mean Prefinery fled to a country without extradition and got a brand new identity.</p>
<h2 style="padding-left: 30px;">Landing / Welcome page</h2>
<p style="padding-left: 30px;">Create a custom landing page for your testers using our easy to use Web page editor.  You don&#8217;t need to know any HTML to create a beautiful welcome page.  We&#8217;ll add generic log in and join links to the page, but the rest of the content is up to you.</p>
<h2 style="padding-left: 30px;">Improved custom branding</h2>
<p style="padding-left: 30px;">When you subscribe to a plan with custom branding, you&#8217;ll be getting a blank slate.  You&#8217;ll have complete control over the content and styling of the page so that you may provide your testers with a familiar experience.  In fact, once you add your logo to the page, testers may not even realize they&#8217;re not on your site.</p>
<h2 style="padding-left: 30px;">Guestbook creation</h2>
<p style="padding-left: 30px;">Specify what contact information is required to be gathered from testers when they join your beta.  Pick from email address, name, address, employer, job title, and telephone.</p>
<h2 style="padding-left: 30px;">Require a survey to join</h2>
<p style="padding-left: 30px;">Require testers to take one of your surveys prior to joining your beta.  Perfect if you want to collect more information than the guestbook supports.  Also a great way to attach a sign up application to your beta.</p>
<h2 style="padding-left: 30px;">Require a survey to download files</h2>
<p style="padding-left: 30px;">Require testers to take one of your surveys prior to downloading a specific file.  Perhaps anyone can download version 1.0, but you want to require the survey &#8220;1.0 Feedback&#8221; prior to downloading version 2.0.</p>
<h2 style="padding-left: 30px;">Sexy survey results</h2>
<p style="padding-left: 30px;">We&#8217;re using a whole new package for our graphs and charts.  They&#8217;re faster, interactive, and look great when sporting your data.</p>
<h2 style="padding-left: 30px;">Bugs, comments consolidated</h2>
<p style="padding-left: 30px;">We&#8217;ve combined bugs and comments.  Prefinery is not competing in the bug tracking and ticket management space.  Plenty of excellent tools already exist.  So, we&#8217;ve merged bugs and comments since both are nothing more than tester feedback.  You&#8217;ll still be able to export the data.</p>
<h2 style="padding-left: 30px;">Plus, dozens of tiny improvements</h2>
<p>We hope you enjoy these additions and enhancements.  We&#8217;d love to hear your feedback!</p>
<img src="http://feeds.feedburner.com/~r/Compulsivo/~4/mGXiOvYRkPY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.compulsivoco.com/2008/11/major-enhancements-for-prefinery-beta-management-software/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.compulsivoco.com/2008/11/major-enhancements-for-prefinery-beta-management-software/</feedburner:origLink></item>
		<item>
		<title>Calling Rails Render Partial in a Model or Background Task</title>
		<link>http://feedproxy.google.com/~r/Compulsivo/~3/1ClTnbcIh2g/</link>
		<comments>http://www.compulsivoco.com/2008/10/rendering-rails-partials-in-a-model-or-background-task/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 20:03:39 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.compulsivoco.com/?p=161</guid>
		<description><![CDATA[Why?
You want to store raw HTML in the database for a given model and you want to do this with the ease of partials and not a bunch of nasty string manipulation.
Rails makes this difficult for you by not giving you access to the render method when not called from ActionController.  However, you&#8217;d like to [...]]]></description>
			<content:encoded><![CDATA[<h2>Why?</h2>
<p>You want to store raw HTML in the database for a given model and you want to do this with the ease of partials and not a bunch of nasty string manipulation.</p>
<p>Rails makes this difficult for you by not giving you access to the render method when not called from ActionController.  However, you&#8217;d like to call the partial helper from within a model, or a background task (such as BackgrounDRb or Starling).</p>
<h2>How?</h2>
<p>As an example, let&#8217;s say you have a Page model made up of a <em>title</em> and a <em>body</em>.  You&#8217;d like to cache what a rendered page would look like in the model as the attribute <em>cached_content</em>.</p>
<p><strong>The old way.  This really sucks.</strong></p>
<pre class="brush: ruby">
class Page &lt; ActiveRecord::Base

  def write_cache
    the_content = &quot;&lt;div class=&#039;title&#039;&gt;&quot;
    the_content += &quot;&lt;h1&gt;#{self.title}&lt;/h1&gt;&quot;
    the_content += &quot;&lt;/div&gt;&quot;
    the_content += &quot;&lt;div class=&#039;body&#039;&gt;&quot;
    the_content += &quot;#{self.body}&quot;
    the_content += &quot;&lt;/div&gt;&quot;

    self.cached_content = the_content
    self.save
  end

end
</pre>
<p><strong>The new way.  This is so much easier and cleaner.<br />
</strong></p>
<pre class="brush: ruby">
class Page &lt; ActiveRecord::Base

  def write_cache
    self.cached_content = ActionView::Base.new(Rails::Configuration.new.view_path).render(:partial =&gt; &quot;pages/show&quot;, :locals =&gt; {:page =&gt; self})
    self.save
  end

end
</pre>
<p><em>app/views/pages/_show.html.erb</em></p>
<pre class="brush: html">
&lt;div class=&quot;title&quot;&gt;
  &lt;h1&gt;
    &lt;%= page.title %&gt;
  &lt;/h1&gt;
&lt;/div&gt;

&lt;div class=&quot;body&quot;&gt;
  &lt;%= page.body %&gt;
&lt;/div&gt;
</pre>
<img src="http://feeds.feedburner.com/~r/Compulsivo/~4/1ClTnbcIh2g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.compulsivoco.com/2008/10/rendering-rails-partials-in-a-model-or-background-task/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.compulsivoco.com/2008/10/rendering-rails-partials-in-a-model-or-background-task/</feedburner:origLink></item>
		<item>
		<title>Pilot your Project with Cockpit</title>
		<link>http://feedproxy.google.com/~r/Compulsivo/~3/nf8PoHlnIX0/</link>
		<comments>http://www.compulsivoco.com/2008/10/pilot-your-project-with-cockpit/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 22:21:35 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.compulsivoco.com/?p=147</guid>
		<description><![CDATA[This past weekend we competed in RailsRumble 2008 - a 48-hour Ruby on Rails programming competition where the goal is to produce a complete application in a weekend.  We partnered with Marcus Mateus of SimpliTex to create Cockpit.
We were tired of constantly logging in to various sites to see key data for the various projects [...]]]></description>
			<content:encoded><![CDATA[<p>This past weekend we competed in <a href="http://railsrumble.com" target="_blank">RailsRumble 2008</a> - a 48-hour Ruby on Rails programming competition where the goal is to produce a complete application in a weekend.  We partnered with Marcus Mateus of <a href="http://www.simplitex.com/" target="_blank">SimpliTex</a> to create <a href="http://www.cockpitapp.com/" target="_blank">Cockpit</a>.</p>
<p>We were tired of constantly logging in to various sites to see key data for the various projects we were working on. While RSS feeds can provide much of the data, digging through RSS feeds doesn’t provide you with a true executive level overview of your project. You really want to see only the most important, relevant, and timely data… and ideally act on it. <a title="Cockpit - Pilot your Project" onclick="javascript:pageTracker._trackPageview ('/outbound/www.cockpitapp.com');" href="http://www.cockpitapp.com/" target="_blank">Cockpit</a> is our answer to this most annoying problem.</p>
<p>In the 48 hours we had for the competition we decided to focus on getting a simple proof of concept view of key data from just four widely used web services. Lots of other sites provide similarly useful data, and full interactivity would be great, but the clock was a tickin’, so we limited our scope to the following:</p>
<ul>
<li><a onclick="javascript:pageTracker._trackPageview ('/outbound/basecamphq.com');" href="http://basecamphq.com/" target="_blank">Basecamp</a> messages, todos and milestones</li>
<li><a onclick="javascript:pageTracker._trackPageview ('/outbound/github.com');" href="http://github.com/" target="_blank">Github</a> source code commits</li>
<li><a onclick="javascript:pageTracker._trackPageview ('/outbound/lighthouseapp.com');" href="http://lighthouseapp.com/" target="_blank">Lighhouse</a> bug tickets</li>
<li><a onclick="javascript:pageTracker._trackPageview ('/outbound/hoptoadapp.com');" href="http://hoptoadapp.com/" target="_blank">Hoptoad</a> exceptions</li>
</ul>
<p>We have high hopes that with the feedback that comes via the competition we will be able to create an application to help rescue all of us from project overload. Over the next 10 days, anyone can <a href="http://railsrumble.com/teams/rubysaurus-rex" target="_blank">vote for Cockpit</a>.  So far we&#8217;re off to a great start.  As of the first day we&#8217;re ranked #10 of 131 in the Usefulness category &#8212; in our opinion the only category that truly matters in the long run.</p>
<p>The competition was a blast, even if tiring. A great big thank you goes out to all the organizers, volunteers, and <a onclick="javascript:pageTracker._trackPageview ('/outbound/railsrumble.com');" href="http://railsrumble.com/sponsors" target="_blank">sponsors</a>.</p>
<p><span style="font-size: 0.9em;"><em>Note: Most of this article was authored by Marcus Mateus and was originally posted to the <a href="http://www.simplitex.com/2008/10/21/cockpit-helps-you-pilot-your-project/" target="_blank">SimpliTex blog</a>.</em></span></p>
<img src="http://feeds.feedburner.com/~r/Compulsivo/~4/nf8PoHlnIX0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.compulsivoco.com/2008/10/pilot-your-project-with-cockpit/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.compulsivoco.com/2008/10/pilot-your-project-with-cockpit/</feedburner:origLink></item>
	</channel>
</rss>
