<?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>AlexCline.net &#187; Randomness</title>
	<atom:link href="http://alexcline.net/category/randomness/feed/" rel="self" type="application/rss+xml" />
	<link>http://alexcline.net</link>
	<description>The musings of a geek, cyclist, cinephile, yogi, diver, philosopher and gamer.</description>
	<lastBuildDate>Thu, 02 Feb 2012 19:13:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>&#8220;Message: dualvar is only available with the XS version of Scalar::Util&#8221; Error in CentOS 5</title>
		<link>http://alexcline.net/2012/02/02/message-dualvar-is-only-available-with-the-xs-version-of-scalarutil-error-in-centos-5/</link>
		<comments>http://alexcline.net/2012/02/02/message-dualvar-is-only-available-with-the-xs-version-of-scalarutil-error-in-centos-5/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 19:13:32 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Randomness]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://alexcline.net/?p=508</guid>
		<description><![CDATA[After upgrading the CentOS 5 system that is running my company&#8217;s internal ticketing system (OTRS), the automated cron jobs for processing tickets started throwing the following error: This error was caused by an upgrade to the Compress::Zlib package. The newer version of the package isn&#8217;t compiled with XS support. I found some information about this [...]]]></description>
			<content:encoded><![CDATA[<p>After upgrading the CentOS 5 system that is running my company&#8217;s internal ticketing system (OTRS), the automated cron jobs for processing tickets started throwing the following error:</p>
<pre class="brush: plain; title: ; notranslate">Message: dualvar is only available with the XS version of Scalar::Util at /usr/lib/perl5/vendor_perl/5.8.8/IO/Socket/SSL.pm line 19</pre>
<p>This error was caused by an upgrade to the Compress::Zlib package.  The newer version of the package isn&#8217;t compiled with XS support.  I found some information about this error from this <a href="http://lists.otrs.org/pipermail/otrs/2010-October/033515.html">OTRS mailing list post</a> from 2010 regarding RHEL.  Looks like it takes about a year for RHEL packages to make it downstream to CentOS.</p>
<p>To fix the error, I ran the following from the command line:</p>
<pre class="brush: bash; title: ; notranslate">perl -MCPAN -e &quot;CPAN::Shell-&gt;force(qw(install Scalar::Util));&quot;</pre>
<p>After letting the cronjobs rerun, the error was gone and tickets successfully processed again.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexcline.net/2012/02/02/message-dualvar-is-only-available-with-the-xs-version-of-scalarutil-error-in-centos-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending HTML Email from the Linux Command Line</title>
		<link>http://alexcline.net/2012/01/12/sending-html-email-from-the-linux-command-line/</link>
		<comments>http://alexcline.net/2012/01/12/sending-html-email-from-the-linux-command-line/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 17:27:49 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Randomness]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://alexcline.net/?p=503</guid>
		<description><![CDATA[Just a little tip that I found useful for a project I was working on today. I had to send the results of a MySQL query via email. Since the results are printed in a table, the formatting in the email had to use a monospace font. The easiest way to use a monospace font [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little tip that I found useful for a project I was working on today.  I had to send the results of a MySQL query via email.  Since the results are printed in a table, the formatting in the email had to use a monospace font.  The easiest way to use a monospace font in an email is to enable HTML and wrap everything in a &lt;pre> tag.</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash
mailto=email@awesome.tld
subject=&quot;The awesome subject line of your email message&quot;
(
  echo &quot;Subject: $subject&quot;
  echo &quot;MIME-Version: 1.0&quot;
  echo &quot;Content-Type: text/html&quot;
  echo &quot;Content-Disposition: inline&quot;
  echo &quot;&lt;html&gt;&lt;body&gt;&lt;pre&gt;&quot;
  mysql db -uawesome -pawesomer --table &lt; some-sql-to-run.sql
  echo &quot;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;&quot;
) | /usr/sbin/sendmail $mailto
</pre>
<p>The output looks like this:</p>
<pre class="brush: plain; title: ; notranslate">
To: email@email.tld
From: system@awesome.tld
Subject: The awesome subject line of your email message
+----------+----------+----------+
| Column 1 | Column 2 | Column 3 |
+----------+----------+----------+
| Apples   |        2 |    14.00 |
| Oranges  |        2 |   0.5000 |
+----------+----------+----------+</pre>
]]></content:encoded>
			<wfw:commentRss>http://alexcline.net/2012/01/12/sending-html-email-from-the-linux-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reconfiguring Network Interfaces in CentOS/RHEL Systems Cloned with vCenter</title>
		<link>http://alexcline.net/2011/11/15/reconfiguring-network-interfaces-in-centosrhel-systems-cloned-with-vcenter/</link>
		<comments>http://alexcline.net/2011/11/15/reconfiguring-network-interfaces-in-centosrhel-systems-cloned-with-vcenter/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 17:28:43 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Randomness]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[clone]]></category>
		<category><![CDATA[eth0]]></category>
		<category><![CDATA[mac address]]></category>
		<category><![CDATA[vm]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://alexcline.net/?p=482</guid>
		<description><![CDATA[While cloning CentOS VMs in our environment, I ran into a problem where eth0 wouldn&#8217;t start up. When trying to start the networking service, the following error popped up: The reason this error occurs is because networking adapters in cloned VMs are assigned unique MAC addresses, so they don&#8217;t conflict with the parent VM. During [...]]]></description>
			<content:encoded><![CDATA[<p>While cloning CentOS VMs in our environment, I ran into a problem where eth0 wouldn&#8217;t start up.  When trying to start the networking service, the following error popped up:</p>
<pre class="brush: plain; title: ; notranslate">Bringing up interface eth0: Device eth0 does not seem to be preset, delaying initialization.      [FAILED]</pre>
<p>The reason this error occurs is because networking adapters in cloned VMs are assigned unique MAC addresses, so they don&#8217;t conflict with the parent VM.  During OS installation, the installer detects the network adapter and udev configures the mapping between the device eth0 and the MAC address.  When the MAC address changes udev thinks the device is missing.</p>
<p>To fix this, we need to update udev&#8217;s mapping rules to point the eth0 definition to the device with the correct MAC address.  Open the file /etc/udev/rules.d/70-persistent-net.rules.  You should see something similar to what is below:</p>
<pre class="brush: plain; title: ; notranslate"># This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM==&quot;net&quot;, ACTION==&quot;add&quot;, DRIVERS==&quot;?*&quot;, ATTR{address}==&quot;00:50:56:9c:00:16&quot;, ATTR{type}==&quot;1&quot;, KERNEL==&quot;eth*&quot;, NAME=&quot;eth0&quot;

# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM==&quot;net&quot;, ACTION==&quot;add&quot;, DRIVERS==&quot;?*&quot;, ATTR{address}==&quot;00:50:56:9c:00:18&quot;, ATTR{type}==&quot;1&quot;, KERNEL==&quot;eth*&quot;, NAME=&quot;eth1&quot;</pre>
<p>As you can see there are two PCI ethernet adapters present.  The original one from the parent VM (MAC: 9c:00:16) and the new one from the current VM (MAC: 9c:00:18).  To fix the issue you need to change the eth0 device definition to have the correct MAC address (9c:00:18) and remove the eth1 device.  Your resulting file will look like so:</p>
<pre class="brush: plain; title: ; notranslate"># This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM==&quot;net&quot;, ACTION==&quot;add&quot;, DRIVERS==&quot;?*&quot;, ATTR{address}==&quot;00:50:56:9c:00:18&quot;, ATTR{type}==&quot;1&quot;, KERNEL==&quot;eth*&quot;, NAME=&quot;eth0&quot;</pre>
<p>You&#8217;ll also want to update the /etc/sysconfig/network-scripts/ifcfg-eth0 file to reflect the correct MAC address.  Then, after a quick system restart your eth0 adapter will be back up.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexcline.net/2011/11/15/reconfiguring-network-interfaces-in-centosrhel-systems-cloned-with-vcenter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fix from address (root@localhost.localdomain) in sendmail</title>
		<link>http://alexcline.net/2011/03/22/fix-from-address-rootlocalhost-localdomain-in-sendmail/</link>
		<comments>http://alexcline.net/2011/03/22/fix-from-address-rootlocalhost-localdomain-in-sendmail/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 16:53:13 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Randomness]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://alexcline.net/?p=309</guid>
		<description><![CDATA[I&#8217;m usually a postfix guy. That&#8217;s what I run on my servers and it&#8217;s the configuration I understand. So when someone asked me to take a look at an issue on a server running sendmail, I was a bit befuddled. The problem was that any messages sent from the command line, were arriving with a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m usually a postfix guy.  That&#8217;s what I run on my servers and it&#8217;s the configuration I understand.  So when someone asked me to take a look at an issue on a server running sendmail, I was a bit befuddled.</p>
<p>The problem was that any messages sent from the command line, were arriving with a from address of root@localhost.localdomain.  This was a bit of a problem.  To test and confirm I ran the following:</p>
<pre class="brush: bash; title: ; notranslate">echo &quot;Who will this message be addressed from?  The world may never know.&quot; | mail -s &quot;Testing sendmail&quot; alex</pre>
<p>And sure enough, I get an email address from root@localhost.localdomain.  I end up Googling combinations of &#8216;root@localhost.localdomain&#8217;, &#8216;localhost.localdomain&#8217; and &#8216;sendmail&#8217;.  The options were pretty much useless.  Too much noise about changing the sendmail configuration options.</p>
<p>In the end, I stumbled upon the real way to fix it&#8230;.  Open /etc/hosts and change add the host&#8217;s name <em>before</em> the localhost.localdomain entry on the first line.</p>
<pre class="brush: bash; title: ; notranslate">127.0.0.1     host.foobar.com host localhost.localdomain localhost
::1           localhost6.localdomain6 localhost6</pre>
<p>Turns out, sendmail looks for the first hostname in the hosts file for the loopback address and uses that in the from field when a from address isn&#8217;t specified by the mail client.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexcline.net/2011/03/22/fix-from-address-rootlocalhost-localdomain-in-sendmail/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>List last modified file in all subdirectories</title>
		<link>http://alexcline.net/2010/11/23/list-last-modified-file-in-all-subdirectories/</link>
		<comments>http://alexcline.net/2010/11/23/list-last-modified-file-in-all-subdirectories/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 22:13:05 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Randomness]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://alexcline.net/?p=262</guid>
		<description><![CDATA[I don&#8217;t know when someone would use this little snippet, but I think it&#8217;s useful. It will open every directory in /home and retrieve the last modified file in all subdirectories under that directory. Then it will print out the file&#8217;s modification time and path. This might be useful for a system administrator who wants [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know when someone would use this little snippet, but I think it&#8217;s useful.</p>
<p>It will open every directory in /home and retrieve the last modified file in all subdirectories under that directory.  Then it will print out the file&#8217;s modification time and path.  This might be useful for a system administrator who wants to see when the last time a user modified a file in their home directory.</p>
<pre class="brush: bash; title: Bash; notranslate">
for i in `find /home -maxdepth 1 -mindepth 1 -type d`; do
  cd $i
  find `pwd` -type f -printf &quot;%TY-%Tm-%Td %TT %p\n&quot; | sort | tail -n 1
done
</pre>
<p>To run it, save the code as &#8216;directory-age-check.sh&#8217; and run:</p>
<pre class="brush: bash; title: Run; notranslate"> sudo ./directory-age-check.sh | sort </pre>
]]></content:encoded>
			<wfw:commentRss>http://alexcline.net/2010/11/23/list-last-modified-file-in-all-subdirectories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux screen split tip</title>
		<link>http://alexcline.net/2010/10/28/linux-screen-split-tip/</link>
		<comments>http://alexcline.net/2010/10/28/linux-screen-split-tip/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 17:48:55 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Randomness]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://alexcline.net/?p=227</guid>
		<description><![CDATA[I recently found `screen` on linux. I use it when I&#8217;m developing on a remote server and I don&#8217;t want to lose my session info when I get disconnected. I heard about the ability to split the screen session so I thought I would give it a-go. Seemed easy enough until I tried it. It [...]]]></description>
			<content:encoded><![CDATA[<p>I recently found `screen` on linux.  I use it when I&#8217;m developing on a remote server and I don&#8217;t want to lose my session info when I get disconnected.</p>
<p>I heard about the ability to split the screen session so I thought I would give it a-go.  Seemed easy enough until I tried it.  It splits the screen but doesn&#8217;t clone the existing one.  It just creates a new one.  When you want to split a screen and actually use it you have to use the following:</p>
<pre class="brush: bash; title: Keyboard language=Commands; notranslate">
Ctrl-a S
Ctrl-a c
</pre>
<p>That will split the screen and create a new shell in it.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexcline.net/2010/10/28/linux-screen-split-tip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Water: Blue Gold</title>
		<link>http://alexcline.net/2010/10/15/water-blue-gold/</link>
		<comments>http://alexcline.net/2010/10/15/water-blue-gold/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 16:01:03 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Randomness]]></category>

		<guid isPermaLink="false">http://alexcline.net/?p=218</guid>
		<description><![CDATA[Back in college, I remember my Geography professor saying that potable water (water that is safe for drinking) is the most valuable resource humans have. That if you wanted to make a billion dollars and save the world, solve Earth&#8217;s water problems. Today is a day to reflect on that. Of all the water on [...]]]></description>
			<content:encoded><![CDATA[<p>Back in college, I remember my Geography professor saying that potable water (water that is safe for drinking) is the most valuable resource humans have.   That if you wanted to make a billion dollars and save the world, solve Earth&#8217;s water problems.  Today is a day to reflect on that.</p>
<p>Of all the water on the Earth, only 2.5% of it is suitable for drinking and less than 1% of that water is readily accessible to humans.  This means that approximately 1 in 8 people don&#8217;t have access to clean drinking water.  Here are some disheartening facts about water:</p>
<ul>
<li>More people have access to cell phones than to toilets. As a result, tons of untreated human waste make their way to water sources causing a litany of diseases, and even death.</li>
<li>The US, Mexico and China lead the world in bottled water consumption, with people in the US drinking an average of 200 bottles of water per person each year. Over 17 million barrels of oil are needed to manufacture those water bottles, 86 percent of which will never be recycled.</li>
<li>17% of the world&#8217;s population lack access to clean drinking water.  This is improved from 22% in 1990.</li>
<li>Water shortages near water bottling plants have been reported all over, including Wisconsin, New Hampshire, Florida and Texas.</li>
<li>Countries that have made decisions to not permit the privitization of water include Uruguay, Malaysia and India. </li>
<li>The NRDC tested 103 bottled waters and found over 25% were simply tap water Several tested failed the bacteria test.</li>
<li>1.5 million barrels of crude oil are used annually to produce the plastic used to bottle water.</li>
<li>90% of the cost of a bottle of water is for label, cap and bottle. </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://alexcline.net/2010/10/15/water-blue-gold/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursive JSON to URL function</title>
		<link>http://alexcline.net/2010/04/10/recursive-json-to-url-function/</link>
		<comments>http://alexcline.net/2010/04/10/recursive-json-to-url-function/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 05:14:11 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Randomness]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://alexcline.net/?p=139</guid>
		<description><![CDATA[While working on a snazzy new toy for Velocity, I needed a script to transform JSON to URL parameters. I found this clever method for doing it, but sadly, it wasn&#8217;t recursive, so it would only generate URL parameters for the first level of JSON elements. I rewrote the function to recurse over all elements [...]]]></description>
			<content:encoded><![CDATA[<p>While working on a snazzy new toy for Velocity, I needed a script to transform JSON to URL parameters.  I found <a href="http://snipplr.com/view/21914/form-json-to-url/">this clever method</a> for doing it, but sadly, it wasn&#8217;t recursive, so it would only generate URL parameters for the first level of JSON elements.</p>
<p>I rewrote the function to recurse over all elements in the object tree and spit them out in a URL-safe string.</p>
<pre class="brush: jscript; title: Javascript; notranslate">
  var JSON = {
    params : function(a1){
      var u=[];
      for(x in a1){
        if(a1[x] instanceof Array)
          u.push(x+&quot;=&quot;+encodeURI(a1[x].join(&quot;,&quot;)));
        else if(a1[x] instanceof Object)
          u.push(JSON.params(a1[x]));
        else
          u.push(x+&quot;=&quot;+encodeURI(a1[x]));
      }
      return u.join(&quot;&amp;amp;&quot;);
    }
  };
</pre>
<pre class="brush: jscript; title: JSON; notranslate">
var doc = {
  &quot;env&quot;:{
    &quot;platform&quot;:&quot;linux&quot;,
    &quot;browser&quot;:&quot;Firefox%2F3.5.8&quot;
  },
  &quot;query&quot;:{
    &quot;project&quot;:&quot;user-tracking&quot;,
    &quot;fetch_time&quot;:&quot;0&quot;
  },
  &quot;user&quot;:{
    &quot;locale&quot;:&quot;en-US&quot;,
    &quot;cluster&quot;:&quot;&quot;
  },
  &quot;last_modified&quot;:&quot;1270872812&quot;
};
</pre>
]]></content:encoded>
			<wfw:commentRss>http://alexcline.net/2010/04/10/recursive-json-to-url-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Reloading SQLite data in Rails</title>
		<link>http://alexcline.net/2010/04/06/reloading-sqlite-data-in-rails/</link>
		<comments>http://alexcline.net/2010/04/06/reloading-sqlite-data-in-rails/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 19:33:49 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Randomness]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://alexcline.net/?p=131</guid>
		<description><![CDATA[While developing a new system built on rails, I encountered a peculiar problem. I wanted to reset my database, but keep the data that was currently living it it. This turned out to be a unique problem for the following reasons: Rails has the functionality to &#8216;seed&#8217; the database using the seeds.rb file and running: [...]]]></description>
			<content:encoded><![CDATA[<p>While developing a new system built on rails, I encountered a peculiar problem.  I wanted to reset my database, but keep the data that was currently living it it.  This turned out to be a unique problem for the following reasons:</p>
<ul>
<li>Rails has the functionality to &#8216;seed&#8217; the database using the seeds.rb file and running: &#8220;rake db:seed&#8221;  This is great if you already have the data written out in pretty rails code.  If your data lives in the database, resetting it will wipe out the data.</li>
<li>You can only seed data if it has a model associated with it.  I&#8217;m working with data that uses &#8216;has_and_belongs_to_many&#8217;, which requires a non-modeled table in the db to hold the many-to-many association.  You can&#8217;t import these associations in Rails.</li>
<li>Looking online, I found a nifty rake task to dump the SQL data from the database to a file.  You can then load it into the current environment&#8217;s db after you&#8217;ve done your magic.  I found that over at <a href="http://www.agileweboperations.com/seed-data-in-ruby-on-rails/">Agile Web Operations</a>.  The only problem is, it doesn&#8217;t work for sqlite. <img src='http://alexcline.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </li>
</ul>
<p>So I did what any self-respecting developer would do&#8230; I rewrote it to do what I needed.</p>
<p>My new rake task implements the following changes:</p>
<ol>
<li>Works with sqlite3</li>
<li>Only saves the &#8216;INSERT&#8217; statements from the dump.  No need for the schema info from sqlite since it&#8217;s already in rails.</li>
<li>Fixes a bug where data loaded was always being loaded into the test db.  I like flexibility to load into any environment.</li>
</ol>
<p>Save the following code into /lib/tasks/seed.rake:</p>
<pre class="brush: ruby; title: ; notranslate">
namespace :db do
  namespace :seed do
    require 'db/seed_tables'

    desc &quot;dump the tables holding seed data to db/RAILS_ENV_seed.sql. SEED_TABLES need to be defined in config/environment.rb!!!&quot;
    task :dump =&amp;gt; :environment do
      config = ActiveRecord::Base.configurations[RAILS_ENV]
      dump_cmd = &quot;echo '.dump #{SEED_TABLES.join(&quot; &quot;)}' | sqlite3 #{config['database']} | fgrep INSERT &amp;gt; db/#{RAILS_ENV}_seed.sql&quot;
      system(dump_cmd)
    end

    desc &quot;load the dumped seed data from db/RAILS_ENV_seed.sql into the test database&quot;
    task :load =&amp;gt; :environment do
      config = ActiveRecord::Base.configurations[RAILS_ENV]
      load_cmd = &quot;sqlite3 #{config['database']} &amp;lt; db/#{RAILS_ENV}_seed.sql&amp;quot;
      system(load_cmd)
     end
  end
end</pre>
<p>And, like the previous incarnation, load up the names of the tables you want to dump into a file at /db/seed_tables.rb:</p>
<pre class="brush: ruby; title: ; notranslate">SEED_TABLES = {
  &quot;accounts&quot;,
  &quot;products&quot;,
  &quot;users&quot;
]</pre>
<p>Here&#8217;s an example of how I used it:</p>
<pre class="brush: ruby; title: ; notranslate">rake db:seed:dump
rake db:reset
rake db:seed:load</pre>
]]></content:encoded>
			<wfw:commentRss>http://alexcline.net/2010/04/06/reloading-sqlite-data-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multi-domain WordPressMU Made Easy</title>
		<link>http://alexcline.net/2010/03/18/multi-domain-wordpressmu-made-easy/</link>
		<comments>http://alexcline.net/2010/03/18/multi-domain-wordpressmu-made-easy/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 23:27:58 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Randomness]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://alexcline.net/?p=129</guid>
		<description><![CDATA[So I was fighting with WordPress MU for about 6 hours today attempting to get it to properly serve blogs for multiple domains and paths. This seemed like it wasn&#8217;t going to work since WPMU is configured to use either subdomains or subdirectories and all multi-domain solutions seem to only work when using subdomains. Somehow, [...]]]></description>
			<content:encoded><![CDATA[<p>So I was fighting with WordPress MU for about 6 hours today attempting to get it to properly serve blogs for multiple domains and paths.  This seemed like it wasn&#8217;t going to work since WPMU is configured to use either subdomains or subdirectories and all multi-domain solutions seem to only work when using subdomains.</p>
<p>Somehow, through the magic of mod_rewrite I was able to get multiple domains working while using the &#8216;subdirectory&#8217; configuration in WPMU.  The only problem I ran into was that I was unable to login to wp-admin in the non-default domains.  I realized this is because of the &#8216;domain&#8217; defined in the cookie.  To remedy that, I changed a single line in my wp-config.php to the following:</p>
<pre>define('DOMAIN_CURRENT_SITE', $_SERVER[ 'HTTP_HOST' ] );</pre>
<p>That tells WPMU that the current domain is the one PHP sees.  Surprisingly this fixed the cookie issue, and hasn&#8217;t triggered any other errors.  We&#8217;ll see how it holds up.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexcline.net/2010/03/18/multi-domain-wordpressmu-made-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

