<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Coderkitty - Home</title>
  <id>tag:coderkitty.sweetperceptions.com,2010:mephisto/</id>
  <generator version="0.8.0" uri="http://mephistoblog.com">Mephisto Drax</generator>
  <link href="http://coderkitty.sweetperceptions.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://coderkitty.sweetperceptions.com/" rel="alternate" type="text/html"/>
  <updated>2010-05-18T14:25:40Z</updated>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2010-05-18:2773</id>
    <published>2010-05-18T14:24:00Z</published>
    <updated>2010-05-18T14:25:40Z</updated>
    <category term="Coding"/>
    <category term="Ruby and/or Rails"/>
    <category term="Tips and Tricks"/>
    <category term="date"/>
    <category term="inflections"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="string"/>
    <category term="time"/>
    <category term="tips"/>
    <category term="tricks"/>
    <link href="http://coderkitty.sweetperceptions.com/2010/5/18/picking-up-the-breadcrumbs" rel="alternate" type="text/html"/>
    <title>Picking up the breadcrumbs</title>
<content type="html">
            &lt;p&gt;Its always easy to skip going through the details of what your stacked up knowledge and just go for trying out new stuff.  This time, I take it one step back and skim through pages of books I have always ignored and pick some sections that are worth looking into and post them here.&lt;/p&gt;

&lt;p&gt;I've been trying to cut down on paper materials at home.  Mostly, trying to read all those books and photocopied materials and just jot down notes from them.  I decided to post them instead.  See some string, number, time/date extensions.&lt;/p&gt;
&lt;p&gt;Its always easy to skip going through the details of what your stacked up knowledge and just go for trying out new stuff.  This time, I take it one step back and skim through pages of books I have always ignored and pick some sections that are worth looking into and post them here.&lt;/p&gt;

&lt;p&gt;I've been trying to cut down on paper materials at home.  Mostly, trying to read all those books and photocopied materials and just jot down notes from them.  I decided to post them instead.  So here goes..&lt;/p&gt;

