<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tech Trivia</title>
	<atom:link href="http://www.alethe.com/brad/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alethe.com/brad</link>
	<description>For those who know just enough to be dangerous</description>
	<lastBuildDate>Sun, 28 Feb 2010 04:45:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Recursively set permissions on directories</title>
		<link>http://www.alethe.com/brad/2010/02/recursively-set-permissions-on-directories/</link>
		<comments>http://www.alethe.com/brad/2010/02/recursively-set-permissions-on-directories/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 04:43:57 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech Notes]]></category>

		<guid isPermaLink="false">http://www.alethe.com/brad/?p=129</guid>
		<description><![CDATA[<p>The following command will execute a command on a directory and all its sub-directories:</p>
<pre class="brush: bash">
$ find plugins -type d -exec chmod g+w {} \;
</pre>
<p>In this case, we&#8217;re changing the group permissions on the plugins directory and all sub-directories.</p>
]]></description>
			<content:encoded><![CDATA[<p>The following command will execute a command on a directory and all its sub-directories:</p>
<pre class="brush: bash">
$ find plugins -type d -exec chmod g+w {} \;
</pre>
<p>In this case, we&#8217;re changing the group permissions on the plugins directory and all sub-directories.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alethe.com/brad/2010/02/recursively-set-permissions-on-directories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update your SELinux policy</title>
		<link>http://www.alethe.com/brad/2010/02/update-your-selinux-policy/</link>
		<comments>http://www.alethe.com/brad/2010/02/update-your-selinux-policy/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 14:15:02 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech Notes]]></category>

		<guid isPermaLink="false">http://www.alethe.com/brad/?p=115</guid>
		<description><![CDATA[<p>If you&#8217;ve recently installed an application or applied some patches that begin to generate a lot of SELinux audit entries, you can update your local policy to accommodate your recent changes.  Please note that this isn&#8217;t a substitute for ensuring your files have the appropriate selinux roles and types.</p>
<pre class="brush: plain">
# grep avc /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp
</pre>
]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve recently installed an application or applied some patches that begin to generate a lot of SELinux audit entries, you can update your local policy to accommodate your recent changes.  Please note that this isn&#8217;t a substitute for ensuring your files have the appropriate selinux roles and types.</p>
<pre class="brush: plain">
# grep avc /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.alethe.com/brad/2010/02/update-your-selinux-policy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple select list in rails</title>
		<link>http://www.alethe.com/brad/2009/10/multiple-select-list-in-rails/</link>
		<comments>http://www.alethe.com/brad/2009/10/multiple-select-list-in-rails/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 13:58:21 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby and Rails]]></category>

		<guid isPermaLink="false">http://www.alethe.com/brad/?p=70</guid>
		<description><![CDATA[<p>I have recently been tinkering with ruby on rails again and was banging my head against the wall with a multiple select list for a &#8220;has and belongs to many&#8221; relationship between models.  After a lot of Googling and experimenting I finally got it running.  The resulting code is deceptively simple!</p>
<p>This example illustrates the relationship between users and their roles.  Each user can have multiple roles, and each role can have multiple users.</p>
<p><span id="more-70"></span></p>
<h3>The User Model</h3>
<pre class="brush: ruby">
# models/admin/user.rb
class Admin::User &lt; ActiveRecord::Base
  has_one :division, :class_name =&gt; &quot;Admin::Division&quot;
  has_and_belongs_to_many :role, :class_name =&gt; &quot;Admin::Role&quot;
  validates_presence_of :first_name, :last_name, :user_name, :password
end
</pre>
<h3>The Role Model</h3>
<pre class="brush: ruby">
# models/admin/role.rb
class Admin::Role &lt; ActiveRecord::Base
  has_and_belongs_to_many :user, :class_name =&gt; &quot;Admin::User&quot;
  validates_presence_of :role
end
</pre>
<h3>The User View (partial)</h3>
<pre class="brush: ruby">
# views/admin/users/_form.html.erb
&lt;% form_for(@user) do |f| %&gt;
  &lt;%= f.error_messages %&gt;
  &lt;p&gt;
    &lt;%= f.label :first_name %&gt;&lt;br /&gt;
    &lt;%= f.text_field :first_name %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.label :last_name %&gt;&lt;br /&gt;
    &lt;%= f.text_field :last_name %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.label :user_name %&gt;&lt;br /&gt;
    &lt;%= f.text_field :user_name %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.label :password %&gt;&lt;br /&gt;
    &lt;%= f.password_field :password %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.label :role %&gt;&lt;br /&gt;
	&lt;%= collection_select(:admin_user, :role_ids, @roles, :id, :role,
		{ :selected =&gt; @user.role_ids },
		{:multiple =&gt; true, :role =&gt; &#039;admin_user[role_ids][]&#039; }) %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.submit &#039;Save&#039; %&gt;
  &lt;/p&gt;
&lt;% end %&gt;
</pre>
<h3>The User Controller</h3>
<pre class="brush: ruby">
# excerpt from controllers/admin/users_controller.rb
# This is just the update method
#
  def update
    # if the multiple select list is empty,
    # make sure the role_ids array exists
    params[:admin_user][:role_ids] ||= []

    respond_to do |format|
      if @user.update_attributes(params[:admin_user])
        flash[:notice] = &#039;User was successfully updated.&#039;
        format.html { redirect_to(@user) }
        format.xml  { head :ok }
      else
        format.html { render :action =&gt; &quot;edit&quot; }
        format.xml  { render :xml =&gt; @user.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end
</pre>
<h3>Display Comma Delimited Roles</h3>
<p>Once I got the select list working, I wanted a simple way to display a comma delimited list of a user&#8217;s roles.  I messed about with looping over all roles and just displaying the ones that matched the appropriate values, but it turns out there is a much simpler and elegant way to do this.  The following snippet of code leverages the HMABT mapping between the user model and role model to access all the role names associated with a particular user.  It then joins them all together delimiting the values with commas.</p>
<pre class="brush: ruby">
# excerpt from views/admin/users/index.html.erb
#
&lt;%=h user.role.map(&amp;:role).join(&#039;, &#039;) %&gt;
</pre>
<h3>The Admin Name Space</h3>
<p>Please note that my example is complicated a little by the fact that the models, views and controllers are all within a &#8220;/admin&#8221; name space.  Here&#8217;s an excerpt from my routes.rb file which shows the necessary code to make it work.</p>
<pre class="brush: ruby">
# excerpt from config/routes.rb
map.namespace :admin do |admin|
    admin.resources :roles, :users
  end
</pre>
<h3>Additional Resources</h3>
<p>The following resources were quite helpful to me in getting this working:</p>
<ul>
<li><a href="http://railscasts.com/episodes/17-habtm-checkboxes">Railscast: HABTM Checkboxes</a></li>
<li><a href="http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M001625">RubyOnRails API &#8211; collection_select</a></li>
</ul</p>
]]></description>
			<content:encoded><![CDATA[<p>I have recently been tinkering with ruby on rails again and was banging my head against the wall with a multiple select list for a &#8220;has and belongs to many&#8221; relationship between models.  After a lot of Googling and experimenting I finally got it running.  The resulting code is deceptively simple!</p>
<p>This example illustrates the relationship between users and their roles.  Each user can have multiple roles, and each role can have multiple users.</p>
<p><span id="more-70"></span></p>
<h3>The User Model</h3>
<pre class="brush: ruby">
# models/admin/user.rb
class Admin::User &lt; ActiveRecord::Base
  has_one :division, :class_name =&gt; &quot;Admin::Division&quot;
  has_and_belongs_to_many :role, :class_name =&gt; &quot;Admin::Role&quot;
  validates_presence_of :first_name, :last_name, :user_name, :password
end
</pre>
<h3>The Role Model</h3>
<pre class="brush: ruby">
# models/admin/role.rb
class Admin::Role &lt; ActiveRecord::Base
  has_and_belongs_to_many :user, :class_name =&gt; &quot;Admin::User&quot;
  validates_presence_of :role
end
</pre>
<h3>The User View (partial)</h3>
<pre class="brush: ruby">
# views/admin/users/_form.html.erb
&lt;% form_for(@user) do |f| %&gt;
  &lt;%= f.error_messages %&gt;
  &lt;p&gt;
    &lt;%= f.label :first_name %&gt;&lt;br /&gt;
    &lt;%= f.text_field :first_name %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.label :last_name %&gt;&lt;br /&gt;
    &lt;%= f.text_field :last_name %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.label :user_name %&gt;&lt;br /&gt;
    &lt;%= f.text_field :user_name %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.label :password %&gt;&lt;br /&gt;
    &lt;%= f.password_field :password %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.label :role %&gt;&lt;br /&gt;
	&lt;%= collection_select(:admin_user, :role_ids, @roles, :id, :role,
		{ :selected =&gt; @user.role_ids },
		{:multiple =&gt; true, :role =&gt; &#039;admin_user[role_ids][]&#039; }) %&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;%= f.submit &#039;Save&#039; %&gt;
  &lt;/p&gt;
&lt;% end %&gt;
</pre>
<h3>The User Controller</h3>
<pre class="brush: ruby">
# excerpt from controllers/admin/users_controller.rb
# This is just the update method
#
  def update
    # if the multiple select list is empty,
    # make sure the role_ids array exists
    params[:admin_user][:role_ids] ||= []

    respond_to do |format|
      if @user.update_attributes(params[:admin_user])
        flash[:notice] = &#039;User was successfully updated.&#039;
        format.html { redirect_to(@user) }
        format.xml  { head :ok }
      else
        format.html { render :action =&gt; &quot;edit&quot; }
        format.xml  { render :xml =&gt; @user.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end
</pre>
<h3>Display Comma Delimited Roles</h3>
<p>Once I got the select list working, I wanted a simple way to display a comma delimited list of a user&#8217;s roles.  I messed about with looping over all roles and just displaying the ones that matched the appropriate values, but it turns out there is a much simpler and elegant way to do this.  The following snippet of code leverages the HMABT mapping between the user model and role model to access all the role names associated with a particular user.  It then joins them all together delimiting the values with commas.</p>
<pre class="brush: ruby">
# excerpt from views/admin/users/index.html.erb
#
&lt;%=h user.role.map(&amp;:role).join(&#039;, &#039;) %&gt;
</pre>
<h3>The Admin Name Space</h3>
<p>Please note that my example is complicated a little by the fact that the models, views and controllers are all within a &#8220;/admin&#8221; name space.  Here&#8217;s an excerpt from my routes.rb file which shows the necessary code to make it work.</p>
<pre class="brush: ruby">
# excerpt from config/routes.rb
map.namespace :admin do |admin|
    admin.resources :roles, :users
  end
</pre>
<h3>Additional Resources</h3>
<p>The following resources were quite helpful to me in getting this working:</p>
<ul>
<li><a href="http://railscasts.com/episodes/17-habtm-checkboxes">Railscast: HABTM Checkboxes</a></li>
<li><a href="http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M001625">RubyOnRails API &#8211; collection_select</a></li>
</ul</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alethe.com/brad/2009/10/multiple-select-list-in-rails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Update text in multiple files in Linux</title>
		<link>http://www.alethe.com/brad/2009/06/update-text-in-multiple-files-in-linux/</link>
		<comments>http://www.alethe.com/brad/2009/06/update-text-in-multiple-files-in-linux/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 21:34:09 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech Notes]]></category>

		<guid isPermaLink="false">http://www.alethe.com/brad/?p=63</guid>
		<description><![CDATA[<p>I recently came across a command that allows me to search and replace a string of text in all files within a directory structure.  This is very useful for updating static information in HTML files and the like.</p>
<p><code>find ./ -iname \*.htm\* -exec sed -i 's/www\.example\.com/www2\.example\.com/g' {} \;</code></p>
<p>Note that you must denote special characters with the backslash character (e.g., the dots in www.example.com).</p>
]]></description>
			<content:encoded><![CDATA[<p>I recently came across a command that allows me to search and replace a string of text in all files within a directory structure.  This is very useful for updating static information in HTML files and the like.</p>
<p><code>find ./ -iname \*.htm\* -exec sed -i 's/www\.example\.com/www2\.example\.com/g' {} \;</code></p>
<p>Note that you must denote special characters with the backslash character (e.g., the dots in www.example.com).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alethe.com/brad/2009/06/update-text-in-multiple-files-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find world writable directories</title>
		<link>http://www.alethe.com/brad/2009/05/find-world-writable-directories/</link>
		<comments>http://www.alethe.com/brad/2009/05/find-world-writable-directories/#comments</comments>
		<pubDate>Tue, 12 May 2009 18:47:56 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech Notes]]></category>

		<guid isPermaLink="false">http://www.alethe.com/brad/?p=60</guid>
		<description><![CDATA[<p>I recently found myself needing to locate all world writable files in a directory tree and came across the following useful command:</p>
<p><code>find /var/ -type d -perm -o+w -exec ls -ld {} \;</code></p>
<p>The syntax may vary depending on the flavour of Unix/Linux you&#8217;re using, but this worked on Ubuntu for me.</p>
]]></description>
			<content:encoded><![CDATA[<p>I recently found myself needing to locate all world writable files in a directory tree and came across the following useful command:</p>
<p><code>find /var/ -type d -perm -o+w -exec ls -ld {} \;</code></p>
<p>The syntax may vary depending on the flavour of Unix/Linux you&#8217;re using, but this worked on Ubuntu for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alethe.com/brad/2009/05/find-world-writable-directories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create an ISO image from a DVD in Mac OS X</title>
		<link>http://www.alethe.com/brad/2009/05/create-an-iso-image-from-a-dvd-in-mac-os-x/</link>
		<comments>http://www.alethe.com/brad/2009/05/create-an-iso-image-from-a-dvd-in-mac-os-x/#comments</comments>
		<pubDate>Sun, 10 May 2009 00:26:12 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Apple OS X]]></category>
		<category><![CDATA[Tech Notes]]></category>

		<guid isPermaLink="false">http://www.alethe.com/brad/?p=50</guid>
		<description><![CDATA[<p>1. Insert CD/DVD</p>
<p>2. Open a terminal window and use the following command to determine your DVD device:<br />
<code><br />
$ drutil status<br />
 Vendor   Product           Rev<br />
 HL-DT-ST DVDRW   GSA-S10N   AP09</code><br />
<code><br />
     Type: DVD-ROM              Name: /dev/disk1<br />
</code></p>
<p>3. Umount the disk with the following command:<br />
<code><br />
$ diskutil unmountDisk /dev/disk1<br />
Disk /dev/disk1 unmounted<br />
</code></p>
<p>4. Use the dd command to create the ISO file:<br />
<code><br />
$ dd if=/dev/disk1 of=file.iso bs=2048<br />
</code></p>
<p>5. Mount the ISO file to verify that it is readable:<br />
<code><br />
$ hdid file.iso<br />
</code></p>
<p>If you&#8217;re looking for a utility to allow you to read ISO files on the Windows platform, try <a href="http://www.slysoft.com/en/virtual-clonedrive.html">Virtual Clone drive</a> from SlySoft.</p>
]]></description>
			<content:encoded><![CDATA[<p>1. Insert CD/DVD</p>
<p>2. Open a terminal window and use the following command to determine your DVD device:<br />
<code><br />
$ drutil status<br />
 Vendor   Product           Rev<br />
 HL-DT-ST DVDRW   GSA-S10N   AP09</code><br />
<code><br />
     Type: DVD-ROM              Name: /dev/disk1<br />
</code></p>
<p>3. Umount the disk with the following command:<br />
<code><br />
$ diskutil unmountDisk /dev/disk1<br />
Disk /dev/disk1 unmounted<br />
</code></p>
<p>4. Use the dd command to create the ISO file:<br />
<code><br />
$ dd if=/dev/disk1 of=file.iso bs=2048<br />
</code></p>
<p>5. Mount the ISO file to verify that it is readable:<br />
<code><br />
$ hdid file.iso<br />
</code></p>
<p>If you&#8217;re looking for a utility to allow you to read ISO files on the Windows platform, try <a href="http://www.slysoft.com/en/virtual-clonedrive.html">Virtual Clone drive</a> from SlySoft.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alethe.com/brad/2009/05/create-an-iso-image-from-a-dvd-in-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using rsync over ssh</title>
		<link>http://www.alethe.com/brad/2009/05/using-rsync-over-ssh/</link>
		<comments>http://www.alethe.com/brad/2009/05/using-rsync-over-ssh/#comments</comments>
		<pubDate>Fri, 08 May 2009 00:58:46 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Apple OS X]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech Notes]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.alethe.com/brad/?p=43</guid>
		<description><![CDATA[<p>You can securely synchronize directory structures between two Linux computers by using the following command:</p>
<p><code>rsync -ave ssh --delete myhost.example.com:Documents/ Documents/</code></p>
<p>The &#8722;&#8722;delete option ensures that any files or directories that no longer exist on the source are also removed from the destination.</p>
]]></description>
			<content:encoded><![CDATA[<p>You can securely synchronize directory structures between two Linux computers by using the following command:</p>
<p><code>rsync -ave ssh --delete myhost.example.com:Documents/ Documents/</code></p>
<p>The &#8722;&#8722;delete option ensures that any files or directories that no longer exist on the source are also removed from the destination.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alethe.com/brad/2009/05/using-rsync-over-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reset TYPO3 password</title>
		<link>http://www.alethe.com/brad/2009/04/reset-typo3-password/</link>
		<comments>http://www.alethe.com/brad/2009/04/reset-typo3-password/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 14:06:27 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tech Notes]]></category>
		<category><![CDATA[Typo3 Snippets]]></category>
		<category><![CDATA[typo3]]></category>

		<guid isPermaLink="false">http://www.alethe.com/brad/?p=40</guid>
		<description><![CDATA[<p>If you forget your typo3 password, you can reset it using the mysql command line tool as follows:</p>
<p><code><br />
mysql> use typo3;<br />
mysql> update be_users set password='bacb98acf97e0b6112b1d1b650b84971' where username = 'admin';<br />
</code></p>
<p>This resets the admin user password to &#8220;joh316&#8243;.</p>
]]></description>
			<content:encoded><![CDATA[<p>If you forget your typo3 password, you can reset it using the mysql command line tool as follows:</p>
<p><code><br />
mysql> use typo3;<br />
mysql> update be_users set password='bacb98acf97e0b6112b1d1b650b84971' where username = 'admin';<br />
</code></p>
<p>This resets the admin user password to &#8220;joh316&#8243;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alethe.com/brad/2009/04/reset-typo3-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Date format</title>
		<link>http://www.alethe.com/brad/2008/04/date-format/</link>
		<comments>http://www.alethe.com/brad/2008/04/date-format/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 01:57:34 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby and Rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.alethe.com/brad/?p=39</guid>
		<description><![CDATA[<p>Format a date in ruby using the string from time method (strftime).</p>
<pre>
Format options:
  %a - The abbreviated weekday name (``Sun'')
  %A - The  full  weekday  name (``Sunday'')
  %b - The abbreviated month name (``Jan'')
  %B - The  full  month  name (``January'')
  %c - The preferred local date and time representation
  %d - Day of the month (01..31)
  %H - Hour of the day, 24-hour clock (00..23)
  %I - Hour of the day, 12-hour clock (01..12)
  %j - Day of the year (001..366)
  %m - Month of the year (01..12)
  %M - Minute of the hour (00..59)
  %p - Meridian indicator (``AM''  or  ``PM'')
  %S - Second of the minute (00..60)
  %U - Week  number  of the current year,
          starting with the first Sunday as the first
          day of the first week (00..53)
  %W - Week  number  of the current year,
          starting with the first Monday as the first
          day of the first week (00..53)
  %w - Day of the week (Sunday is 0, 0..6)
  %x - Preferred representation for the date alone, no time
  %X - Preferred representation for the time alone, no date
  %y - Year without a century (00..99)
  %Y - Year with century
  %Z - Time zone name
  %% - Literal ``%'' character
</pre>
<pre class="brush: ruby">
   t = Time.now
   t.strftime(&quot;Today is %m/%d/%Y&quot;)   #=&gt; &quot;Today is 04/29/2008&quot;
   t.strftime(&quot;at %I:%M %p&quot;)            #=&gt; &quot;at 10:04 PM&quot;
</pre>
]]></description>
			<content:encoded><![CDATA[<p>Format a date in ruby using the string from time method (strftime).</p>
<pre>
Format options:
  %a - The abbreviated weekday name (``Sun'')
  %A - The  full  weekday  name (``Sunday'')
  %b - The abbreviated month name (``Jan'')
  %B - The  full  month  name (``January'')
  %c - The preferred local date and time representation
  %d - Day of the month (01..31)
  %H - Hour of the day, 24-hour clock (00..23)
  %I - Hour of the day, 12-hour clock (01..12)
  %j - Day of the year (001..366)
  %m - Month of the year (01..12)
  %M - Minute of the hour (00..59)
  %p - Meridian indicator (``AM''  or  ``PM'')
  %S - Second of the minute (00..60)
  %U - Week  number  of the current year,
          starting with the first Sunday as the first
          day of the first week (00..53)
  %W - Week  number  of the current year,
          starting with the first Monday as the first
          day of the first week (00..53)
  %w - Day of the week (Sunday is 0, 0..6)
  %x - Preferred representation for the date alone, no time
  %X - Preferred representation for the time alone, no date
  %y - Year without a century (00..99)
  %Y - Year with century
  %Z - Time zone name
  %% - Literal ``%'' character
</pre>
<pre class="brush: ruby">
   t = Time.now
   t.strftime(&quot;Today is %m/%d/%Y&quot;)   #=&gt; &quot;Today is 04/29/2008&quot;
   t.strftime(&quot;at %I:%M %p&quot;)            #=&gt; &quot;at 10:04 PM&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.alethe.com/brad/2008/04/date-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails for RHEL 5</title>
		<link>http://www.alethe.com/brad/2008/04/ruby-on-rails-for-rhel-5/</link>
		<comments>http://www.alethe.com/brad/2008/04/ruby-on-rails-for-rhel-5/#comments</comments>
		<pubDate>Mon, 28 Apr 2008 02:06:49 +0000</pubDate>
		<dc:creator>Brad</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ruby and Rails]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[RHEL]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.alethe.com/brad/?p=37</guid>
		<description><![CDATA[<p>Here is the quick and dirty Ruby on Rails setup for Redhat Enterprise Linux v5.0 with MySQL.</p>
<p><em>(2009-12-04 Update: This does not work with RHEL 5.4.  The mysql ruby gem requires ruby 1.8.6 and RHEL 5.4 only ships with ruby 1.8.5)</em></p>
<p>Using <code>yum</code> install ruby and mysql.  The command below does not list all the required packages, but due to dependencies, the additional packages will be installed (or should be &#8211; this is all from memory).<br />
<span id="more-37"></span><br />
<code>[bm@app3 ~]$ sudo su -<br />
[root@app3 ~]# yum install ruby ruby-devel ruby-libs ruby-irb \<br />
> ruby-rdoc subversion-ruby mysql-server mysql-devel<br />
[....]</code></p>
<p>Complete the basic configuration of MySQL.<br />
<code>[root@app3 ~]# /sbin/chkconfig mysqld on<br />
[root@app3 ~]# service mysqld start<br />
[root@app3 ~]# mysql_secure_installation<br />
</code></p>
<p><a href="http://rubyforge.org/projects/rubygems/">Download</a> and install RubyGems.  As of the date this post was written, the latest version is 1.1.1.<br />
<code>[root@app3 ~]# wget http://rubyforge.org/frs/download.php/35284/rubygems-1.1.1.zip<br />
[root@app3 ~]# unzip rubygems-1.1.1.zip<br />
[root@app3 ~]# cd rubygems-1.1.1<br />
[root@app3 rubygems-1.1.1]# ruby setup.rb<br />
[root@app3 ~]# cd ..<br />
[root@app3 ~]# rm -rf rubygems-1.1.1<br />
</code></p>
<p>Now install Rails, Mongrel, the Ruby MySQL interface, Capistrano<br />
<code>[root@app3 ~]# gem install rails --include-dependencies --no-rdoc --no-ri<br />
[root@app3 ~]# gem install mongrel --include-dependencies --no-rdoc --no-ri<br />
[root@app3 ~]# gem install mysql -- --with-mysql-config=/usr/bin/mysql_config<br />
[root@app3 ~]# gem install capistrano --include-dependencies --no-rdoc --no-ri<br />
</code></p>
<p>Phusion&#8217;s <a href="http://modrails.com/">passenger</a> gem provides a &#8220;mod_rails&#8221; module for Apache.  The installation is very straight forward.<br />
<code>[root@app3 ~]# gem install passenger<br />
[root@app3 ~]# passenger-install-apache2-module<br />
</code></p>
<p>Just follow the on-screen instructions to finish the installation.</p>
]]></description>
			<content:encoded><![CDATA[<p>Here is the quick and dirty Ruby on Rails setup for Redhat Enterprise Linux v5.0 with MySQL.</p>
<p><em>(2009-12-04 Update: This does not work with RHEL 5.4.  The mysql ruby gem requires ruby 1.8.6 and RHEL 5.4 only ships with ruby 1.8.5)</em></p>
<p>Using <code>yum</code> install ruby and mysql.  The command below does not list all the required packages, but due to dependencies, the additional packages will be installed (or should be &#8211; this is all from memory).<br />
<span id="more-37"></span><br />
<code>[bm@app3 ~]$ sudo su -<br />
[root@app3 ~]# yum install ruby ruby-devel ruby-libs ruby-irb \<br />
> ruby-rdoc subversion-ruby mysql-server mysql-devel<br />
[....]</code></p>
<p>Complete the basic configuration of MySQL.<br />
<code>[root@app3 ~]# /sbin/chkconfig mysqld on<br />
[root@app3 ~]# service mysqld start<br />
[root@app3 ~]# mysql_secure_installation<br />
</code></p>
<p><a href="http://rubyforge.org/projects/rubygems/">Download</a> and install RubyGems.  As of the date this post was written, the latest version is 1.1.1.<br />
<code>[root@app3 ~]# wget http://rubyforge.org/frs/download.php/35284/rubygems-1.1.1.zip<br />
[root@app3 ~]# unzip rubygems-1.1.1.zip<br />
[root@app3 ~]# cd rubygems-1.1.1<br />
[root@app3 rubygems-1.1.1]# ruby setup.rb<br />
[root@app3 ~]# cd ..<br />
[root@app3 ~]# rm -rf rubygems-1.1.1<br />
</code></p>
<p>Now install Rails, Mongrel, the Ruby MySQL interface, Capistrano<br />
<code>[root@app3 ~]# gem install rails --include-dependencies --no-rdoc --no-ri<br />
[root@app3 ~]# gem install mongrel --include-dependencies --no-rdoc --no-ri<br />
[root@app3 ~]# gem install mysql -- --with-mysql-config=/usr/bin/mysql_config<br />
[root@app3 ~]# gem install capistrano --include-dependencies --no-rdoc --no-ri<br />
</code></p>
<p>Phusion&#8217;s <a href="http://modrails.com/">passenger</a> gem provides a &#8220;mod_rails&#8221; module for Apache.  The installation is very straight forward.<br />
<code>[root@app3 ~]# gem install passenger<br />
[root@app3 ~]# passenger-install-apache2-module<br />
</code></p>
<p>Just follow the on-screen instructions to finish the installation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alethe.com/brad/2008/04/ruby-on-rails-for-rhel-5/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
