<?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&#187; Uncategorized</title>
	<atom:link href="http://www.petermac.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.petermac.com</link>
	<description>Australian freelance programmer and website design</description>
	<lastBuildDate>Thu, 17 Nov 2011 22:50:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<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>:<span style="color: #000000; font-weight: bold;">in</span> <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><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_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/installing-mysql-gem-on-osx-10-6/feed/</wfw:commentRss>
		<slash:comments>2</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>
		<category><![CDATA[Uncategorized]]></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</span> init<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</span> init<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</span> add app<span style="color: #000000; font-weight: bold;">/</span><br />
$ <span style="color: #c20cb9; font-weight: bold;">git</span> add 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</span> status<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: #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</span> init<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: #007800;">$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: #c20cb9; font-weight: bold;">git</span> remote add remote <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<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</span> commit<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</span> push –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</span> archive<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</span> remote 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: <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<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</span> push –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: #c20cb9; font-weight: bold;">git</span> push –all –<span style="color: #007800;">repo</span>=remote</div></div>
<p>That&#8217;s all folks!</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_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/setup-git-local-and-remote-repositories/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[Uncategorized]]></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">$ 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">$ 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">$ 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">$ 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">$ 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">$ 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">$ 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">$ 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">$ 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">$ 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><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_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/rails-3-jquery-and-multiselect-dependencies-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Scaling images in batch mode</title>
		<link>http://www.petermac.com/scaling-images-in-batch-mode/</link>
		<comments>http://www.petermac.com/scaling-images-in-batch-mode/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 07:23:15 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=502</guid>
		<description><![CDATA[I have lots of folders with images uploaded from digital cameras. Average image size is 3MB which is way too large for uploading to web based image sites. What I need to do is to rescale the images but doing them one at a time is a pain so I wrote a little script to [...]]]></description>
			<content:encoded><![CDATA[<p>I have lots of folders with images uploaded from digital cameras. Average image size is 3MB which is way too large for uploading to web based image sites. What I need to do is to rescale the images but doing them one at a time is a pain so I wrote a little script to do them one folder at a time.</p>
<p>The script makes use of a program called &#8216;convert&#8217;. This is part of the ImageMagick suite of tools.</p>
<p>Install ImageMagick</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</span> <span style="color: #c20cb9; font-weight: bold;">install</span> imagemagick</div></div>
<p>Once installed try to verify the location of the convert program</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;">which</span> convert<br />
convert is <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>convert</div></div>
<p>The way the script works is to create a new folder called &#8216;resized&#8217; under the folder you want to process. It then places rescaled versions of the images it finds in the source folder.</p>
<p>The scaling is performed by passing a width x height parameter to the convert program. The question is how do you know what value to provide without screwing up the ratio of your image. What I do is open a sample image in Gimp. Go to the &#8216;Image|Scale&#8217; menu option. I pick a value for the width, hit tab and it provides you with the correct value for the height. This is fine if all your images are of the same size. You&#8217;ll have to put in a bit of work if they are different sizes.</p>
<p>Here&#8217;s the script..it&#8217;s really simple as you can see, but I had an itch and I had to scratch it.</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;">#!/bin/bash</span><br />
<br />
<span style="color: #007800;">convert_command</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>convert<br />
<span style="color: #666666; font-style: italic;">#get the folder name to be procesed</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Error in $0 - Invalid number of arguments.&quot;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Syntax: $0 &lt;folder name&gt; &lt;new size&gt;&quot;</span> <br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Example $0 ./images 1024x680&quot;</span><br />
&nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #007800;">folder</span>=<span style="color: #007800;">$1</span><br />
<span style="color: #007800;">newsize</span>=<span style="color: #007800;">$2</span><br />
<span style="color: #007800;">resized</span>=<span style="color: #ff0000;">&quot;resized&quot;</span><br />
<span style="color: #007800;">resized_dir</span>=<span style="color: #ff0000;">&quot;$1/<span style="color: #007800;">$resized</span>&quot;</span><br />
<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Resized images will be placed into the folder <span style="color: #007800;">$resized</span>&quot;</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$resized_dir</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #007800;">$resized_dir</span><br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$folder</span><br />
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #c20cb9; font-weight: bold;">ls</span> . <span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$file</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Processing <span style="color: #007800;">$file</span>...&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;convert <span style="color: #660033;">-resize</span> <span style="color: #007800;">$newsize</span> <span style="color: #007800;">$file</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$resized</span>/<span style="color: #007800;">$file</span>&quot;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #000000; font-weight: bold;">done</span></div></div>
<p>Save the script as image_resize.sh. Do a chmod a+x so you can execute it. Then create a sample folder with a few images copied just for testing. Run it 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">.<span style="color: #000000; font-weight: bold;">/</span>image_resize.sh path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>images 1024x680</div></div>
<p>That&#8217;s all folks!</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%2Fscaling-images-in-batch-mode%2F&amp;title=Scaling%20images%20in%20batch%20mode" 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/scaling-images-in-batch-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Public Key</title>
		<link>http://www.petermac.com/public-key/</link>
		<comments>http://www.petermac.com/public-key/#comments</comments>
		<pubDate>Wed, 15 Oct 2008 02:23:59 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.petermac.com/2008/10/15/public-key/</guid>
		<description><![CDATA[&#8212;&#8211;BEGIN PGP PUBLIC KEY BLOCK&#8212;&#8211; Version: GnuPG v1.4.9 (MingW32) mQGiBEj1SQoRBACbRUMtyYFvFa81V7cnzbYJzSfk5MDuUdV0Wo+ckxKKRfW4Qf30 +ORIJeqzirJp9tOd8/uoPVnxNOK4LBKw47W+lHHLUYNMy2qByy7zVBXfg9EXuIrU edebiwM92yODj/VoAxTjI1p5Mmr5fhFSSEo8yh7GTqg8g0j4jWPR+eZxywCgi78d CZ6WmIS+tpNvEqrV/DwQUd0D/R9tyFMuwVKKOcyPxpekJ5RmKk8DDJ7cx6z0s6wM kpx5qpL2QKhVp/3s7t9M40FT3ZmT2ERjJwZzncM8JMxDOK/vS8CRGlTd/JJIzWNj 8SOo55HCq1gJP8U01P1wU1AK9/7n+RcENOGvHEPvKfWweY8HuE8OwHkPGxkqT4og 1TNgA/97226C/NTf7MmOmV5y3yo5k5VUzGRjPpyvZIxIxnQJR4viquNEJfnW9BQT kRw4J7qQePvcbYrvDWxHlJJzlIzQxbBUqVry4K79ByudQA8QaQAT+XJIMjjppgHz rKWB6YVTqsSlfjASM9RqjfDCMZpefpjlq2hvJ2WzyLnYGyEJ+rRuUGV0ZXIgTWFj IEdpb2xsYWZoZWFyZ2EgKEtleSBmb3IgbWFpbCBmcm9tIHBldGVyQHBldGVybWFj LmNvbSAtIFBldGVyIE1hYyBBbmQgQXNzb2NpYXRlcykgPHBldGVyQHBldGVybWFj LmNvbT6IZgQTEQIAJgUCSPVJCgIbIwUJCWYBgAYLCQgHAwIEFQIIAwQWAgMBAh4B AheAAAoJEJlpD3yHCMV4/qYAn0WbPZejFQGgFi3g5IT2Q0D8u++xAJsGmFMdEwPm zFi4mAEAbhfO+tuUr7kCDQRI9UkKEAgAhf491b6MaNOCp1qo9hjvX1NLQ1sORkI9 suP7PceRZfXuqc92GMXw8lYds9cPddtOBPpBZCaezxvRZHfERwiSWEVjEdwXyC5z y8ys8L4jxaPS8YS3SnEjkg+1DCLRb5fry+jiSaFeC2YklFFopSxWiSJQow9+jIPF hfvE4ZswP3EBx54SYC92sZgqfq/DcDcqlOp7gGAxHhxP+rdt4ow4aEzhdzyzNVpb C26BwRWH6T1JtsBSiy0PoaxV2eVl3Fb93aHPVldtdk5p6Pqm03KAbowurFfLshK9 jyPuOyaM8cUSN+RXSgi846mXT0EhY6J4Ofb0rClm8maXwtSHpk8wBwADBQf/b4i6 oDa5K69S2tyERpxAPhSBPdUnYT0oxlZvj75Wp1SfBkmUy8O+1jONIE1+OhLslxke WdFMmDrH8AiRU0q19bGEsKDqUWt58UV7GL26+QZbQWjhz7fWzI6ljftgshmXQozI 3725Y2AVQR3U4BaFNiFrJQECPYLB/yypf8OCsZjspERb+d4J7CXfk5mVkFFAOj7N 5UQv0u+dMVJAP3OCVdEibjXc/c4qPPxLUioAqN8MbixM1OzZDOH55K/oJdRoGyIG mfWU1lToNDCSi7BSqXjPGC+DMDjFc4QfnBFJfV0301GvLshuw+b/r8qJNfxkYkk4 zK/sgbPlXPL032aM4ohPBBgRAgAPBQJI9UkKAhsMBQkJZgGAAAoJEJlpD3yHCMV4 JQMAnA21n/10YG9hXHrUEel1HTFcU+opAJ9KlShcMzJoLI5VVIqfJTa8y/GE+Q== =L39p &#8212;&#8211;END PGP PUBLIC KEY BLOCK&#8212;&#8211; Click here to download this as key as a file]]></description>
			<content:encoded><![CDATA[<p>&#8212;&#8211;BEGIN PGP PUBLIC KEY BLOCK&#8212;&#8211;<br />
Version: GnuPG v1.4.9 (MingW32)</p>
<p>mQGiBEj1SQoRBACbRUMtyYFvFa81V7cnzbYJzSfk5MDuUdV0Wo+ckxKKRfW4Qf30<br />
+ORIJeqzirJp9tOd8/uoPVnxNOK4LBKw47W+lHHLUYNMy2qByy7zVBXfg9EXuIrU<br />
edebiwM92yODj/VoAxTjI1p5Mmr5fhFSSEo8yh7GTqg8g0j4jWPR+eZxywCgi78d<br />
CZ6WmIS+tpNvEqrV/DwQUd0D/R9tyFMuwVKKOcyPxpekJ5RmKk8DDJ7cx6z0s6wM<br />
kpx5qpL2QKhVp/3s7t9M40FT3ZmT2ERjJwZzncM8JMxDOK/vS8CRGlTd/JJIzWNj<br />
8SOo55HCq1gJP8U01P1wU1AK9/7n+RcENOGvHEPvKfWweY8HuE8OwHkPGxkqT4og<br />
1TNgA/97226C/NTf7MmOmV5y3yo5k5VUzGRjPpyvZIxIxnQJR4viquNEJfnW9BQT<br />
kRw4J7qQePvcbYrvDWxHlJJzlIzQxbBUqVry4K79ByudQA8QaQAT+XJIMjjppgHz<br />
rKWB6YVTqsSlfjASM9RqjfDCMZpefpjlq2hvJ2WzyLnYGyEJ+rRuUGV0ZXIgTWFj<br />
IEdpb2xsYWZoZWFyZ2EgKEtleSBmb3IgbWFpbCBmcm9tIHBldGVyQHBldGVybWFj<br />
LmNvbSAtIFBldGVyIE1hYyBBbmQgQXNzb2NpYXRlcykgPHBldGVyQHBldGVybWFj<br />
LmNvbT6IZgQTEQIAJgUCSPVJCgIbIwUJCWYBgAYLCQgHAwIEFQIIAwQWAgMBAh4B<br />
AheAAAoJEJlpD3yHCMV4/qYAn0WbPZejFQGgFi3g5IT2Q0D8u++xAJsGmFMdEwPm<br />
zFi4mAEAbhfO+tuUr7kCDQRI9UkKEAgAhf491b6MaNOCp1qo9hjvX1NLQ1sORkI9<br />
suP7PceRZfXuqc92GMXw8lYds9cPddtOBPpBZCaezxvRZHfERwiSWEVjEdwXyC5z<br />
y8ys8L4jxaPS8YS3SnEjkg+1DCLRb5fry+jiSaFeC2YklFFopSxWiSJQow9+jIPF<br />
hfvE4ZswP3EBx54SYC92sZgqfq/DcDcqlOp7gGAxHhxP+rdt4ow4aEzhdzyzNVpb<br />
C26BwRWH6T1JtsBSiy0PoaxV2eVl3Fb93aHPVldtdk5p6Pqm03KAbowurFfLshK9<br />
jyPuOyaM8cUSN+RXSgi846mXT0EhY6J4Ofb0rClm8maXwtSHpk8wBwADBQf/b4i6<br />
oDa5K69S2tyERpxAPhSBPdUnYT0oxlZvj75Wp1SfBkmUy8O+1jONIE1+OhLslxke<br />
WdFMmDrH8AiRU0q19bGEsKDqUWt58UV7GL26+QZbQWjhz7fWzI6ljftgshmXQozI<br />
3725Y2AVQR3U4BaFNiFrJQECPYLB/yypf8OCsZjspERb+d4J7CXfk5mVkFFAOj7N<br />
5UQv0u+dMVJAP3OCVdEibjXc/c4qPPxLUioAqN8MbixM1OzZDOH55K/oJdRoGyIG<br />
mfWU1lToNDCSi7BSqXjPGC+DMDjFc4QfnBFJfV0301GvLshuw+b/r8qJNfxkYkk4<br />
zK/sgbPlXPL032aM4ohPBBgRAgAPBQJI9UkKAhsMBQkJZgGAAAoJEJlpD3yHCMV4<br />
JQMAnA21n/10YG9hXHrUEel1HTFcU+opAJ9KlShcMzJoLI5VVIqfJTa8y/GE+Q==<br />
=L39p<br />
&#8212;&#8211;END PGP PUBLIC KEY BLOCK&#8212;&#8211;</p>
<p><a href="http://www.petermac.com/wp-content/uploads/2008/11/petermac.com.pub.asc">Click here to download this as key as a file</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%2Fpublic-key%2F&amp;title=Public%20Key" 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/public-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Purrfect Java Solutions</title>
		<link>http://www.petermac.com/purrfect-java-solutions/</link>
		<comments>http://www.petermac.com/purrfect-java-solutions/#comments</comments>
		<pubDate>Sun, 05 Aug 2007 04:17:32 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=24</guid>
		<description><![CDATA[Meet &#8220;Java&#8221;, a new addition to the PeterMac team. Although only 9 weeks old, she shows great focus in object oriented design (she chases any object that moves). She&#8217;s got an excellent grasp of string manipulation technniques and we have to agree that her display of experience in the J2SE (Sleeping and Eating) area is beyond [...]]]></description>
			<content:encoded><![CDATA[<p>Meet &#8220;Java&#8221;, a new addition to the PeterMac team.</p>
<p><img height="132" alt="java at 9 weeks" src="http://www.petermac.com/wp-content/uploads/2007/08/java_20070805_sm.png" width="214" /></p>
<p>Although only 9 weeks old, she shows great focus in object oriented design (she chases any object that moves). She&#8217;s got an excellent grasp of string manipulation technniques and we have to agree that her display of experience in the J2SE (Sleeping and Eating) area is beyond expectations for one so young.</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%2Fpurrfect-java-solutions%2F&amp;title=Purrfect%20Java%20Solutions" 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/purrfect-java-solutions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Minister for misCommunication</title>
		<link>http://www.petermac.com/minister-for-miscommunication/</link>
		<comments>http://www.petermac.com/minister-for-miscommunication/#comments</comments>
		<pubDate>Tue, 22 Aug 2006 22:21:27 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.petermac.com/?p=9</guid>
		<description><![CDATA[A recent brain-fart by the Australian Minister for Communications, Helen Coonan, has exemplefied why Australia remains a relative technology backwater. She said that she expects people ought to be happy with existing Internet speeds. &#8220;Well they ought to be in Sydney, Melbourne, Adelaide, Brisbane, certainly and Perth,&#8221; she said. &#8220;They should be reasonably happy with [...]]]></description>
			<content:encoded><![CDATA[<p class="western" style="margin-bottom: 0cm">A recent brain-fart by the Australian Minister for Communications, Helen Coonan, has exemplefied why Australia remains a relative technology backwater.  She said that she expects people ought to be happy with existing  Internet speeds.</p>
<p class="western">&#8220;Well they ought to be in Sydney, Melbourne, Adelaide, Brisbane, certainly and Perth,&#8221; she said.</p>
<p class="western">&#8220;They should be reasonably happy with their speed of broadband, if they have ADSL 2 Plus.</p>
<p class="western">&#8220;There are nine providers that already provide these speeds.&#8221;</p>
<p class="western">This outburst happened as a result of an announcement by Telstra (the 51% government owned body responsible for maintaining the telecomms infrastructure) that it was pulling out of a <a href="http://whirlpool.net.au/article.cfm/1656">proposed fibre optic upgrade to existing networks.</a></p>
<p class="western" style="margin-bottom: 0cm">Indeed there is access to ADSL 2+ in these cities but no thanks to Government support. The roll-out has been excruciatingly slow and is only available in higher population density areas. It (the ADSL2 network)has been taken on by a consortium of private companies with the previous threat of the Telstra upgrade having the potential to render their effort futile.</p>
<p class="western" style="margin-bottom: 0cm">For a Minister of Communications to make such a generalised and uninformed comment smacks of a level of ignorance that can only come from some-one whos&#8217; tenure in the role is transient. Be warned, your communications minister does not have the best interests of Australian Internet users at heart.</p>
<p class="western" style="margin-bottom: 0cm"><a href="http://www.oecd.org/document/39/0,2340,en_2825_495656_36459431_1_1_1_1,00.html">Statistics from the OECD</a> show Australia in 18<sup>th</sup> place in terms of broadband take-up. Although this is not a reflection of Internet speeds, it is a reflection on the perceived cost/benefit available to Australian consumers. Get your act together Minister!</p>
<p class="western" style="margin-bottom: 0cm">For more information check out <a href="http://www.abc.net.au/news/newsitems/200608/s1710074.htm">this article</a> by the Australian Broadcasting Corporation</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%2Fminister-for-miscommunication%2F&amp;title=Minister%20for%20misCommunication" 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/minister-for-miscommunication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