&lt;p&gt;From a photocopy of a ruby/rails book (no title gathered):&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some string extensions:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;string = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Now is the time&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts string.at(&lt;span class=&quot;i&quot;&gt;2&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; &amp;quot;w&amp;quot;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts string.from(&lt;span class=&quot;i&quot;&gt;8&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; &amp;quot;he time&amp;quot;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts string.to(&lt;span class=&quot;i&quot;&gt;8&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; &amp;quot;Now is th&amp;quot;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts string.first  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; &amp;quot;N&amp;quot;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts string.first(&lt;span class=&quot;i&quot;&gt;3&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; &amp;quot;Now&amp;quot;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts string.last  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; &amp;quot;e&amp;quot;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts string.last(&lt;span class=&quot;i&quot;&gt;4&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; &amp;quot;time&amp;quot;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;puts string.starts_with?(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;No&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; true&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts string.ends_with?(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ME&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; false&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;count = &lt;span class=&quot;co&quot;&gt;Hash&lt;/span&gt;.new(&lt;span class=&quot;i&quot;&gt;0&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;string.each_char { |ch | count[ch] += &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt; }  &lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;#=&amp;gt; {&amp;quot; &amp;quot; =&amp;gt; 3, &amp;quot;w&amp;quot; =&amp;gt; 1, &amp;quot;N&amp;quot; =&amp;gt; 1, &amp;quot;o&amp;quot; =&amp;gt; 1, &amp;quot;e&amp;quot; =&amp;gt; 2, &amp;quot;h&amp;quot; =&amp;gt; 1, &amp;quot;s&amp;quot; =&amp;gt; 1, &amp;quot;t&amp;quot; =&amp;gt; 2, &amp;quot;i&amp;quot; =&amp;gt; 2 }&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
&lt;strong&gt;Customizing inflections:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;co&quot;&gt;Inflector&lt;/span&gt;.inflections &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |inflect|&lt;tt&gt;
&lt;/tt&gt;  inflect.plural(&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;-in-law$&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;s-in-law&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  inflect.singular(&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;s-in-law$&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;-in-law&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  inflect.uncountable(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;air&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;information&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;water&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#no singular form, no plural form&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
&lt;strong&gt;Extensions to numbers:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;puts &lt;span class=&quot;i&quot;&gt;3&lt;/span&gt;.ordinalize  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; &amp;quot;3rd&amp;quot;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;321&lt;/span&gt;.ordinalize  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; &amp;quot;321st&amp;quot;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.byes  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 20&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.kilobytes  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 20480&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.megabytes  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 20971520&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.gigabytes  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 21474836480&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.terabytes  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 21990232555520&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.petabytes  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 22517998136852480&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;.exabyte  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 1152921504606846976&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.seconds  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 20&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.minutes  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 1200&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.hours  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 72000&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.days  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 1728000&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.weeks  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 12096000&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.fortnights  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 24192000&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.months  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 51840000&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.years  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 630720000&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;co&quot;&gt;Time&lt;/span&gt;.now  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Tue May 18 22:03:21 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.minutes.ago  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Tue May 18 21:43:53 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.hours.from_now  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Wed May 19 18:04:11 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.weeks.from_now  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Tue Oct 05 22:04:22 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.months.ago  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Thu Sep 18 22:04:34 +0800 2008&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.minutes.until(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;2010-12-26 12:00:00&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;.to_time)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Sun Dec 26 11:40:00 UTC 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;.minutes.since(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;2006-11-08 01:15:00&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;.to_time)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Wed Nov 08 01:35:00 UTC 2006&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
&lt;strong&gt;Time and Date Extensions:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;33&lt;tt&gt;
&lt;/tt&gt;34&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;35&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;36&lt;tt&gt;
&lt;/tt&gt;37&lt;tt&gt;
&lt;/tt&gt;38&lt;tt&gt;
&lt;/tt&gt;39&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;now = &lt;span class=&quot;co&quot;&gt;Time&lt;/span&gt;.now  &lt;tt&gt;
&lt;/tt&gt;puts now  &lt;span class=&quot;c&quot;&gt;#=&amp;gt;  Tue May 18 22:09:17 0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.to_date  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 2010-05-18&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.to_s  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Tue May 18 22:09:17 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.to_s(&lt;span class=&quot;sy&quot;&gt;:short&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 18 May 22:09&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.to_s(&lt;span class=&quot;sy&quot;&gt;:long&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; May 18, 2010 22:09&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.to_s(&lt;span class=&quot;sy&quot;&gt;:db&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 2010-05-18 22:09:17&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.to_s(&lt;span class=&quot;sy&quot;&gt;:rfc822&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Tue, 18 May 2010 22:09:17 +0900&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.ago(&lt;span class=&quot;i&quot;&gt;3600&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Tue May 18 21:09:17 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.at_beginning_of_day  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Tue May 18 00:00:00 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.at_beginning_of_month  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Sat May 01 00:00:00 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.at_beginning_of_week  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Mon May 17 00:00:00 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.beginning_of_quarter  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Thu Apr 01 00:00:00 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.at_beginning_of_year  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Fri Jan 01 00:00:00 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.at_midnight  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Tue May 18 00:00:00 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.change(&lt;span class=&quot;sy&quot;&gt;:hour&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;13&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Tue May 18 13:00:00 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.last_month  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Sun Apr 18 22:09:17 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.last_year  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Mon May 18 22:09:17 +0800 2009&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.midnight  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Tue May 18 00:00:00 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.monday  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Mon May 17 00:00:00 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.months_ago(&lt;span class=&quot;i&quot;&gt;2&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Thu Mar 18 22:09:17 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.months_since(&lt;span class=&quot;i&quot;&gt;2&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Sun Jul 18 22:09:17 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.next_week  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Mon May 24 00:00:00 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.next_year  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Wed May 18 22:09:17 +0800 2011&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.seconds_since_midnight  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 79757.033881&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.since(&lt;span class=&quot;i&quot;&gt;7200&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Wed May 19 00:09:17 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.tomorrow  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Wed May 19 22:09:17 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.years_ago(&lt;span class=&quot;i&quot;&gt;2&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Sun May 18 22:09:17 +0800 2008&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.years_since(&lt;span class=&quot;i&quot;&gt;2&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Fri May 18 22:09:17 +0800 2012&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.yesterday  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Mon May 17 22:09:17 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;puts now.advance(&lt;span class=&quot;sy&quot;&gt;:days&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;30&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; Thu Jun 17 22:09:17 +0800 2010&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;co&quot;&gt;Time&lt;/span&gt;.days_in_month(&lt;span class=&quot;i&quot;&gt;2&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 28&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;puts &lt;span class=&quot;co&quot;&gt;Time&lt;/span&gt;.days_in_month(&lt;span class=&quot;i&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;2000&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#=&amp;gt; 29&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
&lt;strong&gt;Extension to Ruby Symbols:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;groups = posts.group_by { |post| post.author_id }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;or&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;groups = post.group_by(&amp;amp;&lt;span class=&quot;sy&quot;&gt;:author_id&lt;/span&gt;)&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2010-02-25:2720</id>
    <published>2010-02-25T06:05:00Z</published>
    <updated>2010-02-25T06:05:41Z</updated>
    <category term="Life can't wait!"/>
    <category term="cycle"/>
    <category term="development"/>
    <category term="known"/>
    <category term="poetry"/>
    <category term="programming"/>
    <category term="solution"/>
    <category term="technical"/>
    <category term="unknown"/>
    <link href="http://coderkitty.sweetperceptions.com/2010/2/25/acknowledging-the-unknown-as-part-of-the-process" rel="alternate" type="text/html"/>
    <title>Acknowledging the unknown as part of the process</title>
<content type="html">
            &lt;p&gt;I think this is by far the best, though vague and ambiguous poetry I've ever seen and I loved it!&lt;/p&gt;

&lt;p&gt;Makes me want to keep in mind that knowledge in programming is quite volatile as it comes to real world problems to be solved, and that no accurate solution is definite across a period of time.  The unknown is really a part of the process.&lt;/p&gt;
&lt;p&gt;I think this is by far the best, though vague and ambiguous poetry I've ever seen and I loved it!&lt;/p&gt;

&lt;p&gt;It puts the technical context of programming in a development cycle into lay context.  :)  I stumbled upon &lt;a href=&quot;http://www.slate.com/id/2081042/&quot;&gt;this lovely piece of work&lt;/a&gt;, through CodingHorror's article entitled: &lt;a href=&quot;http://www.codinghorror.com/blog/2009/12/version-1-sucks-but-ship-it-anyway.html&quot;&gt;Version 1 Sucks, But Ship It Anyway&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
As we know, &lt;br&gt;
There are known knowns. &lt;br&gt;
There are things we know we know. &lt;br&gt;
We also know &lt;br&gt;
There are known unknowns. &lt;br&gt;
That is to say &lt;br&gt;
We know there are some things &lt;br&gt;
We do not know. &lt;br&gt;
But there are also unknown unknowns, &lt;br&gt;
The ones we don't know &lt;br&gt;
We don't know.
&lt;/blockquote&gt;

&lt;p&gt;Makes me want to keep in mind that knowledge in programming is quite volatile as it comes to real world problems to be solved, and that no accurate solution is definite across a period of time.  The unknown is really a part of the process.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2010-02-18:2707</id>
    <published>2010-02-18T15:10:00Z</published>
    <updated>2010-02-18T15:10:52Z</updated>
    <category term="Coding"/>
    <category term="Ruby and/or Rails"/>
    <category term="activerecord"/>
    <category term="api"/>
    <category term="boolean"/>
    <category term="default"/>
    <category term="primary"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="toggle"/>
    <link href="http://coderkitty.sweetperceptions.com/2010/2/18/the-power-of-toggle" rel="alternate" type="text/html"/>
    <title>The power of toggle</title>
<content type="html">
            &lt;p&gt;I don't know if we've been missing out on deliberate API lovin' or that we're becoming dumber every minute because of too much work, or its just the love month? :P  ...but we've been missing the power of &quot;&lt;em&gt;toggle&lt;/em&gt;&quot;. &lt;/p&gt;

&lt;p&gt;Toggle is [defined][1] as: &lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;any instruction that works first one
    way and then the other; it turns
    something on the first time it is used
    and then turns it off the next time&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Needless to say, &lt;em&gt;toggle&lt;/em&gt; is very efficient for use with boolean values (defined by either &lt;em&gt;true&lt;/em&gt; or &lt;em&gt;false&lt;/em&gt;).  Of course you might think its easy to implement, but this is an explicit example to illustrate on saving database reads and writes.  Aside from that, you'll write a more elegant code.  ;)&lt;/p&gt;
&lt;p&gt;I don't know if we've been missing out on deliberate API lovin' or that we're becoming dumber every minute because of too much work, or its just the love month? :P  ...but we've been missing the power of &quot;&lt;em&gt;toggle&lt;/em&gt;&quot;. &lt;/p&gt;

&lt;p&gt;Toggle is &lt;a href=&quot;http://www.google.com.ph/search?sourceid=chrome&amp;amp;ie=UTF-8&amp;amp;q=define:+toggle&quot;&gt;defined&lt;/a&gt; as: &lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;any instruction that works first one
    way and then the other; it turns
    something on the first time it is used
    and then turns it off the next time&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Needless to say, &lt;em&gt;toggle&lt;/em&gt; is very efficient for use with boolean values (defined by either &lt;em&gt;true&lt;/em&gt; or &lt;em&gt;false&lt;/em&gt;).  Let's take a specific scenario:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  create_table &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;profiles&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:force&lt;/span&gt; =&amp;gt; &lt;span class=&quot;pc&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |t|&lt;tt&gt;
&lt;/tt&gt;    t.string   &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;salutation&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,            &lt;span class=&quot;sy&quot;&gt;:limit&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;8&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:default&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    t.string   &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,                  &lt;span class=&quot;sy&quot;&gt;:limit&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;200&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:default&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    t.datetime &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;created_at&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    t.datetime &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;updated_at&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  create_table &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;themes&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:force&lt;/span&gt; =&amp;gt; &lt;span class=&quot;pc&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |t|&lt;tt&gt;
&lt;/tt&gt;    t.integer &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;profile_id&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    t.string   &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,            &lt;span class=&quot;sy&quot;&gt;:limit&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;100&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:default&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    t.boolean &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;primary&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,        &lt;span class=&quot;sy&quot;&gt;:default&lt;/span&gt; =&amp;gt; &lt;span class=&quot;pc&quot;&gt;false&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;So, there are multiple themes per profile.  You should get at least that part.  Your boolean column should always be set to false by default.  Either you replace the name of your column to suit that requirement, or write dirtier code.  (I.e., instead of have a &quot;public&quot; column all set to true, use &quot;private&quot; column all set to false by default).  Now, of course, your associations should be setup properly similar to:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;Profile&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ActiveRecord&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Base&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# filter_chain methods here...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# validations here...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# associations start...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  has_many &lt;span class=&quot;sy&quot;&gt;:themes&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; &lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;primary&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      find(&lt;span class=&quot;sy&quot;&gt;:first&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:conditions&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;primary = ?&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;pc&quot;&gt;true&lt;/span&gt;])&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# associations end...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;Theme&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ActiveRecord&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Base&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# filter_chain methods here...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# validations here...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# associations start...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  belongs_to &lt;span class=&quot;sy&quot;&gt;:profile&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# associations end...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  named_scope &lt;span class=&quot;sy&quot;&gt;:current_theme_of&lt;/span&gt;, lambda { |profile|&lt;tt&gt;
&lt;/tt&gt;    { &lt;span class=&quot;sy&quot;&gt;:conditions&lt;/span&gt; =&amp;gt; [ &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;profile_id = ? and primary = ?&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, profile.id, &lt;span class=&quot;pc&quot;&gt;true&lt;/span&gt; ] }&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Of course, there would be several records for the Theme table that will belong to a profile.  You will offer a checkbox on every create and update of the themes of a particular profile, but how do you ensure that there will only be one primary theme set for each profile record?&lt;/p&gt;

&lt;p&gt;This is dirty: (KIDS, DO NOT TRY THIS AT HOME)&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;Theme&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ActiveRecord&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Base&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# filter_chain methods here...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  after_save &lt;span class=&quot;sy&quot;&gt;:verify_unique_primary_theme&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# validations here...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# associations start...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  belongs_to &lt;span class=&quot;sy&quot;&gt;:profile&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# associations end...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  named_scope &lt;span class=&quot;sy&quot;&gt;:current_theme_of&lt;/span&gt;, lambda { |profile|&lt;tt&gt;
&lt;/tt&gt;    { &lt;span class=&quot;sy&quot;&gt;:conditions&lt;/span&gt; =&amp;gt; [ &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;profile_id = ? and primary = ?&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, profile.id, &lt;span class=&quot;pc&quot;&gt;true&lt;/span&gt; ] }&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;verify_unique_primary_theme&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# get all themes by this profile &lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# set all their primary value to false&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# set this new one's primary value to true&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Man, I wouldn't bet on a quick update on a profile whose set of themes would be more than hundreds, or even thousands!  This, of course, is always worth a try:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;Theme&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ActiveRecord&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Base&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# filter_chain methods here...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# validations here...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# associations start...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  belongs_to &lt;span class=&quot;sy&quot;&gt;:profile&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# associations end...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  named_scope &lt;span class=&quot;sy&quot;&gt;:current_theme_of&lt;/span&gt;, lambda { |profile|&lt;tt&gt;
&lt;/tt&gt;    { &lt;span class=&quot;sy&quot;&gt;:conditions&lt;/span&gt; =&amp;gt; [ &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;profile_id = ? and primary = ?&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, profile.id, &lt;span class=&quot;pc&quot;&gt;true&lt;/span&gt; ] }&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;primary?&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    primary&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;validate&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;#ensure that primary true is for one record only&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; primary? &lt;span class=&quot;r&quot;&gt;and&lt;/span&gt; !profile.themes.primary.nil?&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;c&quot;&gt;#toggle the old primary theme of this said profile&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      profile.themes.primary.toggle!(&lt;span class=&quot;sy&quot;&gt;:primary&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Simple, yet it works!  Each time another theme gets toggled to be the primary theme, you only need to make two writes to your database:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Save your new item&lt;/li&gt;
&lt;li&gt;Flip the old primary to false&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;PS:  I did write messy code on purpose to illustrate what I meant for this post.&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;I hope this toggle magic works for you too the next time you think about boolean switches! :)&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2010-02-14:2698</id>
    <published>2010-02-14T11:48:00Z</published>
    <updated>2010-02-14T11:52:47Z</updated>
    <category term="Coding"/>
    <category term="Ruby and/or Rails"/>
    <category term="amazon"/>
    <category term="attachments"/>
    <category term="download"/>
    <category term="openoffice"/>
    <category term="paypal"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="s3"/>
    <category term="sftp"/>
    <category term="textwrangler"/>
    <category term="tip"/>
    <category term="transfer"/>
    <category term="upload"/>
    <link href="http://coderkitty.sweetperceptions.com/2010/2/14/diy-ruby-sftp-to-s3" rel="alternate" type="text/html"/>
    <title>DIY Ruby SFTP to S3</title>
<content type="html">
            &lt;p&gt;I was faced by a challenge of transferring some files from an FTP server to S3.  At first, the nature of the problem seemed simple.  I just had to get the files to my local machine and then upload them to S3.  Piece of cake!  But lo and behold, when I saw that there were over 32K files and each step took me almost 2 minutes each!  Oooh lala!  &lt;/p&gt;

&lt;p&gt;I knew this was a job for &lt;em&gt;fanfare sound here&lt;/em&gt; the almighty ruby! :)&lt;/p&gt;

&lt;p&gt;And so, I set my priorities straight.. I had to work elegantly and save time altogether.  I'm feeling quite exhausted and would really love to get some sleep soon, so here I am, depending on my great yet simple ruby skills and the power of ruby itself to help me achieve this task!&lt;/p&gt;

&lt;p&gt;As I write this article, my script is silently running in the background as a very obedient and competent slave. :P  But to help you out, here is a brief guide on how to sit back, relax and let the task be accomplished in no time!  &lt;em&gt;You should really be sending me gifts.. or better yet, donate to me via Paypal!&lt;/em&gt; I'll love it, I promise.. I might even give you a page of exposure! :)&lt;/p&gt;







&lt;p&gt;I was faced by a challenge of transferring some files from an FTP server to S3.  At first, the nature of the problem seemed simple.  I just had to get the files to my local machine and then upload them to S3.  Piece of cake!  But lo and behold, when I saw that there were over 32K files and each step took me almost 2 minutes each!  Oooh lala!  &lt;/p&gt;

&lt;p&gt;I knew this was a job for &lt;em&gt;fanfare sound here&lt;/em&gt; the almighty ruby! :)&lt;/p&gt;

&lt;p&gt;And so, I set my priorities straight.. I had to work elegantly and save time altogether.  I'm feeling quite exhausted and would really love to get some sleep soon, so here I am, depending on my great yet simple ruby skills and the power of ruby itself to help me achieve this task!&lt;/p&gt;

&lt;p&gt;As I write this article, my script is silently running in the background as a very obedient and competent slave. :P  But to help you out, here is a brief guide on how to sit back, relax and let the task be accomplished in no time!  &lt;em&gt;You should really be sending me gifts.. or better yet, donate to me via Paypal!&lt;/em&gt; I'll love it, I promise.. I might even give you a page of exposure! :)&lt;/p&gt;








&lt;p&gt;So, here's the deal.  You have a set of files to download via FTP and a particular folder structure where you want it to go.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;STEP 1:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Gather your FTP credentials as follows:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;host: my.server.com&lt;tt&gt;
&lt;/tt&gt;username: my_username&lt;tt&gt;
&lt;/tt&gt;password: my_password&lt;tt&gt;
&lt;/tt&gt;port: &lt;span class=&quot;i&quot;&gt;12345&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;STEP 2:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We will need some gems here.  Now, if you don't have them yet, now is a good time to install them:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;sudo gem install net-sftp&lt;tt&gt;
&lt;/tt&gt;sudo gem install fastercsv&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href=&quot;http://net-ssh.rubyforge.org&quot;&gt;Net-Sftp&lt;/a&gt; is needed for the communication to your FTP server.  You can use this even if your access is just set to anonymous.  You might want to use another &lt;a href=&quot;http://fastercsv.rubyforge.org/&quot;&gt;CSV parser&lt;/a&gt; if you want, or if you already have something else in mind.  You can just tweak the code for that section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;STEP 3:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, pull out your beloved spreadsheet editor (mine is &lt;a href=&quot;http://www.openoffice.org&quot;&gt;OpenOffice&lt;/a&gt;) and aggregate your data.&lt;/p&gt;

&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;Full remote path to the files&lt;/td&gt;
    &lt;td&gt;Full local path to save into&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;/your/ultra/deep-stack/of/remote/folders/path/to/filename.doc&lt;/td&gt;
    &lt;td&gt;/Users/coderkitty/attachments/not-so-deep-stack/filename.doc&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;/your/ultra/deep-stack/of/remote/folders/path/to/filename2.doc&lt;/td&gt;
    &lt;td&gt;/Users/coderkitty/attachments/not-so-deep-stack/filename2.doc&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;/your/ultra/deep-stack/of/remote/folders/path/to/A super special filename here.doc&lt;/td&gt;
    &lt;td&gt;/Users/coderkitty/attachments/not-so-deep-stack/itsnolongerspecial.doc&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;STEP 4:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With this, you should export your file to CSV format and remove the Text Delimiter setting.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;STEP 5:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Open your CSV file using your favorite text editor (mine is &lt;a href=&quot;http://www.barebones.com/products/TextWrangler/download.html&quot;&gt;TextWrangler&lt;/a&gt;, you might want to try it.  Its opensource and free).  Make sure that all spaces in your filenames are escaped properly, so that you have something like this:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;your&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;/span&gt;deep-stack/of/remote/folders/&lt;span class=&quot;co&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;super&lt;/span&gt; special filename here.doc&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;changed into:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;your&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;/span&gt;deep-stack/of/remote/folders/&lt;span class=&quot;co&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;\&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;\&lt;/span&gt; special&lt;span class=&quot;er&quot;&gt;\&lt;/span&gt; filename&lt;span class=&quot;er&quot;&gt;\&lt;/span&gt; here.doc&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;then don't forget to save your csv file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;STEP 6:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, this is a fork.  You have two (2) choices you can take.  Either one works fine.  Just pick your desired approach.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Save the remote path and the local path in two separate csv files for loading (&lt;a href=&quot;http://gist.github.com/303957#file_ruby_sftp_to_s3_v1.rb&quot;&gt;version 1&lt;/a&gt;), or&lt;/li&gt;
&lt;li&gt;Use one big csv file of remote, local path (&lt;a href=&quot;http://gist.github.com/303957#file_ruby_sftp_to_s3_v2.rb&quot;&gt;version 2&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;STEP 7:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The rest is quite straightforward from this point onwards.  Just fill in your constants in the ruby script and then make sure that your files are in the right directories.   All set?  Execute away!&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;ruby sftp_to_local.rb&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;You might also find that the generated errors.txt file could help you reiterate on some parts of downloading/uploading your file.  Sometimes your path could be wrong, or that you forgot to specify the correct local directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;STEP 8:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, your files should be created in your machine.  Now what?  For this, you will need the handy-dandy S3Fox.  Get it here:  &lt;a href=&quot;http://www.s3fox.net/&quot;&gt;http://www.s3fox.net/&lt;/a&gt;  Launch the tool from your browser.  Now, you can simply sync your folders from your machine to your S3 buckets.  Its as easy as that!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;STEP ???:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Grab your favorite coffee and wait for the script to complete.  Try to sleep for awhile, watch a movie, maybe give me a tip?  &lt;/p&gt;








&lt;p&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;PROFIT!!!!&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Check your buckets after some time and enjoy the presence of your easily uploaded files. :)&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2010-02-05:2678</id>
    <published>2010-02-05T03:34:00Z</published>
    <updated>2010-02-05T03:56:44Z</updated>
    <category term="Coding"/>
    <category term="Ruby and/or Rails"/>
    <category term="before_filter"/>
    <category term="https"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="security"/>
    <category term="ssl"/>
    <link href="http://coderkitty.sweetperceptions.com/2010/2/5/forcing-urls-to-use-https" rel="alternate" type="text/html"/>
    <title>Forcing urls to use https</title>
<content type="html">
            &lt;p&gt;If you have the need to force certain pages of your site to use ssl, but its becoming extremely cumbersome to find out the links that point to that page, this is a better approach, which seems to be more adhering to SPOT or (single point of truth).  &lt;/p&gt;

&lt;p&gt;Just add one method to your application controller and call before_filters to your specific controllers.  That's it!&lt;/p&gt;
&lt;p&gt;I found this extremely useful:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;redirect_to_ssl&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    redirect_to url_for params.merge({&lt;span class=&quot;sy&quot;&gt;:protocol&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;https://&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;}) &lt;span class=&quot;r&quot;&gt;unless&lt;/span&gt; request.ssl?&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Put this in your application controller and call&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;before_filter &lt;span class=&quot;sy&quot;&gt;:redirect_to_ssl&lt;/span&gt; &lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;on every controller that would require ssl.  You can pick which actions would only require this by extending your before_filter declaration as such:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;before_filter &lt;span class=&quot;sy&quot;&gt;:redirect_to_ssl&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:only&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;sy&quot;&gt;:new&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:purchase&lt;/span&gt;]&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;or even by exclusion, whichever is more convenient for your case:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;before_filter &lt;span class=&quot;sy&quot;&gt;:redirect_to_ssl&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:except&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;sy&quot;&gt;:show&lt;/span&gt;]&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;PS:  There are other resources too, such as this one (that could be of help): &lt;a href=&quot;http://fuadcse.blogspot.com/2009/01/redirecting-http-request-to-https-in.html&quot;&gt;http://fuadcse.blogspot.com/2009/01/redirecting-http-request-to-https-in.html&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2009-08-14:1002</id>
    <published>2009-08-14T13:09:00Z</published>
    <updated>2009-08-14T13:10:46Z</updated>
    <category term="Coding"/>
    <category term="Tech Juices"/>
    <category term="download"/>
    <category term="git"/>
    <category term="php"/>
    <category term="release"/>
    <category term="security"/>
    <category term="update"/>
    <category term="wordpress"/>
    <link href="http://coderkitty.sweetperceptions.com/2009/8/14/wordpress-2-8-4-release-a-joke" rel="alternate" type="text/html"/>
    <title>Wordpress 2.8.4 release, a joke?</title>
<content type="html">
            &lt;p&gt;I have been maintaining several &lt;a href=&quot;http://wordpress.org&quot;&gt;Wordpress&lt;/a&gt; blogs (all currently running 2.8.3 as of the time of writing).  I logged in earlier today, and found that there was a new release.  Of course, I wanted to have them all updated at the soonest possible time.  &lt;/p&gt;

&lt;p&gt;By practice, I download the zipped file to apply them manually onto our &lt;a href=&quot;http://www.git-scm.org&quot;&gt;source code repositories&lt;/a&gt; for update.  Usually, I find this useful because I get to see what the changes really were for the new release.  I was surprised to see that the new version I downloaded was a complete joke.  &lt;/p&gt;

&lt;p&gt;I got Wordpress 2.8.4 &lt;a href=&quot;http://wordpress.org/wordpress-2.8.4.zip&quot;&gt;here&lt;/a&gt;.  I downloaded the file also inside the server, for a quick copy of the latest version, in case it will be needed.  Applying it to local copy of the repository, I found some big joke.  Amusing, but also confusing.&lt;/p&gt;
&lt;p&gt;I have been maintaining several &lt;a href=&quot;http://wordpress.org&quot;&gt;Wordpress&lt;/a&gt; blogs (all currently running 2.8.3 as of the time of writing).  I logged in earlier today, and found that there was a new release.  Of course, I wanted to have them all updated at the soonest possible time.  &lt;/p&gt;

&lt;p&gt;By practice, I download the zipped file to apply them manually onto our &lt;a href=&quot;http://www.git-scm.org&quot;&gt;source code repositories&lt;/a&gt; for update.  Usually, I find this useful because I get to see what the changes really were for the new release.  I was surprised to see that the new version I downloaded was a complete joke.  &lt;/p&gt;

&lt;p&gt;I got Wordpress 2.8.4 &lt;a href=&quot;http://wordpress.org/wordpress-2.8.4.zip&quot;&gt;here&lt;/a&gt;.  I downloaded the file also inside the server, for a quick copy of the latest version, in case it will be needed.  Applying it to local copy of the repository, I found some big joke.  Amusing, but also confusing.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Now tell me.. Is this real?  Could I be wrong? Could this be a mistake perhaps?  &lt;a href=&quot;http://wordpress.org/development/2009/08/2-8-4-security-release/&quot;&gt;Where is the security release?&lt;/a&gt;  I'm not moving a muscle.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2009-08-02:969</id>
    <published>2009-08-02T11:39:00Z</published>
    <updated>2009-08-03T06:17:47Z</updated>
    <category term="Coding"/>
    <category term="Database"/>
    <category term="adodb"/>
    <category term="ajax"/>
    <category term="cms"/>
    <category term="freebie"/>
    <category term="html"/>
    <category term="mini store"/>
    <category term="php"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="search"/>
    <category term="stores"/>
    <link href="http://coderkitty.sweetperceptions.com/2009/8/2/free-mini-store-search-app-in-php-and-ajax-for-dummies" rel="alternate" type="text/html"/>
    <title>Free mini store search app in PHP and AJAX - for dummies</title>
<content type="html">
            &lt;p&gt;This is a very crude and very simple application which was for a demo purpose as requested by the client.  I haven't been using PHP and (moreso) AJAX in over a year and a half already.  This task was really more of a fun challenge that I cannot resist.  I just wanted to see how long I can work on this and deliver what the client's requests were.  Funny that this simple task was quoted to take 14 days of dev work, while it took me less than 5hours (since I was able to work on a CMS from scratch along with this all in 5hours of work time).&lt;/p&gt;

&lt;p&gt;If you find yourself in need of a jumpstart, consider this the best freebie for you.  Enjoy, and next time, give the client the correct estimates.  It might save you both from hating each other and ruining possible future projects. ;)&lt;/p&gt;
&lt;p&gt;My &lt;a href=&quot;http://sweetperceptions.com/projects/4&quot;&gt;last PHP project&lt;/a&gt; was almost a year and a half ago.  I started working in &lt;a href=&quot;http://php.net&quot;&gt;PHP&lt;/a&gt; eversince college.  Moved on to &lt;a href=&quot;http://java.com&quot;&gt;Java&lt;/a&gt;, &lt;a href=&quot;http://python.org&quot;&gt;Python&lt;/a&gt; and now, &lt;a href=&quot;http://www.ruby-lang.org&quot;&gt;Ruby&lt;/a&gt;.  I must say, &lt;a href=&quot;http://php.net&quot;&gt;PHP&lt;/a&gt; was the longest scripting language I used in my entire professional programming career.  Maybe because it was the easiest language to learn (and abuse).  &lt;/p&gt;

&lt;p&gt;So many resources on the Web have fluttered around for so long, even after frameworks were born.  There came &lt;a href=&quot;http://cakephp.org&quot;&gt;CakePHP&lt;/a&gt;, &lt;a href=&quot;http://zend.com&quot;&gt;Zend&lt;/a&gt;, &lt;a href=&quot;http://xisc.com&quot;&gt;Prado&lt;/a&gt;, &lt;a href=&quot;http://symfony-project.org&quot;&gt;Symfony&lt;/a&gt;, etc.  There were other tools too to help in making PHP a truly object orientd scripting language.  Some of my few favorites were: &lt;a href=&quot;http://www.smarty.net/&quot;&gt;Smarty&lt;/a&gt; and &lt;a href=&quot;http://adodb.sourceforge.net/&quot;&gt;AdoDB&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I've quit on &lt;a href=&quot;http://php.net&quot;&gt;PHP&lt;/a&gt;, but I do not abhor it.  I still understand the old businesses still running their cash-cow apps in &lt;a href=&quot;http://php.net&quot;&gt;PHP&lt;/a&gt; and is not yet looking forward to trusting Ruby on Rails or even other alternatives.  The business is always driven by finances and resources.  Sometimes, the best technological decisions elude the managers' table during meetings.. hence, the prevalence of a lot of legacy &lt;a href=&quot;http://php.net&quot;&gt;PHP&lt;/a&gt; applications.  With this understanding, I still believe that these businesses would very much benefit upgrading their systems and even the skill sets of their own developers.  Even if they wanted to remain with &lt;a href=&quot;http://php.net&quot;&gt;PHP&lt;/a&gt;, there are a lot of options out there that do not involve complete development of applications from the ground up.  Some would even prefer built systems that allow plugins for upgrade--like &lt;a href=&quot;http://drupal.org&quot;&gt;Drupal&lt;/a&gt;, &lt;a href=&quot;http://joomla.org&quot;&gt;Joomla&lt;/a&gt;, and even &lt;a href=&quot;http://wordpress.org&quot;&gt;Wordpress&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There are cons of using such built systems (dependency on plugin upgrades, general hacking, and a becoming a prey to overly customizing them), and so, I myself would &lt;strong&gt;&lt;em&gt;not&lt;/strong&gt;&lt;/em&gt; recommend using them if you won't be able to protect your site from these downside.&lt;/p&gt;

&lt;p&gt;Though its been quite a while since I last worked on &lt;a href=&quot;http://php.net&quot;&gt;PHP&lt;/a&gt;, it became a challenge for me to just do this mini store application just for fun of measuring how long I could work on such a request given that I have been out of touch from the &lt;a href=&quot;http://php.net&quot;&gt;PHP&lt;/a&gt; world, and that the requirement could also involve &lt;a href=&quot;http://en.wikipedia.org/.../Ajax_&quot; title=&quot;programming&quot;&gt;AJAX&lt;/a&gt;.. and it would be from the ground up!&lt;/p&gt;

&lt;p&gt;This would be a very simple application though needing a database and javascript support for &lt;a href=&quot;http://en.wikipedia.org/.../Ajax_&quot; title=&quot;programming&quot;&gt;AJAX&lt;/a&gt;.  Let me now guide you to how it was done.&lt;/p&gt;

&lt;p&gt;First, create the database with the following schema:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;r&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;&quot;&gt;areas&lt;/span&gt; (&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;11&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt; &lt;span class=&quot;di&quot;&gt;auto_increment&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;&quot;&gt;country_id&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;11&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;255&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;PRIMARY&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;KEY&lt;/span&gt;  (&lt;span class=&quot;&quot;&gt;id&lt;/span&gt;),&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;KEY&lt;/span&gt; &lt;span class=&quot;&quot;&gt;country_id_index&lt;/span&gt; (&lt;span class=&quot;&quot;&gt;country_id&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;) &lt;span class=&quot;r&quot;&gt;ENGINE&lt;/span&gt;=&lt;span class=&quot;&quot;&gt;MyISAM&lt;/span&gt;  &lt;span class=&quot;di&quot;&gt;DEFAULT&lt;/span&gt; &lt;span class=&quot;di&quot;&gt;CHARSET&lt;/span&gt;=&lt;span class=&quot;&quot;&gt;latin1&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;&quot;&gt;countries&lt;/span&gt; (&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;11&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt; &lt;span class=&quot;di&quot;&gt;auto_increment&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;255&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;PRIMARY&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;KEY&lt;/span&gt;  (&lt;span class=&quot;&quot;&gt;id&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;) &lt;span class=&quot;r&quot;&gt;ENGINE&lt;/span&gt;=&lt;span class=&quot;&quot;&gt;MyISAM&lt;/span&gt;  &lt;span class=&quot;di&quot;&gt;DEFAULT&lt;/span&gt; &lt;span class=&quot;di&quot;&gt;CHARSET&lt;/span&gt;=&lt;span class=&quot;&quot;&gt;latin1&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;&quot;&gt;stores&lt;/span&gt; (&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;11&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt; &lt;span class=&quot;di&quot;&gt;auto_increment&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;255&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;&quot;&gt;contact_person&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;255&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;&quot;&gt;contact_info&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;255&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;&quot;&gt;address&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;255&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;&quot;&gt;email&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;40&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;&quot;&gt;website&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;varchar&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;255&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;&quot;&gt;area_id&lt;/span&gt; &lt;span class=&quot;pt&quot;&gt;int&lt;/span&gt;(&lt;span class=&quot;i&quot;&gt;11&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;NOT&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;NULL&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;PRIMARY&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;KEY&lt;/span&gt;  (&lt;span class=&quot;&quot;&gt;id&lt;/span&gt;),&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;KEY&lt;/span&gt; &lt;span class=&quot;&quot;&gt;name_index&lt;/span&gt; (&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt;),&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;KEY&lt;/span&gt; &lt;span class=&quot;&quot;&gt;area_id_index&lt;/span&gt; (&lt;span class=&quot;&quot;&gt;area_id&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;) &lt;span class=&quot;r&quot;&gt;ENGINE&lt;/span&gt;=&lt;span class=&quot;&quot;&gt;MyISAM&lt;/span&gt;  &lt;span class=&quot;di&quot;&gt;DEFAULT&lt;/span&gt; &lt;span class=&quot;di&quot;&gt;CHARSET&lt;/span&gt;=&lt;span class=&quot;&quot;&gt;latin1&lt;/span&gt;;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Next, let's prepare the main file.  We are going to need a stores.php, getareas.php, getstores.php, search.php, ajax.js and include files for connecting to the database and query functions.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stores.php&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The most important parts of this file are the section handlers.  We'll need handles for: (1) search results, (2) areas list, (3) stores list.  These should have distinct ids that you'll have to note.&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;33&lt;tt&gt;
&lt;/tt&gt;34&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;35&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;36&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;xmlns&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;http://www.w3.org/1999/xhtml&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;xml:lang&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;en&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;lang&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;en&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ta&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Mini store app&lt;span class=&quot;ta&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;js/ajax.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;js/prototype.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;js/scriptaculous.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;    &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ta&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ta&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;searchForm&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;ta&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;search&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;ta&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;submit&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;onclick&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;showSearchResults(Form.findFirstElement(document.forms[0]).value);$('searchBox').setStyle('display: block');new Effect.SlideDown($('searchBox'));return false;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;value&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Search for stores&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        &lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;searchBox&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;display: none;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;float: left;clear: both;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;c&quot;&gt;&amp;lt;?php&lt;tt&gt;
&lt;/tt&gt;        $results = Site::getCountries();&lt;tt&gt;
&lt;/tt&gt;      &lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;ul class='item' style='overflow:auto;height: 500px;'&amp;gt;&amp;quot;;  &lt;tt&gt;
&lt;/tt&gt;        foreach($results as $country){&lt;tt&gt;
&lt;/tt&gt;            echo &amp;quot;&amp;lt;li&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;            echo &amp;quot;&amp;lt;a href='' onclick=\&amp;quot;javascript:showAreas('&amp;quot; . $country['id'] . &amp;quot;');$('areaHint').setStyle('display: none;');$('areaHint').undoPositioned();new Effect.Move($('areaHint'), { x: 0, y: 0, mode: 'absolute' });$('areaHint').setStyle('display: block;');new Effect.Move($('areaHint'), { x: 60, y: 0 });return false;\&amp;quot;&amp;gt;&amp;quot; . $country['name'] . &amp;quot;&amp;lt;/a&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;            echo &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;        }&lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;/ul&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;      ?&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;storeHint&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;border: 0px solid blue; margin-top: 15px; overflow: auto; float: right; width: 300px; height: 500px; display: block;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;areaHint&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;border: 0px solid red; margin-top: 30px; overflow: auto; width: 300px; height: 500px; display: block;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ta&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Getareas.php&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&amp;lt;?php&lt;tt&gt;
&lt;/tt&gt;  $results = Site::getAreasOfCountry($_GET[&amp;quot;q&amp;quot;]);&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  if($results){&lt;tt&gt;
&lt;/tt&gt;    echo &amp;quot;&amp;lt;ul class='item'&amp;gt;&amp;quot;;  &lt;tt&gt;
&lt;/tt&gt;    foreach($results as $area){&lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;li&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;a href='' onclick=\&amp;quot;javascript:showStores('&amp;quot; . $area['id'] . &amp;quot;');$('storeHint').setStyle('display: none;');$('storeHint').setStyle('display: block;');$('storeHint').undoPositioned();new Effect.Move($('storeHint'), { x: 0, y: 0, mode: 'absolute' });$('storeHint').setStyle('display: block;');new Effect.Move($('storeHint'), { x: -60, y: 0 });return false;\&amp;quot;&amp;gt;&amp;quot; . $area['name'] . &amp;quot;&amp;lt;/a&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;    }&lt;tt&gt;
&lt;/tt&gt;    echo &amp;quot;&amp;lt;/ul&amp;gt;&amp;quot;;   &lt;tt&gt;
&lt;/tt&gt;  }else{&lt;tt&gt;
&lt;/tt&gt;    echo &amp;quot;&amp;lt;p style='text-align: center;'&amp;gt;Whoops, no areas found.&amp;lt;/p&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;?&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Getstores.php&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&amp;lt;?php&lt;tt&gt;
&lt;/tt&gt;  $results = Site::getStoresOfArea($_GET[&amp;quot;q&amp;quot;]);&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  if($results){&lt;tt&gt;
&lt;/tt&gt;    echo &amp;quot;&amp;lt;ul class='item'&amp;gt;&amp;quot;;  &lt;tt&gt;
&lt;/tt&gt;    foreach($results as $row){&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;li&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;a href='' onclick=\&amp;quot;javascript:showStoreDetails('&amp;quot; . $row['id'] . &amp;quot;');return false;\&amp;quot;&amp;gt;&amp;quot; . $row['name'] . &amp;quot;&amp;lt;/a&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;div id='storeDetail&amp;quot; . $row['id'] . &amp;quot;' style='display: none;'&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;table&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Contact Person&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot; . $row['contact_person'] . &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Contact Info&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot; . $row['contact_info'] . &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Address&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot; . $row['address'] . &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Email&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot; . $row['email'] . &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Website&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot; . $row['website'] . &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;        echo &amp;quot;&amp;lt;/table&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;/div&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;    }&lt;tt&gt;
&lt;/tt&gt;    echo &amp;quot;&amp;lt;/ul&amp;gt;&amp;quot;;   &lt;tt&gt;
&lt;/tt&gt;  }else{&lt;tt&gt;
&lt;/tt&gt;    echo &amp;quot;&amp;lt;p style='text-align: center;'&amp;gt;Whoops, no stores found.&amp;lt;/p&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;?&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Search.php&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&amp;lt;?php&lt;tt&gt;
&lt;/tt&gt;  $results = Site::getSearch($_GET[&amp;quot;search&amp;quot;]);&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  if($results){&lt;tt&gt;
&lt;/tt&gt;?&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &amp;lt;a href=&amp;quot;#&amp;quot; style=&amp;quot;float: right;padding-right: 15px;&amp;quot; onclick=&amp;quot;$('searchBox').setStyle('display: none;');&amp;quot;&amp;gt;CLOSE&amp;lt;/a&amp;gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;tt&gt;
&lt;/tt&gt;&amp;lt;?php    &lt;tt&gt;
&lt;/tt&gt;    echo &amp;quot;&amp;lt;table border='1' style='margin: 10px; background-color: rgb(83, 131, 219); width: 90%;'&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;    echo &amp;quot;&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Contact Person&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Contact Info&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Address&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Email&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Website&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Country&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Area&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;    &lt;tt&gt;
&lt;/tt&gt;    foreach($results as $row){&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;tr&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;td&amp;gt;&amp;quot; . $row['name'] . &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot; . $row['contact_person'] . &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot; . $row['contact_info'] . &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot; . $row['address'] . &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot; . $row['email'] . &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot; . $row['website'] . &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;a href='' onclick=\&amp;quot;javascript:showAreas('&amp;quot; . $row['country_id'] . &amp;quot;');$('searchBox').setStyle('display: none;');$('areaHint').setStyle('display: none;');$('areaHint').undoPositioned();new Effect.Move($('areaHint'), { x: 0, y: 0, mode: 'absolute' });$('areaHint').setStyle('display: block;');new Effect.Move($('areaHint'), { x: 60, y: 0 }); return false;\&amp;quot;&amp;gt;&amp;quot; . $row['country_name'] . &amp;quot;&amp;lt;/a&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;a href='' onclick=\&amp;quot;javascript:showStores('&amp;quot; . $row['area_id'] . &amp;quot;');$('searchBox').setStyle('display: none;');$('storeHint').setStyle('display: none;');$('storeHint').undoPositioned();$('storeHint').setStyle('display: block;');new Effect.BlindDown('storeHint'); return false;\&amp;quot;&amp;gt;&amp;quot; . $row['area_name'] . &amp;quot;&amp;lt;/a&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;/td&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;      echo &amp;quot;&amp;lt;/tr&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;    }&lt;tt&gt;
&lt;/tt&gt;    echo &amp;quot;&amp;lt;/table&amp;gt;&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;  }else{&lt;tt&gt;
&lt;/tt&gt;    echo &amp;quot;Whooops! No store matched your search criteria.&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;?&amp;gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ajax.js&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;33&lt;tt&gt;
&lt;/tt&gt;34&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;35&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;36&lt;tt&gt;
&lt;/tt&gt;37&lt;tt&gt;
&lt;/tt&gt;38&lt;tt&gt;
&lt;/tt&gt;39&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;40&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;41&lt;tt&gt;
&lt;/tt&gt;42&lt;tt&gt;
&lt;/tt&gt;43&lt;tt&gt;
&lt;/tt&gt;44&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;45&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;46&lt;tt&gt;
&lt;/tt&gt;47&lt;tt&gt;
&lt;/tt&gt;48&lt;tt&gt;
&lt;/tt&gt;49&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;50&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;51&lt;tt&gt;
&lt;/tt&gt;52&lt;tt&gt;
&lt;/tt&gt;53&lt;tt&gt;
&lt;/tt&gt;54&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;55&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;56&lt;tt&gt;
&lt;/tt&gt;57&lt;tt&gt;
&lt;/tt&gt;58&lt;tt&gt;
&lt;/tt&gt;59&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;60&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;61&lt;tt&gt;
&lt;/tt&gt;62&lt;tt&gt;
&lt;/tt&gt;63&lt;tt&gt;
&lt;/tt&gt;64&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;65&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;66&lt;tt&gt;
&lt;/tt&gt;67&lt;tt&gt;
&lt;/tt&gt;68&lt;tt&gt;
&lt;/tt&gt;69&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;70&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;71&lt;tt&gt;
&lt;/tt&gt;72&lt;tt&gt;
&lt;/tt&gt;73&lt;tt&gt;
&lt;/tt&gt;74&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;75&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;76&lt;tt&gt;
&lt;/tt&gt;77&lt;tt&gt;
&lt;/tt&gt;78&lt;tt&gt;
&lt;/tt&gt;79&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;80&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;81&lt;tt&gt;
&lt;/tt&gt;82&lt;tt&gt;
&lt;/tt&gt;83&lt;tt&gt;
&lt;/tt&gt;84&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;85&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;86&lt;tt&gt;
&lt;/tt&gt;87&lt;tt&gt;
&lt;/tt&gt;88&lt;tt&gt;
&lt;/tt&gt;89&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;90&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;91&lt;tt&gt;
&lt;/tt&gt;92&lt;tt&gt;
&lt;/tt&gt;93&lt;tt&gt;
&lt;/tt&gt;94&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;95&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;96&lt;tt&gt;
&lt;/tt&gt;97&lt;tt&gt;
&lt;/tt&gt;98&lt;tt&gt;
&lt;/tt&gt;99&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;100&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;101&lt;tt&gt;
&lt;/tt&gt;102&lt;tt&gt;
&lt;/tt&gt;103&lt;tt&gt;
&lt;/tt&gt;104&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;105&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;106&lt;tt&gt;
&lt;/tt&gt;107&lt;tt&gt;
&lt;/tt&gt;108&lt;tt&gt;
&lt;/tt&gt;109&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;110&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;111&lt;tt&gt;
&lt;/tt&gt;112&lt;tt&gt;
&lt;/tt&gt;113&lt;tt&gt;
&lt;/tt&gt;114&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;115&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;116&lt;tt&gt;
&lt;/tt&gt;117&lt;tt&gt;
&lt;/tt&gt;118&lt;tt&gt;
&lt;/tt&gt;119&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; xmlhttp;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; areaHandle;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; storeHandle;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt; showSearchResults(str)&lt;tt&gt;
&lt;/tt&gt;{&lt;tt&gt;
&lt;/tt&gt;xmlhttp=GetXmlHttpObject();&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;if&lt;/span&gt; (xmlhttp==&lt;span class=&quot;kw&quot;&gt;null&lt;/span&gt;){  &lt;tt&gt;
&lt;/tt&gt;  alert (&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Browser does not support HTTP Request&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;kw&quot;&gt;return&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; url=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;search.php&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;url=url+&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;?search=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;+str;&lt;tt&gt;
&lt;/tt&gt;url=url+&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&amp;amp;sid=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;+Math.random();&lt;tt&gt;
&lt;/tt&gt;xmlhttp.onreadystatechange=stateChangedSearch;&lt;tt&gt;
&lt;/tt&gt;xmlhttp.open(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;GET&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,url,&lt;span class=&quot;kw&quot;&gt;true&lt;/span&gt;);&lt;tt&gt;
&lt;/tt&gt;xmlhttp.send(&lt;span class=&quot;kw&quot;&gt;null&lt;/span&gt;);&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt; showAreas(str)&lt;tt&gt;
&lt;/tt&gt;{&lt;tt&gt;
&lt;/tt&gt;xmlhttp=GetXmlHttpObject();&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;if&lt;/span&gt; (xmlhttp==&lt;span class=&quot;kw&quot;&gt;null&lt;/span&gt;){  &lt;tt&gt;
&lt;/tt&gt;  alert (&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Browser does not support HTTP Request&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;kw&quot;&gt;return&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;areaHandle = str;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; url=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;getareas.php&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;url=url+&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;?q=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;+str;&lt;tt&gt;
&lt;/tt&gt;url=url+&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&amp;amp;sid=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;+Math.random();&lt;tt&gt;
&lt;/tt&gt;xmlhttp.onreadystatechange=stateChangedAreas;&lt;tt&gt;
&lt;/tt&gt;xmlhttp.open(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;GET&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,url,&lt;span class=&quot;kw&quot;&gt;true&lt;/span&gt;);&lt;tt&gt;
&lt;/tt&gt;xmlhttp.send(&lt;span class=&quot;kw&quot;&gt;null&lt;/span&gt;);&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt; showStores(str)&lt;tt&gt;
&lt;/tt&gt;{&lt;tt&gt;
&lt;/tt&gt;xmlhttp=GetXmlHttpObject();&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;if&lt;/span&gt; (xmlhttp==&lt;span class=&quot;kw&quot;&gt;null&lt;/span&gt;){  &lt;tt&gt;
&lt;/tt&gt;  alert (&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Browser does not support HTTP Request&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;kw&quot;&gt;return&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;storeHandle = str;  &lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;var&lt;/span&gt; url=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;getstores.php&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;url=url+&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;?q=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;+str;&lt;tt&gt;
&lt;/tt&gt;url=url+&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&amp;amp;sid=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;+Math.random();&lt;tt&gt;
&lt;/tt&gt;xmlhttp.onreadystatechange=stateChangedStores;&lt;tt&gt;
&lt;/tt&gt;xmlhttp.open(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;GET&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,url,&lt;span class=&quot;kw&quot;&gt;true&lt;/span&gt;);&lt;tt&gt;
&lt;/tt&gt;xmlhttp.send(&lt;span class=&quot;kw&quot;&gt;null&lt;/span&gt;);&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt; stateChangedSearch()&lt;tt&gt;
&lt;/tt&gt;{&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;kw&quot;&gt;switch&lt;/span&gt;(xmlhttp.readyState){&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;kw&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;i&quot;&gt;4&lt;/span&gt;:&lt;tt&gt;
&lt;/tt&gt;      document.getElementById(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;searchBox&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).innerHTML=xmlhttp.responseText;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;kw&quot;&gt;break&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;      &lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;kw&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;:&lt;tt&gt;
&lt;/tt&gt;      document.getElementById(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;searchBox&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).innerHTML=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Loading...&amp;amp;nbsp;&amp;lt;img src='ajax-loader.gif' alt='loading...' /&amp;gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;kw&quot;&gt;break&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  }  &lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt; stateChangedAreas()&lt;tt&gt;
&lt;/tt&gt;{&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;kw&quot;&gt;switch&lt;/span&gt;(xmlhttp.readyState){&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;kw&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;i&quot;&gt;4&lt;/span&gt;:&lt;tt&gt;
&lt;/tt&gt;      handleId = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;areaHint&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;      document.getElementById(handleId).innerHTML=xmlhttp.responseText;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;kw&quot;&gt;break&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;      &lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;kw&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;:&lt;tt&gt;
&lt;/tt&gt;      document.getElementById(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;areaHint&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).innerHTML=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Loading...&amp;amp;nbsp;&amp;lt;img src='ajax-loader.gif' alt='loading...' /&amp;gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;kw&quot;&gt;break&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  }  &lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt; stateChangedStores()&lt;tt&gt;
&lt;/tt&gt;{&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;kw&quot;&gt;switch&lt;/span&gt;(xmlhttp.readyState){&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;kw&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;i&quot;&gt;4&lt;/span&gt;:&lt;tt&gt;
&lt;/tt&gt;      handleId = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;storeHint&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;      document.getElementById(handleId).innerHTML=xmlhttp.responseText;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;kw&quot;&gt;break&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;      &lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;kw&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;:&lt;tt&gt;
&lt;/tt&gt;      document.getElementById(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;storeHint&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).innerHTML=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Loading...&amp;amp;nbsp;&amp;lt;img src='ajax-loader.gif' alt='loading...' /&amp;gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;kw&quot;&gt;break&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  } &lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt; showStoreDetails(storeId){&lt;tt&gt;
&lt;/tt&gt;  storeHandle = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;storeDetail&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; + storeId;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;kw&quot;&gt;if&lt;/span&gt;(document.getElementById(storeHandle).style.display==&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;){&lt;tt&gt;
&lt;/tt&gt;    document.getElementById(storeHandle).style.display = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  }&lt;span class=&quot;kw&quot;&gt;else&lt;/span&gt;{&lt;tt&gt;
&lt;/tt&gt;    document.getElementById(storeHandle).style.display = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt; GetXmlHttpObject()&lt;tt&gt;
&lt;/tt&gt;{&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;if&lt;/span&gt; (window.XMLHttpRequest)&lt;tt&gt;
&lt;/tt&gt;  {&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;// code for IE7+, Firefox, Chrome, Opera, Safari&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;kw&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;new&lt;/span&gt; XMLHttpRequest();&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;if&lt;/span&gt; (window.ActiveXObject)&lt;tt&gt;
&lt;/tt&gt;  {&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;// code for IE6, IE5&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;kw&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;new&lt;/span&gt; ActiveXObject(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Microsoft.XMLHTTP&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;null&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Of course, it will be totally up to you how you will implement your query functions and other includes for this, but here is what I have:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;includes/site.inc.php&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  function getCountries(){&lt;tt&gt;
&lt;/tt&gt;    $db = $GLOBALS['db'];&lt;tt&gt;
&lt;/tt&gt;    $sql = &amp;quot;select * from countries order by name asc&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;    $a = $db-&amp;gt;CacheGetAll(3600,$sql);&lt;tt&gt;
&lt;/tt&gt;    return $a;&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  function getSearch($key){&lt;tt&gt;
&lt;/tt&gt;    $db = $GLOBALS['db'];&lt;tt&gt;
&lt;/tt&gt;    $sql = &amp;quot;select stores.name, stores.contact_person, stores.contact_info, stores.address, countries.name as country_name, countries.id as country_id, areas.name as area_name, areas.id as area_id from stores, countries, areas where (stores.name like '%{$key}%' or stores.address like '%{$key}%' or stores.contact_person like '%{$key}%' or stores.contact_info like '%{$key}%' or stores.email like '%{$key}%' or stores.website like '%{$key}%') and stores.area_id = areas.id and areas.country_id = countries.id order by stores.name, stores.address asc&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;    $a = $db-&amp;gt;GetAll($sql);&lt;tt&gt;
&lt;/tt&gt;    return $a;&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  function getAreasOfCountry($countryId){&lt;tt&gt;
&lt;/tt&gt;    $db = $GLOBALS['db'];&lt;tt&gt;
&lt;/tt&gt;    $sql = &amp;quot;select areas.*, countries.name as country_name from areas, countries where areas.country_id = countries.id and areas.country_id = $countryId order by areas.name asc&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;    $a = $db-&amp;gt;CacheGetAll(3600,$sql);&lt;tt&gt;
&lt;/tt&gt;    return $a;&lt;tt&gt;
&lt;/tt&gt;  }&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  function getStoresOfArea($areaId){&lt;tt&gt;
&lt;/tt&gt;    $db = $GLOBALS['db'];&lt;tt&gt;
&lt;/tt&gt;    $sql = &amp;quot;select * from stores where area_id=$areaId order by name asc&amp;quot;;&lt;tt&gt;
&lt;/tt&gt;    $a = $db-&amp;gt;CacheGetAll(3600,$sql);&lt;tt&gt;
&lt;/tt&gt;    return $a;&lt;tt&gt;
&lt;/tt&gt;  }  &lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;To briefly explain, the stores.php page displays a search form at the top and lists all available countries at the left side.  For better display, the list of countries, areas and stores are clipped and set overflow to automatic only.  Each country is displayed a link which then triggers and ajax call to get the areas for this specific country.  This link points to a javascript method that invokes AJAX and returns the results of the invoked file to the handle specified in our stores.php page.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The list of areas are displayed in the next pane.  The AJAX method displays a loading message while waiting for the results.  Added effects were used from the use of &lt;a href=&quot;http://prototypejs.org&quot;&gt;prototype&lt;/a&gt; and &lt;a href=&quot;http://script.aculo.us&quot;&gt;scriptaculous&lt;/a&gt; for eye candy only.  If you don't want to implement prototype/scriptaculous, you can remove the following files from being loaded in the head section of your stores.php:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;js/prototype.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;js/scriptaculous.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;    &lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;and, use these lines to display the names of the country/area:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in stores.php:&lt;/strong&gt;  &lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;echo &amp;quot;&lt;span class=&quot;ta&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;href&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;onclick&lt;/span&gt;=&lt;span class=&quot;er&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;javascript:showAreas('&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;er&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;an&quot;&gt;country&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;an&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;er&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;an&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&amp;quot; . $country['name'] . &amp;quot;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&amp;quot;;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in getareas.php:&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;echo &amp;quot;&lt;span class=&quot;ta&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;href&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;onclick&lt;/span&gt;=&lt;span class=&quot;er&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;javascript:showStores('&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;er&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;an&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;an&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;er&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;an&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&amp;quot; . $area['name'] . &amp;quot;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&amp;quot;;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;You're officially good to go.  There are other tips you can use too.  If you're interested with personalizing your ajax-loader.gif, you can &lt;a href=&quot;http://www.ajaxload.info/&quot;&gt;visit this site&lt;/a&gt; and create your own.  And if however, you have a huge amount of information to be stored, make sure you have the correct indices for your database.&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;&quot;&gt;ALTER&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;areas&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;&quot;&gt;ADD&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;INDEX&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;country_id_index&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; ( &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;country_id&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; );&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;&quot;&gt;ALTER&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;stores&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;&quot;&gt;ADD&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;INDEX&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;store_name_index&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; ( &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; );&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;&quot;&gt;ALTER&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;stores&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;&quot;&gt;ADD&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;INDEX&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;store_area_id_index&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; ( &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;area_id&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;`&lt;/span&gt;&lt;/span&gt; );&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;This mini store app plus a CMS to maintain it (both from scratch) took me a whole deal of 5hours' work.  I must admit, it was a bit hard for me to go back to working in &lt;a href=&quot;http://php.net&quot;&gt;PHP&lt;/a&gt; when I was so overjoyed with &lt;a href=&quot;http://ruby-lang.org&quot;&gt;Ruby&lt;/a&gt;.  I knew I could have done this all in &lt;a href=&quot;http://rubyonrails.org&quot;&gt;Ruby on Rails&lt;/a&gt; in a little less than 5hours' work and with much lesser code.  I still think that for an application to be neat, less cluttered and specifically working in &lt;a href=&quot;http://en.wikipedia.org/wiki/Don't_repeat_yourself&quot;&gt;DRY&lt;/a&gt;, it would take so much effort not like in &lt;a href=&quot;http://rubyonrails.org&quot;&gt;Rails&lt;/a&gt;.  And that's the reason why I don't want to go back to &lt;a href=&quot;http://php.net&quot;&gt;PHP&lt;/a&gt; again.&lt;/p&gt;

&lt;p&gt;But do help yourself, I saved an archive of this code for your consumption.  Download &lt;a href=&quot;http://sweetperceptions.com/downloads/ministore-freebie.zip&quot;&gt;here&lt;/a&gt; or &lt;a href=&quot;http://www.4shared.com/file/122365495/8e8f3221/ministore-freebie.html&quot;&gt;here&lt;/a&gt;.  I'm pretty sure you'll put better evolution to this short but sweet app.  Its very crude, and most styles where just hard coded for the benefit of fulfilling a demo for the &lt;a href=&quot;http://dakilangbum.com&quot;&gt;client&lt;/a&gt;'s request.  You may want to visit the store playground &lt;a href=&quot;http://playground.dakilangbum.com/stores/stores.php&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thanks and Enjoy!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2009-07-05:961</id>
    <published>2009-07-05T06:38:00Z</published>
    <updated>2009-07-05T06:50:17Z</updated>
    <category term="Coding"/>
    <category term="Design and CSS"/>
    <category term="css"/>
    <category term="dakilangbum"/>
    <category term="indomagz2"/>
    <category term="php"/>
    <category term="premium"/>
    <category term="python"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="theme"/>
    <category term="ugaling pinoy"/>
    <category term="validation"/>
    <category term="wordpress"/>
    <category term="xhtml"/>
    <link href="http://coderkitty.sweetperceptions.com/2009/7/5/premium-should-be-quality" rel="alternate" type="text/html"/>
    <title>Premium should be quality</title>
<content type="html">
            &lt;p&gt;Aside from daily tinkering of &lt;a href=&quot;http://rubyonrails.org&quot;&gt;Ruby on Rails&lt;/a&gt; application, both for &lt;a href=&quot;http://devex.com/maricris&quot;&gt;work&lt;/a&gt; and &lt;a href=&quot;http://sweetperceptions.com&quot;&gt;play&lt;/a&gt;, I have to serve requests that involve other scripting languages such as &lt;a href=&quot;http://www.php.net/&quot;&gt;PHP&lt;/a&gt; and &lt;a href=&quot;http://www.python.org/&quot;&gt;Python&lt;/a&gt;.  &lt;a href=&quot;http://www.php.net/&quot;&gt;PHP&lt;/a&gt; is the least of my favorites, but since its still the most widely used scripting language, &lt;em&gt;in which more and more non CS grads have been so boastful of knowing&lt;/em&gt;, then I still go ways to cater to such applications.  Love of &lt;a href=&quot;http://www.python.org/&quot;&gt;Python&lt;/a&gt; is another thing.  Its as beautiful as Ruby is for me, and as strict as how I tend to live my life. &lt;/p&gt;

&lt;p&gt;As of the moment, I have a project running in &lt;a href=&quot;http://www.php.net/&quot;&gt;PHP&lt;/a&gt; which was built using &lt;a href=&quot;http://www.smarty.net/&quot;&gt;Smarty&lt;/a&gt;, though is &lt;a href=&quot;http://upnec.sweetperceptions.com&quot;&gt;not yet deployed&lt;/a&gt; on client's public server.  Aside from this, I am also happily supporting &lt;a href=&quot;http://dakilangbum.com&quot;&gt;several Wordpress powered blogs&lt;/a&gt;.  I don't choose the themes, but I do have an input on whether its a good choice or not.  We have completed customization of &lt;a href=&quot;http://dakilangbum.com&quot;&gt;two&lt;/a&gt; of &lt;a href=&quot;http://rebyu.dakilangbum.com&quot;&gt;these&lt;/a&gt; blogs and was working on the last one yesterday.  The chosen theme was &lt;a href=&quot;http://www.magznetwork.com/wordpress-themes/indomagz-free-premium-wordpress-theme.html&quot;&gt;IndoMagz2&lt;/a&gt;.  Of course, I immediately uploaded the theme for use.  After that was the anticipation of other stuff to be removed or added.  &lt;/p&gt;

&lt;p&gt;I couldn't have reacted negatively if I didn't have to go through the codes themselves to make some tweeks.  At first glance, it looked just like any other &lt;a href=&quot;http://www.themespreview.com/category/magazine-style/&quot;&gt;magazine type wordpress theme&lt;/a&gt;.  Blocks of elements are organized in the left and right columns of the layout.  Although, I quite believe that three columned layouts are far better in information exposure, I don't have anything against using two columned layouts.  I even thought that the layout was neat looking and the default banner would have really suited the new blog we were fixing.  It was called &quot;&lt;a href=&quot;http://ugalingpinoy.dakilangbum.com&quot;&gt;Ugaling Pinoy&lt;/a&gt;&quot; which translates to &quot;Filipino Attitudes&quot; or even &quot;Filipino Characteristics&quot;.&lt;/p&gt;
&lt;p&gt;Aside from daily tinkering of &lt;a href=&quot;http://rubyonrails.org&quot;&gt;Ruby on Rails&lt;/a&gt; application, both for &lt;a href=&quot;http://devex.com/maricris&quot;&gt;work&lt;/a&gt; and &lt;a href=&quot;http://sweetperceptions.com&quot;&gt;play&lt;/a&gt;, I have to serve requests that involve other scripting languages such as &lt;a href=&quot;http://www.php.net/&quot;&gt;PHP&lt;/a&gt; and &lt;a href=&quot;http://www.python.org/&quot;&gt;Python&lt;/a&gt;.  &lt;a href=&quot;http://www.php.net/&quot;&gt;PHP&lt;/a&gt; is the least of my favorites, but since its still the most widely used scripting language, &lt;em&gt;in which more and more non CS grads have been so boastful of knowing&lt;/em&gt;, then I still go ways to cater to such applications.  Love of &lt;a href=&quot;http://www.python.org/&quot;&gt;Python&lt;/a&gt; is another thing.  Its as beautiful as Ruby is for me, and as strict as how I tend to live my life. ;)&lt;/p&gt;

&lt;p&gt;As of the moment, I have a project running in &lt;a href=&quot;http://www.php.net/&quot;&gt;PHP&lt;/a&gt; which was built using &lt;a href=&quot;http://www.smarty.net/&quot;&gt;Smarty&lt;/a&gt;, though is &lt;a href=&quot;http://upnec.sweetperceptions.com&quot;&gt;not yet deployed&lt;/a&gt; on client's public server.  Aside from this, I am also happily supporting &lt;a href=&quot;http://dakilangbum.com&quot;&gt;several Wordpress powered blogs&lt;/a&gt;.  I don't choose the themes, but I do have an input on whether its a good choice or not.  We have completed customization of &lt;a href=&quot;http://dakilangbum.com&quot;&gt;two&lt;/a&gt; of &lt;a href=&quot;http://rebyu.dakilangbum.com&quot;&gt;these&lt;/a&gt; blogs and was working on the last one yesterday.  The chosen theme was &lt;a href=&quot;http://www.magznetwork.com/wordpress-themes/indomagz-free-premium-wordpress-theme.html&quot;&gt;IndoMagz2&lt;/a&gt;.  Of course, I immediately uploaded the theme for use.  After that was the anticipation of other stuff to be removed or added.  &lt;/p&gt;

&lt;p&gt;I couldn't have reacted negatively if I didn't have to go through the codes themselves to make some tweeks.  At first glance, it looked just like any other &lt;a href=&quot;http://www.themespreview.com/category/magazine-style/&quot;&gt;magazine type wordpress theme&lt;/a&gt;.  Blocks of elements are organized in the left and right columns of the layout.  Although, I quite believe that three columned layouts are far better in information exposure, I don't have anything against using two columned layouts.  I even thought that the layout was neat looking and the default banner would have really suited the new blog we were fixing.  It was called &quot;&lt;a href=&quot;http://ugalingpinoy.dakilangbum.com&quot;&gt;Ugaling Pinoy&lt;/a&gt;&quot; which translates to &quot;Filipino Attitudes&quot; or even &quot;Filipino Characteristics&quot;.&lt;/p&gt;

&lt;p&gt;After a series of tickets have been filed to me for resolution, I needed to open up the codes of the theme and make the actual tweaking.  I started out with the homepage.  Several requests were to totally remove the functionality that the theme offered.  Well, of course, nothing is impossible.  Only time is the variable for every request.  The quality and standard must always be fixed.  This is where the real misery started.  &lt;/p&gt;

&lt;p&gt;I suddenly felt like I wouldn't really be tweaking the theme, but throwing it away altogether!  But this was not the request!  I only have to change some parts to get it going the way it was supposed to.. but this was not my case.  I was dismayed to see its code was nowhere close to premium value!&lt;/p&gt;

&lt;p&gt;I took the liberty of defining &lt;a href=&quot;http://www.google.com.ph/search?q=define%3A+premium&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;aq=t&amp;amp;rls=org.mozilla:en-US:official&amp;amp;client=firefox-a&quot;&gt;&quot;premium&quot; via Google search&lt;/a&gt;.  Among the varied definitions of premium were:&lt;/p&gt;

&lt;blockquote&gt;
    &lt;ul&gt;
    &lt;li&gt;the amount that something in scarce supply is valued above its
    nominal value; &quot;they paid a premium
    for access to water&quot;&lt;/li&gt;
    &lt;li&gt;having or reflecting superior quality or value; &quot;premium gasoline at
    a premium price&quot; -
    wordnet.princeton.edu/perl/webwn&lt;/li&gt;
    &lt;li&gt;The amount by which a bond or stick sells above its par value. -
    www.deltaindex.com/learningcentre/JargonBuster&lt;/li&gt;
    &lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Oh, and the quality was nowhere close to what I have expected!  And here, I have to make my own test to prove to myself that I have not misjudged the quality of this product.  Wordpress has already formed a group effort of identifying which themes deserve the limelight.  Not only to put a few above the rest, but to create models for a good quality theme.  At &lt;a href=&quot;http://www.themespreview.com/&quot;&gt;Themes Preview&lt;/a&gt;, they quantify the good qualities of each theme into three groups: gold, silver and bronze with a &lt;a href=&quot;http://www.themespreview.com/theme-info/&quot;&gt;distinct list of criteria&lt;/a&gt; used for judging.  Let's try to do the same for this case.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div&gt;

&lt;/div&gt;

&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I run the validator and I get errors &lt;/p&gt;&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;&lt;/p&gt;
&lt;/blockquote&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I run the validator and css passed &lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;&lt;/p&gt;
&lt;/blockquote&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;guess, what? no support. &lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;&lt;/p&gt;
&lt;/blockquote&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IE6?  Good thing, yes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;Firefox compatible?  Good thing, yes.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Gravatar supported &lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;&lt;/p&gt;
&lt;/blockquote&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Auto adjustment within the sidebar is also a failure &lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;&lt;/p&gt;
&lt;/blockquote&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I adjusted the default post image to something larger than the post area and it passes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Floating content within post area is okay, but the style is not good.   Photo is not padded. &lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;&lt;/p&gt;
&lt;/blockquote&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Proper image alignment doesn't work.  I tried to force alignment values to no avail.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;Proper sidebar heirarchy fail 
&lt;blockquote&gt;
    &lt;p&gt;&lt;/li&gt;
    &lt;/ul&gt;
    There are others more that exemplify that this premium is nothing better than any other free.  Despite the &lt;a href=&quot;http://www.magznetwork.com/download/3/&quot;&gt;guide that was downloadable from the site&lt;/a&gt;, there were items that drew more negative comments.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;The theme was not tested on the latest version.  It only supported up to 2.6.x.&lt;/li&gt;
  &lt;li&gt;The only way to make changes to this theme was to directly edit the code.  Which was kind of hard for the normal, average blogger.&lt;/li&gt;
  &lt;li&gt;The code for the home.php alone was about ~185 lines.  This is quite huge considering that Wordpress and PHP is already modular.&lt;/li&gt;
  &lt;li&gt;Though the styles passed the validation, it wasn't semantic enough.  The naming of the styles were not intuitive enough nor is it reusable anywhere outside the name context.&lt;/li&gt;
  &lt;li&gt;Not all posts may have a photo.  The theme doesn't support this complexity.  Instead, it forces you to put a photo there unless you'd rather see the default &quot;missing photo thumbnail&quot;.&lt;/li&gt;
  &lt;li&gt;The code was not properly indented.  Not readable. &lt;/li&gt;
  &lt;li&gt;The link for support on the themes management page did not go to the correct page.  Instead, they have a forum for the support where as of the moment had only three (3) posts.  I wonder how else I can get support for this?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I really can't say its simple.  Nor can I say its clean (for it should be clean inside and out).  Its customizeable alright, but only if you can survive reading the jungle-like code.  I definitely wouldn't recommend using this. &lt;/p&gt;

&lt;p&gt;Watch out for what becomes of &lt;a href=&quot;http://ugalingpinoy.dakilangbum.com&quot;&gt;Ugaling Pinoy&lt;/a&gt; soon.  We won't be using Indomagz2 theme anymore, rest assured.&lt;/p&gt;

&lt;div&gt;&lt;/div&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2009-07-01:956</id>
    <published>2009-07-01T13:52:00Z</published>
    <updated>2009-07-02T13:55:57Z</updated>
    <category term="Life can't wait!"/>
    <category term="Wordless Wednesday"/>
    <category term="codinghorror"/>
    <category term="habits"/>
    <category term="programming"/>
    <category term="twitter"/>
    <category term="wordless wednesday"/>
    <link href="http://coderkitty.sweetperceptions.com/2009/7/1/be-wrong-to-be-correct" rel="alternate" type="text/html"/>
    <title>Be wrong to be correct</title>
<content type="html">
            &lt;p&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2009-06-20:949</id>
    <published>2009-06-20T18:02:00Z</published>
    <updated>2009-06-27T18:13:18Z</updated>
    <category term="Life can't wait!"/>
    <category term="Tech Juices"/>
    <category term="aim"/>
    <category term="calendar"/>
    <category term="email"/>
    <category term="geektool"/>
    <category term="google calendar"/>
    <category term="gtd"/>
    <category term="hiveminder"/>
    <category term="ical"/>
    <category term="im"/>
    <category term="isync"/>
    <category term="jabber"/>
    <category term="lifehacker"/>
    <category term="mac"/>
    <category term="mobile"/>
    <category term="msn"/>
    <category term="tastyplanner"/>
    <category term="twitter"/>
    <category term="yahoo"/>
    <link href="http://coderkitty.sweetperceptions.com/2009/6/20/making-gtd-work-for-you-using-hiveminder-google-calendar-ical-isync-and-your-mobile" rel="alternate" type="text/html"/>
    <title>Making GTD work for you using Hiveminder, Google Calendar, iCal, iSync and your mobile</title>
<content type="html">
            &lt;p&gt;&lt;/p&gt;

&lt;p&gt;I'm a fairly new member of &lt;a href=&quot;http://hiveminder.com&quot;&gt;Hiveminder&lt;/a&gt;.  I remember, I saw it first from a &lt;a href=&quot;http://lifehacker.com/software/to-do-managers/track-and-share-your-to-dos-with-hiveminder-193401.php&quot;&gt;Lifehacker article&lt;/a&gt; discussing about the best &lt;a href=&quot;http://en.wikipedia.org/wiki/Getting_Things_Done&quot;&gt;GTD&lt;/a&gt; tool.  I wanted something unobstrusive and could be used in a variety of ways.&lt;/p&gt;

&lt;p&gt;I found &lt;a href=&quot;http://hiveminder.com&quot;&gt;Hiveminder&lt;/a&gt; and I gave it a spin.  I immediately liked its simple layout which is quite refreshing and neat.  I don't have to think much about how to use it.  I immediately began using the &quot;braindump&quot; for all the tasks I had to work on.  Though I'm a fan of handy notebooks, I would very much love to have technology remind me of things I need to work on too.  Sometimes, I get too lazy to read my notebook or scribble down my thoughts for most of the time, I think faster than I could write!&lt;/p&gt;
&lt;p&gt;I'm a fairly new member of &lt;a href=&quot;http://hiveminder.com&quot;&gt;Hiveminder&lt;/a&gt;.  I remember, I saw it first from a &lt;a href=&quot;http://lifehacker.com/software/to-do-managers/track-and-share-your-to-dos-with-hiveminder-193401.php&quot;&gt;Lifehacker article&lt;/a&gt; discussing about the best &lt;a href=&quot;http://en.wikipedia.org/wiki/Getting_Things_Done&quot;&gt;GTD&lt;/a&gt; tool.  I wanted something unobstrusive and could be used in a variety of ways.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;I found &lt;a href=&quot;http://hiveminder.com&quot;&gt;Hiveminder&lt;/a&gt; and I gave it a spin.  I immediately liked its simple layout which is quite refreshing and neat.  I don't have to think much about how to use it.  I immediately began using the &quot;braindump&quot; for all the tasks I had to work on.  Though I'm a fan of handy notebooks, I would very much love to have technology remind me of things I need to work on too.  Sometimes, I get too lazy to read my notebook or scribble down my thoughts for most of the time, I think faster than I could write!&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;At first, I just put everything in the braindump.  Later on, I got to study the integration of the tools available to &lt;a href=&quot;http://hiveminder.com&quot;&gt;Hiveminder&lt;/a&gt;.  Its really wonderful that several services could be made available through the use of already institutionalized basic services such as IMs and Emails.  Right now, &lt;a href=&quot;http://twitter.com&quot;&gt;Twitter&lt;/a&gt; is becoming another one of those basic services, along with &lt;a href=&quot;http://facebook.com/sweetperceptions&quot;&gt;Facebook&lt;/a&gt;, of course.&lt;/p&gt;

&lt;p&gt;Although they haven't integrated their IM service to &lt;a href=&quot;http://yahoo.com&quot;&gt;Yahoo&lt;/a&gt; yet, its already available to those using AIM and &lt;a href=&quot;http://gmail.com&quot;&gt;Gmail&lt;/a&gt;/jabber IM accounts.  They have a very &lt;a href=&quot;http://hiveminder.com/help/reference/IM&quot;&gt;comprehensive list of commands available for IM use&lt;/a&gt; and a short but sweet &lt;a href=&quot;http://hiveminder.com/help/how-to/tasks-by-IM.html&quot;&gt;guide to using the IM service&lt;/a&gt;.  The email tool seems very helpful too!  I figured if you can't do IM in your office but would really love to be able to collate your tasks in &lt;a href=&quot;http://hiveminder.com&quot;&gt;Hiveminder&lt;/a&gt;, you're gonna love this.  Well, whilst the other may be using their IMs or Emails for this, &lt;a href=&quot;http://twitter.com&quot;&gt;Twitter&lt;/a&gt; buffs won't be ostracized too!  They have an account at Twitter which they hooked up for us when if we want to jot down tasks via &lt;a href=&quot;http://twitter.com&quot;&gt;Twitter&lt;/a&gt;.  Its a direct message, so nobody will see it at all.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Over the couple of months that I've been using &lt;a href=&quot;http://hiveminder.com&quot;&gt;Hiveminder&lt;/a&gt;, what I find lacking in it is a good security setup (though they reserve it for their Pro users--I'm only using the basic free one).  And another, would be a good roundtrip syncing of items with their available tools.&lt;/p&gt;

&lt;p&gt;Apart from jotting down your tasks, of course you'd want to be reminded of them.  I use &lt;a href=&quot;http://projects.tynsoe.org/en/geektool/&quot;&gt;GeekTool&lt;/a&gt; to display my &lt;a href=&quot;http://hiveminder.com&quot;&gt;Hiveminder&lt;/a&gt; items on my desktop via an export of my tasks in text format.  Another more useful tool for me is the export to &lt;a href=&quot;http://en.wikipedia.org/wiki/ICal&quot;&gt;iCal&lt;/a&gt;.  And this marks where I make a more holistic approach to my &lt;a href=&quot;http://en.wikipedia.org/wiki/Getting_Things_Done&quot;&gt;GTD&lt;/a&gt; life.&lt;/p&gt;

&lt;p&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Google Calendar, the center of the agenda&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I don't know how it is that others get to do their &lt;a href=&quot;http://en.wikipedia.org/wiki/Getting_Things_Done&quot;&gt;GTD&lt;/a&gt;s via a sole tool or process alone, but I do use several tools at different times.  I'm a sort of a Google buff/Google whore (or whatever you might want to call a person who spends most of their time within Google services).  I use mostly Google powered tools to power my lifestyle.  I email, I read, I surf, I check my sites, etc. using Google related services.  Its not surprising, I'd find &lt;a href=&quot;http://www.google.com/calendar/render&quot;&gt;Google calendar&lt;/a&gt; better than any other online calendars out there.&lt;/p&gt;

&lt;p&gt;Our office shares calendars via &lt;a href=&quot;http://www.google.com/calendar/render&quot;&gt;Google calendar&lt;/a&gt; and also in Apptix (which I hate by the way).  I like the fact that I could subscribe/unsubscribe from several calendars using only one account.  With this, I keep the personal events from the public events in separate entities, while I'm able to access/view them using only one account.  Routinely, I would backup my calendar via an export to &lt;a href=&quot;http://en.wikipedia.org/wiki/ICal&quot;&gt;iCal&lt;/a&gt; format.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Exporting to &lt;a href=&quot;http://en.wikipedia.org/wiki/ICal&quot;&gt;iCal&lt;/a&gt; format seems to work best for me whenever I'm offline (which I so often hate to be).  I can quickly breeze through my appointments and reminders via &lt;a href=&quot;http://en.wikipedia.org/wiki/ICal&quot;&gt;iCal&lt;/a&gt;.  Note that, even if Google Calendar has an option for sync already, I haven't been able to get it to sync with my &lt;a href=&quot;http://www.sonyericsson.com/cws/products/mobilephones/overview/w960i&quot;&gt;W960&lt;/a&gt;, that's why I'm opting to do it this way.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;iCal, one step closer to me offline&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/ICal&quot;&gt;iCal&lt;/a&gt; is very flexible tool that I have not yet maximized.  You can jot notes on your events, create alarms, sync with other calendars, etc.  Although I have not yet used it to its full potential, I'm already happy with making use of it with what I have and for my needs.  It makes my life easier when I'm in offline mode.&lt;/p&gt;

&lt;p&gt;Right now, I have my &lt;a href=&quot;http://www.google.com/calendar/render&quot;&gt;Google calendar&lt;/a&gt; imported into &lt;a href=&quot;http://en.wikipedia.org/wiki/ICal&quot;&gt;iCal&lt;/a&gt; (which I manually do from time to time).  As part of the whole integration, I also export my &lt;a href=&quot;http://hiveminder.com&quot;&gt;Hiveminder&lt;/a&gt; tasks to &lt;a href=&quot;http://en.wikipedia.org/wiki/ICal&quot;&gt;iCal&lt;/a&gt;.  I also have another calendar for TastyPlanner which I have included in my &lt;a href=&quot;http://en.wikipedia.org/wiki/ICal&quot;&gt;iCal&lt;/a&gt; setup.  &lt;/p&gt;

&lt;p&gt;I just set my &lt;a href=&quot;http://hiveminder.com&quot;&gt;Hiveminder&lt;/a&gt; and &lt;a href=&quot;http://tastyplanner.com/&quot;&gt;TastyPlanner&lt;/a&gt; subscription to auto refresh every now and then to receive updates.  I do the manual import of my &lt;a href=&quot;http://www.google.com/calendar/render&quot;&gt;Google Calendar&lt;/a&gt; since I want the items there to be grouped into one subscription.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;iSync, the bridge to mobility&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finally, there's the missing link.  None of these tools could have been any more useful than they are alone without syncing them all to my mobile.  Of course, when internet and laptop are both missing, I still have to survive.  Good thing &lt;a href=&quot;http://www.apple.com/support/isync/&quot;&gt;iSync&lt;/a&gt; is there to give my life a fuller shape.&lt;/p&gt;

&lt;p&gt;For a long while back, I wasn't able to find a plugin that could help me link &lt;a href=&quot;http://www.apple.com/support/isync/&quot;&gt;iSync&lt;/a&gt; with my &lt;a href=&quot;http://www.sonyericsson.com/cws/products/mobilephones/overview/w960i&quot;&gt;W960i&lt;/a&gt; phone.  I have searched long and hard to find it since it wasn't automatically detected by &lt;a href=&quot;http://www.apple.com/support/isync/&quot;&gt;iSync&lt;/a&gt;'s native setup alone.&lt;/p&gt;

&lt;p&gt;I have found &lt;a href=&quot;http://www.esato.com/archive/t.php/t-162631,1.html&quot;&gt;this&lt;/a&gt; and gave it a try.  It worked for me!  Now, my calendars and todos can be synced to my mobile and I don't have to miss anything!&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maximizing this setup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, there are tricky items in this setup.  &lt;a href=&quot;http://hiveminder.com&quot;&gt;Hiveminder&lt;/a&gt; doesn't really show up in your &lt;a href=&quot;http://en.wikipedia.org/wiki/ICal&quot;&gt;iCal&lt;/a&gt; after the export/import has been put in place.  The key factor is to always put due dates in your tasks if you want them to be visible in your synced calendar.  &lt;/p&gt;

&lt;p&gt;Another thing would be if you keep on missing your appointments/reminders just because you failed to look at your calendar.  But this can be fixed!  What I do for this, is to setup Google to send me SMS reminders from &lt;a href=&quot;http://www.google.com/calendar/render&quot;&gt;Google Calendar&lt;/a&gt;.  You can do this too by going to your Google Calendar &gt;&gt; Settings &gt;&gt; Mobile Setup.&lt;/p&gt;

&lt;p&gt;So there, if this doesn't work for you, you can still explore other ways of making your life's tasks easier and faster to accomplish.  Maybe sometime soon, I can come up with something better for me too.  Who knows? :)&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2009-06-04:933</id>
    <published>2009-06-04T04:57:00Z</published>
    <updated>2009-06-27T18:14:12Z</updated>
    <category term="dupliate title"/>
    <category term="duplicate meta"/>
    <category term="duplicate tags"/>
    <category term="google"/>
    <category term="google webmaster"/>
    <category term="mephisto"/>
    <category term="monitor"/>
    <category term="themes"/>
    <category term="tools"/>
    <category term="webmaster"/>
    <link href="http://coderkitty.sweetperceptions.com/2009/6/4/playing-it-safe-with-google-s-web-tools" rel="alternate" type="text/html"/>
    <title>Playing it safe with Google's web tools</title>
<content type="html">
            &lt;p&gt;Just for the sake of 'doing-it-right', I enrolled all my sites into &lt;a href=&quot;http://www.google.com/analytics/&quot;&gt;Google's Analytics&lt;/a&gt; and subjected them to &lt;a href=&quot;http://www.google.com/webmasters&quot;&gt;Google Webmaster's tools&lt;/a&gt;.  I'd check them from time to time to set some updates and fix reported errors.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.google.com/webmasters&quot;&gt;Google Webmaster's tools&lt;/a&gt; is quite a handy measure for beginners who don't know where to start with their site monitoring or how to improve their pages the way Google sees it.  You can optimize your page titles, see how to do it..&lt;/p&gt;
&lt;p&gt;Just for the heck of 'doing-it-right', I enrolled all my sites into &lt;a href=&quot;http://www.google.com/analytics/&quot;&gt;Google's Analytics&lt;/a&gt; and subjected them to &lt;a href=&quot;http://www.google.com/webmasters&quot;&gt;Google Webmaster's tools&lt;/a&gt;.  I'd check them from time to time to set some updates and fix reported errors.&lt;/p&gt;

&lt;p&gt;Google Webmaster's tools is quite a handy measure for beginners who don't know where to start with their site monitoring or how to improve their pages the way Google sees it.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;What has been confusing was that, Google reports multiple instances of the same title tag for some of my pages.  This doesn't happen with &lt;a href=&quot;http://livinglife.sweetperceptions.com&quot;&gt;Wordpress&lt;/a&gt; though.  Since I just ported a &lt;a href=&quot;http://www.templatelite.com/&quot;&gt;Wordpress theme&lt;/a&gt; look to mephisto, I wondered if it was just my fault and if ever, how could I fix it.  I looked into the default mephisto theme, and found this in the layout:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&amp;lt;title&amp;gt;{{ site.title }} {&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;% &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt; &lt;/span&gt;&lt;/span&gt;article &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%}&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; {{ article.title &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;} {&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;% &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt; &lt;/span&gt;&lt;/span&gt;%} {{ site.subtitle }} {&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;% &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;endif&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt; &lt;/span&gt;&lt;/span&gt;%}&amp;lt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;title&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;This sets the title to the title of the article when an article is present, but to the site subtitle for pages such as article archive, tag archive, page or even section archive.  Some &lt;a href=&quot;http://themes.benlog.org/&quot;&gt;mephisto themes&lt;/a&gt; (like &lt;a href=&quot;http://evil.che.lu/projects/skittlish&quot;&gt;skittlish&lt;/a&gt;) support the change in the page title (for its archives, dunno for the tag archives).  I haven't tried skittlish myself, but here's my take on how you can make your mephisto pages have unique titles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In your themes directory (or whichever path you have your theme in), create a new file called &lt;em&gt;title&lt;/em&gt;header.liquid (or whatever you'd have it called) inside the templates directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Put the following code in it:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;{&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;% &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt; &lt;/span&gt;&lt;/span&gt;article &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%}&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&lt;tt&gt;
&lt;/tt&gt;  &amp;lt;meta name=&amp;quot;description&amp;quot; content=&amp;quot;Put your site description here.  Put an intro to article here '{{ article.title &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;}&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;.&amp;quot;/&amp;gt;  &lt;tt&gt;
&lt;/tt&gt;  &amp;lt;meta name=&amp;quot;keywords&amp;quot; content=&amp;quot;put, your, default, keywords, here, separated, by, commas, {{ article.title }}&amp;quot;/&amp;gt;&lt;tt&gt;
&lt;/tt&gt;{% endif %}&lt;tt&gt;
&lt;/tt&gt;{% if section %} &lt;tt&gt;
&lt;/tt&gt;  {% if section.name == &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;co&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; and archive_date %}&lt;tt&gt;
&lt;/tt&gt;    &amp;lt;meta name=&amp;quot;description&amp;quot; content=&amp;quot;Put your site description here.  Put an intro to the archive date {{ archive_date | format_date: &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;my&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}} articles.&amp;quot;/&amp;gt;    &lt;tt&gt;
&lt;/tt&gt;    &amp;lt;meta name=&amp;quot;keywords&amp;quot; content=&amp;quot;put, your default, keywords, here, separated, by, commas, {{ archive_date | format_date: &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;my&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}}&amp;quot;/&amp;gt;&lt;tt&gt;
&lt;/tt&gt;  {% else %}&lt;tt&gt;
&lt;/tt&gt;    &amp;lt;meta name=&amp;quot;description&amp;quot; content=&amp;quot;Put your site description here.  Put an intro to the section archive {{ section.name }} articles.&amp;quot;/&amp;gt;&lt;tt&gt;
&lt;/tt&gt;    &amp;lt;meta name=&amp;quot;keywords&amp;quot; content=&amp;quot;put, your default, keywords, here, separated, by, commas, {{ section.name }}&amp;quot;/&amp;gt;&lt;tt&gt;
&lt;/tt&gt;  {% endif %}&lt;tt&gt;
&lt;/tt&gt;{% endif %}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;In your layout.liquid, find the meta tag with the content-type and put the following code:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  &amp;lt;meta content=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;application/xhtml+xml; charset=utf-8&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; http-equiv=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;content-type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;/&amp;gt;&lt;tt&gt;
&lt;/tt&gt;  {&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;% &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;title_header&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; %}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;And, that's it!  Save your templates, and give it a restart.  You should be able to get rid of the Google webmaster errors in its diagnostics section.  If you're interested to find out more about the archiving, you can start &lt;a href=&quot;http://groups.google.com/group/MephistoBlog/browse_thread/thread/fde557ffc03bace2&quot;&gt;here&lt;/a&gt; or explore the codes of &lt;a href=&quot;http://evil.che.lu/projects/skittlish&quot;&gt;skittlish theme&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Feel free to leave me a message if you enjoyed this post.  ;) &lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2009-05-31:929</id>
    <published>2009-05-31T11:36:00Z</published>
    <updated>2009-06-27T18:14:47Z</updated>
    <category term="Coding"/>
    <category term="Ruby and/or Rails"/>
    <category term="atom"/>
    <category term="blog"/>
    <category term="i.ph"/>
    <category term="publishing"/>
    <category term="ruby"/>
    <category term="scraping"/>
    <category term="wordpress"/>
    <link href="http://coderkitty.sweetperceptions.com/2009/5/31/migrate-your-wordpress-blog-using-ruby-and-atom" rel="alternate" type="text/html"/>
    <title>Migrate to your Wordpress blog using Ruby and Atom</title>
<content type="html">
            &lt;p&gt;Recently, I have encountered a dilemma regarding my personal blog.  I have it hosted by a &lt;a href=&quot;http://i.ph&quot;&gt;local blog host provider&lt;/a&gt;.  It was great staying there and blogging there when there was still this very tight-knit community of bloggers.  From time to time, we'd all meet up and just express our thoughts in person.  The providers were really great with hearing out their users' thoughts, wishes including rants and raves.  They were really good with what they were doing (up to some point in time).&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;Now, being the Ruby lover that I am, I decided to write a Ruby script that would scrape my content and push it onto my &lt;a href=&quot;http://livinglife.sweetperceptions.com&quot;&gt;new Wordpress blog&lt;/a&gt;.  There are a couple of assumptions/caveats for this script:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can scrape off content from only &lt;strong&gt;YOUR OWN BLOG&lt;/strong&gt;.  Please don't use this to steal other people's content.  &lt;strong&gt;&lt;em&gt;I am not liable for any online content theft from the use of this script.&lt;/strong&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;You must be able to understand the structure of the blog you are scraping.  You should know where the &quot;excerpt&quot;, &quot;main body&quot;, &quot;post date&quot;, &quot;post author&quot;, etc. info are located from the markup/source of the blog you are scraping.&lt;/li&gt;
&lt;li&gt;You must have the credentials of the blog where you want to push the scraped content.&lt;/li&gt;
&lt;li&gt;If in case you need something else, or some more tweaking to this script, you must know Ruby, or maybe you can &lt;a href=&quot;mailto:coderkitty @ sweetperceptions.com&quot;&gt;drop me a line&lt;/a&gt; and I'll see how I can help you.&lt;/li&gt;
&lt;li&gt;This script uses Atom tools, although there are other gems available, this is what I chose to use.&lt;/li&gt;
&lt;li&gt;Turn on Atom publishing in your Wordpress blog.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;Recently, I have encountered a dilemma regarding my personal blog.  I have it hosted by a &lt;a href=&quot;http://sweetperceptions.i.ph&quot;&gt;local blog host provider&lt;/a&gt;.  It was great staying there and blogging there when there was still this very tight-knit community of bloggers.  From time to time, we'd all meet up and just express our thoughts in person.  The providers were really great with hearing out their users' thoughts, wishes including rants and raves.  They were really good with what they were doing (up to some point in time).&lt;/p&gt;

&lt;p&gt;Here are a couple of my raves about their service and the community:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Most of the members were real people.  Not just an avenue for spammers and anonymous bloggers&lt;/li&gt;
&lt;li&gt;People of that community were intelligent people.  Its nice to have some good conversations with them.&lt;/li&gt;
&lt;li&gt;There's always a superhero in the forum who always tries to help (though he's not connected with the providers themselves)&lt;/li&gt;
&lt;li&gt;Even their higher management mingle with the people of their community&lt;/li&gt;
&lt;li&gt;Customer support is quick to reply&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And some of my rants too:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sometimes, they forget about threads/issues &lt;/li&gt;
&lt;li&gt;Their customer support is very poor in their knowledge of how the system works&lt;/li&gt;
&lt;li&gt;Their customer support cannot provide tech support&lt;/li&gt;
&lt;li&gt;No integration to offline blogging software (though &lt;a href=&quot;http://wordpress.org&quot;&gt;Wordpress&lt;/a&gt; supports this)&lt;/li&gt;
&lt;li&gt;I found out, (while writing this script), that they had a lot of substandard tweaks (especially in the markup)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And yes, it might be too obvious for some, I have experienced all of my rants in the past few weeks that have passed.  I was under the intent of making an offline backup of my blog (hosted with them).  And with this, I got in touch with their customer support.  I have been courteous enough, patient and understanding that my request might come in weird, or exceptional to that case.  The &lt;a href=&quot;http://i.ph&quot;&gt;I.ph&lt;/a&gt; platform is really made of &lt;a href=&quot;http://wordpress.org&quot;&gt;Wordpress engine&lt;/a&gt;, and that they tweaked this engine to conform to some of their requirements in providing their own bloghost.  I knew for a fact that a backup could easily have been given only to special requests like mine.   But this was not my case.&lt;/p&gt;

&lt;p&gt;It seemed to me that they were reluctant, if not totally disagreeing with the fact that they'd release a backup of my blog.. for what reason, I don't know why.  Maybe because their tweaks have made &lt;a href=&quot;http://wordpress.org&quot;&gt;Wordpress engine&lt;/a&gt;'s support for one click backup unusable??  I tried to reason out by giving them clarification of what I needed from them, but they made me wait in vain.  Alas, my patience broke out when I received an email from their customer support saying..&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Of course I know my own &lt;a href=&quot;http://feeds.feedburner.com/Coderkitty-Home&quot;&gt;RSS feed&lt;/a&gt;, don't I?  But that was not what was asked for!  At rage, I decided to take matters into my own fiery hands.  I couldn't say well enough that that email only made me furious.. well, it also made me excited and happy!  Happy that I could once again write my own code to reach my own goal!  Since I was bent on getting my own backup in an easy way, I looked up some reference online on whether somebody else could have done or wrote something similar to what I had in mind.  I found &lt;a href=&quot;http://www.technetra.com/2009/02/24/migrating-your-blogs-content-to-wordpress/&quot;&gt;this&lt;/a&gt;, but it seems to be dead as of the time of writing.&lt;/p&gt;

&lt;p&gt;Now, being the Ruby lover that I am, I decided to write a Ruby script that would scrape my content and push it onto my &lt;a href=&quot;http://livinglife.sweetperceptions.com&quot;&gt;new Wordpress blog&lt;/a&gt;.  There are a couple of assumptions/caveats for this script:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can scrape off content from only &lt;strong&gt;YOUR OWN BLOG&lt;/strong&gt;.  Please don't use this to steal other people's content.  &lt;strong&gt;&lt;em&gt;I am not liable for any online content theft from the use of this script.&lt;/strong&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;You must be able to understand the structure of the blog you are scraping.  You should know where the &quot;excerpt&quot;, &quot;main body&quot;, &quot;post date&quot;, &quot;post author&quot;, etc. info are located from the markup/source of the blog you are scraping.&lt;/li&gt;
&lt;li&gt;You must have the credentials of the blog where you want to push the scraped content.&lt;/li&gt;
&lt;li&gt;If in case you need something else, or some more tweaking to this script, you must know Ruby, or maybe you can &lt;a href=&quot;mailto:coderkitty@sweetperceptions.com&quot;&gt;drop me a line&lt;/a&gt; and I'll see how I can help you.&lt;/li&gt;
&lt;li&gt;This script uses Atom tools, although there are other gems available, this is what I chose to use.&lt;/li&gt;
&lt;li&gt;Turn on Atom publishing in your Wordpress blog.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Ready?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;First, of course, have a working Ruby setup.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next, make sure you have the following gems: (1) &lt;a href=&quot;http://wiki.github.com/why/hpricot&quot;&gt;Hpricot&lt;/a&gt; and (2) &lt;a href=&quot;http://raa.ruby-lang.org/project/atom-tools/&quot;&gt;Atom&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;sudo gem install hpricot&lt;tt&gt;
&lt;/tt&gt;sudo gem install atom-tools&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Test the following requires in your irb.  If it doesn't raise an error, then you're good to go. :)&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;require &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;rubygems&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;require &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;open-uri&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;require &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;net/http&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;require &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;hpricot&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;require &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;atom/entry&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;require &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;atom/collection&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Secure all the variables you'll need:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;wp_blog_host = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;livinglife.sweetperceptions.com&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;#the wordpress blog you want to post to&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;wp_blog_uri = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;http://&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;wp_blog_host&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;#making it browseable&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;wp_base = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;http://&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;wp_blog_host&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/wp-app.php&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;#appending the base for publishing posts&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;wp_blog_username = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;myusername&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;#username to the wordpress blog you want to post to&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;wp_blog_password = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;mypassword&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;#password to the wordpress blog you want to post to&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;your_blog_source = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;http://sweetperceptions.i.ph&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;#the page you want to scrape content from&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;which_pages = &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;..&lt;span class=&quot;i&quot;&gt;19&lt;/span&gt;  &lt;span class=&quot;c&quot;&gt;#put the pages here, if the content source will need this, see how I used it &lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;You must have registered categories on your recipient wordpress blog to be able to automatically categorize your posts.  If your blog source already have categories, then you can use these exact names for the migration.  If you only have tags, I can still help you out (as this was my trouble too).  You'll need to declare your registered categories as such (these are my own categories):&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;registered_categories = [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;About me&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Artistry&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Cool Finds&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Dreams&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Events&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Health and Beauty&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Horoscope&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Living Life&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Meme&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Movies&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Music&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Notes&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Pet Love&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Quotes&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Random thoughts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Stories to share&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Techie&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Travel&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;] &lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;If these new registered categories do not match those that you currently have in your blog source, then explicitly setting &quot;synonym categories&quot; would help.  For those who did not categorize their posts, and solely rely on their tags, this could be your best avenue for categorizing your posts automatically.  Try to categorize which tags (and old categories) would fall into your new categories.  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;synonym_categories = {&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;About me&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;me&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;], &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Artistry&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;poem&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Cool Finds&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;cool&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Dreams&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;dream&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;dreams&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Events&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;bday&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;birthday&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Christmas&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;New year&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new-year&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;celebration&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Health and Beauty&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;health&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;sickness&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;headache&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;fever&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;cancer&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Horoscope&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;cookie&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;fortune&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;horoscope&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;astrology&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;psych&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Living Life&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;life&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;kalokohan&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Meme&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;meme&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Movies&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;hollywood&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;movie&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;movies&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;movie-lines&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;happy-feet&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Music&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;song&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;songs&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;singer&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;music&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ost&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Notes&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;notes&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Pet Love&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;pet&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;dog&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;animal&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;animals&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;pets&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Quotes&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;quote&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;quotes&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Random thoughts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;thought&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;thoughts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;think&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;logic&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Stories to share&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;story&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;stories&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;adventure&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Techie&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;tech&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;techie&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;work&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;web2.0&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;development&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;software&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;online&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;skype&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;pc&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Travel&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;philippines&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;travel&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;province&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;When everything here is set, you'll need to understand that if you don't have your own sitemap of posts' links, you'll need to extract them manually by visiting all pages of your blog_source to get their urls.  This might take some time.  Its better if you have a list of your own posts' urls via a sitemap.  If not, then you'll have to set your blog source pages like this (mine had the format http://sweetperceptions.i.ph/page/N):&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;which_pages.each &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |page|&lt;tt&gt;
&lt;/tt&gt;  from = Hpricot(open(your_blog_source + &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/page/&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;page.to_s&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;))&lt;tt&gt;
&lt;/tt&gt;  urls &amp;lt;&amp;lt; (from/&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;h3[@class='entrytitle']/a&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).collect{|x| x[&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;]}&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Or, use your links from a sitemap.  I only used text format for my own use.  To do this,&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;urls = &lt;span class=&quot;co&quot;&gt;File&lt;/span&gt;.readlines(urls_to_import).map { |line| line.chomp }&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Now, let's take a deep breath.  The next steps would be more about &lt;a href=&quot;http://wiki.github.com/why/hpricot&quot;&gt;Hpricot&lt;/a&gt;, and parsing your own document to extract the necessary information.  I'll walk you through how I got mine, but then you'll have to construct your own for each section necessary.  ;)  I'll show you the snippet of the section involved, followed by the &lt;a href=&quot;http://wiki.github.com/why/hpricot&quot;&gt;Hpricot&lt;/a&gt; code to get it.  I used &lt;a href=&quot;https://addons.mozilla.org/firefox/addon/1843&quot;&gt;Firebug&lt;/a&gt; to help me with this, by the way. &lt;/p&gt;

&lt;p&gt;This is an example of one post in my blog source:&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Get the title of your post.  Each blog entry in my blog source is enclosed in a div which contains an h3 tag with class 'entrytitle'.  The actual title is enclosed in a link.  You always call the inner_html of the element node you're looking at to get the text.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  title = (&lt;span class=&quot;co&quot;&gt;CGI&lt;/span&gt;::unescapeHTML((doc/&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;div/h3[@class='entrytitle']/a&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).inner_html.strip)).gsub(&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;ch&quot;&gt;\r&lt;/span&gt;&lt;span class=&quot;ch&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;I explicitly set the author to my name.  Next, we get the time stamp.  Some would have the timestamp displayed, while the others won't.  If you want to capture the exact timestamp of the post, better to have this in the script.  Mine was displayed at the bottom of the blog entry inside a div with class 'meta-post'.  Since this entire thing contains other information too, I used regular expression to match the format of my timestamp.  &lt;em&gt;NOTE:  Others would have a different timestamp format.  Please adjust as necessary.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  timestr = (doc/&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;div[@class='meta-post']&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).inner_html[&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;ch&quot;&gt;\d&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;+:&lt;/span&gt;&lt;span class=&quot;ch&quot;&gt;\d&lt;/span&gt;&lt;span class=&quot;ch&quot;&gt;\d&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;ch&quot;&gt;\d&lt;/span&gt;&lt;span class=&quot;ch&quot;&gt;\d&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;/span&gt;]&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The date is still out there.  The date stamp of my post is found inside a div with a span whose class is called 'date'.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  datestr = ((doc/&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;div/span[@class='date']&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).inner_html.strip).gsub(&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;ch&quot;&gt;\r&lt;/span&gt;&lt;span class=&quot;ch&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;After we have the time and the date stamp, we concatenate them to form a string that would be accepted as a valid date via Atom publishing.  &lt;em&gt;NOTE: You may need to adjust your timezone calculations for this.  Mine resolves to be -0500.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  datestr = datestr + &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; + timestr&lt;tt&gt;
&lt;/tt&gt;  datestr = &lt;span class=&quot;co&quot;&gt;DateTime&lt;/span&gt;.parse(datestr).strftime(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;%a, %-d %b %Y %T -0500&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Next comes the tricky part: Categorizing your post!  If you were able to correctly assemble your registered categories and synonym categories, this would be a breeze.  Well, at any rate, you can keep on emptying your blog for the posts and redoing them again as frequent as you have/want to.  Find where your tags are enclosed.  Mine is found inside a div with class 'tag-list'.  If your tags match the exact name of a category, then its automatically added to your filtered tags.  Next, your synonym categories would be parsed to see if your tags can be used to classify to your new registered category.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  filtered_tags = []&lt;tt&gt;
&lt;/tt&gt;  tags = (doc/&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;div[@class='tag-list']/a&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).collect{|x| x.inner_html}&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;#rule 1 -&amp;gt; exact match&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  filtered_tags &amp;lt;&amp;lt; tags.collect{|x| x &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; registered_categories.include?(x)}.compact&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;#rule 2 -&amp;gt; synonyms&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  synonym_categories.keys.each &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |syn|&lt;tt&gt;
&lt;/tt&gt;    filtered_tags &amp;lt;&amp;lt; tags.collect{|x| syn &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; (synonym_categories[syn]).include?(x)}.compact&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  tags = filtered_tags.flatten.compact.uniq.join(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Now to get your entire post.  Yipee!  You need to find a distinguishable id attached to every post.  There really should be one unique id for each post.  They usually look like 'post-id' or any flavors of that.  Mine was enclosed in a div with id called 'postentry-{id}'.  You'll need to get the this id!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  &lt;span class=&quot;c&quot;&gt;# Get your contents by finding all paras in the entry post&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  entry_id = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;postentry-&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;doc.at(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;div[@class='blog']&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)[&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;].split(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).last&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# Get the main body content&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  contents = (doc/&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;entry_id&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;We are almost done.  With this, there could be some parts of the body that you'd want to remove.  You can do this by getting to the element via Hpricot and remove each of them.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  &lt;span class=&quot;c&quot;&gt;# Remove unneeded elements  &lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  (doc/&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;entry_id&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/h3&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).remove  &lt;tt&gt;
&lt;/tt&gt;  (doc/&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;entry_id&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/span[@class='date']&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).remove  &lt;tt&gt;
&lt;/tt&gt;  (doc/&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;entry_id&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/div[@class='tag-list']&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).remove&lt;tt&gt;
&lt;/tt&gt;  (doc/&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;entry_id&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/div[@class='meta-post']&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).remove&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Lastly, assemble your element and post away!&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  &lt;span class=&quot;c&quot;&gt;# Atom Author element&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  author = &lt;span class=&quot;co&quot;&gt;Atom&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Author&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;  author.name = author&lt;tt&gt;
&lt;/tt&gt;  author.uri = wp_blog_uri&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# Atom Entry element  &lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  entry = &lt;span class=&quot;co&quot;&gt;Atom&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Entry&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;  entry.title = title&lt;tt&gt;
&lt;/tt&gt;  entry.summary = hExcerpt&lt;tt&gt;
&lt;/tt&gt;  entry.content = content&lt;tt&gt;
&lt;/tt&gt;  entry.content.type = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  entry.published = datestr&lt;tt&gt;
&lt;/tt&gt;  entry.updated = datestr&lt;tt&gt;
&lt;/tt&gt;  entry.tag_with(tags, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  entry.authors &amp;lt;&amp;lt; author&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  req = &lt;span class=&quot;co&quot;&gt;Atom&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;HTTP&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;  req.user = wp_blog_username&lt;tt&gt;
&lt;/tt&gt;  req.pass = wp_blog_password&lt;tt&gt;
&lt;/tt&gt;  req.always_auth = &lt;span class=&quot;sy&quot;&gt;:basic&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt; &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# Atom Collection&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  c = &lt;span class=&quot;co&quot;&gt;Atom&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Collection&lt;/span&gt;.new(wp_base + &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/posts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, req)&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  res = c.post! entry&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Did you enjoy this?  I knew I did the first time!  It feels great not having to manually copy and paste my content from the old blog source to the new one.  Best of it all, I was able to keep my categories.  I'm still looking at how to transfer all of my tags into the new one along with the comments, but I'm not yet successful with doing it as of the moment.  If you'd like a full copy of this script, you can find it &lt;a href=&quot;http://pastie.org/495598&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Goodluck to your migration!  I hope this helped.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2009-04-11:921</id>
    <published>2009-04-11T07:27:00Z</published>
    <updated>2009-06-27T18:15:28Z</updated>
    <category term="Coding"/>
    <category term="Life can't wait!"/>
    <category term="cleanup"/>
    <category term="coding"/>
    <category term="housekeeping"/>
    <link href="http://coderkitty.sweetperceptions.com/2009/4/11/code-revisiting-and-housekeeping" rel="alternate" type="text/html"/>
    <title>Code revisiting and housekeeping</title>
<content type="html">
            &lt;p&gt;Its a great success for every programmer once a project or an assignment has been completed.  But give it a day, a week or even a month and the good old code in place is now stale.&lt;/p&gt;

&lt;p&gt;Its every programmer's duty to revisit their codes once in awhile and reassess if the old codes are still pretty much the best codes to be inplace or if there's something new that could do something better, faster and easier with much less effort than before.  &lt;/p&gt;
&lt;p&gt;Its a great success for every programmer once a project or an assignment has been completed.  But give it a day, a week or even a month and the good old code in place is now stale.&lt;/p&gt;

&lt;p&gt;Its every programmer's duty to revisit their codes once in awhile and reassess if the old codes are still pretty much the best codes to be inplace or if there's something new that could do something better, faster and easier with much less effort than before.  Guess that's part of of every code/project's &lt;a href=&quot;http://www.codinghorror.com/blog/archives/001230.html&quot;&gt;technical debt&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This &lt;strong&gt;&lt;em&gt;old&lt;/strong&gt;&lt;/em&gt; code could really say a lot:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;languages_s&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    tmp_array = &lt;span class=&quot;pc&quot;&gt;self&lt;/span&gt;.languages&lt;tt&gt;
&lt;/tt&gt;    txt_array = &lt;span class=&quot;co&quot;&gt;Array&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;for&lt;/span&gt; tmp &lt;span class=&quot;r&quot;&gt;in&lt;/span&gt; tmp_array&lt;tt&gt;
&lt;/tt&gt;      txt_array &amp;lt;&amp;lt; tmp.name.delete(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; txt_array&lt;tt&gt;
&lt;/tt&gt;      tmp_arr = txt_array.sort&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; tmp_arr&lt;tt&gt;
&lt;/tt&gt;        &lt;span class=&quot;r&quot;&gt;return&lt;/span&gt; tmp_arr.join(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        &lt;span class=&quot;r&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Could really be waiting to become something like this: (if only programmers weren't as lazy as they are)&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;languages&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    (&lt;span class=&quot;pc&quot;&gt;self&lt;/span&gt;.languages.blank?) ? &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; : &lt;span class=&quot;pc&quot;&gt;self&lt;/span&gt;.languages.collect{|x| x.name}.sort.join(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Personally, everytime I have a free time to spare, I take a breeze through old codes, and try to keep them in tougher shape.  I do believe your code says a lot about yourself.  So everytime you improve your skills, go improve on all possible evidence too! :)&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2009-04-05:210</id>
    <published>2009-04-05T11:53:00Z</published>
    <updated>2009-06-27T18:15:45Z</updated>
    <category term="Design and CSS"/>
    <category term="css"/>
    <category term="design"/>
    <link href="http://coderkitty.sweetperceptions.com/2009/4/5/easy-css-rounded-corners" rel="alternate" type="text/html"/>
    <title>Easy CSS rounded corners</title>
<content type="html">
            Rounded corners are easily achievable.  Either via CSS or Javascript.  See this sample using CSS, or the resource in Javascript.
&lt;p&gt;I tried working on different approaches for rounded corners using CSS.  I really didn't want to resort to using the old fashioned tabled layout.  &lt;/p&gt;

&lt;p&gt;What I wanted was really simple:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It should be cross browser compatible&lt;/li&gt;
&lt;li&gt;it should look undistorted&lt;/li&gt;
&lt;li&gt;it should be easily configured&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I got all that I wanted &lt;a href=&quot;http://www.svay.com/coins_arrondis/rounded_corners.html&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add the following CSS code to your stylesheet:


&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;cl&quot;&gt;.upperleft&lt;/span&gt;{&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;width&lt;/span&gt; : &lt;span class=&quot;fl&quot;&gt;100%&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;margin-left&lt;/span&gt; : &lt;span class=&quot;vl&quot;&gt;auto&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;margin-right&lt;/span&gt; : &lt;span class=&quot;vl&quot;&gt;auto&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-color&lt;/span&gt; : &lt;span class=&quot;cr&quot;&gt;#fff&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-image&lt;/span&gt; : &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;url(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;'/images/upperleft.gif'&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;)&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-repeat&lt;/span&gt; : &lt;span class=&quot;vl&quot;&gt;no-repeat&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-position&lt;/span&gt; : &lt;span class=&quot;vl&quot;&gt;top&lt;/span&gt; &lt;span class=&quot;vl&quot;&gt;left&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;cl&quot;&gt;.upperright&lt;/span&gt;{&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-image&lt;/span&gt; : &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;url(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;'/images/upperright.gif'&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;)&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-repeat&lt;/span&gt; : &lt;span class=&quot;vl&quot;&gt;no-repeat&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-position&lt;/span&gt; : &lt;span class=&quot;vl&quot;&gt;top&lt;/span&gt; &lt;span class=&quot;vl&quot;&gt;right&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;cl&quot;&gt;.lowerleft&lt;/span&gt;{&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-image&lt;/span&gt; : &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;url(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;'/images/lowerleft.gif'&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;)&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-repeat&lt;/span&gt; : &lt;span class=&quot;vl&quot;&gt;no-repeat&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-position&lt;/span&gt; : &lt;span class=&quot;vl&quot;&gt;bottom&lt;/span&gt; &lt;span class=&quot;vl&quot;&gt;left&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;cl&quot;&gt;.lowerright&lt;/span&gt;{&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-image&lt;/span&gt; : &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;url(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;'/images/lowerright.gif'&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;)&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-repeat&lt;/span&gt; : &lt;span class=&quot;vl&quot;&gt;no-repeat&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;background-position&lt;/span&gt; : &lt;span class=&quot;vl&quot;&gt;bottom&lt;/span&gt; &lt;span class=&quot;vl&quot;&gt;right&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ke&quot;&gt;padding&lt;/span&gt; : &lt;span class=&quot;fl&quot;&gt;3%&lt;/span&gt; &lt;span class=&quot;fl&quot;&gt;3%&lt;/span&gt; &lt;span class=&quot;fl&quot;&gt;3%&lt;/span&gt; &lt;span class=&quot;fl&quot;&gt;3%&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Enclose your desired content like this:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;upperleft&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        &lt;span class=&quot;ta&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;upperright&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;            &lt;span class=&quot;ta&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;lowerleft&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;                 &lt;span class=&quot;ta&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;lowerright&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;                            YOUR DESIRED CONTENT HERE&lt;tt&gt;
&lt;/tt&gt;                &lt;span class=&quot;ta&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;            &lt;span class=&quot;ta&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        &lt;span class=&quot;ta&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;ta&quot;&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div&gt;
&lt;div class=&quot;upperleft&quot;&gt;
    &lt;div class=&quot;upperright&quot;&gt;
        &lt;div class=&quot;lowerleft&quot;&gt;
            &lt;div class=&quot;lowerright&quot;&gt;
SAMPLE HERE
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/div&gt;&lt;/p&gt;

This solution is only good if you want to have it done via CSS.  Using Javascript is another thing, but here's a very good resource to get you going in that direction: [http://www.html.it/articoli/niftycube/index.html][1]


  [1]: http://www.html.it/articoli/niftycube/index.html
          </content>  </entry>
  <entry xml:base="http://coderkitty.sweetperceptions.com/">
    <author>
      <name>chris</name>
    </author>
    <id>tag:coderkitty.sweetperceptions.com,2009-03-27:911</id>
    <published>2009-03-27T13:48:00Z</published>
    <updated>2009-06-27T18:16:07Z</updated>
    <category term="Coding"/>
    <category term="Ruby and/or Rails"/>
    <category term="acts_as_solr"/>
    <category term="index"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="search"/>
    <category term="solr"/>
    <category term="sync"/>
    <link href="http://coderkitty.sweetperceptions.com/2009/3/27/removing-out-of-sync-error-in-acts_as_solr" rel="alternate" type="text/html"/>
    <title>Removing &quot;out of sync&quot; error in acts_as_solr</title>
<content type="html">
            It could've been pretty straightforward removing this concerned item from the solr index and then everything would be well.. but its a lot harder than that if you're looking at over a thousand indexed elements vs their 'existing' counterparts in the database!  Finding the exact data to remove was really the hardest part!  I never knew this until I took the liberty of helping out our kind Infra Team to resolve the problem.   I decided to tweak the solr parser method returning the &quot;out of  sync&quot; error.  I thought that it would actually be brilliant to just display the concerned element's id so that they could delete it from the index itself.  And so, I had something like this: (in acts_as_solr/lib/parser_methods.rb)
&lt;blockquote&gt;
  &lt;p&gt;&lt;a href=&quot;http://lucene.apache.org/solr/&quot;&gt;Solr&lt;/a&gt; is an open source enterprise
  search server based on the Lucene Java
  search library, with XML/HTTP and JSON
  APIs, hit highlighting, faceted
  search, caching, replication, a web
  administration interface and many more
  features. It runs in a Java servlet
  container such as Tomcat.&amp;nbsp;&amp;nbsp;-&lt;a href=&quot;http://lucene.apache.org/solr/&quot;&gt;Apache Solr&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Solr can be used in &lt;a href=&quot;http://wiki.apache.org/solr/#head-f5e0c63a9a48037a2200cf9ceabda53898142d80&quot;&gt;different containers&lt;/a&gt; and &lt;a href=&quot;http://wiki.apache.org/solr/#head-ab1768efa59b26cbd30f1acd03b633f1d110ed47&quot;&gt;different wrappers&lt;/a&gt;.  Our application runs on Ruby on Rails, and we used &lt;a href=&quot;http://github.com/railsfreaks/acts_as_solr/tree/master&quot;&gt;acts_as_solr&lt;/a&gt;.  Though solr is a powerful, already stable and yet flexible third party solution that we could rely on, we were still not able to maximize its full capacity.  We used the bare minimum features of solr for our search modules. &lt;/p&gt;

&lt;p&gt;As of now, we've used a couple of acts_as_solr enhancments and add ons, some of which we learned from different online resources.  We were able to use &lt;a href=&quot;http://www.elctech.com/projects/advanced-db_free_solr&quot;&gt;db_free_solr&lt;/a&gt; and explored on the &lt;a href=&quot;http://www.quarkruby.com/2007/9/14/advanced-acts_as_solr&quot;&gt;highlighting and faceting capabilities of solr&lt;/a&gt;.  Its been pretty helpful, but of course nothing is almost always seamless.  We encounter few problems with syncing records from the database and onto solr.  For sure, you've come across this trouble before, if you've been using solr:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Out of sync! Found N items
  in index, but only n were
  found in database!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It sure was putting down every page wherein there was this glitch in the count of the records retrieved.  It therefore gave the negative impression that our site was frequently unstable.  Removing a certain indexed element from the solr index is easy as:&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;co&quot;&gt;ActsAsSolr&lt;/span&gt;:: &lt;span class=&quot;co&quot;&gt;Post&lt;/span&gt;.execute(&lt;span class=&quot;co&quot;&gt;Solr&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Request&lt;/span&gt;:: &lt;span class=&quot;co&quot;&gt;Delete&lt;/span&gt;.new(&lt;span class=&quot;sy&quot;&gt;:query&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%{&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;type_s:Model AND id:&amp;quot;Model:110809&amp;quot;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;))&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;co&quot;&gt;ActsAsSolr&lt;/span&gt;:: &lt;span class=&quot;co&quot;&gt;Post&lt;/span&gt;.execute(&lt;span class=&quot;co&quot;&gt;Solr&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Request&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Commit&lt;/span&gt;.new)&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;It could've been pretty straightforward removing this concerned item from the solr index and then everything would be well.. but its a lot harder than that if you're looking at over a thousand indexed elements vs their 'existing' counterparts in the database!  Finding the exact data to remove was really the hardest part!  I never knew this until I took the liberty of helping out our kind Infra Team to resolve the problem.   I decided to tweak the solr parser method returning the &quot;out of  sync&quot; error.  I thought that it would actually be brilliant to just display the concerned element's id so that they could delete it from the index itself.  And so, I had something like this: (in acts&#95;solr/lib/parser_methods.rb)&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;raise &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Out of sync! Found &lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;ids.size&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; items in index, but only &lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;things.size&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; were found in database! Remove &lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;(ids - (things.collect{|x| x.id})).to_sentence&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;unless&lt;/span&gt; things.size == ids.size&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;And yes, viola!  I can now see the faulty ids that were causing the &quot;out of sync&quot; problem.  I presented this not-so-brilliant solution to our Infra Team, and they came up with a better idea.  My colleague thought that it would be nicer if I could just do away with the &quot;out of sync&quot; error altogether. Since I can already pinpoint the cause of the trouble, then why not remove it for good?  I came up with half the solution.  It was the quicker one to implement and didn't require much from their end either.  &lt;/p&gt;

&lt;p&gt;Distinguishing the faulty id from the list of objects from solr vs those that were from the db, it paved the way for me to simply remove these ids from the checking.  It was half the solution because (hint, hint.. I may be doing this next time when I have time) I could actually delete the certain indexed element from solr instead of simply removing it from solr's items on hand.  This &quot;full&quot; solution could actually bring forth other complications since you'd have to deal with what models were concerned and what fields will solr need to look at, etc.  &lt;/p&gt;

&lt;p&gt;And so.. the half solution that I did was to clean up the elements on hand for solr.  This &lt;a href=&quot;http://pastie.org/pastes/426482&quot;&gt;snippet&lt;/a&gt; is found in acts_as_solr/lib/parser_methods.rb.&lt;/p&gt;

&lt;div class=&quot;coderay-macro&quot;&gt;&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;reorder&lt;/span&gt;(things, ids)&lt;tt&gt;
&lt;/tt&gt;    ordered_things = &lt;span class=&quot;co&quot;&gt;Array&lt;/span&gt;.new(things.size)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;unless&lt;/span&gt; things.size == ids.size&lt;tt&gt;
&lt;/tt&gt;      (ids - (things.collect{|x| x.id})).collect{|missing| ids[ids.index(missing)] = &lt;span class=&quot;pc&quot;&gt;nil&lt;/span&gt;}&lt;tt&gt;
&lt;/tt&gt;      ids = ids.compact&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    raise &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Out of sync! Found &lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;ids.size&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; items in index, but only &lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;things.size&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; were found in database! Remove &lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;(ids - (things.collect{|x| x.id})).to_sentence&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;unless&lt;/span&gt; things.size == ids.size&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    things.each &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |thing|&lt;tt&gt;
&lt;/tt&gt;      position = ids.index(thing.id)&lt;tt&gt;
&lt;/tt&gt;      ordered_things[position] = thing&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    ordered_things&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;The first four lines above the &quot;out of sync&quot; message is what is critical.  It will attempt to remove the missing object from the items that solr will return.  If all else fails, then it will be displaying the &quot;out of sync&quot; error, but would still be displaying the ids that were causing the problem. &lt;/p&gt;

&lt;p&gt;Its quick, but not dirty.  It works, but will not really guarantee that your problem will go away permanently.  I suggest you do a complete reindex of your whole data.  Or better yet, whatever was causing it, just make sure that there are no direct database deletion of any data so that solr will always remain in sync with your database.&lt;/p&gt;

&lt;p&gt;Hope this helps.&lt;/p&gt;
          </content>  </entry>
</feed>
