<?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>Chris Miller &#187; 2010 &#187; April</title>
	<atom:link href="http://chris-miller.org/archives/2010/04/feed/" rel="self" type="application/rss+xml" />
	<link>http://chris-miller.org</link>
	<description>Life, and how to live it!</description>
	<lastBuildDate>Tue, 24 Jan 2012 14:41:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Filtered keystrokes with JavaScript</title>
		<link>http://chris-miller.org/archives/2010/04/14/filtered-keystrokes-with-javascript/</link>
		<comments>http://chris-miller.org/archives/2010/04/14/filtered-keystrokes-with-javascript/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 08:36:45 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[keystroke]]></category>

		<guid isPermaLink="false">http://chris-miller.org/?p=511</guid>
		<description><![CDATA[This small set of scripts should give you a starting point for filtering the valid input to certain form fields to ensure that you shouldn&#8217;t end up with input that you don&#8217;t want*. Basically you&#8217;d have the following javascript functions defined: function isNumber( evt ) { valid = true; if( evt.which &#124;&#124; ( evt.which != [...]]]></description>
			<content:encoded><![CDATA[<p>This small set of scripts should give you a starting point for filtering the valid input to certain form fields to ensure that you shouldn&#8217;t end up with input that you don&#8217;t want*.</p>
<p>Basically you&#8217;d have the following javascript functions defined:</p>
<pre class="javascript" name="code" id="filtered-keystrokes-with-javascript_functions">
function isNumber( evt ) {
	valid		= true;
	if( evt.which || ( evt.which != 0 &#038;&#038; evt.charCode != 0 ) ) {
		var charCode	= ( evt.which ) ? evt.which : event.keyCode;
		if( charCode > 31 &#038;&#038; ( charCode < 48 || charCode > 57 ) ) {
			valid	= false;
		}
	}
	return valid;
}

function isValidEmailCharacter( evt ) {
	valid	= true;
	if( evt.which == null || ( evt.which != 0 &#038;&#038; evt.charCode != 0 ) ) {
		var charCode	= ( evt.which ) ? evt.which : event.keyCode;
		var char		= String.fromCharCode( charCode );
		var re			= new RegExp( /([0-9A-Za-z-_@.])/ );
		valid			= re.test( char );
	}
	return valid;
}

function isValidPhoneCharacter( evt ) {
	valid	= true;
	if( evt.which == null || ( evt.which != 0 &#038;&#038; evt.charCode != 0 ) ) {
		var charCode	= ( evt.which ) ? evt.which : event.keyCode;
		var char		= String.fromCharCode( charCode );
		var re			= new RegExp( /([0-9+\s\[\]])/ );
		valid			= re.test( char );
	}
	return valid;
}
</pre>
<p><span id="more-511"></span>Then we add an <code>onkeypress</code> event to the relevant form fields to filter out any of the keystrokes you don&#8217;t want.  This would look something like:</p>
<pre class="xhtml" name="code" id="filtered-keystrokes-with-javascript_html">
<input
	type="text" name="num"
	onkeypress="return isNumber( event );"
/>
<input
	type="text" name="year" maxlength="4"
	onkeypress="return isNumber( event );"
/>
<input
	type="text" name="email"
	onkeypress="return isValidEmailCharacter( event );"
/>
<input type="text" name="phone" onkeypress="return isValidPhoneCharacter( event );" />
</pre>
<p>The only problem with this method of filtering input to the form elements is that key combos using filtered characters will not work, i.e. <abbr title="Cmd + A">&#8984;+A</abbr> to select the entire entry in a text field will not work when we&#8217;re applying the isNumber filter to that field.  The solution would be to create a list of key combonations that are allowed.</p>
<p>Not a necessity, but it can&#8217;t hurt.<br />
- Chris</p>
<p>* That&#8217;s not to say you shouldn&#8217;t validate the form when it&#8217;s submitted, the non-JavaScript action will be to allow anything.</p>
]]></content:encoded>
			<wfw:commentRss>http://chris-miller.org/archives/2010/04/14/filtered-keystrokes-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting and Setting anchors with JavaScript</title>
		<link>http://chris-miller.org/archives/2010/04/09/getting-and-setting-anchors-with-javascript/</link>
		<comments>http://chris-miller.org/archives/2010/04/09/getting-and-setting-anchors-with-javascript/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 10:10:49 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[anchor]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://chris-miller.org/?p=504</guid>
		<description><![CDATA[Something I&#8217;ve been playing with recently that&#8217;s not very well documented is using JavaScript to retrieve and to update the current page anchor from a URL. It&#8217;s very simple to do. In order to retrieve the page anchor (i.e. get test from http://chris-miller.org/88#test: var anchor = self.document.location.hash.substring( 1 ); Setting the anchor to update, for [...]]]></description>
			<content:encoded><![CDATA[<p>Something I&#8217;ve been playing with recently that&#8217;s not very well documented is using JavaScript to retrieve and to update the current page anchor from a URL.</p>
<p>It&#8217;s very simple to do.  In order to retrieve the page anchor (i.e. get <code>test</code> from http://chris-miller.org/88#test:</p>
<pre class="javascript" name="code" id="getting-and-setting-anchors-with-javascript_get_snippit">
var anchor = self.document.location.hash.substring( 1 );
</pre>
<p>Setting the anchor to update, for example to http://chris-miller.org/88#newAnchor it can be achived using:</p>
<pre class="javascript" name="code" id="getting-and-setting-anchors-with-javascript_set_snippit">
self.document.location.hash = "newAnchor";
</pre>
<p>Very useful for creating permalinks to AJAX loaded content or JS popups.<br />
- Chris</p>
]]></content:encoded>
			<wfw:commentRss>http://chris-miller.org/archives/2010/04/09/getting-and-setting-anchors-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fade between two divs using mootools</title>
		<link>http://chris-miller.org/archives/2010/04/08/fade-between-two-divs-using-mootools/</link>
		<comments>http://chris-miller.org/archives/2010/04/08/fade-between-two-divs-using-mootools/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 14:17:05 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[fade]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[mootools]]></category>

		<guid isPermaLink="false">http://chris-miller.org/?p=488</guid>
		<description><![CDATA[I&#8217;ve been playing with mootools for a while, they&#8217;re very nice, making easy work of some nice visual tweens and effects. One thing I was struggling a bit to do was fade between two divs, having the first one fade out then the second fade in. Rather than grabbing a plugin to do it I [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://chris-miller.org/wp-content/uploads/2010/04/mootools.png" alt="MooTools" width="184" height="46" class="alignright size-full wp-image-491" />I&#8217;ve been playing with mootools for a while, they&#8217;re very nice, making easy work of some nice visual tweens and effects.</p>
<p>One thing I was struggling a bit to do was fade between two divs, having the first one fade out then the second fade in.  Rather than grabbing a plugin to do it I wanted a small bit of JavaScript I could embed in a page, I couldn&#8217;t find one <em>anywhere</em>.</p>
<p>It&#8217;s pretty simple to do, the code below should give you a starting point to set up some JS to fade between 2 or more divs.</p>
<pre class="javascript" name="code" id="fade-between-two-divs-using-mootools_snippit">
function fadeBetweenDivs( div1, div2 ) {
	$$( div1 ).fade( "out" );
	(function(){
		$$( div1 ).setStyles({
			display:	'none',
			opacity:	0
		});
	}).delay( 150 );
	(function(){
		$( div2 ).setStyles({
			display:	'block',
			opacity:	0
		});
	}).delay( 150 );
	$$( div2 ).fade( "in" );
}
</pre>
<p>That is all,<br />
- Chris</p>
]]></content:encoded>
			<wfw:commentRss>http://chris-miller.org/archives/2010/04/08/fade-between-two-divs-using-mootools/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sequel Pro: Manage MySQL Databases under Mac OS X</title>
		<link>http://chris-miller.org/archives/2010/04/08/sequel-pro-manage-mysql-databases-under-mac-os-x/</link>
		<comments>http://chris-miller.org/archives/2010/04/08/sequel-pro-manage-mysql-databases-under-mac-os-x/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 12:27:41 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Essential Apps]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[DBMS]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHPMyAdmin]]></category>
		<category><![CDATA[Sequel Pro]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://chris-miller.org/?p=378</guid>
		<description><![CDATA[I do a lot of web development; it&#8217;s my full time job, my hobby and a means to potentially earn some money on the side. I need a set of good tools in order to make aspects of the work easier or I&#8217;d spend my entire life at odds with what I do. A good [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://chris-miller.org/wp-content/uploads/2010/02/Sequel-Pro-Icon.png" alt="Sequel Pro Icon" title="Sequel Pro Icon" width="105" height="128" class="alignright size-full wp-image-380" /><br />
I do a lot of web development; it&#8217;s my full time job, my hobby and a means to potentially earn some money on the side.  I need a set of good tools in order to make aspects of the work easier or I&#8217;d spend my entire life at odds with what I do.  A good Database Management System (DBMS) tool is one such tool since database management and manipulation plays such a large part of developing any content managed website, especially for quick modifications, testing and deployment.</p>
<p>MySQL is my DB of choice, due to working mainly on <abbr title="Linux, Apache, MySQL and PHP">LAMP</abbr> architecture systems.  The best tool by far I&#8217;ve found for managing MySQL databases under Mac OS X is <a target="_blank" href="http://www.sequelpro.com/" title="View the Sequel Pro website">Sequel Pro</a> (previously CocoaMySQL).</p>
<p><span id="more-378"></span><br />
<div id="sequel-pro-manage-mysql-databases-under-mac-os-x_image1" class="wp-caption aligncenter" style="width: 560px"><img src="http://chris-miller.org/wp-content/uploads/2009/12/Sequel-Pro-Scaled.png" alt="Sequel Pro interface showing the table editor view" title="Sequel-Pro-Scaled" width="550" height="401" class="size-full wp-image-387" /><p class="wp-caption-text">Sequel Pro interface showing the table editor view</p></div><br />
Sequel Pro is a very streamlined and powerful program for database management, it provides the facility to add, modify and remove entire databases; supports various import and export formats for singular tables, entire databases or selected query results; allowing modification of table properties as well as inline SQL querying.</p>
<p>Before finding Sequel Pro I was a full-time user of PHPMyAdmin, a system which I continue to use in some instances.  Sequel Pro essentially provides a desktop solution that is very similar to PHPMyAdmin, anyone who has experience using PHPMyAdmin should have no problems to adjusting to using Sequel Pro in its stead.</p>
<p><div id="sequel-pro-manage-mysql-databases-under-mac-os-x_image2" class="wp-caption aligncenter" style="width: 560px"><img src="http://chris-miller.org/wp-content/uploads/2009/12/Annotated-Sequel-Pro.png" alt="Caption" title="Annotated Sequel Pro" width="550" height="401" class="size-full wp-image-379" /><p class="wp-caption-text">Annotated Sequel Pro</p></div><br />
<a href="#sequel-pro-manage-mysql-databases-under-mac-os-x_image2" title="Sequel Pro Annotated View" onmouseover="document.getElementById('sequel-pro-manage-mysql-databases-under-mac-os-x_image2').style.borderColor = '#2266aa'; document.getElementById('sequel-pro-manage-mysql-databases-under-mac-os-x_image2').style.borderWidth = '2px'; document.getElementById('sequel-pro-manage-mysql-databases-under-mac-os-x_image2').style.paddingTop = '3px'; document.getElementById('sequel-pro-manage-mysql-databases-under-mac-os-x_image2').style.paddingBottom = '0px';" onmouseout="document.getElementById('sequel-pro-manage-mysql-databases-under-mac-os-x_image2').style.borderColor = '#d6d6d6'; document.getElementById('sequel-pro-manage-mysql-databases-under-mac-os-x_image2').style.borderWidth = '1px'; document.getElementById('sequel-pro-manage-mysql-databases-under-mac-os-x_image2').style.paddingTop = '4px'; document.getElementById('sequel-pro-manage-mysql-databases-under-mac-os-x_image2').style.paddingBottom = '1px';">The image above</a> is an annotated view of the Sequel Pro interface, the main portions of the interface that I use day-to-day are highlighted and numbered, each of the numbered areas correspond to:</p>
<ol>
<li>
<h4>Database Selector</h4>
<p>		A basic drop-down list where you can select a database to work with or add a new database.
	</li>
<li>
<h4>Table Selector</h4>
<p>		The list of tables in the currently selected database.  If the number of tables is large enough a filter field appears at the top of this list allowing you to filter the tables based upon their names.  Below the list of tables is a small section with meta-data on the currently selected table, under this is the controls for the database tables.  From here we can add, remove, duplicate and truncate tables with ease (with conformation on the obviously destructive actions).
	</li>
<li>
<h4>Field Viewer/Editor</h4>
<p>		This portion of the interface is controlled by whichever view is selected from the icons appearing in the application toolbar.
	</li>
<li>
<h4>Keys Viewer/Editor</h4>
<p>		This area allows you to manage keys and indexes of the table you&#8217;re viewing.  The +/- toggle at the bottom left allows you to add and remove keys/indexes.
	</li>
<li>
<h4>Structure View (shown)</h4>
<p>		Changes the view to the structure view as shown and detailed above.
	</li>
<li>
<h4>Table Contents View</h4>
<p>		Switches to the table contents view.
	</li>
<li>
<h4>SQL Query Editor</h4>
<p>		Switches to the SQL query editor view.
	</li>
</ol>
<p>Another of the real selling points for Sequel Pro for me is the ability to easily import and export data.  From the <code>File > Export</code> menu you can export data in various formats, <code>CSV</code> and <code>XML</code> being the most useful.<br />
<img src="http://chris-miller.org/wp-content/uploads/2009/12/sequel_pro_export.png" alt="sequel_pro_export" title="sequel_pro_export" width="107" height="28" class="alignright size-full wp-image-382" /></p>
<p><abbr title="Cmd + Shift + I">&#8984;+&#8679;+I</abbr> invokes the import dialog which allows you to select an SQL dump or CSV of values to import into the selected database.  The SQL import will obviously just run the query and update the various tables as required, the CSV import on the other hand allows you to select the table and marry rows in the CSV file to those in the table you wish to import to.</p>
<h3 style="vertical-align: center; line-height: 38px; background-image: url( 'http://chris-miller.org/wp-content/uploads/2009/12/table_structure.png' ); background-repeat: no-repeat; padding-left: 35px;">
	Table Structure<br />
</h3>
<p>As detailed above the table structure view allows you to define the structure of the tables in the database and to set up the indexing and keys for the fields.</p>
<p>A nice touch available here is the ability to reorder pre-existing fields by dragging and dropping them in the relevant places and the ability to duplicate fields rather than have to re-enter details for virtually identical fields.</p>
<h3 style="vertical-align: center; line-height: 38px; background-image: url( 'http://chris-miller.org/wp-content/uploads/2009/12/table_contents.png' ); background-repeat: no-repeat; padding-left: 35px;">
	Table Contents<br />
</h3>
<p>From there you can add, modify, duplicate and delete rows in the table, all of which you&#8217;d really expect from the table contents view.</p>
<p>Again, like the table structure view, you can duplicate entries to save re-entering similar data.  Inserting <code>NULL</code> values is as simple as hitting <abbr title="Ctrl + Shift + N">^+&#8679;+N</abbr>.  Copying rows as INSERT statements is a big plus (<abbr title="Ctrl + Optn + Cmd + C">^+&#8997;+&#8984;+C</abbr>) and useful when copying singular entries between a development and live database, rather than dumping the data from a custom query.</p>
<h3 style="vertical-align: center; line-height: 38px; background-image: url( 'http://chris-miller.org/wp-content/uploads/2009/12/sql_query.png' ); background-repeat: no-repeat; padding-left: 35px;">
	SQL Query<br />
</h3>
<p>This view allows you to enter queries and run them against the database.  The editor itself has autocompletion and some niceties like smart quoting of field names.</p>
<p>The power here comes from the ability to store previously used queries and access recent queries via a query history.  Any of the generated result sets can be exported in the previously mentioned formats for easy data filtering and export.</p>
<h3>
	In summary<br />
</h3>
<p>It&#8217;s a bloody useful tool and a <em>must</em> for anyone working with MySQL databases under Mac OS X.  It&#8217;s not a silver-bullet solution of course; it doesn&#8217;t do much more than PHPMyAdmin and the things it does can be replicated in PHPMyAdmin with relative ease; but then it can&#8217;t be a bad thing to have lying about, especially since it&#8217;s free!</p>
<ul>
<li>You can <a href="http://www.sequelpro.com/" title="Download Sequel Pro">download a copy of Sequel Pro from their website</a>.</li>
<li>Developed by <a href="http://www.mjmedia.com.au/" title="mjmedia">mjmedia</a>.</li>
</ul>
<p>Go have a play with Sequel Pro <em>now</em>,<br />
- Chris</p>
]]></content:encoded>
			<wfw:commentRss>http://chris-miller.org/archives/2010/04/08/sequel-pro-manage-mysql-databases-under-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

