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

<channel>
	<title>Peter Mac And Associates</title>
	<atom:link href="http://www.petermac.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.petermac.com</link>
	<description>Australian freelance programmer and website design</description>
	<lastBuildDate>Tue, 08 May 2012 07:03:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Capistrano Without Root Privileges</title>
		<link>http://www.petermac.com/capistrano-without-root-privileges/</link>
		<comments>http://www.petermac.com/capistrano-without-root-privileges/#comments</comments>
		<pubDate>Tue, 08 May 2012 07:02:25 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=643</guid>
		<description><![CDATA[Given a user with sudo (but not root) access on a remote box, the following deploy.rb script will perform a capistrano deploy of a ruby application: Assumptions: 1. You&#8217;re using &#8216;git&#8217;. Although svn can be used, the script targets a git setup. 2. You&#8217;re using mongrel_cluster. Change the script accordingly if using passenger etc. 3. [...]]]></description>
			<content:encoded><![CDATA[<p>Given a user with sudo (but not root) access on a remote box, the following deploy.rb script will perform a capistrano deploy of a ruby application:</p>
<p>Assumptions:</p>
<p>1. You&#8217;re using &#8216;git&#8217;. Although svn can be used, the script targets a git setup.</p>
<p>2. You&#8217;re using mongrel_cluster. Change the script accordingly if using passenger etc.</p>
<p>3. The application being deployed is dropped into a subfolder/subdirectory on the remote server. You can remove the task :recreate_public_link if you&#8217;re deploying to the root of a virtual directory.</p>
<p>4. A user and group called &#8216;mongrel&#8217; has been created on the remote server. This owns the running mongrel_cluster processes. Relevant permissions are set by the script.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#-----------------------------------------------------</span><br />
<span style="color: #666666; font-style: italic;"># deploy.rb - controls deployment setup/configuration </span><br />
<span style="color: #666666; font-style: italic;"># using the capistrano or 'cap' deployment utility.</span><br />
<span style="color: #666666; font-style: italic;">#-----------------------------------------------------</span><br />
<span style="color: #666666; font-style: italic;"># requires mongrel_cluster recipes to allow restart of mongrel cluster</span><br />
require <span style="color: #ff0000;">'mongrel_cluster/recipes'</span><br />
<br />
<span style="color: #000000; font-weight: bold;">set</span> :application, <span style="color: #ff0000;">&quot;rentmanager&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :user, <span style="color: #ff0000;">&quot;peter&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :web_user, <span style="color: #ff0000;">&quot;apache&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :location, <span style="color: #ff0000;">&quot;192.168.0.15&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;"># If you are using Passenger mod_rails uncomment this:</span><br />
<span style="color: #666666; font-style: italic;"># if you're still using the script/reapear helper you will need</span><br />
<span style="color: #666666; font-style: italic;"># these http://github.com/rails/irs_process_scripts</span><br />
<br />
<span style="color: #666666; font-style: italic;"># namespace :deploy do</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; task :start do ; end</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; task :stop do ; end</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; task :restart, :roles =&gt; :app, :except =&gt; { :no_release =&gt; true } do</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; run &quot;#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}&quot;</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; end</span><br />
<span style="color: #666666; font-style: italic;"># end</span><br />
<br />
ssh_options<span style="color: #7a0874; font-weight: bold;">&#91;</span>:forward_agent<span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #c20cb9; font-weight: bold;">true</span><br />
<br />
default_run_options<span style="color: #7a0874; font-weight: bold;">&#91;</span>:pty<span style="color: #7a0874; font-weight: bold;">&#93;</span> = <span style="color: #c20cb9; font-weight: bold;">true</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :scm, <span style="color: #ff0000;">&quot;git&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :scm_user, <span style="color: #ff0000;">&quot;git&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :repository, &nbsp;<span style="color: #ff0000;">&quot;#{scm_user}@#{location}:/usr/local/share/gitrepos/#{application}.git&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :scm_passphrase, <span style="color: #ff0000;">&quot;your password&quot;</span> <span style="color: #666666; font-style: italic;">#This is your custom users password</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :git_shallow_clone, <span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :deploy_via, :remote_cache<br />
<span style="color: #000000; font-weight: bold;">set</span> :branch, <span style="color: #ff0000;">&quot;master&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :use_sudo, <span style="color: #c20cb9; font-weight: bold;">true</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :site_root, <span style="color: #ff0000;">&quot;app/rentmanager&quot;</span><br />
role :app, location<br />
role :web, location<br />
role :db, location, :<span style="color: #007800;">primary</span>=<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #c20cb9; font-weight: bold;">true</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :deploy_to, <span style="color: #ff0000;">&quot;/var/www/html/test.threerock.com/#{application}&quot;</span><br />
<br />
<span style="color: #666666; font-style: italic;">#---------------</span><br />
<span style="color: #666666; font-style: italic;">#mongrel details</span><br />
<span style="color: #666666; font-style: italic;">#---------------</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :mongrel_conf, <span style="color: #ff0000;">&quot;#{deploy_to}/current/config/mongrel_cluster.yml&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :mongrel_user, <span style="color: #ff0000;">&quot;mongrel&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :mongrel_group, <span style="color: #ff0000;">&quot;mongrel&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :runner, nil<br />
<span style="color: #000000; font-weight: bold;">set</span> :mongrel_clean, <span style="color: #c20cb9; font-weight: bold;">true</span> &nbsp;<span style="color: #666666; font-style: italic;"># helps keep mongrel pid files clean</span><br />
<br />
<span style="color: #666666; font-style: italic;">#-----------------------</span><br />
<span style="color: #666666; font-style: italic;"># migration parameters</span><br />
<span style="color: #666666; font-style: italic;">#----------------------</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :rake, <span style="color: #ff0000;">&quot;rake&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :rails_env, <span style="color: #ff0000;">&quot;production&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :migrate_env, <span style="color: #ff0000;">&quot;&quot;</span><br />
<span style="color: #000000; font-weight: bold;">set</span> :migrate_target, :latest <br />
<br />
before <span style="color: #ff0000;">&quot;deploy:update_code&quot;</span>, <span style="color: #ff0000;">&quot;custom:set_permissions_for_checkout&quot;</span><br />
<br />
before <span style="color: #ff0000;">&quot;deploy:migrate&quot;</span>, <span style="color: #ff0000;">&quot;custom:set_permissions_pre_schema_dump&quot;</span><br />
after <span style="color: #ff0000;">&quot;deploy:migrate&quot;</span>, <span style="color: #ff0000;">&quot;custom:set_permissions_post_schema_dump&quot;</span><br />
<br />
before <span style="color: #ff0000;">&quot;deploy:migrations&quot;</span>, <span style="color: #ff0000;">&quot;custom:set_permissions_pre_schema_dump&quot;</span><br />
after <span style="color: #ff0000;">&quot;deploy:migrations&quot;</span>, <span style="color: #ff0000;">&quot;custom:set_permissions_post_schema_dump&quot;</span>, <span style="color: #ff0000;">&quot;deploy:cleanup&quot;</span><br />
<br />
before <span style="color: #ff0000;">&quot;deploy:symlink&quot;</span>, <span style="color: #ff0000;">&quot;custom:get_current_ownership&quot;</span><br />
<br />
after <span style="color: #ff0000;">&quot;deploy:symlink&quot;</span>, <span style="color: #ff0000;">&quot;custom:update_application_controller&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;custom:yield_current_ownership&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;custom:set_permissions_for_runtime&quot;</span>, <br />
&nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;custom:recreate_public_link&quot;</span><br />
<br />
namespace<span style="color: #7a0874; font-weight: bold;">&#40;</span>:deploy<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">do</span><br />
<br />
&nbsp; desc <span style="color: #ff0000;">&quot;Restart the Mongrel processes on the app server.&quot;</span><br />
&nbsp; task :restart, :roles =<span style="color: #000000; font-weight: bold;">&gt;</span> :app <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; mongrel.cluster.stop<br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">2.5</span><br />
&nbsp; &nbsp; mongrel.cluster.start<br />
&nbsp; end<br />
<br />
end<br />
<br />
namespace<span style="color: #7a0874; font-weight: bold;">&#40;</span>:custom<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">do</span><br />
<br />
&nbsp; desc <span style="color: #ff0000;">&quot;Change ownership of target folders and files to current user&quot;</span><br />
&nbsp; task :set_permissions_for_checkout, :except =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> :no_release =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">true</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">#chown of files to current user</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #ff0000;">&quot;chown -R #{scm_user}:#{scm_user} #{deploy_to}&quot;</span><br />
&nbsp; end<br />
<br />
&nbsp; desc <span style="color: #ff0000;">&quot;Change ownership of target folders and files to current user&quot;</span><br />
&nbsp; task :set_permissions_for_runtime, :except =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> :no_release =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">true</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">#chown of files to current user</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #ff0000;">&quot;chown -R #{web_user}:#{web_user} #{deploy_to}&quot;</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #ff0000;">&quot;chown #{mongrel_user}.#{mongrel_group} -R #{deploy_to}/current/tmp/pids&quot;</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #ff0000;">&quot;chown #{mongrel_user}.#{mongrel_group} -R #{deploy_to}/current/log&quot;</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #ff0000;">&quot;chown #{mongrel_user}.#{mongrel_group} -R #{shared_path}/pids&quot;</span><br />
&nbsp; end<br />
<br />
&nbsp; desc <span style="color: #ff0000;">&quot;Recreate link to serve public folders when hosting within subfolder&quot;</span><br />
&nbsp; task :recreate_public_link <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; run <span style="color: #000000; font-weight: bold;">&lt;&lt;</span>-CMD<br />
&nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #666666; font-style: italic;">#{deploy_to}/current/public &amp;&amp; sudo ln -s . #{application}</span><br />
&nbsp; &nbsp; CMD<br />
&nbsp; end<br />
<br />
&nbsp; desc <span style="color: #ff0000;">&quot;Take temporary ownership of current folder to allow symlink updates&quot;</span><br />
&nbsp; task :get_current_ownership <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #ff0000;">&quot;chown #{user}:#{user} #{release_path}&quot;</span><br />
&nbsp; end<br />
<br />
&nbsp; desc <span style="color: #ff0000;">&quot;Take temporary ownership of current folder to allow symlink updates&quot;</span><br />
&nbsp; task :yield_current_ownership <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #ff0000;">&quot;chown -R #{web_user}:#{web_user} #{release_path}&quot;</span><br />
&nbsp; end<br />
<br />
&nbsp; desc <span style="color: #ff0000;">&quot;Change ownership of db folders and files to current user&quot;</span><br />
&nbsp; task :set_permissions_pre_schema_dump, :except =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> :no_release =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">true</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">#chown of files to current user</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #ff0000;">&quot;chown -R #{user}:#{user} #{release_path}/db&quot;</span><br />
&nbsp; end<br />
<br />
&nbsp; desc <span style="color: #ff0000;">&quot;Change ownership of db folders and files to current user&quot;</span><br />
&nbsp; task :set_permissions_post_schema_dump, :except =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> :no_release =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">true</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">#chown of files to current user</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #ff0000;">&quot;chown -R #{web_user}:#{web_user} #{release_path}/db&quot;</span><br />
&nbsp; end<br />
<br />
&nbsp; desc <span style="color: #ff0000;">&quot;Update application.rb to application_controller.rb&quot;</span><br />
&nbsp; task :update_application_controller, :roles =<span style="color: #000000; font-weight: bold;">&gt;</span> :app <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; run <span style="color: #000000; font-weight: bold;">&lt;&lt;</span>-CMD<br />
&nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #666666; font-style: italic;">#{deploy_to}/current/ &amp;&amp; sudo rake rails:update:application_controller</span><br />
&nbsp; &nbsp; CMD<br />
&nbsp; end &nbsp;<br />
&nbsp; task :config, :roles =<span style="color: #000000; font-weight: bold;">&gt;</span> :app <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; run <span style="color: #000000; font-weight: bold;">&lt;&lt;</span>-CMD<br />
&nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-nfs</span> <span style="color: #666666; font-style: italic;">#{shared_path}/system/database.yml #{release_path}/config/database.yml</span><br />
&nbsp; &nbsp; CMD<br />
&nbsp; end<br />
<br />
&nbsp; desc <span style="color: #ff0000;">&quot;Creating symbolic link (custom namespace)&quot;</span><br />
&nbsp; task :symlink, :roles =<span style="color: #000000; font-weight: bold;">&gt;</span> :app <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; run <span style="color: #000000; font-weight: bold;">&lt;&lt;</span>-CMD<br />
&nbsp; &nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-nfs</span> <span style="color: #666666; font-style: italic;">#{shared_path}/system/uploads #{release_path}/public/uploads</span><br />
&nbsp; &nbsp; CMD<br />
&nbsp; end<br />
<br />
end</div></div>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.petermac.com/capistrano-without-root-privileges/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.petermac.com%2Fcapistrano-without-root-privileges%2F&amp;title=Capistrano%20Without%20Root%20Privileges" id="wpa2a_2"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/capistrano-without-root-privileges/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keep your ubuntu server up to date with apt-get</title>
		<link>http://www.petermac.com/keep-your-ubuntu-server-up-to-date-with-apt-get/</link>
		<comments>http://www.petermac.com/keep-your-ubuntu-server-up-to-date-with-apt-get/#comments</comments>
		<pubDate>Fri, 06 Apr 2012 00:15:08 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=629</guid>
		<description><![CDATA[Keeping your Ubuntu server up to date couldn&#8217;t be simpler sudo apt-get update; sudo apt-get upgrade That&#8217;s all folks! Share on Facebook]]></description>
			<content:encoded><![CDATA[<p>Keeping your Ubuntu server up to date couldn&#8217;t be simpler</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get update</span>; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get upgrade</span></div></div>
<p>That&#8217;s all folks!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.petermac.com/keep-your-ubuntu-server-up-to-date-with-apt-get/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.petermac.com%2Fkeep-your-ubuntu-server-up-to-date-with-apt-get%2F&amp;title=Keep%20your%20ubuntu%20server%20up%20to%20date%20with%20apt-get" id="wpa2a_4"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/keep-your-ubuntu-server-up-to-date-with-apt-get/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hey Gerry, Where’s the ‘Add to Cart’ button?</title>
		<link>http://www.petermac.com/hey-gerry-where%e2%80%99s-the-%e2%80%98add-to-cart%e2%80%99-button/</link>
		<comments>http://www.petermac.com/hey-gerry-where%e2%80%99s-the-%e2%80%98add-to-cart%e2%80%99-button/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 22:50:22 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=622</guid>
		<description><![CDATA[I had the pleasure to work on a project for Sausage Software in Melbourne back in 1999. It was called Business In A Box and was designed to enable local retailers put their business online i.e. introduce a catalogue of products with options to the internet. There was no programming involved on the part of [...]]]></description>
			<content:encoded><![CDATA[<p>I had the pleasure to work on a project for Sausage Software in Melbourne back in 1999. It was called Business In A Box and was designed to enable local retailers put their business online i.e. introduce a catalogue of products with options to the internet. There was no programming involved on the part of the retailer. Unfortunately it was a product way ahead of its time.</p>
<p>I can&#8217;t remember the numbers exactly but I think 150 units were sold throughout Australia in spite of a fairly heavy marketing push. I remember thinking at the time &#8220;bricks and mortar&#8230;bricks and mortar&#8221;. Australian shoppers at the time may have been slow to take up online shopping, but the retailers were even slower to spot the trend. I hear the resounding Australian chorus &#8220;She&#8217;ll be right mate!&#8221; on the part of the retailers who didn&#8217;t have to think too hard to turn a buck the way they&#8217;ve been turning a buck for the last 50 years. The cash registers may have changed, the shelf stock systems may have changed but essentially they&#8217;re still selling stuff the way their grandparents sold stuff.</p>
<p>Now, we look at the furore over the last year or so and see the retailers (vocally headed up by Gerry Harvey of Harvey Norman fame) complaining that the market is being skewed by foreign internet retailers selling their wares without charging GST (that’s VAT to some). Fair enough, I feel your pain, my bottom line has been cut by more than 10% for the last ten years by the exporting of IT related work to cheaper economies. Sorry that you feel like the rug’s been pulled from under you. Hang on, I’ll help you out. I’m going to log into your web-site and I’ll order a big 27inch screen. I’ll also pay the GST on my purchase so you don’t feel ripped off.</p>
<p>Hey Gerry, Where’s the ‘Add to Cart’ button?</p>
<p>That’s right there isn’t one. No, you cannot order any product from the Harvey Norman chain through their website (except from their photo center wooohoo!). Is this a retailer run by luddites? Is it run by cost conscious accountants who can’t see an increased bottom line by enabling online sales? Is there a team of people running Gerry’s IT services who are resting on their laurels or haven’t been able to impress on him the importance of installing these new fangled interweb concepts.</p>
<p>As of July 2011 (yep, that’s just this year) there’s a whole media buzz about dear Gerry dipping his toes in the online sales market. He’s not selling the FMCG stuff that his chain is famous for. He’s selling 48bars of soap at a time through another chain with another name (and I’m not going to promote the name here). In the meantime, a visit to the Harvey Norman website shows a total lack of online enablement. I guess I shouldn’t complain, it gives me something to do some price comparisons with and then place my order with Dick Smith’s (and get it delivered to my door).</p>
<p>So, what’s happening in other online businesses? </p>
<p>You can buy a holiday online and you can book a flight online (note the international nature of these businesses).  If Borders had the foresight, they could now be rivalling Amazon.com.  Have you tried booking a movie ticket online lately..or tried to find out what’s  running in Gold Class next month? It&#8217;s a horrific experience.</p>
<p>Apart from a few exceptions, I have the feeling that Australian retailers are letting the side down by either adopting the &#8216;wait and see&#8217; approach to their eCommerce presence or doing the absolute minimum to keep up with their competition. Why is there no ingenuity? If there is some good stuff happening I&#8217;m all ears and willing to include references to this blog. In the mean time Mr Harvey, my unsolicited advice is pull your finger out and get with the 21st century.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.petermac.com/hey-gerry-where%e2%80%99s-the-%e2%80%98add-to-cart%e2%80%99-button/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.petermac.com%2Fhey-gerry-where%25e2%2580%2599s-the-%25e2%2580%2598add-to-cart%25e2%2580%2599-button%2F&amp;title=Hey%20Gerry%2C%20Where%E2%80%99s%20the%20%E2%80%98Add%20to%20Cart%E2%80%99%20button%3F" id="wpa2a_6"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/hey-gerry-where%e2%80%99s-the-%e2%80%98add-to-cart%e2%80%99-button/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing MySQL gem on OSX 10.6</title>
		<link>http://www.petermac.com/installing-mysql-gem-on-osx-10-6/</link>
		<comments>http://www.petermac.com/installing-mysql-gem-on-osx-10-6/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 11:09:03 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=585</guid>
		<description><![CDATA[Hopefully this will be a time saver for anyone else who goes through the following pain. I have a brand spanking new OSX 10.6 installation. I installed mysql 5.5.9-OSX10.6-X86 (because I thought everything was still i386 based&#8230;watch this space!) I installed RVM and installed ruby 1.92 under RVM control. I then do a &#8216;bundle install&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>Hopefully this will be a time saver for anyone else who goes through the following pain.</p>
<p>I have a brand spanking new OSX 10.6 installation.<br />
I installed mysql 5.5.9-OSX10.6-X86 (because I thought everything was still i386 based&#8230;watch this space!)<br />
I installed RVM and installed ruby 1.92 under RVM control.<br />
I then do a &#8216;bundle install&#8217; and it gripes about not having mysql2 gem installed. I do a manual install using the following command.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql2</div></div>
<p>and after a bit of crunching, we get to the following error:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Building native extensions. &nbsp;This could take a while...<br />
ERROR: &nbsp;Error installing mysql2:<br />
&nbsp; &nbsp; ERROR: Failed to build gem native extension.<br />
<br />
1.9.1<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>ruby.h:<span style="color: #000000;">108</span>: error: <span style="color: #c20cb9; font-weight: bold;">size</span> of array ‘ruby_check_sizeof_long’ is negative<br />
<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>peter<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>rubies<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.1<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>ruby.h:<span style="color: #000000;">112</span>: error: <span style="color: #c20cb9; font-weight: bold;">size</span> of array ‘ruby_check_sizeof_voidp’ is negative<br />
In <span style="color: #c20cb9; font-weight: bold;">file</span> included from <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>peter<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>rubies<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.1<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>intern.h:<span style="color: #000000;">29</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>peter<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>rubies<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.1<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>ruby.h:<span style="color: #000000;">1327</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>peter<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>rubies<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.1<span style="color: #000000; font-weight: bold;">/</span>ruby.h:<span style="color: #000000;">32</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from .<span style="color: #000000; font-weight: bold;">/</span>mysql2_ext.h:<span style="color: #000000;">4</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from client.c:<span style="color: #000000;">1</span>:<br />
<span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>peter<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>rubies<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.1<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>st.h:<span style="color: #000000;">69</span>: error: <span style="color: #c20cb9; font-weight: bold;">size</span> of array ‘st_check_for_sizeof_st_index_t’ is negative</div></div>
<h2>The Solution</h2>
<p>Uninstall your MySQL using the commands below</h2>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">*</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>StartupItems<span style="color: #000000; font-weight: bold;">/</span>MySQLCOM<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>PreferencePanes<span style="color: #000000; font-weight: bold;">/</span>My<span style="color: #000000; font-weight: bold;">*</span><br />
edit <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hostconfig and remove the line <span style="color: #007800;">MYSQLCOM</span>=-YES-<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Receipts<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">*</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Receipts<span style="color: #000000; font-weight: bold;">/</span>MySQL<span style="color: #000000; font-weight: bold;">*</span></div></div>
<p>Now go and download the 64 bit version of the MySQL package &#8211; get the dmg rather than the gzip file.</p>
<p>The rationale behind this is that your new beaut 10.6 is actually referencing 64 bit modules by default. How to prove this I do not know &#8211; I&#8217;m confused and still searching for the answer. If I do a uname &#8211; a I get&#8230;</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Darwin MacBook-Air.local 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov <span style="color: #000000;">10</span> <span style="color: #000000;">18</span>:<span style="color: #000000;">13</span>:<span style="color: #000000;">17</span> PST <span style="color: #000000;">2010</span>; root:xnu-1504.9.26~<span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span>RELEASE_I386 i386</div></div>
<p>Now, if I&#8217;m not mistaken that&#8217;s an i386 at the end &#8211; go figure. If anyone has any further insights please let me know.</p>
<p>The next step is to download the gem for your ruby/rails use</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">ARCHFLAGS</span>=<span style="color: #ff0000;">&quot;-arch x86_64&quot;</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql <span style="color: #660033;">--</span> \<br />
&nbsp; <span style="color: #660033;">--with-mysql-dir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql <span style="color: #660033;">--with-mysql-lib</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>lib \<br />
&nbsp; <span style="color: #660033;">--with-mysql-include</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>include</div></div>
<p>The next error encountered is when I try to start the rails server using &#8216;rails s&#8217;</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>peter<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>mysql2-0.2.6<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql2.rb:<span style="color: #000000;">7</span>:in <span style="color: #000000; font-weight: bold;">`</span>require<span style="color: #ff0000;">': dlopen(/Users/peter/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib (LoadError)</span></div></div>
<p>The answer to this problem is to run the following command&#8230;</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> install_name_tool <span style="color: #660033;">-change</span> libmysqlclient.16.dylib <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>libmysqlclient.16.dylib ~<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>mysql2-0.2.6<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql2<span style="color: #000000; font-weight: bold;">/</span>mysql2.bundle<span style="color: #000000; font-weight: bold;">/</span></div></div>
<p>Bear in mind, I&#8217;m running version 1.9.2-p180 fo ruby &#8211; you will need to change the command for whatever version you&#8217;re running.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.petermac.com/installing-mysql-gem-on-osx-10-6/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.petermac.com%2Finstalling-mysql-gem-on-osx-10-6%2F&amp;title=Installing%20MySQL%20gem%20on%20OSX%2010.6" id="wpa2a_8"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/installing-mysql-gem-on-osx-10-6/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Recovering the root password</title>
		<link>http://www.petermac.com/recovering-the-root-password/</link>
		<comments>http://www.petermac.com/recovering-the-root-password/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 08:59:22 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=13</guid>
		<description><![CDATA[A client who shall remain nameless recently required the installation of some spam filtering software (spamassassin) on their linux mail server. Not a problem I thought. &#8220;All I need is root access&#8221; I said. &#8220;Huh&#8221; he said. Turns out the their system administrator of 5 years had left to go travelling around Europe and no-one [...]]]></description>
			<content:encoded><![CDATA[<p>A client who shall remain nameless recently required the installation of some spam filtering software (spamassassin) on their linux mail server. Not a problem I thought. &#8220;All I need is root access&#8221; I said. &#8220;Huh&#8221; he said. Turns out the their system administrator of 5 years had left to go travelling around Europe and no-one could remember where he left the folder with all the system documentation.  No root password, no history of what was installed when, no history of custom configuration changes. Nichts, Nada!</p>
<p>Question: How to get root access to a machine without the root password.</p>
<p>1. Reboot and select the grub &#8216;recovery&#8217; option &#8211; you can get to this from the boot menu or if you have a linux box with a single boot option, hold down the shift key during boot (occasionally the escape key works &#8211; watch the messages during the boot sequence).</p>
<p>2. The next screen to display will present you with a couple of sub-options. You need to select the &#8216;Drop to root shell prompt&#8217;.</p>
<p>3. You should now be presented with a prompt sign. Now&#8217;s your chance to reset the password for the appropriate user.  Enter passwd [username] where [username] is the name of the &#8230;you get the drift.</p>
<p>4. Next enter the new password and buy a 15ft billboard ad to display across the road from your client&#8217;s site. Of course the ad will display the encrypted version of the password:)</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.petermac.com/recovering-the-root-password/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.petermac.com%2Frecovering-the-root-password%2F&amp;title=Recovering%20the%20root%20password" id="wpa2a_10"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/recovering-the-root-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joomla out of memory error with exception.php</title>
		<link>http://www.petermac.com/joomla-out-of-memory-error-with-exception-php/</link>
		<comments>http://www.petermac.com/joomla-out-of-memory-error-with-exception-php/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 03:31:44 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=577</guid>
		<description><![CDATA[I&#8217;ve just suffered a strange out of memory exception with one of my Joomla sites. All the posts I read indicated that I needed to allocate more memory in my php configuration &#8211; crazy I thought &#8211; I already had 64MB allocated. There must be something more fundamentally wrong for this nasty gremlin to be [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just suffered a strange out of memory exception with one of my Joomla sites. All the posts I read indicated that I needed to allocate more memory in my php configuration &#8211; crazy I thought &#8211; I already had 64MB allocated. There must be something more fundamentally wrong for this nasty gremlin to be happening. The actual error is&#8211; </p>
<p>Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 40 bytes) in /home/site/public_html/libraries/joomla/error/exception.php on line 117</p>
<p>What I did (thanks to a couple of fragmented suggestions is change the line on 117 to the following</p>
<p>$this->backtrace = debug_print_backtrace();</p>
<p>Then re-render the site and you should see your browser fill with tons of crap. Hit the stop button after a second or two (before your browser crashes) and you should be able to see the root cause of your issue. For me it was a corruption of my jos_session table which I was able to fix with a truncate jos_session; command from the mysql command line.</p>
<p>I hope this note may save someone else a couple of hours of messing around with their memory settings.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.petermac.com/joomla-out-of-memory-error-with-exception-php/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.petermac.com%2Fjoomla-out-of-memory-error-with-exception-php%2F&amp;title=Joomla%20out%20of%20memory%20error%20with%20exception.php" id="wpa2a_12"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/joomla-out-of-memory-error-with-exception-php/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Setup Git Local and Remote Repositories</title>
		<link>http://www.petermac.com/setup-git-local-and-remote-repositories/</link>
		<comments>http://www.petermac.com/setup-git-local-and-remote-repositories/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 20:19:38 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=562</guid>
		<description><![CDATA[If you are a remote worker or, like me get some work done on the train on the way to/from your office, you&#8217;ll appreciate the need for set up of a local and remote source code repository, This allows you to develop using your laptop/netbook, check in your changes locally and when you arrive at [...]]]></description>
			<content:encoded><![CDATA[<p>If you are a remote worker or, like me get some work done on the train on the way to/from your office, you&#8217;ll appreciate the need for set up of a local and remote source code repository, This allows you to develop using your laptop/netbook, check in your changes locally and when you arrive at the mothership later, you can synchronise your local repository with the remote one ensuring all your changes are available for other developers. This article shows how to set up git for both a mothership type repository (let&#8217;s call it the remote repository) and a local version on your own laptop.</p>
<h2>Configuring Git project on the mothership.</h2>
<p>Prerequisites:</p>
<p>A Git server (the mothership) has been set up on a box called bluelight. This box is available to the network as git.petermac.com.</p>
<p>A git user has been created on the server called &#8216;git&#8217;. This user has access to the folder where the git repositories are stored.</p>
<p>The Steps:</p>
<p>1.On your dev machine create your code project using whatever tools you need.</p>
<p>2.Initialise this working project under the git version control system</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>projects<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>myprojectname<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
$ <span style="color: #c20cb9; font-weight: bold;">git init</span><br />
peter<span style="color: #000000; font-weight: bold;">@</span>peter-desktop:~<span style="color: #000000; font-weight: bold;">/</span>Projects<span style="color: #000000; font-weight: bold;">/</span>rentmanager$ <span style="color: #c20cb9; font-weight: bold;">git init</span><br />
Initialized empty Git repository <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>peter<span style="color: #000000; font-weight: bold;">/</span>Projects<span style="color: #000000; font-weight: bold;">/</span>rentmanager<span style="color: #000000; font-weight: bold;">/</span>.git<span style="color: #000000; font-weight: bold;">/</span></div></div>
<p>3.Add whatever work you&#8217;ve done to the repository</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">git add</span> app<span style="color: #000000; font-weight: bold;">/</span><br />
$ <span style="color: #c20cb9; font-weight: bold;">git add</span> docs<span style="color: #000000; font-weight: bold;">/</span></div></div>
<p>4.Check the files you want added have been added</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">git status</span><br />
<span style="color: #666666; font-style: italic;"># On branch master</span><br />
<span style="color: #666666; font-style: italic;"># Initial commit</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># Changes to be committed:</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; (use &quot;git rm --cached ...&quot; to unstage)</span><br />
<span style="color: #666666; font-style: italic;">#</span><br />
<span style="color: #666666; font-style: italic;"># &nbsp; &nbsp;new file: app/rentmanager/,</span><br />
<span style="color: #666666; font-style: italic;">#</span></div></div>
<p>5.Open a SSH session to bluelight – (the central git repository server)</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>gitrepos<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>myprojectname<span style="color: #7a0874; font-weight: bold;">&#93;</span>.git</div></div>
<p>6.Obviously substitute your real projectname and don&#8217;t forget to leave the .git extenstion</p>
<p>7.Initialise the repository under the new folder</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">$cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>gitrepos<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>myprojectname<span style="color: #7a0874; font-weight: bold;">&#93;</span>.git<br />
<br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span>peter<span style="color: #000000; font-weight: bold;">@</span>bluelight myprojectname.git<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">git init</span><br />
Initialized empty Git repository <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>gitrepos<span style="color: #000000; font-weight: bold;">/</span>myprojectname.git<span style="color: #000000; font-weight: bold;">/</span>.git<span style="color: #000000; font-weight: bold;">/</span></div></div>
<p>8.Change ownership of the repository to the system git user</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$</span><span style="color: #7a0874; font-weight: bold;">cd</span> ..; <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> git.git <span style="color: #660033;">-R</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>gitrepos<span style="color: #000000; font-weight: bold;">/</span>myprojectname.git</div></div>
<h2>Configure git on your laptop to use the remote repository</h2>
<p>1. Return back to the local machine and add reference to the new &#8216;remote&#8217; repository from the base directory of the project.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">git remote</span> add remote ssh:<span style="color: #000000; font-weight: bold;">//</span><span style="color: #c20cb9; font-weight: bold;">git</span> at git.petermac.com<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>gitrepos<span style="color: #000000; font-weight: bold;">/</span>myprojectname<span style="color: #7a0874; font-weight: bold;">&#93;</span>.git</div></div>
<p>2. Here the &#8216;git remote add&#8217; part says add a reference to a remote repository. The second &#8216;remote&#8217; is the friendly name I want to use when referring to the repository on the git server</p>
<p>3. Now commit the local files to the local repository – Note: Step 3 was only an add, not a commit.  When you commit you&#8217;ll be prompted (or you can enter it as a -m option) to enter a message to be used as a comment.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">peter<span style="color: #000000; font-weight: bold;">@</span>peter-desktop:~<span style="color: #000000; font-weight: bold;">/</span>Projects<span style="color: #000000; font-weight: bold;">/</span>myprojectname$ <span style="color: #c20cb9; font-weight: bold;">git commit</span><br />
Created initial commit 633fd3c: initial checkin of project core and data migration files</div></div>
<p>4. It&#8217;s time to test the new remote repository by &#8216;pushing your local repository info up to it. This is done using git push</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">peter<span style="color: #000000; font-weight: bold;">@</span>peter-desktop:~<span style="color: #000000; font-weight: bold;">/</span>Projects<span style="color: #000000; font-weight: bold;">/</span>myprojectname$ <span style="color: #c20cb9; font-weight: bold;">git push</span> –dry-run –all <span style="color: #660033;">--repo</span>=remote<br />
fatal: <span style="color: #ff0000;">'origin'</span>: unable to chdir or not a <span style="color: #c20cb9; font-weight: bold;">git archive</span><br />
fatal: The remote end hung up unexpectedly</div></div>
<p>Didn&#8217;t quite go to plan – so let&#8217;s see what&#8217;s wrong</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">peter<span style="color: #000000; font-weight: bold;">@</span>peter-desktop:~<span style="color: #000000; font-weight: bold;">/</span>Projects<span style="color: #000000; font-weight: bold;">/</span>myprojectname$ <span style="color: #c20cb9; font-weight: bold;">git remote</span> show remote<br />
The authenticity of host <span style="color: #ff0000;">'git.petermac.com (192.168.0.15)'</span> can<span style="color: #ff0000;">'t be established.<br />
RSA key fingerprint is 5a:ce:6e:a4:78:d5:01:50:36:2b:bb:12:67:e1:be:53.<br />
Are you sure you want to continue connecting (yes/no)? yes<br />
Warning: Permanently added '</span>git.petermac.com<span style="color: #ff0000;">' (RSA) to the list of known hosts.<br />
git at git.petermac.com'</span>s password:<br />
<span style="color: #000000; font-weight: bold;">*</span> remote remote<br />
URL: ssh:<span style="color: #000000; font-weight: bold;">//</span><span style="color: #c20cb9; font-weight: bold;">git</span> at git.petermac.com<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>gitrepos<span style="color: #000000; font-weight: bold;">/</span>myprojectname.git</div></div>
<p>let&#8217;s try again</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">git push</span> –dry-run –all –<span style="color: #007800;">repo</span>=remote<br />
<span style="color: #c20cb9; font-weight: bold;">git</span> at git.petermac.com<span style="color: #ff0000;">'s password:<br />
To ssh://git at git.petermac.com/usr/local/share/gitrepos/myprojectname.git<br />
[new branch] &nbsp; &nbsp; &nbsp;master -&amp;gt; master</span></div></div>
<p>looks like it will work so remove the dry-run parameter</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">git push</span> –all –<span style="color: #007800;">repo</span>=remote</div></div>
<p>That&#8217;s all folks!</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.petermac.com/setup-git-local-and-remote-repositories/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.petermac.com%2Fsetup-git-local-and-remote-repositories%2F&amp;title=Setup%20Git%20Local%20and%20Remote%20Repositories" id="wpa2a_14"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/setup-git-local-and-remote-repositories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>msi wind u100, ubuntu and wireless grrrr!</title>
		<link>http://www.petermac.com/msi-wind-u100-ubuntu-and-wireless-grrrr/</link>
		<comments>http://www.petermac.com/msi-wind-u100-ubuntu-and-wireless-grrrr/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 21:56:19 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=557</guid>
		<description><![CDATA[Up until earlier this week, I had my lovely little netbook working nicely with Ubuntu 8.04 and a 90% satisfaction rate with the network manager utility. I could connect to my home network, office network and with abit of hassle, other free wifi spots. I started to get a message that my version of ubuntu [...]]]></description>
			<content:encoded><![CDATA[<p>Up until earlier this week, I had my lovely little netbook working nicely with Ubuntu 8.04 and a 90% satisfaction rate with the network manager utility. I could connect to my home network, office network and with abit of hassle, other free wifi spots. I started to get a message that my version of ubuntu was now unsupported, so I thought I&#8217;d set about upgrading to 10.04 (maybe 10.10 if I had the time). </p>
<p>I chose the default upgrade process using the system update options progressively moving from 8.04 to 9.04, 9.10 and finally settling on 10.04.  I did all the upgrading with a hard-wired ethernet cable.</p>
<p>Bang!! unplugged the network cable and moved to the comfort of my living room to finish some minor tweaks. No wireless network connectivity. I thought network manager may have been giving me hell and I heard some good stories about wicd (which I have running with 100% success on my laptop).</p>
<p>Here comes a lesson&#8230;are you paying attention?  I decided to uninstall network manager and install wicd (in that order). Doh!! Ok, now I have an unconnected netbook with no wireless and ethernet connectivity and I&#8217;ve spent the last two mornings on the way to work on the train trying to patch the system with uploads from a usb stick. No fun, no glory. </p>
<p>What I&#8217;m going to have to do is burn 10.04 to a bootable memory stick and do a re-install from scratch. Then I&#8217;m going to have to pray I can fix the original issue with wireless card. It&#8217;s an RA2860 and there&#8217;s bundles of articles in discussion forums regarding it&#8217;s incompatibility with Linux distros.  Here&#8217;s praying I don&#8217;t have to install XP to get my work done on the train.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.petermac.com/msi-wind-u100-ubuntu-and-wireless-grrrr/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.petermac.com%2Fmsi-wind-u100-ubuntu-and-wireless-grrrr%2F&amp;title=msi%20wind%20u100%2C%20ubuntu%20and%20wireless%20grrrr%21" id="wpa2a_16"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/msi-wind-u100-ubuntu-and-wireless-grrrr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 3, jQuery and multiselect dependencies part 2.</title>
		<link>http://www.petermac.com/rails-3-jquery-and-multiselect-dependencies-part-2/</link>
		<comments>http://www.petermac.com/rails-3-jquery-and-multiselect-dependencies-part-2/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 01:16:09 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=512</guid>
		<description><![CDATA[This article is a follow up to another article on this website which focuses on using jQuery to manage the processing of multiple inter-dependent select lists on a single web page. I had a number of requests to explain the data model in a bit more detail so here goes. I have worked on a [...]]]></description>
			<content:encoded><![CDATA[<p>This article is a follow up to <a href="http://www.petermac.com/rails-3-jquery-and-multi-select-dependencies/">another article</a> on this website which focuses on using jQuery to manage the processing of multiple inter-dependent select lists on a single web page. I had a number of requests to explain the data model in a bit more detail so here goes.</p>
<p>I have worked on a number of internationalised (in the US, that&#8217;s spelt internationalized) applications where the selection of a &#8216;home country&#8217; by a user means the display of their address fields should change to reflect their selection of a country. I&#8217;ve used this example as the basis of the multi-select article.</p>
<h3>MySQL Data Structure</h3>
<p>The relevant tables are in a MySQL database and are as follows:</p>
<ul>
<li>locales</li>
<li>countries</li>
<li>countrynames</li>
<li>regionnames</li>
<li>regions</li>
<li>cities</li>
<li>citynames</li>
<li>users</li>
</ul>
<p>The structure of each of the tables is as follows. Note, this is by no means a strict design criteria for your tables, it&#8217;s just a design decision that I made because it made sense to me and my warped view of the world.</p>
<p>The locales table contains a listing of a possible 29 locales that can be used to tailor how your application displays and interprets data</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> desc locales;<br />
+----------+-------------+------+-----+---------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> Field &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Type &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Null <span style="color: #000000; font-weight: bold;">|</span> Key <span style="color: #000000; font-weight: bold;">|</span> Default <span style="color: #000000; font-weight: bold;">|</span> Extra <span style="color: #000000; font-weight: bold;">|</span><br />
+----------+-------------+------+-----+---------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">id</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> YES &nbsp;<span style="color: #000000; font-weight: bold;">|</span> UNI <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> locale &nbsp; <span style="color: #000000; font-weight: bold;">|</span> char<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> PRI <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> name &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">60</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> fullname <span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">60</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
+----------+-------------+------+-----+---------+-------+</div></div>
<p>The countries table contains core country information including their names in English, their international code and their latitude and longitude.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> desc countries;<br />
+-----------+-------------+------+-----+---------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> Field &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> Type &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Null <span style="color: #000000; font-weight: bold;">|</span> Key <span style="color: #000000; font-weight: bold;">|</span> Default <span style="color: #000000; font-weight: bold;">|</span> Extra <span style="color: #000000; font-weight: bold;">|</span><br />
+-----------+-------------+------+-----+---------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">id</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> YES &nbsp;<span style="color: #000000; font-weight: bold;">|</span> UNI <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> code &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> char<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> PRI <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> code3 &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> char<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> YES &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> numcode &nbsp; <span style="color: #000000; font-weight: bold;">|</span> smallint<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> YES &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> url &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">50</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> MUL <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> name &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">50</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> UNI <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> latitude &nbsp;<span style="color: #000000; font-weight: bold;">|</span> double &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> longitude <span style="color: #000000; font-weight: bold;">|</span> double &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
+-----------+-------------+------+-----+---------+-------+</div></div>
<p>The countrynames table contains the names of countries as it is interpreted in each locale. For example the country Andorra is the same in most locales &#8216;Andorra&#8217; but in Russian it is &#8216;Андорра&#8217;.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> desc countrynames;<br />
+------------+-------------+------+-----+---------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> Field &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Type &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Null <span style="color: #000000; font-weight: bold;">|</span> Key <span style="color: #000000; font-weight: bold;">|</span> Default <span style="color: #000000; font-weight: bold;">|</span> Extra <span style="color: #000000; font-weight: bold;">|</span><br />
+------------+-------------+------+-----+---------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">id</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> YES &nbsp;<span style="color: #000000; font-weight: bold;">|</span> UNI <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> country_id <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> locale_id &nbsp;<span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> YES &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> name &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">60</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> fullname &nbsp; <span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">60</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
+------------+-------------+------+-----+---------+-------+</div></div>
<p>Now we&#8217;re into the messy bit. If you live in the United States, well it&#8217;s like it says on the box&#8230;it&#8217;s united &#8216;States&#8217;; however if you live in the United Kingdom it&#8217;s all about counties. If like me you live in Australia, we have both States and Territories (it&#8217;s a long story..look up the difference on google). Regardless of the type of country divisions, the name I&#8217;ve used is &#8216;Region&#8217;.</p>
<p>The regions table defines the region names within countries.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> desc regions;<br />
+------------+-----------------+------+-----+---------+----------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> Field &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Null <span style="color: #000000; font-weight: bold;">|</span> Key <span style="color: #000000; font-weight: bold;">|</span> Default <span style="color: #000000; font-weight: bold;">|</span> Extra &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
+------------+-----------------+------+-----+---------+----------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">id</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> unsigned <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> PRI <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> auto_increment <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> country_id <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> YES &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> code &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> char<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> url &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">50</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> name &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">50</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> latitude &nbsp; <span style="color: #000000; font-weight: bold;">|</span> double &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> longitude &nbsp;<span style="color: #000000; font-weight: bold;">|</span> double &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
+------------+-----------------+------+-----+---------+----------------+</div></div>
<p>The localised version of the regions table is regionnames.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> desc regionnames;<br />
+-----------+-------------+------+-----+---------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> Field &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> Type &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Null <span style="color: #000000; font-weight: bold;">|</span> Key <span style="color: #000000; font-weight: bold;">|</span> Default <span style="color: #000000; font-weight: bold;">|</span> Extra <span style="color: #000000; font-weight: bold;">|</span><br />
+-----------+-------------+------+-----+---------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">id</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> PRI <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">0</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> region_id <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> locale_id <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> name &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">60</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> fullname &nbsp;<span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">60</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
+-----------+-------------+------+-----+---------+-------+</div></div>
<p>Next is the cities within the regions and their localised versions. These use the tables &#8216;cities&#8217; and &#8216;citynames&#8217; respectively. You can see the foreign key link to the country and region tables below.</p>
<p>The cities table</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> desc cities;<br />
+------------+-----------------+------+-----+---------+----------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> Field &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Null <span style="color: #000000; font-weight: bold;">|</span> Key <span style="color: #000000; font-weight: bold;">|</span> Default <span style="color: #000000; font-weight: bold;">|</span> Extra &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
+------------+-----------------+------+-----+---------+----------------+<br />
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">id</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> unsigned <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> PRI <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> auto_increment <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> country_id <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> region_id &nbsp;<span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> YES &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> url &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">50</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> name &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">50</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> latitude &nbsp; <span style="color: #000000; font-weight: bold;">|</span> double &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> longitude &nbsp;<span style="color: #000000; font-weight: bold;">|</span> double &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span><br />
+------------+-----------------+------+-----+---------+----------------+</div></div>
<p>The citynames table holds the localised version of city names.</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mysql<span style="color: #000000; font-weight: bold;">&gt;</span> desc citynames;<br />
+-----------+-------------+------+-----+---------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> Field &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> Type &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> Null <span style="color: #000000; font-weight: bold;">|</span> Key <span style="color: #000000; font-weight: bold;">|</span> Default <span style="color: #000000; font-weight: bold;">|</span> Extra <span style="color: #000000; font-weight: bold;">|</span><br />
+-----------+-------------+------+-----+---------+-------+<br />
<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">id</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> YES &nbsp;<span style="color: #000000; font-weight: bold;">|</span> UNI <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> city_id &nbsp; <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> locale_id <span style="color: #000000; font-weight: bold;">|</span> int<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> YES &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> name &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">60</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
<span style="color: #000000; font-weight: bold;">|</span> fullname &nbsp;<span style="color: #000000; font-weight: bold;">|</span> varchar<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">60</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> NO &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span> NULL &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">|</span><br />
+-----------+-------------+------+-----+---------+-------+</div></div>
<p>There are other tables in the system including a users&#8217; table with a locale_id which the user sets by selecting from a drop-down list on their profile-page. I haven&#8217;t included that table her because there&#8217;s also a bundle of application specific stuff in there too.</p>
<h3>The Rails Schema</h3>
<p>Now, like all good rails developers, you&#8217;re using schema migrations. If you&#8217;re not, go stand in the corner for twenty minutes and think about spending the same twenty minutes every week wasted looking at the conjoin between two walls. Rails database migrations are the way to go. They take a little bit of getting used to but well worth it to keep all your team on the same page, or if you&#8217;re doing your bit as a solo programmer it means you can screw it up and rewind to the last working version with ease.</p>
<p>As an example, I&#8217;ll show you how to create a new schema file for the cities entity. I&#8217;ll leave the remaining entities for your own interpretation.</p>
<p>In Rails 2, you&#8217;d use the following line</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>ruby script<span style="color: #000000; font-weight: bold;">/</span>generate migration create_cities</div></div>
<p>In Rails 3, it&#8217;s more DRY</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>rails g migration create_cities</div></div>
<p>This will create a new file in you db/migrate folder ending in &#8216;create cities.rb&#8217;. Edit this accordingly and add the fields to the migration that reflect the structure of the table we want to create. My version looks like the following:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> CreateCities <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Migration</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span><br />
&nbsp; &nbsp; create_table <span style="color:#ff3333; font-weight:bold;">:cities</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>t<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#CC0066; font-weight:bold;">integer</span> <span style="color:#ff3333; font-weight:bold;">:country_id</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#CC0066; font-weight:bold;">integer</span> <span style="color:#ff3333; font-weight:bold;">:region_id</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#CC0066; font-weight:bold;">string</span> <span style="color:#ff3333; font-weight:bold;">:url</span>, <span style="color:#ff3333; font-weight:bold;">:limit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">50</span>, &nbsp;<span style="color:#ff3333; font-weight:bold;">:default</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;&quot;</span>, &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:null</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#CC0066; font-weight:bold;">string</span> <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#ff3333; font-weight:bold;">:limit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">50</span>, &nbsp;<span style="color:#ff3333; font-weight:bold;">:default</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;&quot;</span>, &nbsp; &nbsp;<span style="color:#ff3333; font-weight:bold;">:null</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#CC0066; font-weight:bold;">float</span> <span style="color:#ff3333; font-weight:bold;">:latitude</span><br />
&nbsp; &nbsp; &nbsp; t.<span style="color:#CC0066; font-weight:bold;">float</span> <span style="color:#ff3333; font-weight:bold;">:longitude</span><br />
&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span><br />
&nbsp; &nbsp; drop_table <span style="color:#ff3333; font-weight:bold;">:cities</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<h2>The Models</h2>
<p>In the root of your application, create the necessary models. Under Rails 3, that can be done by entering</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>rails g model city</div></div>
<p>A new file is generated under the app/models folder called city.rb.</p>
<p>The full listing of my models folder is as follows:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">locale.rb &nbsp; <br />
city.rb<br />
country.rb<br />
region.rb<br />
cityname.rb<br />
countryname.rb<br />
regionname.rb &nbsp;<br />
profile.rb<br />
user.rb<br />
role.rb<br />
admin.rb</div></div>
<p>For the purposes of this discussion we&#8217;re interested in everything but the last 4 files. These are used to store user permissions, roles, and profile data.</p>
<p>The content of the relevant model files is used to implement the relationships between the different entities and some field level validation rules. There is nothing whiz-bang about this, just the use of the Rails convention over configuration principle at work.</p>
<p>Taking it from the top, my files look like the following:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>app<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>locale.rb</div></div>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> Locale <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span><br />
&nbsp; validates_presence_of <span style="color:#ff3333; font-weight:bold;">:name</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>app<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>city.rb</div></div>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> City <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span><br />
&nbsp; validates_presence_of <span style="color:#ff3333; font-weight:bold;">:name</span><br />
<br />
&nbsp; belongs_to <span style="color:#ff3333; font-weight:bold;">:country</span><br />
&nbsp; has_many <span style="color:#ff3333; font-weight:bold;">:citynames</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>app<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>country.rb</div></div>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> Country <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span><br />
&nbsp; validates_presence_of <span style="color:#ff3333; font-weight:bold;">:name</span><br />
&nbsp; validates_presence_of <span style="color:#ff3333; font-weight:bold;">:code</span><br />
<br />
&nbsp; has_many <span style="color:#ff3333; font-weight:bold;">:regions</span><br />
&nbsp; has_many <span style="color:#ff3333; font-weight:bold;">:citys</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>app<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>region.rb</div></div>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> Region <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span><br />
&nbsp; validates_presence_of <span style="color:#ff3333; font-weight:bold;">:name</span><br />
<br />
&nbsp; belongs_to <span style="color:#ff3333; font-weight:bold;">:country</span><br />
&nbsp; has_many <span style="color:#ff3333; font-weight:bold;">:regionnames</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>app<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>cityname.rb</div></div>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> Cityname <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span><br />
&nbsp; belongs_to:city<br />
&nbsp; belongs_to:locale<br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>app<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>countryname.rb</div></div>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> Countryname <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span><br />
&nbsp; belongs_to <span style="color:#ff3333; font-weight:bold;">:country</span><br />
&nbsp; belongs_to <span style="color:#ff3333; font-weight:bold;">:locale</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>app<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>regionname.rb</div></div>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> Regionname <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span><br />
&nbsp; belongs_to <span style="color:#ff3333; font-weight:bold;">:region</span><br />
&nbsp; belongs_to <span style="color:#ff3333; font-weight:bold;">:locale</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>So, there you have it, fairly simple really, a couple of tables, a couple of model files and the material from this article and the previous article should have you up and running. As always, any queries, comments or improvements, please let me know.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.petermac.com/rails-3-jquery-and-multiselect-dependencies-part-2/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.petermac.com%2Frails-3-jquery-and-multiselect-dependencies-part-2%2F&amp;title=Rails%203%2C%20jQuery%20and%20multiselect%20dependencies%20part%202." id="wpa2a_18"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/rails-3-jquery-and-multiselect-dependencies-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Do you own your software?</title>
		<link>http://www.petermac.com/do-you-own-your-software/</link>
		<comments>http://www.petermac.com/do-you-own-your-software/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 05:39:15 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=498</guid>
		<description><![CDATA[Being a freelance programmer, I like to hack programs or more correctly I like to be able to hack programs. If I can&#8217;t get access to the code and change things to work just the way I want I feel like I&#8217;ve been restrained. I used to accept this feeling of restraint as a simple [...]]]></description>
			<content:encoded><![CDATA[<p>Being a freelance programmer, I like to hack programs or more correctly I like to be able to hack programs. If I can&#8217;t get access to the code and change things to work just the way I want I feel like I&#8217;ve been restrained. I used to accept this feeling of restraint as a simple fact of life but the more I&#8217;ve seen, the more I&#8217;ve started to question it. I&#8217;m now at the stage where as a matter of principle I won&#8217;t use software if I can&#8217;t hack it and I&#8217;ll try to find an equivalent piece of software that gives me the freedoms I want. </p>
<p>I use lots of Open Source software where I have access to code, I can modify the code and copy any changes to friends. This is almost good enough, but there&#8217;s something missing. The problem with Open Source is that it can be comprised of non open source software i.e. proprietary libraries and no access to code and $29 license fees. If you&#8217;ve ever played with Joomla or Drupal, you know what I mean. While all the code to each CMS is open source, programmers are free to build proprietary add-ons and not release them under a GPL license. </p>
<p>So, although Open Source is a great concept, it doesn&#8217;t go far enough by insisting that everyone plays by the same rules. This brings me to the whole point of this post. Who owns your software? If you own it, you can do what you want with it, including changing it, copying it to your friends, letting your friends change it and letting them share it with their friends. If your software is free from the restraints of use, copying, modifying and distribution at a basic level you benefit from the community that feeds back improvements to that software. If you want to change the way a piece of free software works, you can hire anybody who knows how to code in the appropriate language. You don&#8217;t have to go to vendor X and check before-hand if you&#8217;ve paid your annual maintenance fees.</p>
<p>As a programmer, building software systems, I will get asked by clients to build custom systems that suit their business needs. I generally have to sign a confidentiality agreement and sign over the intellectual property rights to that customer. Fair enough, they have the code and they can get in any other programmer later on to tweak anything that I&#8217;ve done. Very often the code is specific to the client&#8217;s business purposes, but being a smart programmer, copy and paste are my favourite commands so I tend to liberate code from other programmers around the planet. This makes my job easier, quicker and usually provides a good source of sanity checking for my thought process (somebody else had the same problem to solve in the past).</p>
<p>It&#8217;s interesting to note the arrival of LibreOffice, a breakaway effort from OpenOffice. When Oracle swallowed up Sun Microsystems, the OpenOffice effort was kept alive by the benevolence of Oracle, but all was not well. As a result of proprietary machinations on Oracle management&#8217;s part, the development team took the code and ran, all the way across the road to a new garage and kept the effort moving under a completely free software banner. </p>
<p>Anyways, it&#8217;s food for thought. Check the license and make sure you&#8217;re getting what you&#8217;re not paying for.</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.petermac.com/do-you-own-your-software/" target="_blank" title="Share on Facebook">Share on Facebook</a></p><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.petermac.com%2Fdo-you-own-your-software%2F&amp;title=Do%20you%20own%20your%20software%3F" id="wpa2a_20"><img src="http://www.petermac.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.petermac.com/do-you-own-your-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

