<?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>Matthew Riches</title>
	<atom:link href="http://www.matthewriches.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.matthewriches.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 01 Apr 2013 13:28:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Chrome Extension Tutorial: Highlighted Text Used to Send AJAX Request to Remote Server and Display Results</title>
		<link>http://www.matthewriches.com/blog/2013/04/01/chrome-extension-tutorial-highlighted-text-used-to-send-ajax-request-to-remote-server-and-display-results/</link>
		<comments>http://www.matthewriches.com/blog/2013/04/01/chrome-extension-tutorial-highlighted-text-used-to-send-ajax-request-to-remote-server-and-display-results/#comments</comments>
		<pubDate>Mon, 01 Apr 2013 13:18:58 +0000</pubDate>
		<dc:creator>matthew</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Chrome]]></category>

		<guid isPermaLink="false">http://www.matthewriches.com/blog/?p=228</guid>
		<description><![CDATA[Creating a Google Chrome extension is actually pretty straight forward as you can utilise your existing knowledge of HTML and JavaScript (and even jQuery) when creating the extension. This tutorial is based on the No Fuss Reviews extension I published &#8230; <a href="http://www.matthewriches.com/blog/2013/04/01/chrome-extension-tutorial-highlighted-text-used-to-send-ajax-request-to-remote-server-and-display-results/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Creating a Google Chrome extension is actually pretty straight forward as you can utilise your existing knowledge of HTML and JavaScript (and even jQuery) when creating the extension.</p>
<p>This tutorial is based on the <a href="https://chrome.google.com/webstore/detail/no-fuss-reviews/pdoomhbiobokbhdcpfldidaopnpgobkb" target="_blank">No Fuss Reviews extension</a> I published and <a href="http://www.matthewriches.com/blog/wp-content/uploads/nfr.zip" target="_blank">the full source can be downloaded here</a>.</p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/screen2.jpg"><img class="aligncenter size-full wp-image-243" alt="No Fuss Reviews Chrome Extension" src="http://www.matthewriches.com/blog/wp-content/uploads/screen2.jpg" width="640" height="400" /></a></p>
<p><span id="more-228"></span>Whether you work from the source or from scratch the first thing you should do is create a folder to hold your extension (or unzip the download from above) and learn how load the unpacked extension into Chrome. To do this, open the extensions menu of Chrome and tick &#8220;Developer Mode&#8221; on at the top of the page.</p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/dev1.jpg"><img class="aligncenter size-full wp-image-245" alt="Chrome Developer Mode" src="http://www.matthewriches.com/blog/wp-content/uploads/dev1.jpg" width="768" height="175" /></a></p>
<p>This will show additional options, but the one you should focus on is the &#8220;Load Unpacked Extension&#8230;&#8221; button; clicking this will allow you to load an extension by selecting a folder on your computer, if you downloaded the source point it towards the freshly unzipped folder &#8211; now you can edit the files and click the reload button after each change to see your changes.</p>
<p><strong>Manifest</strong></p>
<p>The first thing an extension needs is an manifest file called &#8220;manifest.json&#8221;, the manifest file for this project looks like this&#8230;</p>
<pre class="brush: javascript; gutter: true">{
   &quot;background&quot;:{&quot;page&quot;: &quot;background.html&quot;},
   &quot;browser_action&quot;: {
      &quot;default_icon&quot;: &quot;t.png&quot;
   },
   &quot;content_scripts&quot;: [ {
      &quot;js&quot;: [ &quot;jquery.js&quot;, &quot;my.js&quot; ],
      &quot;matches&quot;: [ &quot;http://*/*&quot;, &quot;https://*/*&quot; ]
   } ],
   &quot;description&quot;: &quot;Get scores out of ten for any video game, highlight any text on any web site, hit &#039;n&#039; and scores will be displayed.&quot;,
   &quot;icons&quot;: {
      &quot;128&quot;: &quot;T128.png&quot;,
      &quot;16&quot;: &quot;T16.png&quot;,
      &quot;48&quot;: &quot;T48.png&quot;
   },
   &quot;name&quot;: &quot;No Fuss Reviews&quot;,
   &quot;permissions&quot;: [ &quot;tabs&quot;, &quot;http://www.nofussreviews.com/*&quot; ],
   &quot;version&quot;: &quot;1.1&quot;,
   &quot;manifest_version&quot;: 2
}</pre>
<p>The format of this file is JSON so all the parts are encapsulated in parentheses and arrays with square brackets. First up is the background page declaration, this page is required for specific events, in this extension to launch a new tab from a button in the browser &#8211; its also useful for debugging as when in developer mode you can click the background page link to show the developer console which will list any errors.</p>
<p>Browser action adds specific functions to the Chrome browser, &#8220;default_icon&#8221; adds an icon to the tray at the top right of the browser. The location of the file is relative to the extension so &#8220;t.png&#8221; will be located in the root of the extension.</p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/dev2.jpg"><img class="aligncenter size-full wp-image-246" alt="No Fuss Reviews Chrome Icon" src="http://www.matthewriches.com/blog/wp-content/uploads/dev2.jpg" width="172" height="118" /></a></p>
<p>Content scripts includes the scripts you require for your extension to operate, in this example I&#8217;m loading in jQuery and &#8220;my.js&#8221; which contains all of my custom functionality, all of which are stored in the extension directory. The matches array contains values as to where the scripts can be run for example &#8220;http://*/*&#8221; allows the scripts to run on any domain on any webpage the user may be on.</p>
<p>The description parameter is the description of your plugin as shown in the extension list and used by Google in the store as the bold part of your description &#8211; it can only be 132 characters long, so keep it snappy.</p>
<p>After this icons are declared and again these are stored locally, these are used both in the store and in the extension for example on the extensions list page within the browser. The image sizes should match to their values (128, 48 and 16) and the images should be in PNG format ideally with transparency.</p>
<p>The name is the overall name of the extension as shown in the extension list and on the store.</p>
<p>The permissions part is used to set specific action permissions, in this extension the permission is set to allow the extension to open up a specific domain name in a new tab, specifically in this extension when you click the icon at the top right it will open the site.</p>
<p>Lastly the version is your own versioning of your plugin and must be higher each time you upload a new version to the <a href="chrome.google.com/webstore/developer/dashboard" target="_blank">developer console</a>. The manifest version is the version of the actual &#8220;manifest.json&#8221; file and in this example must be version 2 due the layout used.</p>
<p><strong>Background Page</strong></p>
<p>The background page is required if you need to perform browser actions such as opening new tabs or showing information when you click the extension icon. It seems strange but the background page in this extension does nothing but load a script but without this page it will not work.</p>
<pre class="brush: html; gutter: true">&lt;html&gt;
&lt;head&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;background.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;/html&gt;</pre>
<p>The page is stored as &#8220;background.html&#8221; as designated in the manifest file and all this page does is load a script called &#8220;background.js&#8221;. The background JavaScript file also includes not a lot:</p>
<pre class="brush: javascript; gutter: true">chrome.browserAction.onClicked.addListener(function() {
    chrome.tabs.create({&#039;url&#039;: &quot;http://www.nofussreviews.com&quot;});
});</pre>
<p>This Chrome script simply adds a listener to the extension&#8217;s icon and creates a new tab with the URL as specified.</p>
<p><strong>My.js</strong></p>
<p>The &#8220;My.js&#8221; file is called in the manifest file, you can call as many scripts as you like and call them whatever you like, it really doesn&#8217;t matter. In this extension the &#8220;My.js&#8221; file contains all of the workings of the extension and is detailed below.</p>
<pre class="brush: javascript; gutter: true">$(document).ready(function(){
    selection = new Object()
    make_popup()
});
function make_popup(){
    $(&#039;body&#039;).append(&#039;&lt;div id=&quot;nfr-chrome-popup&quot;&gt;&lt;/div&gt;&#039;)
    $(&#039;#nfr-chrome-popup&#039;).css({
        &#039;font-family&#039;: &#039;Verdana&#039;,
        &#039;font-size&#039;: &#039;12px&#039;,
        &#039;color&#039;: &#039;black&#039;,
        &#039;display&#039;: &#039;none&#039;,
        &#039;z-index&#039;: &#039;1000&#039;,  
        &#039;position&#039;: &#039;absolute&#039;, 
        &#039;top&#039;: &#039;0px&#039;, 
        &#039;left&#039;: &#039;0px&#039;,
        &#039;text-align&#039;:&#039;left&#039;
    })
};
$(&#039;body&#039;).mouseup(function(e){
    selection.x = e.pageX + 20
    selection.y = e.pageY + 10
    selection.text = window.getSelection().toString()
});
$(&#039;body&#039;).keypress(function(event){
    if (event.keyCode == 110){
		if((selection.x+360) &gt; ($(window).width())) {
			var popupLeft = parseInt(selection.x-320);
		} else {
			var popupLeft = selection.x;
		}
        if (selection.text != &#039;&#039;){
            $(&#039;#nfr-chrome-popup&#039;).css({&#039;top&#039;: selection.y, &#039;left&#039;:popupLeft, &#039;width&#039;: 350 +&#039;px&#039; })
            $(&#039;#nfr-chrome-popup&#039;).html(&#039;&lt;div id=&quot;fetching&quot; style=&quot;padding:10px;background-color:#333;text-align:center;&quot;&gt;&lt;img src=&quot;http://www.nofussreviews.com/images/ajax-loader.gif&quot; /&gt;&lt;/div&gt;&#039;)
            $(&#039;#nfr-chrome-popup&#039;).show()
            chrome.extension.sendRequest({highlighted: selection.text }, function(response) {
				querySite(selection.text);
            });
        }
    } else{
        $(&#039;#nfr-chrome-popup&#039;).hide()
    }
});
$(document).on(&#039;click&#039;,&#039;#nfr-close-popup,#errorclose&#039;,function(){
    $(&#039;#nfr-chrome-popup&#039;).hide()
});	
function querySite(term) {
url = &quot;http://www.nofussreviews.com/chrome.php?q=&quot;+term;
	$.get(url)
     .success(function(data) {$(&#039;#nfr-chrome-popup&#039;).html(&#039;&#039;);
      $(&#039;#nfr-chrome-popup&#039;).html(data);})
     .error(function(jqXHR, textStatus, errorThrown) {$(&#039;#nfr-chrome-popup&#039;).html(&#039;&lt;div id=&quot;fetching&quot; style=&quot;padding:10px;background-color:#333;color:#fff;&quot;&gt;&lt;p&gt;An error occured, please try again.&lt;/p&gt;&lt;p id=&quot;errorclose&quot;&gt;&lt;a href=&quot;javascript:void(0)&quot; style=&quot;color:#eee;&quot;&gt;close&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&#039;);});	
}</pre>
<p>For anyone familiar with JavaScript and jQuery this file should make for very light reading, but I&#8217;ll break down each section anyway.</p>
<p>First up a &#8220;document ready&#8221; bind is created.</p>
<pre class="brush: javascript; gutter: true">$(document).ready(function(){
    selection = new Object()
    make_popup()
});</pre>
<p>This bind creates a new object to hold the selection information (the information the user is going to select on the page, highlighting text or double clicking a word) and secondly a function is called to create a popup. This popup is appended to the bottom of the page so it can be manipulated as required, here&#8217;s the function:</p>
<pre class="brush: javascript; gutter: true">function make_popup(){
    $(&#039;body&#039;).append(&#039;&lt;div id=&quot;nfr-chrome-popup&quot;&gt;&lt;/div&gt;&#039;)
    $(&#039;#nfr-chrome-popup&#039;).css({
        &#039;font-family&#039;: &#039;Verdana&#039;,
        &#039;font-size&#039;: &#039;12px&#039;,
        &#039;color&#039;: &#039;black&#039;,
        &#039;display&#039;: &#039;none&#039;,
        &#039;z-index&#039;: &#039;1000&#039;,  
        &#039;position&#039;: &#039;absolute&#039;, 
        &#039;top&#039;: &#039;0px&#039;, 
        &#039;left&#039;: &#039;0px&#039;,
        &#039;text-align&#039;:&#039;left&#039;
    })
};</pre>
<p>As discussed first up the function appends a new &#8220;div&#8221; element to the body of the page, this element will always exist but the CSS added changes the display to &#8220;none&#8221; so it won&#8217;t show. Its important that if you used ID&#8217;s or classes you keep them very specific to prevent them from clashing with styles that might already be on the page the user is looking at, in this extension everything has the prefix of &#8220;nfr&#8221;. The rest of this function is used to set some initial styles of the popup ensuring it has a high &#8220;z-index&#8221; and that it&#8217;s positioned absolutely.</p>
<p>Next up we have a bind on &#8220;mouseup&#8221; so when the user finishes clicking (useful for when something has been selected).</p>
<pre class="brush: javascript; gutter: true">$(&#039;body&#039;).mouseup(function(e){
    selection.x = e.pageX + 20
    selection.y = e.pageY + 10
    selection.text = window.getSelection().toString()
});</pre>
<p>The bind is attached to the body and the function stores the position of the selection (it seems to be the end of the string, and we add an offset) and the actual selected text.</p>
<p>Now the big one:</p>
<pre class="brush: javascript; gutter: true">$(&#039;body&#039;).keypress(function(event){
    if (event.keyCode == 110){
		if((selection.x+360) &gt; ($(window).width())) {
			var popupLeft = parseInt(selection.x-320);
		} else {
			var popupLeft = selection.x;
		}
        if (selection.text != &#039;&#039;){
            $(&#039;#nfr-chrome-popup&#039;).css({&#039;top&#039;: selection.y, &#039;left&#039;:popupLeft, &#039;width&#039;: 350 +&#039;px&#039; })
            $(&#039;#nfr-chrome-popup&#039;).html(&#039;&lt;div id=&quot;fetching&quot; style=&quot;padding:10px;background-color:#333;text-align:center;&quot;&gt;&lt;img src=&quot;http://www.nofussreviews.com/images/ajax-loader.gif&quot; /&gt;&lt;/div&gt;&#039;)
            $(&#039;#nfr-chrome-popup&#039;).show()
            chrome.extension.sendRequest({highlighted: selection.text }, function(response) {
				querySite(selection.text);
            });
        }
    } else{
        $(&#039;#nfr-chrome-popup&#039;).hide()
    }
});</pre>
<p>This bind itself listens for all key presses and firstly checks the character that was pressed. In this example its character &#8220;110&#8243; which is a lowercase &#8220;n&#8221;.</p>
<pre class="brush: javascript; gutter: false">    if (event.keyCode == 110){</pre>
<p>Next is a simple condition to check that the popup won&#8217;t go off the edge of the page and set a variable called &#8220;popupLeft&#8221; either way. The width of the popup is fixed to 350 pixels so we add the selection x coordinate (which is the end of the string) to a fixed integer of 360 (just to allow a little room) and check to see if this resulting value is bigger than the overall screen width; if it is we detract a fixed value of 320 pixels and if not keep it as it is.</p>
<pre class="brush: javascript; gutter: true">		if((selection.x+360) &gt; ($(window).width())) {
			var popupLeft = parseInt(selection.x-320);
		} else {
			var popupLeft = selection.x;
		}</pre>
<p>After this a simple condition to ensure the selection text is not empty is performed, so we can continue if it indeed holds something.</p>
<pre class="brush: javascript; gutter: false">if (selection.text != &#039;&#039;){</pre>
<p>So if there is selected text the next thing we do is move the popup div &#8220;nfr-chrome-popup&#8221; to the correct position (remember it was already created on document ready) also including the &#8220;popupLeft&#8221; variable to make sure it appears entirely within the viewport.</p>
<pre class="brush: javascript; gutter: false"> $(&#039;#nfr-chrome-popup&#039;).css({&#039;top&#039;: selection.y, &#039;left&#039;:popupLeft, &#039;width&#039;: 350 +&#039;px&#039; })</pre>
<p>After this we load some default content into the div which will be overwritten later on, in this case I&#8217;ve simply added an animated loading GIF.</p>
<pre class="brush: javascript; gutter: false">$(&#039;#nfr-chrome-popup&#039;).html(&#039;&lt;div id=&quot;fetching&quot; style=&quot;padding:10px;background-color:#333;text-align:center;&quot;&gt;&lt;img src=&quot;http://www.nofussreviews.com/images/ajax-loader.gif&quot; /&gt;&lt;/div&gt;&#039;)</pre>
<p>After the default content has been added, we simply show the div so the user can see the loading animation.</p>
<pre class="brush: javascript; gutter: false">$(&#039;#nfr-chrome-popup&#039;).show()</pre>
<p>The last part of this function is the most important part and is the Chrome specific script that calls a new function to deal with the highlighted text.</p>
<pre class="brush: javascript; gutter: true">chrome.extension.sendRequest({highlighted: selection.text }, function(response) {
				querySite(selection.text);
            });
</pre>
<p>This snippet will call the function named &#8220;querySite&#8221; and pass over the actual string for the selected text. This function uses basic jQuery to perform an AJAX call and is as follows:</p>
<pre class="brush: javascript; gutter: true">function querySite(term) {
    url = &quot;http://www.nofussreviews.com/chrome.php?q=&quot;+term;
    $.get(url)
            .success(function(data) {
                $(&#039;#nfr-chrome-popup&#039;).html(&#039;&#039;);
                $(&#039;#nfr-chrome-popup&#039;).html(data);
            })
            .error(function(jqXHR, textStatus, errorThrown) {
                $(&#039;#nfr-chrome-popup&#039;).html(&#039;&lt;div id=&quot;fetching&quot; style=&quot;padding:10px;background-color:#333;color:#fff;&quot;&gt;&lt;p&gt;An error occured, please try again.&lt;/p&gt;&lt;p id=&quot;errorclose&quot;&gt;&lt;a href=&quot;javascript:void(0)&quot; style=&quot;color:#eee;&quot;&gt;close&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&#039;);
            });	
}</pre>
<p>The first part of this function is to set an URL variable for the AJAX call to use, I&#8217;m using a get parameter with the remote server so the selected text is simply added to the end of the URL string.</p>
<pre class="brush: javascript; gutter: false">url = &quot;http://www.nofussreviews.com/chrome.php?q=&quot;+term;</pre>
<p>This variable is then directly used in a jQuery get request.</p>
<pre class="brush: javascript; gutter: false">$.get(url)</pre>
<p>Its important that you include both a success and error part to the GET call, this way if something goes wrong (such as your server goes down) you can deal with it. The success part of this GET call firstly empties the contents of the &#8220;nfr-chrome-popup&#8221; div and then fills it with whatever the remote server returns.</p>
<pre class="brush: javascript; gutter: true">.success(function(data) {
     $(&#039;#nfr-chrome-popup&#039;).html(&#039;&#039;);
     $(&#039;#nfr-chrome-popup&#039;).html(data);
})</pre>
<p>The error part of this get call captures all the error data (but doesn&#8217;t use it, but could) and fills the &#8220;nfr-chrome-popup&#8221; div with some static HTML stating that an error has occurred.</p>
<pre class="brush: javascript; gutter: true">.error(function(jqXHR, textStatus, errorThrown) {
    $(&#039;#nfr-chrome-popup&#039;).html(&#039;&lt;div id=&quot;fetching&quot; style=&quot;padding:10px;background-color:#333;color:#fff;&quot;&gt;&lt;p&gt;An error occured, please try again.&lt;/p&gt;&lt;p id=&quot;errorclose&quot;&gt;&lt;a href=&quot;javascript:void(0)&quot; style=&quot;color:#eee;&quot;&gt;close&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&#039;);
});	
</pre>
<p>One of the snippets I skipped over is the bind to close the popup window.</p>
<pre class="brush: javascript; gutter: true">$(document).on(&#039;click&#039;,&#039;#nfr-close-popup,#errorclose&#039;,function(){
    $(&#039;#nfr-chrome-popup&#039;).hide()
});</pre>
<p>This bind uses the new jQuery &#8220;on&#8221; syntax and importantly binds to the document, the reason for this is that because the elements are created dynamically as they are called in via AJAX it needs to see these new elements as they pop into the DOM. The elements &#8220;nfr-close-popup&#8221; and &#8220;errorclose&#8221; are both loaded in dynamically  the &#8220;nfr-close-popup&#8221; is part of the content returned from a successful AJAX response and the &#8220;errorclose&#8221; element is added in as static HTML on error as described above.</p>
<p>The content returned by the server can be previewed <a href="http://www.nofussreviews.com/chrome.php?q=Mario" target="_blank">here</a>, as you may notice in the source the content includes all of the styles needed baked right into the response, this is so tweaks can be made without having to update the extension.</p>
<p>When your plugin is completed, all you need to do is ZIP the whole folder up, pay Google $5 and upload it to the <a href="https://chrome.google.com/webstore/developer/dashboard" target="_blank">developer console</a>.</p>
<p>Well that&#8217;s it, a simple plugin that allows users to highlight text, sends the text to a remote server and creates a popup with a response, simple huh?</p>
<p><em><strong>If you have any questions or comments please feel free to pop them in the comments box below.</strong></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewriches.com/blog/2013/04/01/chrome-extension-tutorial-highlighted-text-used-to-send-ajax-request-to-remote-server-and-display-results/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Art Slideshow</title>
		<link>http://www.matthewriches.com/blog/2013/01/12/art-slideshow/</link>
		<comments>http://www.matthewriches.com/blog/2013/01/12/art-slideshow/#comments</comments>
		<pubDate>Sat, 12 Jan 2013 14:44:13 +0000</pubDate>
		<dc:creator>matthew</dc:creator>
				<category><![CDATA[Creativity]]></category>
		<category><![CDATA[Art]]></category>
		<category><![CDATA[digital art]]></category>
		<category><![CDATA[lost signal]]></category>
		<category><![CDATA[photography]]></category>
		<category><![CDATA[tarik]]></category>

		<guid isPermaLink="false">http://www.matthewriches.com/blog/?p=207</guid>
		<description><![CDATA[I was going to showcase a video here me and my friends on Facebook have been putting together showcasing some of the  best digital art and photography from around the web &#8211; unfortunately some of the artists have stated they &#8230; <a href="http://www.matthewriches.com/blog/2013/01/12/art-slideshow/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I was going to showcase a video here me and my friends on Facebook have been putting together showcasing some of the  best digital art and photography from around the web &#8211; unfortunately some of the artists have stated they don&#8217;t want to be featured&#8230;so here&#8217;s a video of 5 people playing &#8220;Someone I used to know&#8221; instead.</p>
<p><a href="http://www.youtube.com/watch?v=d9NF2edxy-M&#038;fmt=18">http://www.youtube.com/watch?v=d9NF2edxy-M</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewriches.com/blog/2013/01/12/art-slideshow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>20,000 Video Game Scores in One PDF</title>
		<link>http://www.matthewriches.com/blog/2012/12/22/20000-video-game-scores-in-one-pdf/</link>
		<comments>http://www.matthewriches.com/blog/2012/12/22/20000-video-game-scores-in-one-pdf/#comments</comments>
		<pubDate>Sat, 22 Dec 2012 18:21:41 +0000</pubDate>
		<dc:creator>matthew</dc:creator>
				<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Reviews]]></category>

		<guid isPermaLink="false">http://www.matthewriches.com/blog/?p=198</guid>
		<description><![CDATA[One of the sites I help provide scores for is No Fuss Reviews, a site that simply gives you a mark out of ten for any game &#8211; in particular retro games. The database has just hit the 20,000 mark, &#8230; <a href="http://www.matthewriches.com/blog/2012/12/22/20000-video-game-scores-in-one-pdf/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>One of the sites I help provide scores for is <a href="http://www.nofussreviews.com">No Fuss Reviews</a>, a site that simply gives you a mark out of ten for any game &#8211; in particular retro games.</p>
<p><span id="more-198"></span>The database has just hit the <strong>20,000</strong> mark, so I&#8217;ve taken the liberty to compile all 20,000 scores into one PDF that you can take around with you. Being a PDF means you can easily search within the document on your phone or tablet making it the perfect companion for when you&#8217;re browsing the video game stores and need a little help or are after some hidden gems (or you could just use the site <a href="http://www.nofussreviews.com">www.nofussreviews.com</a> which has a mobile version.)</p>
<p><strong>The PDF can be <a href="http://www.matthewriches.com/blog/wp-content/uploads/20k.pdf">downloaded here</a>, so consider it an early Christmas present.</strong></p>
<p>Within the document you&#8217;ll find scores from games as early as 1972 to the Wii U - that&#8217;s a whopping 40 years worth of games in one document. I just hope you find this document as useful as I do and some of your favourites are listed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewriches.com/blog/2012/12/22/20000-video-game-scores-in-one-pdf/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Feel good videos</title>
		<link>http://www.matthewriches.com/blog/2012/11/20/feel-good-videos/</link>
		<comments>http://www.matthewriches.com/blog/2012/11/20/feel-good-videos/#comments</comments>
		<pubDate>Tue, 20 Nov 2012 09:24:16 +0000</pubDate>
		<dc:creator>matthew</dc:creator>
				<category><![CDATA[Funny]]></category>
		<category><![CDATA[Opinion Piece]]></category>
		<category><![CDATA[Videos]]></category>

		<guid isPermaLink="false">http://www.matthewriches.com/blog/?p=159</guid>
		<description><![CDATA[We all have our own collection, but here&#8217;s my selection off videos that no matter how many times I watch, always make me smile. They are funny, clever or just epic and all well produced. If you are ever in a bad &#8230; <a href="http://www.matthewriches.com/blog/2012/11/20/feel-good-videos/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>We all have our own collection, but here&#8217;s my selection off videos that no matter how many times I watch, always make me smile. They are funny, clever or just epic and all well produced.</p>
<p>If you are ever in a bad mood and need cheering up, these are sure to help.</p>
<p><span id="more-159"></span></p>
<p><strong>Epic Rap Battle of </strong><strong>Manliness</strong></p>
<p>Just hearing the first few lines of this video makes me grin, &#8220;I was bornnnnn with hair on my chest&#8230;&#8221; take a listen and you&#8217;ll see what I mean.</p>
<p><a href="http://www.youtube.com/watch?v=_EzDRpkfaO4&#038;fmt=18">http://www.youtube.com/watch?v=_EzDRpkfaO4</a></p>
<p>Its very well produced, the lyrics are eloquent and tails of nicely towards the end, all-in-all one of my favourite videos.</p>
<p><strong>Ultimate Dog Tease</strong></p>
<p>There is something about putting human voices to animals that just makes me smile, this video is done perfectly and the emotions of the dog seem almost scripted &#8211; its both clever and humorous and certainly brings out the child in me.</p>
<p><a href="http://www.youtube.com/watch?v=nGeKSiCQkPw&#038;fmt=18">http://www.youtube.com/watch?v=nGeKSiCQkPw</a></p>
<p><strong>People Are Awesome</strong></p>
<p>If there is something that can really motivate you, its seeing what people can actually achieve.  The montage below blows my mind at what some people have the courage, skill and time to practice doing &#8211; it really is people being awesome and I love it.</p>
<p><a href="http://www.youtube.com/watch?v=Vo0Cazxj_yc&#038;fmt=18">http://www.youtube.com/watch?v=Vo0Cazxj_yc</a></p>
<p>Epic no?</p>
<p><em><strong>If thereis a video you think I should check out, let me know below.</strong></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewriches.com/blog/2012/11/20/feel-good-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What if Wipeout was taken up by&#8230;</title>
		<link>http://www.matthewriches.com/blog/2012/11/18/what-if-wipeout-was-taken-up-by/</link>
		<comments>http://www.matthewriches.com/blog/2012/11/18/what-if-wipeout-was-taken-up-by/#comments</comments>
		<pubDate>Sun, 18 Nov 2012 18:44:18 +0000</pubDate>
		<dc:creator>matthew</dc:creator>
				<category><![CDATA[Gaming]]></category>
		<category><![CDATA[Bethesda]]></category>
		<category><![CDATA[Criterion Games]]></category>
		<category><![CDATA[Ea]]></category>
		<category><![CDATA[Evolution Studios]]></category>
		<category><![CDATA[From Software]]></category>
		<category><![CDATA[Media Molecule]]></category>
		<category><![CDATA[Polyphony Digital]]></category>
		<category><![CDATA[Studio Liverpool]]></category>
		<category><![CDATA[ThatGameCompany]]></category>
		<category><![CDATA[Wipeout]]></category>
		<category><![CDATA[Wipeout HD]]></category>

		<guid isPermaLink="false">http://www.matthewriches.com/blog/?p=161</guid>
		<description><![CDATA[The closure of Studio Liverpool by Sony was an event close to my heart. Not only do I know people that worked at the studio and its former incarnation Psygnosis, but I have grown up with the Wipeout games, even &#8230; <a href="http://www.matthewriches.com/blog/2012/11/18/what-if-wipeout-was-taken-up-by/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The closure of <a href="http://www.worldwidestudios.net/liverpool">Studio Liverpool</a> by Sony was an event close to my heart. Not only do I know people that worked at the studio and its former incarnation <a href="http://en.wikipedia.org/wiki/SCE_Studio_Liverpool">Psygnosis</a>, but I have grown up with the <a href="http://en.wikipedia.org/wiki/Wipeout_(series)">Wipeout games</a>, even going out of my way to purchase devices that feature an entry in the series.</p>
<p>I would love to see the games continued, the games that demanded precision piloting while gorgeous graphics from the futuristic landscapes rushed pass your eyes while Techno notes and beats filled your senses&#8230;so what would happen if a different studio bought the Wipeout license &#8211; and what would the game be like?</p>
<p><strong>Evolution Studios </strong></p>
<p>Famed for the <a href="http://en.wikipedia.org/wiki/MotorStorm_(series)">Motorstorm series</a> of games, a Wipeout game from ES would certainly be a different affair. The landscapes would be varied, racing over sandy desert scenes, molten rock erupting from a nearby volcano, tropical forna, snow and maybe even water events. The ships would be fully destructible to the point of seemingly being made from LEGO and the pilots would fly through their cockpit windows after every small knock.</p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/wipeout-desert.jpg"><img class="aligncenter size-large wp-image-169" title="wipeout-desert" src="http://www.matthewriches.com/blog/wp-content/uploads/wipeout-desert-1024x576.jpg" alt="" width="640" height="360" /></a></p>
<p><span id="more-161"></span></p>
<p>A key point to the game, would be that smaller nibbler ships could carry far less fire power while the juggernauts of this future World could carry an armada of weaponry, so you would need to race accordingly.</p>
<p><strong>Criterion Games</strong></p>
<p>Sticking with the destructible theme, <a href="http://blog.criteriongames.com/">Criterion Games</a> famed most favourable for <a href="http://www.ea.com/uk/burnout-paradise">Burnout Paradise</a> and more recently <a href="http://www.needforspeed.com/most-wanted">Need for Speed Most: Wanted</a>; the game would be a open world affair with a mix of race styles. The cost of ships would go through the roof as destruction would be at a premium, new ships could be obtained through winning events and the insurance on floating futuristic billboards would be at a all time high.</p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/wipeout-carnage.jpg"><img class="aligncenter size-large wp-image-170" title="wipeout-carnage" src="http://www.matthewriches.com/blog/wp-content/uploads/wipeout-carnage-1024x598.jpg" alt="" width="640" height="373" /></a></p>
<p>The mix of Wipeout in an open World city style could be very enjoyable, a mix up the series enough to gain new fans and completely new directions of play style. Lets just hope the anti-grav biker fuzz wouldn&#8217;t catch up to us&#8230;</p>
<p><strong>ThatGameCompany</strong></p>
<p>Flower, Journey and Flow are all titles by <a href="http://thatgamecompany.com">ThatGameCompany</a>. Driven by emotion, a Wipeout game would work on the same principal as the <a href="http://en.wikipedia.org/wiki/Planet_Express_Ship">Planet Express ship</a>, you wouldn&#8217;t control the ship but instead move the World around it.</p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/wipout-snow.jpg"><img class="aligncenter size-large wp-image-172" title="wipout-snow" src="http://www.matthewriches.com/blog/wp-content/uploads/wipout-snow-1024x576.jpg" alt="" width="640" height="360" /></a></p>
<p>Your ship would develop upgrades and materialise additional parts as you overtake other racers, the game would look stunning and focus around overcoming natural events such as storms or earthquakes in bid to evolve into the perfect ship.</p>
<p><strong>Bethesda</strong></p>
<p>A game from <a href="http://en.wikipedia.org/wiki/Bethesda_Softworks">Bethesda</a> would entail a lot less racing a more procuring parts, new ships and kitting them out. You would mingle with the locals, explore the futuristic cities and hang out in racer bars.</p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/wipeout-fallout.jpg"><img class="aligncenter size-large wp-image-174" title="wipeout-fallout" src="http://www.matthewriches.com/blog/wp-content/uploads/wipeout-fallout-1024x605.jpg" alt="" width="640" height="378" /></a></p>
<p>When racing did start every time you fired a weapon the game would pause and you could target separate parts of enemy ships; providing you had driven over enough blue pads for action points of course.</p>
<p><strong>EA</strong></p>
<p>The game would play pretty much the same, but every different ship would need to be purchased as DLC.</p>
<p><strong>From Software</strong></p>
<p>The Wipeout games are not known for being easy, however if <a href="http://en.wikipedia.org/wiki/From_Software">From Software</a> took over the reigns they would be almost impossible.</p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/wipeout-concept.jpg"><img class="aligncenter size-large wp-image-176" title="wipeout-concept" src="http://www.matthewriches.com/blog/wp-content/uploads/wipeout-concept-1024x556.jpg" alt="" width="640" height="347" /></a></p>
<p>The first race your ship would spontaneously explode and you&#8217;d have to spend the rest of the race walking until you can find a key to unlock a garage to speak to a man who could give you the information on where to find someone that might help if you find a new ship if you supply him with fifty mystic plasma coils.</p>
<p><strong>Polyphony Digital</strong></p>
<p>More of a traditional choice, <a href="http://en.wikipedia.org/wiki/Polyphony_Digital">Polyphony Digital</a> (PD) most well known for the <a href="http://en.wikipedia.org/wiki/Gran_Turismo_(series)">Gran Turismo</a> series would take almost a decade to make a new Wipeout game, but when released would look amazing. The game would feature over 1,000 different ships and almost as integral as the racing component of the game, the modifying and improving of your ship could be a game all onto itself. Second hand ships could be purchased and you could even teach an AI driver all your skills to have him or her race in their own events to earn your team money.</p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/wipeout-garage.jpg"><img class="aligncenter size-large wp-image-171" title="wipeout-garage" src="http://www.matthewriches.com/blog/wp-content/uploads/wipeout-garage-1024x576.jpg" alt="" width="640" height="360" /></a></p>
<p>Damage would feature on a selection of random ships with the same going for internal cockpit views, you would end up spending most of your winnings on repairing your ships and buying ammo.</p>
<p><strong>Media Molecule</strong></p>
<p><a href="http://en.wikipedia.org/wiki/Media_Molecule">Mm</a> would have to get a mention here, as a Wipeout game where you could build the courses, your own ships and power-ups would be pretty amazing. The only downside would be that the gravity would be rather floaty and ships would tend to bounce of walls and the track rather than slam into walls in a fiery and spark fuelled inferno.</p>
<p>An interesting mode could consist of a top down approach when the player would need to build the track from raw materials as the ships raced, ensuring to place down blue speed pads and weapon pads in strategic parts to aid your driver and not the others in a slowed down pace. All of this could be watched back in real-time after the race has finished.</p>
<p>At any point you would be able to pause and rewind just in case you cut a hole in a piece of cardboard by mistake.</p>
<p><em><strong>So, what studio am I missing, let me know in the comments section below.</strong></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewriches.com/blog/2012/11/18/what-if-wipeout-was-taken-up-by/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Laminated List</title>
		<link>http://www.matthewriches.com/blog/2012/11/15/the-laminated-list/</link>
		<comments>http://www.matthewriches.com/blog/2012/11/15/the-laminated-list/#comments</comments>
		<pubDate>Thu, 15 Nov 2012 10:48:13 +0000</pubDate>
		<dc:creator>matthew</dc:creator>
				<category><![CDATA[Opinion Piece]]></category>
		<category><![CDATA[Amanda Righetti]]></category>
		<category><![CDATA[Beyonce]]></category>
		<category><![CDATA[Hayden Panettiere]]></category>
		<category><![CDATA[Olivia Munn]]></category>
		<category><![CDATA[Taylor Swift]]></category>

		<guid isPermaLink="false">http://www.matthewriches.com/blog/?p=140</guid>
		<description><![CDATA[We all kinda-of have one, a top list of celebrities we really like above all others. Mine has been extremely difficult to create and just like Ross only consists of five entries. Still I found it hard to pick five and for a long while &#8230; <a href="http://www.matthewriches.com/blog/2012/11/15/the-laminated-list/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>We all kinda-of have one, a top list of celebrities we really like above all others. Mine has been extremely difficult to create and just like Ross only consists of five entries. Still I found it hard to pick five and for a long while only had two as I have to like both their manner and personality. I believe beauty is the combination of both the outward and inward appearance of someone.</p>
<p>People have fallen straight off my list just by the way they act, and others have flown upward by simply being funny and kind-hearted.</p>
<p>I also think my list encompasses the 5 distinct categories <del>people</del> women tend to get pigeon holed into, if only they could all me merged together huh?</p>
<p><span id="more-140"></span></p>
<p><strong>1) The Classy One: <em>Amanda Righetti</em></strong></p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/amanda-righetti-smiling_146247-1920x10801.jpg"><img class="aligncenter size-large wp-image-153" title="amanda-righetti-smiling_146247-1920x1080[1]" src="http://www.matthewriches.com/blog/wp-content/uploads/amanda-righetti-smiling_146247-1920x10801-1024x576.jpg" alt="" width="640" height="360" /></a></p>
<p>The star of <a href="http://www.imdb.com/title/tt1196946/" target="_blank">The Mentalist</a> in my eyes is Amanda. She is both stunningly beautiful but always carries this off with an unprecedented level of class. Not only this, but Amanda dedicates a lot of her time to charity work including but not limited too Animal Rescue organisations.</p>
<p>In interviews she shows a clear head that&#8217;s confident yet humble, her experience in acting always shows and her quick wit is unmatched. She is beautiful inside and out and it shows.</p>
<p><strong>2) The Sexy One: <em>Olivia Munn</em></strong></p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/olivia-munn-models-pictures-4827831.jpg"><img class="aligncenter size-large wp-image-142" title="olivia-munn-models-pictures-482783[1]" src="http://www.matthewriches.com/blog/wp-content/uploads/olivia-munn-models-pictures-4827831-1024x576.jpg" alt="" width="640" height="360" /></a></p>
<p>There is no doubt Olivia is sexy and she know&#8217;s it. Only a quick search on Google images will reveal numerous raunchy images. Being both an actor and comedian means she also seems to be a great laugh, somewhat apparent from her frequent cosplaying.</p>
<p>She also features heavily in the techie side of the Internet appearing on &#8220;<a href="http://www.g4tv.com/attackoftheshow/" target="_blank">Attack of the show</a>&#8221; amongst other features and site videos, but recently has appeared acting again in the show <a href="http://www.imdb.com/title/tt1870479/" target="_blank">The Newsroom</a> where both her skills at acting and comedy are put through their paces with success.</p>
<p><strong> 3) The One That Can Move: <em>Beyonce</em></strong></p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/happy-beyonce-beyonce-30379561-1920-10801.jpg"><img class="aligncenter size-large wp-image-144" title="happy-beyonce-beyonce-30379561-1920-1080[1]" src="http://www.matthewriches.com/blog/wp-content/uploads/happy-beyonce-beyonce-30379561-1920-10801-1024x576.jpg" alt="" width="640" height="360" /></a></p>
<p>If you were to pick any celebrity that could really move, Beyonce would most likely pop into your mind. Being flexible and able to dance is an understatement, she can pull shapes most of us couldn&#8217;t draw &#8211; she may be a little on the crazy side but her voluptuous nature makes her an easy choice for this list. Her signing is excellent, and depending on which one of her personalities you are talking to she can be rather humble and respectful also able to carry a decent conversation.</p>
<p>She also is known for helping others break into the industry together with her partner.</p>
<p><strong>4) The Funny One: <em>Taylor Swift</em></strong></p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/taylor-swift-taylor-swift-21470449-1920-10801.jpg"><img class="aligncenter size-large wp-image-145" title="taylor-swift-taylor-swift-21470449-1920-1080[1]" src="http://www.matthewriches.com/blog/wp-content/uploads/taylor-swift-taylor-swift-21470449-1920-10801-1024x576.jpg" alt="" width="640" height="360" /></a></p>
<p>Taylor Swift is a new entry to my list, I have always thought she was pretty (and rather innocent) but it was only recently when I saw interviews on TV that discovered she is really funny, something that clearly comes over in her music videos.</p>
<p>She was able to provide related jokes, witty come-backs and dry-wit; something me as a Brit could really appreciate, so much so she had be laughing out loud at some points (which is rare).  So being very pretty, very funny and witty places her at number four on my list.</p>
<p><strong>5) The Girl Next Door: <em>Hayden Panettiere</em></strong></p>
<p><a href="http://www.matthewriches.com/blog/wp-content/uploads/Hayden_Panettiere_wallpaper_HD_00381.jpg"><img class="aligncenter size-large wp-image-146" title="Hayden_Panettiere_wallpaper_HD_0038[1]" src="http://www.matthewriches.com/blog/wp-content/uploads/Hayden_Panettiere_wallpaper_HD_00381-1024x576.jpg" alt="" width="640" height="360" /></a></p>
<p>To be honest (I suspect like most people) I hadn&#8217;t heard of Hayden before the excellent but disappointing towards the end of the series <a href="http://www.imdb.com/title/tt0813715/" target="_blank">Heroes</a>.</p>
<p>Hayden for me embodies the girl next door, sweet and innocent enough to fit the bill, but not so much that you wouldn&#8217;t have fun hanging-out with her. She has only appeared in a handful of films and TV shows but still dedicates a lot of her time to great foundations and charities like &#8220;<a href="http://www.whaleman.org/" target="_blank">The Whaleman Foundation</a>&#8221; and the <a title="Ronald McDonald House Charities" href="http://en.wikipedia.org/wiki/Ronald_McDonald_House_Charities">Ronald McDonald House Charities</a>.</p>
<p>Her kind nature, natural beauty and friendly manner earns her the fifth place on my list.</p>
<p><em><strong>So that&#8217;s it, my laminated top 5, what do you think? How right am I?</strong></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewriches.com/blog/2012/11/15/the-laminated-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Super Humans, Terry Crews and Fareast Movement</title>
		<link>http://www.matthewriches.com/blog/2012/11/14/super-humans-terry-crews-and-fareast-movement/</link>
		<comments>http://www.matthewriches.com/blog/2012/11/14/super-humans-terry-crews-and-fareast-movement/#comments</comments>
		<pubDate>Wed, 14 Nov 2012 09:16:46 +0000</pubDate>
		<dc:creator>matthew</dc:creator>
				<category><![CDATA[Creativity]]></category>
		<category><![CDATA[channel 4]]></category>
		<category><![CDATA[Far East Movement]]></category>
		<category><![CDATA[old spice]]></category>
		<category><![CDATA[olympics]]></category>
		<category><![CDATA[paralympics]]></category>
		<category><![CDATA[terry crews]]></category>

		<guid isPermaLink="false">http://www.matthewriches.com/blog/?p=132</guid>
		<description><![CDATA[One of the things I actually like about TV are the adverts, I think advertisements are an excellent convergence of creativeness and objective. Over the last few months there have been some stand out advertisements for me, one viral, one featured during the Olympics and the other &#8230; <a href="http://www.matthewriches.com/blog/2012/11/14/super-humans-terry-crews-and-fareast-movement/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>One of the things I actually like about TV are the adverts, I think advertisements are an excellent convergence of creativeness and objective. Over the last few months there have been some stand out advertisements for me, one viral, one featured during the Olympics and the other and interactive affair &#8211; all are excellent however.</p>
<p><strong>Channel 4 Paralympics -  Meet the Superhumans</strong></p>
<p>As the Olympics drew to close the Paralympics began. I&#8217;m more of a fan of the latter, seeing what people can achieve haven gone through such hardship shows extreme dedication and true courage and commitment, the Channel 4 advert embodies this perfectly.<span id="more-132"></span></p>
<p><a href="http://www.youtube.com/watch?v=vavJK1McHUo&#038;fmt=18">http://www.youtube.com/watch?v=vavJK1McHUo</a></p>
<p>The advert is expertly crafted and delivers a powerful and emotional message that really makes something inside of you stir. The cinematography is perfect and the song chosen a perfect fit. There is not a single thing wrong with this advert and the message of meeting the super-humans is spot on.</p>
<p><strong>The Dirty Bass Boombox Sessions</strong></p>
<p>If you wanted to promote the L.A. Dance Institute in a creative and fun way, this is the way to do it, get the Fareast movement involved.</p>
<p><iframe src="http://www.dailymotion.com/embed/video/xs8qnq" frameborder="0" width="480" height="270"></iframe></p>
<p>The video is fun, creative and highlights the exceptional dance being taught. Humour is punctuated throughout the video and really makes for a great viral piece.</p>
<p><strong>Old Spice Muscle Music</strong></p>
<p>The old spice adverts never seem to let you down. Their newest viral advert starring Terry Crews is no exception. The video is pure unadulterated fun, it makes no sense and doesn&#8217;t have to; it just makes you smile with its craziness.</p>
<p><iframe src="http://player.vimeo.com/video/47875656" width="480" height="270" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
<p>The thing that tips this viral video from awesome to epic is the fact you can interact with the player and make you&#8217;re own music &#8220;Sausages! don&#8217;t worry, you&#8217;ll answer the reference once you&#8217;ve hit a few buttons.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewriches.com/blog/2012/11/14/super-humans-terry-crews-and-fareast-movement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When Do Games Become Art</title>
		<link>http://www.matthewriches.com/blog/2012/11/13/when-do-games-become-art/</link>
		<comments>http://www.matthewriches.com/blog/2012/11/13/when-do-games-become-art/#comments</comments>
		<pubDate>Tue, 13 Nov 2012 19:34:11 +0000</pubDate>
		<dc:creator>matthew</dc:creator>
				<category><![CDATA[Opinion Piece]]></category>
		<category><![CDATA[Art]]></category>
		<category><![CDATA[Demoscenes]]></category>
		<category><![CDATA[Flower]]></category>
		<category><![CDATA[Heavy Rain]]></category>
		<category><![CDATA[Journey]]></category>
		<category><![CDATA[Linger in Shadows]]></category>
		<category><![CDATA[Roger Ebert]]></category>
		<category><![CDATA[Shadow of Colossus]]></category>
		<category><![CDATA[To the Moon]]></category>

		<guid isPermaLink="false">http://www.matthewriches.com/blog/?p=50</guid>
		<description><![CDATA[A while ago Roger Ebert commented that video games would never be art and even expanded on his reasoning  an article despite never having explored the medium. But the point still remains, when do video games become art and with a World &#8230; <a href="http://www.matthewriches.com/blog/2012/11/13/when-do-games-become-art/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>A while ago <a href="http://en.wikipedia.org/wiki/Roger_Ebert">Roger Ebert</a> commented that video games would never be art and even expanded on his reasoning  an<a href="http://blogs.suntimes.com/ebert/2010/07/okay_kids_play_on_my_lawn.html"> article</a> despite never having explored the medium.</p>
<p>But the point still remains, when do video games become art and with a World filled with chopped up cows and hanging light bulbs &#8211; are video games already art?</p>
<p style="text-align: center;"><a href="http://www.matthewriches.com/blog/wp-content/uploads/unfinished-swan1.jpg"><img class="size-large wp-image-97 aligncenter" title="The Unfinished Swan" src="http://www.matthewriches.com/blog/wp-content/uploads/unfinished-swan1-1024x576.jpg" alt="" width="640" height="360" /></a></p>
<p><span id="more-50"></span><br />
First of all what is art defined as, the common definition is as follows:</p>
<blockquote>
<p style="text-align: left;">The expression or application of human creative skill and imagination is quite encompassing, by this logic a bridge, a signature and even medical surgery could all be classed as art.</p>
</blockquote>
<p style="text-align: left;">However an important point that I feel should receive further highlighting is that in definition art needs to be appreciated primarily for its beauty or emotional power (who&#8217;d thought that <a href="https://www.google.co.uk/search?q=amanda+righetti&amp;aq=0&amp;um=1&amp;ie=UTF-8&amp;hl=en&amp;tbm=isch&amp;source=og&amp;sa=N&amp;tab=wi&amp;ei=yJuiUMPCKIyr0AWKmYGQBQ&amp;biw=1280&amp;bih=699&amp;sei=y5uiUKvlKciq0AXDz4G4Bw" target="_blank">Amanda Righetti</a> could technically be classed as art). This is where the line becomes hazy, often games look beautiful but few games are able to emotionally affect you.</p>
<p style="text-align: left;">Art is the appreciation of human creativity in a way that interests others. With modern art this can often include making overly detailed creations, pieces that make you stop and think about its meaning often which question society or humanity and forms that are abstractly expressive.</p>
<p style="text-align: left;"><strong>Under Rated</strong></p>
<p style="text-align: left;">Often because of their nature, video games are classed as nothing more than just that, games. Within the last decade we have seen a shift in perspective, where games are often accepted as entertainment in much the same way a book or film is. Games made now often have budgets, staff even screenplay almost directly comparably to big budget films but yet are not treated as so.</p>
<p style="text-align: left;">Games are more often than not designed and constructed to form pieces of rounded entertainment with the objective to keep the player engaged and in some cases addicted to its realm.</p>
<p style="text-align: left;">Often accomplished by targets, objectives and levels to reach, games take advantage of the common human trait of competitiveness, something that is cast into our genome.  Therefore it is difficult to class any such game as art when its main aim is to entertain us and not to display creative skill.</p>
<p style="text-align: left;">This doesn&#8217;t mean that games aren&#8217;t beautiful in their own right, it simply means that art is not their purpose.</p>
<p style="text-align: left;">Along the same lines games will often use emotion to create a bond with the player and characters within a game. This normally isn&#8217;t done to extend beyond the screen but instead engage and engulf the player into the World of the game and connect with its characters, again this is an extension to game-play to ensure the game leaves a lasting mark and that players feel they must complete the story as they feel a connection to their digital persona.</p>
<p style="text-align: left;"><strong>When emotion is key</strong></p>
<p style="text-align: left;"><a href="http://en.wikipedia.org/wiki/Shadow_of_Colossus">Shadow of Colossus</a> is often heralded as a game closely resembling art. Despite still encasing similar mechanics the reason it is chosen it because of the emotion involved.</p>
<p style="text-align: left;">The core of the game is to create a strong tie to your character. There are no towns, or enemies (other than Colossi) no other characters or dungeons to roam or chat to. It follows a story of a young man trying to restore life to a beautiful girl.</p>
<p style="text-align: left;">
<p><a href="http://www.youtube.com/watch?v=DazoTQaqJrs&#038;fmt=18">http://www.youtube.com/watch?v=DazoTQaqJrs</a></p>
</p>
<p style="text-align: left;">The game has a distinctive art style, puzzle like challenges and emotional sound track.</p>
<p style="text-align: left;">Players will often tell you the game moved them in some way, referring to the emotional rollercoaster supplied; a direct outcome of the creativity the developers crafted to convey such as message.</p>
<p style="text-align: left;"><a href="http://freebirdgames.com/to_the_moon/" target="_blank">To the Moon</a> is another exceptional example of how the video game medium extends just entertainment. In To the Moon you travel through the memories as a doctor of a dying man to try and furfil his last wish. Not only is the game beautiful constructed  it is moving and a story that is worth hearing, if written down in some form it would surely heralded as art.</p>
<p style="text-align: left;">
<p><a href="http://www.youtube.com/watch?v=Xi2UZrnGXQo&#038;fmt=18">http://www.youtube.com/watch?v=Xi2UZrnGXQo</a></p>
</p>
<p style="text-align: left;">My Final example is a title called <a href="http://iandallas.com/games/swan/" target="_blank">The Unfinished Swan</a>, resembling a traditional game players explore the unknown and literally paint their path onward. The game is a surreal adventure of a boy chasing a swan who has wandered. Only through the throwing of paint are the surroundings and the environment revealed.</p>
<p style="text-align: left;">
<p><a href="http://www.youtube.com/watch?v=xFfteZaAXq4&#038;fmt=18">http://www.youtube.com/watch?v=xFfteZaAXq4</a></p>
</p>
<p style="text-align: left;">When speaking to art lovers they will often tell you that a book was able to show things about themselves from flaws to positives. People that watch artistic films will convey how the medium dragged them into the feelings of the director and thoughts and desires they never knew they had.</p>
<p style="text-align: left;">From this respect games seem very similar, often what artists forget is that game players of today treat a control pad as an extension to themselves often completely ignoring the connection is there. When this is the case, could games actually be a transcendent of art?</p>
<p style="text-align: center;"><a href="http://www.matthewriches.com/blog/wp-content/uploads/big11.jpg"><img class="aligncenter size-large wp-image-105" title="Heavy Rain" src="http://www.matthewriches.com/blog/wp-content/uploads/big11-1024x576.jpg" alt="" width="640" height="360" /></a></p>
<p style="text-align: left;">A film is something you watch, a book you read and painting you admire. A game can be all of these things but also involve the viewer in a way traditional art cannot; it can react to the user and the user can react to the game.</p>
<p style="text-align: left;">Consider that a film is a story to be told, the viewer becomes engaged with the film investing in its plot and believing the emotions and feelings displayed in front of them. Now consider that like any good pieces of art that a film is open to interpretation, giving different messages to different people at different levels.</p>
<p style="text-align: left;">A game can perform all of this but moreover the user can interact in a way that emotion can be heighten as your decisions affect the outcome and your actions change the story. A game places the player into the movie screen where the story is told around you, where as a movie is told in front of you.</p>
<p style="text-align: left;"><strong>Demoscenes</strong></p>
<p style="text-align: left;">With the recent reinvention of Demoscenes from yesteryear, items such as <a href="http://en.wikipedia.org/wiki/Linger_In_Shadows">Linger in Shadows</a> are quite possibly the closest to art in its traditional sense a video game can be.</p>
<p style="text-align: left;">Linger in Shadows is barely a game, it could be better described as an interactive art piece, and just like any important piece of art, it polarised its audience dramatically. But according to definition does it tick all the boxes?</p>
<ul>
<li>Expression and application of human creative skill and imagination</li>
<li>Primarily appreciated for its beauty or emotion</li>
</ul>
<p>Well, it&#8217;s certainly expressive. Telling an interpreted story of the dangers that lurk within us all and how time is often wasted with procrastination. But the very fact that every one who has experienced the &#8216;game&#8217; has a different view on its meaning further extends its case of being art, abstract and modern.</p>
<p style="text-align: center;"><a href="http://www.matthewriches.com/blog/wp-content/uploads/linger1.jpg"><img class="aligncenter size-large wp-image-102" title="Linger in Shadows" src="http://www.matthewriches.com/blog/wp-content/uploads/linger1-1024x576.jpg" alt="" width="640" height="360" /></a></p>
<p>It also shows the application of human creative skill, thanks to the beautifully drawn and rendered objects and scenes in the game. Imagination is also not lacking here using fuzzy and direct symbolism to push your mind from rational to existential.</p>
<p>Finally is it widely appreciated for its beauty or emotion, well no. The only reason it is not, is because we are asking ourselves if it is art. Our own question is our own answer, video games will never be art if we keep wondering if they are. This is where the problem lies, our own insecurities about what is classed as art is the very thing that is preventing us from expanding this area.</p>
<p><strong>A personal view</strong></p>
<p>From a personal view I sincerely believe that video games are often overlooked and under-rated as an art form. When I think of games like <a href="http://en.wikipedia.org/wiki/Flower_game">Flower</a> and <a href="http://en.wikipedia.org/wiki/Heavy_Rain">Heavy Rain</a> I remember how the emotion fuelled the game or the beauty and creativity made the game more a spectacle than a challenge.</p>
<p>With games such as <a href="http://blog.us.playstation.com/2010/06/17/introducing-thatgamecompanys-journey/">&#8220;journey&#8221;</a>, I feel as the generations become older, we will see more types of art emerge with emphasis on digital creation and maybe only then will the hidden gems of today be realised.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewriches.com/blog/2012/11/13/when-do-games-become-art/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>64 Useful jQuery Snippets</title>
		<link>http://www.matthewriches.com/blog/2012/11/13/64-useful-jquery-snippets/</link>
		<comments>http://www.matthewriches.com/blog/2012/11/13/64-useful-jquery-snippets/#comments</comments>
		<pubDate>Tue, 13 Nov 2012 16:50:45 +0000</pubDate>
		<dc:creator>matthew</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.matthewriches.com/blog/?p=10</guid>
		<description><![CDATA[This list is a useful combination of frequently used functions, useful to know snippets and ways to use jQuery (with some JavaScript thrown in) effectively. The syntax highlighter can be a bit temperamental at times, so if the code doesn&#8217;t &#8230; <a href="http://www.matthewriches.com/blog/2012/11/13/64-useful-jquery-snippets/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This list is a useful combination of frequently used functions, useful to know snippets and ways to use jQuery (with some JavaScript thrown in) effectively.</p>
<p>The syntax highlighter can be a bit temperamental at times, so if the code doesn&#8217;t work, check there are no extra html entities &#8211; and of course leave comments below.</p>
<p><span id="more-10"></span><strong>1. An AJAX Call On Click</strong><br />
This snippet will bind a click to the element with id &#8220;button&#8221;. The click function then fires an AJAX call. The request is sent to the URL string &#8220;/ajax/test.html&#8221;, the response is placed in the object called &#8220;data&#8221;, since the response type hasn&#8217;t been specified it will default to text. The resulting data is then added inside the element &#8220;result&#8221; using the html function to ensure it is added and rendered as HTML, using the text option &#8220;text(data)&#8221; would add the result as plain text.</p>
<pre class="brush: javascript; gutter: true">$(&quot;#button&quot;).on(&quot;click&quot;, function(e){
    $.ajax({
        url: &#039;/ajax/test.html&#039;,
        success: function(data) {
            $(&#039;#result&#039;).html(data);
        }
    });
});</pre>
<p><strong>2. Prevent a form submitting on errors</strong><br />
This snippet will bind the submit of the form with the id of &#8220;myform&#8221;, if you only have one form on the page you could simply use just &#8220;form&#8221;.</p>
<p>The submit function will first create a local variable called errors. Next for each matching input, textarea and select box it finds, it will check if the length of the value is equal to zero. If it is, it will add the class of &#8220;error&#8221; and increment the error variable.</p>
<p>Finally it will check if the error variable is still set to zero, if it is it returns true allowing the form to submit, if not it will prevent the default action of the form and return false, preventing the form from submitting providing JavaScript is enabled of course <img src='http://www.matthewriches.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>You would remove the error class based on validation for the input separately.</p>
<pre class="brush: javascript; gutter: true">$(&quot;#myform&quot;).submit(function(e) {
    e.preventDefault();
    var errors = 0;
    $(&quot;#myform input, #myform textarea, #myform select&quot;).each(function(index, element) {
        if($(this).val().length == 0) {
            $(this).addClass(&quot;error&quot;);
            errors++;
        }
    });
    if(errors == 0) {
        return true;
        $(&quot;#myform&quot;).submit();
    } else {
        return false;
    }
});</pre>
<p><strong>3. Toggle a set of Checkboxes on or off</strong><br />
For each checkbox with the class of &#8220;checkbox&#8221;, (you could also use &#8220;input[type=check]&#8221; to match it), it will set the checkbox to the opposite to what it is currently set to by using the exclamation modifier.</p>
<pre class="brush: javascript; gutter: true">$(&quot;.checkbox&quot;).each(function(index, element) {
    $(this).attr(&#039;checked&#039;, !$(this).attr(&#039;checked&#039;));
});</pre>
<p><strong>4. Perform an action when a specific keyboard key is hit</strong><br />
This one is quite a simply one. The bind is place on the &#8220;keydown&#8221; event of the element, we capture the whole event into an object in this example called &#8220;e&#8221; so we can interogate it.</p>
<p>Inside the function, we check the &#8220;keycode&#8221; of the event, in this case we check for the key code of the down arrow and perform a specific action. You can change the key code to whatever you want (just Google the key code for the key you are after) or add more. Be aware that some operating systems may pass different codes for special keys.</p>
<pre class="brush: javascript; gutter: true">$(&#039;input&#039;).keydown(function(e){
    if (e.keyCode == 40) {
        console.log(&quot;you sunk my battleship&quot;);
    }
});</pre>
<p><strong>5. Move multiple background images with the mouse to create depth</strong><br />
This snippet binds to the mouse moving and captures the coordinates. In then makes these values into a percentage before multiplying them by minus 1 to ensure the backgrounds flow in the correct direction for prospective (you don&#8217;t have to do this if you want to inverse the effect.)</p>
<p>Separate values are created using different divisions to create different speeds of movement. The values are then applied to separate elements changing the position of their background images, this creates the effect.</p>
<pre class="brush: javascript; gutter: true">$(document).mousemove(function(e) {
    var x = ((e.pageX/$(window).width())*100)*-1;
    var y = ((e.pageY/$(window).height())*100)*-1;
    var pos = (x/80*-1)+&quot;% &quot;+(y/80*-1)+&quot;%&quot;;
    var pos2 = (x/3+60)+&quot;% &quot;+(y/3+60)+&quot;%&quot;;
    var pos3 = (x/5+30)+&quot;% &quot;+(y/5+30)+&quot;%&quot;;
    var pos4 = (x/2+60)+&quot;% &quot;+(y/2+60)+&quot;%&quot;;
    $(&quot;#background&quot;).css(&quot;background-position&quot;,pos);
    $(&quot;#midground&quot;).css(&quot;background-position&quot;,pos2);
    $(&quot;#foreground&quot;).css(&quot;background-position&quot;,pos3);
    $(&quot;#flare&quot;).css(&quot;background-position&quot;,pos4);
});</pre>
<p><strong>6. Go old skool and make text alternate colours</strong><br />
First setup your on and off styles.</p>
<pre class="brush: css; gutter: true; first-line: 1; highlight: []; html-script: false">.off {color:blue;}
.on {color:red;}</pre>
<p>Then, just toggle the classes at a set interval. The element must start with one of the classes for this to work. You can change the timeout depending on how trippy you want the effect to pie and how quick you want your browser to crash.</p>
<pre class="brush: javascript; gutter: true">setInterval(function() {
    $(&quot;.on&quot;).toggleClass(&#039;on off&#039;);
}, 1000);</pre>
<p><strong>7. Stop the screen scrolling when a popup is open</strong><br />
This one is more CSS than jQuery, but here you go. Create a class that hides all overflow. When your popup appears ensure it is fixed or absolutely positioned and fits within the window (best to use percentages).</p>
<pre class="brush: css; gutter: true; first-line: 1; highlight: []; html-script: false">.fix {
overflow:hidden;
}</pre>
<p>Then just call this snippet any way you like to toggle this class on the body to stop the window being scrolled and call it again to allow it to be scrolled.</p>
<pre class="brush: javascript; gutter: true">$(body).toggleClass(&quot;fix&quot;);</pre>
<p><strong>8. Fade between images</strong><br />
First up, you&#8217;ll need some HTML for the images</p>
<pre class="brush: html; gutter: true; first-line: 1; highlight: []; html-script: false">&lt;div id=&quot;wallpaper&quot;&gt;
&lt;img src=&quot;/one.jpg&quot; id=&quot;w1&quot; rel=&quot;1&quot; /&gt;
&lt;img src=&quot;/two.jpg&quot; id=&quot;w2&quot; rel=&quot;2&quot; /&gt;
&lt;img src=&quot;/three.jpg&quot; id=&quot;w3&quot; rel=&quot;3&quot; /&gt;
&lt;/div&gt;</pre>
<pre class="brush: css; gutter: true; first-line: 1; highlight: []; html-script: false">#wallpaper img {
position:fixed;
top:0px;
left:0px;
}</pre>
<p>This function will first count how many images there are to derive a total. Text it will determine the current image which is visible and pinch its position from the rel attribute (you could pragmatically do this however this way means they don&#8217;t have to be in the order they are written).</p>
<p>Next the function determines the next image to show by adding one and checks there is a next image to show, if not resets to 1. Finally it fades between the current image and the next image. For this to work the images will need to be position on top of each other as shown in the CSS.</p>
<pre class="brush: javascript; gutter: true">function animateWallpaper() {
    var total = $(&quot;#wallpaper img&quot;).length;
    var liveWallpaper = $(&quot;#wallpaper img:visible&quot;).attr(&quot;rel&quot;);
    var next = parseInt(liveWallpaper)+1;
    if (next &gt; total) {
        var next = next-total;
    }
    $(&quot;#w&quot;+liveWallpaper+&quot;, #w&quot;+next).fadeToggle(5000);
}
var timer = setInterval(&quot;animateWallpaper()&quot;, 15000);</pre>
<p><strong>9. Action when user stops moving over a target (hints)</strong><br />
Sometimes you want to be able to fire an action or show a hint if a user stops moving over a target for a set period of time, here&#8217;s the snippet.</p>
<p>This function will monitor the movement of the mouse over the element with the id box. It uses a timer for this, so when the user stops moving their mouse over the element upon which they have been moving it, the function &#8220;thread&#8221; is fired. This function clears all existing timeouts with the same name and counts for two seconds before firing the event; in this case it makes the box black.</p>
<pre class="brush: javascript; gutter: true">$(&#039;#box&#039;)[0].onmousemove = (function() {
    var onmousestop = function() {
    $(&#039;#box&#039;).css(&#039;background-color&#039;, &#039;red&#039;);
}, thread;
    return function() {
        $(&#039;#box&#039;).css(&#039;background-color&#039;, &#039;black&#039;);
        clearTimeout(thread);
        thread = setTimeout(onmousestop, 2000);
    };
})();</pre>
<p><strong>10. Make links look active based on the current page URL</strong><br />
Sometime you may not want to add in active classes by hand, but instead have these dynamically set based on the pages URL. This could also be used to deactivate links that lead back to the page you are on.</p>
<pre class="brush: javascript; gutter: true">var url = document.URL;
$(&#039;a[href=&quot;&#039;+url+&#039;&quot;]&#039;).addClass(&#039;active&#039;);</pre>
<p><strong>11. Make links offsite automatically open in a new window</strong><br />
This snippet will add in a target of &#8220;_blank&#8221; if your site isn&#8217;t found in the href. Of course this only works if you use full links, although could be modified to do both full and relative.</p>
<pre class="brush: javascript; gutter: true">var site = location.protocol + &#039;//&#039; + location.host;
$(&#039;a&#039;).not(&#039;:contains(site)&#039;).click(function(){
    this.target = &quot;_blank&quot;;
});</pre>
<p><strong>12. Test if an image is loadable and load it</strong><br />
Checking if an image can be loaded is quite simple using jQuery, just attempt a load via the standard methods. This snippet will check if the image can be loaded then add it to a specific element. In this case a new tag has been created, however this can be changed to existing images.</p>
<pre class="brush: javascript; gutter: true">var imgsrc = &#039;http://placekitten.com/200/300&#039;;
$(&#039;&lt;img /&gt;&#039;).load(function () {
    console.log(&quot;image loaded!&quot;);
}).error(function () {
    console.log(&quot;couldn&#039;t load image&quot;);
}).attr(&#039;src&#039;, imgsrc);</pre>
<p><strong>13. Alphabetically order a list of values</strong><br />
It far nicer to have a list ordered alphabetically.</p>
<pre class="brush: html; gutter: true">&lt;ul&gt;
	&lt;li&gt;cloud&lt;/li&gt;
	&lt;li&gt;sun&lt;/li&gt;
	&lt;li&gt;rain&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- becomes --&gt;
&lt;ul&gt;
	&lt;li&gt;cloud&lt;/li&gt;
	&lt;li&gt;rain&lt;/li&gt;
        &lt;li&gt;sun&lt;/li&gt;
&lt;/ul&gt;</pre>
<p>The jQuery to sort the list. Currently it just looks at a single ul, but changing the &#8220;ul&#8221; selector in both places will allow you to target the list you require.</p>
<pre class="brush: javascript; gutter: true">var items = $(&#039;ul li&#039;).get();
items.sort(function(a,b){
    var keyA = $(a).text();
    var keyB = $(b).text();
    if (keyA &lt; keyB) return -1;
    if (keyA &gt; keyB) return 1;
    return 0;
});
var ul = $(&#039;ul&#039;);
$.each(items, function(i, li){
    ul.append(li);
});</pre>
<p><strong>14. Write a custom selector to save time</strong><br />
Creating your own selector is very easy, and useful to do if there is something you are regularly looking for. This snippet will create a selector that filters what you select to only those that contain integers over ten, the example colours it red.</p>
<pre class="brush: javascript; gutter: true">$.extend($.expr[&#039;:&#039;], {
    //name of your special selector
    gtTen : function (a){
        //Matching element
        return parseInt($(a).html()) &gt; 10;
    }
});

$(document).ready(function() {
    $(&#039;td:gtTen&#039;).css(&#039;background-color&#039;, &#039;#ff0000&#039;);
});</pre>
<p><strong>15. Quick way to check if an element exists</strong><br />
Doesn&#8217;t get quicker than this.</p>
<pre class="brush: javascript; gutter: true">if ($(&quot;#elementid&quot;).length) {
    // exists
}</pre>
<p><strong>16. Open the print dialogue</strong><br />
This will work for the majority of people including those without printers.</p>
<pre class="brush: javascript; gutter: true">$(&#039;.print&#039;).click(function(e){
    window.print();
    preventDefault(e);
    return false;
});</pre>
<p><strong>17. Animate an object from left to right</strong><br />
Animation in jQuery is a powerful feature, as a primer this is a short snippet on how easy it is to move an object from the left to the right of the screen. This snippet will animate a sprite one hundred percent from the left. If this object is position relatively it will be 100% of what ever its held within, if absolutely 100% of the screen.</p>
<pre class="brush: javascript; gutter: true">$(&quot;#sprite&quot;).animate({
    left: &quot;+=100%&quot;
}, 2000);</pre>
<p><strong>18. A digital clock</strong><br />
This snippet creates a 12 hour time based on the client machines local time. It will then add this string to the element with the id of &#8220;clock&#8221;.</p>
<pre class="brush: javascript; gutter: true">function clock() {
    var currentTime = new Date;
    var currentHours = currentTime.getHours();
    var currentMinutes = currentTime.getMinutes();
    var currentSeconds = currentTime.getSeconds();
    currentMinutes = (currentMinutes &amp;amp;&amp;amp; lt; 10 ? &quot;0&quot; : &quot;&quot;) + currentMinutes;
    currentSeconds = (currentSeconds &amp;amp;&amp;amp; lt; 10 ? &quot;0&quot; : &quot;&quot;) + currentSeconds;
    var timeOfDay = currentHours &amp;amp;&amp;amp; lt;
    12 ? &quot;AM&quot; : &quot;PM&quot;;
    currentHours = currentHours &amp;amp;&amp;amp; gt; 12 ? currentHours - 12 : currentHours;
currentHours = currentHours == 0 ? 12 : currentHours;
    var currentTimeString = currentHours + &quot;:&quot; + currentMinutes + &quot;:&quot; + currentSeconds + &quot; &quot; + timeOfDay;
$(&quot;#clock&quot;).text(currentTimeString);
}

myCounter = setInterval(function () {
    clock();
}, 1000);</pre>
<p><strong>19. Slide content in and out</strong><br />
Sometimes is nice to be able to slide additional content in and out if a user clicks a more info button, slide toggle is perfect for this.</p>
<p>In this snippet given that you bind an event to the read more button, slide toggle will allow you to slide in and out the extended content based on the faux id placed in the href value. Slide toggle is useful as it will show or hide content based on its current state.</p>
<pre class="brush: html; gutter: true">This is some content, &lt;a href=&quot;#content1&quot;&gt;read more&lt;/a&gt;
&lt;p class=&quot;hidden&quot; id=&quot;content1&quot;&gt;More content&lt;/p&gt;</pre>
<pre class="brush: javascript; gutter: true">var target = $(this).attr(&#039;href&#039;);
$(target).slideToggle(&quot;slow&quot;);</pre>
<p><strong>20. Clone an element</strong><br />
In this snippet, clicking an image within an element with the id of &#8220;clonebox&#8221;, the image will be cloned and added to the end after all other images. Cloning can be useful for such things as form elements, where users can add additional information.</p>
<pre class="brush: javascript; gutter: true">$(&quot;#clonebox img&quot;).on(&quot;click&quot;, function(e) {
    $(&quot;#clonebox img:first&quot;).clone().appendTo(&quot;#clonebox&quot;);
});</pre>
<p><strong>21. Loop through an array</strong><br />
In this snippet, an array is created of cat names, then using jQuery&#8217;s each function, the names are appended to the element with the id of &#8220;litterbox&#8221; preceded with the number of its position in the array (plus one, as for users having a position of zero would be confusing). A comma is appended if there are more array elements to add and a fullstop if not.</p>
<pre class="brush: javascript; gutter: true">var cats = [&quot;Mr Moggles&quot;, &quot;Mindy&quot;, &quot;Patch&quot;, &quot;Socks&quot;, &quot;The Destroyer&quot;, &quot;Lily&quot;, &quot;Alfie&quot;, &quot;Bob&quot;];
$.each(cats, function (index, value) {
    $(&quot;#litterbox&quot;).append(index + 1 + &quot;. &quot; + value);
    if (!(index == len - 1)) {
        $(&quot;#litterbox&quot;).append(&quot;, &quot;);
    } else {
        $(&quot;#litterbox&quot;).append(&quot;.&quot;);
    }
});</pre>
<p><strong>22. Automatically link Twitter mentions</strong><br />
Although barely jQuery this little snippet will match whole words that start with an @ sign and convert them to links to twitter using the username in question. Using the replace feature of JavaScript the Regular Expression used could be changed to match all sorts of things.</p>
<pre class="brush: javascript; gutter: true">var text = $(&quot;#content&quot;).html();
text.replace(/\B@([\w-]+)/gm, &#039;&lt;a href=&quot;http://twitter.com/$1&quot; target=&quot;_blank&quot;&gt;@$1&lt;/a&gt;&#039;);</pre>
<p><strong>23. Bad at CSS? Use jQuery to make all column heights match</strong><br />
This simple snippet will loop through all of the elements with the class of &#8220;col&#8221;. It will set the &#8220;max&#8221; variable to the highest height it finds. One the each loop has finished it then sets all of the columns to this height.</p>
<pre class="brush: javascript; gutter: true">var max = 0;
$(&quot;.col&quot;).each(function(){
    if ($(this).height() &gt; max) {
        max = $(this).height();
    }
});
$(&quot;.col&quot;).height(max);</pre>
<p><strong>24. Get named access to all of the URL parameters</strong><br />
This snippet again doesn&#8217;t use a great deal of jQuery, but does give you quick access to variables in the URL. In this example the snippet logs the contents of the &#8220;id&#8221; value in the URL.</p>
<pre class="brush: javascript; gutter: true">$.params = function(name){
    var results = new RegExp(&#039;[\\?&amp;amp;]&#039; + name + &#039;=([^&amp;amp;#]*)&#039;).exec(window.location.href);
    if (!results) { return 0; }
        return results[1] || 0;
    }
console.log($.params (&#039;id&#039;));</pre>
<p><strong>25. Disable the enter key</strong><br />
Similar to binding specific keys, you can also prevent certain keys from performing their normal action. In this case you can prevent the enter key (key code 13) from doing anything within a form. Of course &#8220;form&#8221; can be switches to anything you like, just for laughs try assigning it to &#8220;body&#8221;.</p>
<pre class="brush: javascript; gutter: true">$(&quot;form&quot;).keypress(function(e) {
    if (e.which == 13) {
        preventDefault(e);
        return false;
    }
});</pre>
<p><strong>26. Validate someones age</strong><br />
Often you will want to age gate certain content. You would need to also perform this check server side, but in a user friendly manner you can also check their age while they complete a form. This snippet will fire when the element with the id of &#8220;checkage&#8221; is clicked, and will look for values in elements with the id&#8217;s of &#8220;day&#8221;, &#8220;month&#8221; and &#8220;year&#8221;. In this example if the age is found to be less that 18 and alert is triggered.</p>
<pre class="brush: javascript; gutter: true">$(&quot;#checkage&quot;).on(&quot;click&quot;, function(){
    var day = $(&quot;#day&quot;).val();
    var month = $(&quot;#month&quot;).val();
    var year = $(&quot;#year&quot;).val();
    var age = 18;
    var mydate = new Date();
    mydate.setFullYear(year, month-1, day);
    var today = new Date();
    today.setFullYear(today.getFullYear() - age);
    if ((today - mydate) &lt; 0){
        alert(&quot;Sorry, only persons over the age of &quot; + age + &quot; may enter this site&quot;);
    } else {
        alert(&quot;Welcome in!&quot;);
    }
});</pre>
<p><strong>27. Highlight text nodes on a page that contain a specific string</strong><br />
Sometimes it would be useful to the user to highlight full text nodes that contain a specific term. In this example the function is run for the term &#8220;jquery&#8221; and the results stored in a variable called matches, then each of these matches is given a yellow highlight.</p>
<pre class="brush: javascript; gutter: true">$.fn.egrep = function(pat) {
    var out = [];
    var textNodes = function(n) {
    if (n.nodeType == Node.TEXT_NODE) {
        var t = typeof pat == &#039;string&#039; ?
        n.nodeValue.indexOf(pat) != -1 :
        pat.test(n.nodeValue);
        if (t) {
            out.push(n.parentNode);
        }
    } else {
        $.each(n.childNodes, function(a, b) {
            textNodes(b);
        });
    }
};
this.each(function() {
    textNodes(this);
});
    return out;
};

var matches = $(&#039;body&#039;).egrep(/jquery/i);
for (var i = 0; i &lt; matches .length; ++i) {
    void($(matches [i]).css(&#039;background&#039;, &#039;yellow&#039;));
}</pre>
<p><strong>28. Detect browsers</strong><br />
Although no browser detection can be fail-safe, using jQuery makes it super easy to find the browser and its version, then you can do as you please with the information.</p>
<pre class="brush: javascript; gutter: true">if( $.browser.safari ) {
    console.log(&quot;any version of safari&quot;);
}

if ($.browser.msie &amp;&amp; $.browser.version &gt; 6 ) {
console.log(&quot;IE7 and above&quot;);
}

if ($.browser.msie &amp;&amp; $.browser.version &lt; = 6 ) {
console.log(&quot;What the hell, IE6 or below&quot;);
}

if ($.browser.mozilla &amp;amp;&amp;amp; $.browser.version &gt;= &quot;3.5&quot; ) {
console.log(&quot;Firefox 3.5 or higher&quot;);
}</pre>
<p><strong>29. Parse XML</strong><br />
Parsing XML in jQuery is so easy you&#8217;ll wonder how you lived without it. In this example &#8220;xml&#8221; is a variable that contains all of the XML data. The powerful each function then finds each instance of book and logs its attribute named &#8220;author&#8221;.</p>
<pre class="brush: javascript; gutter: true">$(xml).find(&quot;book&quot;).each(function() {
    console.log($(this).attr(&quot;author&quot;));
});</pre>
<p><strong>30. Reload all Iframes</strong><br />
Using the jQuery each function, this snippet will refresh each iframe on the page.</p>
<pre class="brush: javascript; gutter: true">$(&#039;iframe&#039;).each(function() {
    this.contentWindow.location.reload(true);
});</pre>
<p><strong>31. Delay Fading</strong><br />
The delay function can be used to create delays between fading, in this example the element will start of hidden while the delay is running for 3 seconds, fade in over 1 second, again delay while visible for 5 seconds before fading out over 1 second. This sort of action could be useful for informative messages. Of course a mix of effects can be used with delay.</p>
<pre class="brush: javascript; gutter: true">$(&quot;#element&quot;).delay(3000).fadeIn(1000).delay(5000).fadeOut(1000);</pre>
<p><strong>32. Dynamically Change the stylesheet</strong><br />
Assuming your style sheet is the second one one on the page (after your reset style sheet of course) targeting the screen as its media type, this small snippet will change it.</p>
<pre class="brush: javascript; gutter: true">$(&#039;link[media=&#039;screen&#039;]:nth-child(1)&#039;).attr(&#039;href&#039;, &#039;ie.css&#039;);</pre>
<p><strong>33. Animate Anchor Movement</strong><br />
Sure anchors are cool, they jump straight to the relevant matching id of anchor name on the page, but how about animating them?</p>
<p>This code will target all anchors, that is, links that start with a hash, and then animates to that point on the page over 1 second. If you fancy the anchor to be more middle of the page you could always divide the height of the window by two and add this to the top offset&#8230;</p>
<pre class="brush: javascript; gutter: true">$(&#039;a[href^=&quot;#&quot;]&#039;).on(&#039;click&#039;, function () {
    var anchor = $(this).attr(&#039;href&#039;);
    $(&#039;html,body&#039;).animate({scrollTop: $(anchor).offset().top}, 1000);
});</pre>
<p><strong>34. Disable the right click context menu</strong><br />
Sometimes if designing a web app, the context menu can really break the flow, other times you may want to replace the context menu. Although this won&#8217;t work in every browser, this snippet will try to prevent the context menu from showing.</p>
<pre class="brush: javascript; gutter: true">$(document).bind(&#039;contextmenu&#039;, function(e) {
    e.preventDefault();
    return false;
});</pre>
<p><strong>35. Remove the Default Text from Input Boxes</strong><br />
Often you will want to blank the default text currently in the box so the user can type their input, and if they leave the input with a blank value put it back in. This snippet does that for every element with the class of &#8220;swap&#8221; and which has a value to begin with.</p>
<pre class="brush: javascript; gutter: true">swap_val = [];
$(&quot;.swap&quot;).each(function(i){
    swap_val[i] = $(this).val();
    $(this).focusin(function(){
        if ($(this).val() == swap_val[i]) {
            $(this).val(&quot;&quot;);
        }
    }).focusout(function(){
        if ($.trim($(this).val()) == &quot;&quot;) {
            $(this).val(swap_val[i]);
        }
    });
});</pre>
<p><strong>36. Find the Closest</strong><br />
Sometimes you will simply want to find the closest item to a given selector, maybe to manipulate it, highlight it or even remove it. In this snippet when a strong element is clicked (that&#8217;s bold to you old skoolers) it will add the class &#8220;highlight&#8221; to the closest strong element it finds.</p>
<pre class="brush: javascript; gutter: true">$(&quot;strong&quot;).click(function(){
    $(this).closest(&quot;strong&quot;).addClass(&quot;.highlight&quot;);
});</pre>
<p><strong>37. Get Siblings</strong><br />
Sometimes you just want to select all of the siblings of a specific element, well there is already a function for that.</p>
<pre class="brush: javascript; gutter: true">$(&quot;#mydiv&quot;).siblings().css(&#039;background-color&#039;, &#039;red&#039;);</pre>
<p><strong>38. Remove an Option from a Select List</strong><br />
If you need to remove a specific option from a select list this is easy achieved in jQuery. Its worth noting that its better to remove than hide them, as not all browsers will actually hide an option within a select list.</p>
<p>In this snippet the option with a value of &#8220;cat&#8221; will be removed.</p>
<pre class="brush: javascript; gutter: true">$(&quot;#mylist option[value=&#039;cat&#039;]&quot;).remove();</pre>
<p><strong>39. Zebra Tables Rows</strong><br />
Often to make tables more readable you will want to alternate the row colours. Using jQuery selectors its easy to target odd or even rows. In this snippet odd rows are added a class of &#8220;odd&#8221;, the &#8220;odd&#8221; class can be any style you want, a subtle green &#8220;DAD&#8221; is always nice.</p>
<pre class="brush: javascript; gutter: true">$(&quot;tr:odd&quot;).addClass(&quot;odd&quot;);</pre>
<p><strong>40. Count Direct Children</strong><br />
Often its advantageous to now how many direct children there are of a given element; often because of logic or calculation. This snippet shows how quickly you can accomplish this, the variable &#8220;rugrats&#8221; will contain the integer of direct children.</p>
<pre class="brush: javascript; gutter: true">var rugrats = $(&quot;#foo &gt; div&quot;).length</pre>
<p><strong>41. Check if Cookies Are Enabled</strong><br />
Did you know JavaScript can read and write cookies? No? Shame on you. This snippet checks if cookies are enabled by created one and then checking to see if it was created, of course this all goes to pot if JavaScript is disabled.</p>
<p>A date is first created, then 60 seconds of lead time added. A cookie is created with the formatted date string as the expire date. Next a check is performed to see if &#8220;cookietest&#8221; exists, if it wasn&#8217;t created the condition matches and you can perform you logic.</p>
<pre class="brush: javascript; gutter: true">$(document).ready(function() {
    var dt = new Date();
    dt.setSeconds(dt.getSeconds() + 60);
    document.cookie = &quot;cookietest=1; expires=&quot; + dt.toGMTString();
    var cookiesEnabled = document.cookie.indexOf(&quot;cookietest=&quot;) != -1;
    if(!cookiesEnabled){
        //cookies are not enabled
    }
});</pre>
<p><strong>42. Move Options Between Two Select Lists</strong><br />
Often you will want lists to dynamically change given certain criteria. In the snippet below buttons with the ids of both &#8220;add&#8221; and &#8220;remove&#8221; will add the selected option from list one to list 2 and the remove option will remove the selected option from list 2 and add it to list 1.</p>
<pre class="brush: javascript; gutter: true">$(document).ready(function() {
    $(&#039;#add&#039;).click(function() {
        !$(&#039;#select1 option:selected&#039;).appendTo(&#039;#select2&#039;);
    });
    $(&#039;#remove&#039;).click(function() {
        !$(&#039;#select2 option:selected&#039;).appendTo(&#039;#select1&#039;);
    });
});</pre>
<p><strong>43. Get the Current URL</strong><br />
Often valuable information, getting the current URL is a JavaScript affair but still very useful.</p>
<pre class="brush: javascript; gutter: true">$(document).ready(function() {
    var fullurl = window.location.pathname;
});</pre>
<p><strong>44. Get a Users IP Address</strong><br />
There are lots of APIs out there that can determine a users IP address based on the material passed in simply requested a page. This function uses the jSON IP app found at appspot to provide an IP address of your user. Remember IP addresses are not very accurate and a better suited for determining a broad location such as state or if you speak English &#8211; county.</p>
<p>This snippet posts a call to the address expecting JSON as the response and then alerts the IP address value from the response.</p>
<pre class="brush: javascript; gutter: true">$.getJSON(&quot;http://jsonip.appspot.com?callback=?&quot;,function(data){
    alert( &quot;Your ip: &quot; + data.ip);
});</pre>
<p><strong>45. Make a Number Pretty and Separate it with Commas</strong><br />
Although this should be done server side, if you are really stuck you can do this in JavaScript. The snippet below will the delimiter as set in the &#8220;delimiter value&#8221;, and add it in every third place. Changing some like 103459 to 103,459.</p>
<pre class="brush: javascript; gutter: true">var delimiter = &#039;,&#039;;
$(&#039;#result&#039;).html()
.toString()
.replace(new RegExp(&quot;(^\\d{&quot;+($this.html().toString().length%3||-1)+&quot;})(?=\\d{3})&quot;),&quot;$1&quot; + delimiter).replace(/(\d{3})(?=\d)/g,&quot;$1&quot; + delimiter);</pre>
<p><strong>46. Count Lines in a Textarea</strong><br />
Useful for formatting or checking if a user is angry, counting the number of new lines in a textarea can be useful information. The following snippet splits the value of the textarea text into a array by both new lines and carriage returns and then sets the variable &#8220;total&#8221; to the number if items in this array.</p>
<pre class="brush: javascript; gutter: true">var text = $(&quot;#textareaId&quot;).val();
var lines = text.split(/\r|\r\n|\n/);
var total = lines.length;</pre>
<p><strong>47. Validate a Credit Card Number</strong><br />
Credit card numbers must conform to a specific algorithm known as the Luhn-10. This function will validate against the number passed to it &#8220;ccnum&#8221; reversing this process until it errors. The function will return true or false depending on whether the number is valid or not. Of course this function only checks the number, all other checks will have to be handled separately, and of course this should be done for user indication not validation.</p>
<pre class="brush: javascript; gutter: true">function isCreditCard(ccnum){
    if (ccnum.length &gt; 19)
        return (false);
        sum = 0; mul = 1; l = ccnum.length;
        for (i = 0; i &lt; l; i++){
            digit = ccnum.substring(l-i-1,l-i);
            tproduct = parseInt(digit ,10)*mul;
            if (tproduct &gt;= 10) {
                sum += (tproduct % 10) + 1;
            } else {
                sum += tproduct;
            }
            if (mul == 1) {
                mul++;
            } else {
                mul–;
            }
    }
    if ((sum % 10) == 0) {
        return (true);
    } else {
        return (false);
    }
}</pre>
<p><strong>48. Add wmode Cross-Browser to Embed Code</strong><br />
Although embedding Flash is rather superseded now with HTML5 video, having Flash embedded without a wmode value set can cause it to float above all objects. This cross-browser script will add the wmode attribute and tag to all the embed tags it finds. It will also wrap embed code that doesn&#8217;t have an outer tag (such as object) inside a div to try and prevent the tag from breaking other elements and the ability to style is easier.</p>
<pre class="brush: javascript; gutter: true">(&quot;embed&quot;).attr(&quot;wmode&quot;, &quot;opaque&quot;);
var embedTag;
$(&quot;embed&quot;).each(function(i) {
    embedTag = $(this).attr(&quot;outerHTML&quot;);
    if ((embedTag != null) &amp;amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp;amp; (embedTag.length &gt; 0)) {
        embedTag = embedTag.replace(/embed /gi, &quot;embed wmode=&quot;opaque&quot; &quot;);
        $(this).attr(&quot;outerHTML&quot;, embedTag);
    } else {
        $(this).wrap(&quot;&lt;div&gt;&lt;/div&gt;&quot;);
    }
});</pre>
<p><strong>49. Check if Action was Native</strong><br />
Sometime it can be useful to tell whether a specific event was native event (such as a user clicking an anchor) or triggered (such as a bind to an anchor that override the default action).</p>
<p>In this snippet whenever an anchor is clicked, it will check to see if additional client variables were passed, if they were is sets the &#8220;jstrigger&#8221; values to false and if not sets it to true. Its up to you how you use this information, an example could be to react differently depending on if a click was performed by the user it triggered from a function.</p>
<pre class="brush: javascript; gutter: true">$(&#039;a&#039;).click(function(event, triggered) {
    if (triggered) {
        var jstrigger = false;
    } else {
        var jstrigger = true;
    }
});</pre>
<p><strong>50. Display the First Feedburner Entry</strong><br />
jQuery is very good at searching strings. This example performs an AJAX &#8220;get&#8221; of a specified Feedburner feed, in this case the PS3 Attitude feed. Next it will find the relevant information from the first instance of tags matching the string &#8220;pubDate&#8221;, link tag, and description tag and set the corresponding elements with the ids &#8220;date&#8221;, &#8220;title&#8221; and &#8220;description&#8221; to be populated.</p>
<p>A quick way to display fresh information from a syndication source.</p>
<pre class="brush: javascript; gutter: true">$(document).ready(function(){
    $.ajax({
        type: &quot;GET&quot;,
        url: &quot;http://feeds.feedburner.com/ps3attitude&quot;,
        success: function(data){
            $(&quot;#date&quot;).text($(data).find(&quot;item:first&gt;pubDate:first&quot;).text());
            $(&quot;#title&quot;).html(&quot;&lt;a href=&#039;&quot;+$(data).find(&quot;item:first&gt;link:first&quot;).text()+&quot;&#039;&gt;&quot;+$(data).find(&quot;item:first&gt;title:first&quot;).text()+&quot;&lt;/a&gt;&quot;);
            $(&quot;#description&quot;).html($(data).find(&quot;item:first&gt;description:first&quot;).text());
        }
    });
});</pre>
<p><strong>51. Exclude the Current Element</strong><br />
Sometimes you want to select everything apart from the current element that has been clicked, changes or any other event you have bound. The snippet below first puts all anchors in a jQuery variable, then the click function explicitly states not to target &#8220;this&#8221; referring to the relevant source of the event &#8211; useful for example if you want to highlight all other links.</p>
<pre class="brush: javascript; gutter: true">var $allAnchors = $(&quot;a&quot;);
$allAnchors.click(function() {
    $allAnchors.not(this).css(&quot;color&quot;, &quot;red&quot;);
});</pre>
<p><strong>52. Provide Fallback if CDN fails</strong><br />
Its great to be able to use a CDN to serve up your jQuery; it ensures speed and reliability, but often it would be nice to have a fallback, you know, just in-case.</p>
<p>Good&#8217;ol JavaScript to the rescue! The below snippet includes the jQuery via CDN and then uses JavaScript to check if jQuery exists, if it doesn&#8217;t it includes a local copy of jQuery instead.</p>
<pre class="brush: javascript; gutter: true">&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.7.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
if (typeof jQuery == &#039;undefined&#039;) {
document.write(unescape(&quot;%3Cscript src=&#039;/javasript/jquery.js&#039; type=&#039;text/javascript&#039;%3E%3C/script%3E&quot;));
}
&lt;/script&gt;</pre>
<p><strong>53. Konami Code</strong><br />
If you don&#8217;t know what the Konami code is, shame on you and move to 54.</p>
<pre class="brush: javascript; gutter: true">var kkeys = [], konami = &quot;38,38,40,40,37,39,37,39,66,65&quot;;
$(document).keydown(function(e) {
kkeys.push( e.keyCode );
if (kkeys.toString().indexOf(konami) &gt;= 0 ) {
$(document).unbind(&#039;keydown&#039;,arguments.callee);
// do something awesome
$(&quot;body&quot;).addClass(&quot;konami&quot;);
}
});</pre>
<p><strong>54. Password Strength</strong><br />
As a more complicated snippet, the code below binds to the element with the id of &#8220;pass&#8221;. It will perform a number of regular expressions and length checks. Based on the length and complexity (uppercase, lowercase and non alphanumeric characters) it will populate the element with ID &#8220;passstrength&#8221; a word describing the passwords strength, this being &#8220;strong&#8221;, &#8220;medium&#8221; or &#8220;weak&#8221;. If the password has less than 6 characters it will add the message &#8220;more characters&#8221;.</p>
<pre class="brush: javascript; gutter: true">$(&#039;#pass&#039;).keyup(function(e) {
var strongRegex = new RegExp(&quot;^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$&quot;, &quot;g&quot;);
var mediumRegex = new RegExp(&quot;^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$&quot;, &quot;g&quot;);
var enoughRegex = new RegExp(&quot;(?=.{6,}).*&quot;, &quot;g&quot;);
if (false == enoughRegex.test($(this).val())) {
    $(&#039;#passstrength&#039;).html(&#039;More Characters&#039;);
} else if (strongRegex.test($(this).val())) {
    $(&#039;#passstrength&#039;).className = &#039;ok&#039;;
    $(&#039;#passstrength&#039;).html(&#039;Strong!&#039;);
} else if (mediumRegex.test($(this).val())) {
    $(&#039;#passstrength&#039;).className = &#039;alert&#039;;
    $(&#039;#passstrength&#039;).html(&#039;Medium!&#039;);
} else {
    $(&#039;#passstrength&#039;).className = &#039;error&#039;;
    $(&#039;#passstrength&#039;).html(&#039;Weak!&#039;);
}
return true;
});</pre>
<p><strong>55. Persistent Headers on Tables</strong><br />
Often when scrolling you would like for the table header to say static while the user is scrolling down the table or even pieces of content to remain static. The below function will target elements that have the class &#8220;persist-area&#8221; and ensure the element inside with class &#8220;floatingHeader&#8221; remains static at the top of the area until the user has scrolled pass.</p>
<p>It achieves this by cloning the header after the user has scrolled passed it and adds the class of &#8220;floatingHeader&#8221;. This class fixes to the top of the section using &#8220;position:fixed&#8221; and remains there until the table has been scrolled completely through at which point its hidden. All of this is achieving by performing caluclations on the offset of the sections, to determine how far down the section is from the top of the page, how tall it is and when the height and offset of the section is scrolled pass hides the header.</p>
<pre class="brush: css; gutter: true; first-line: 1; highlight: []; html-script: false">.floatingHeader {
position: fixed;
top: 0;
visibility: hidden;
}</pre>
<pre class="brush: javascript; gutter: true">function UpdateTableHeaders() {
$(&quot;.persist-area&quot;).each(function() {
var el = $(this),
offset = el.offset(),
scrollTop = $(window).scrollTop(),
floatingHeader = $(&quot;.floatingHeader&quot;, this)

if ((scrollTop &gt; offset.top) &amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp; (scrollTop &lt; offset.top + el.height())) {
floatingHeader.css({
&quot;visibility&quot;: &quot;visible&quot;
});
} else {
floatingHeader.css({
&quot;visibility&quot;: &quot;hidden&quot;
});
};
});
}

$(function() {
var clonedHeaderRow;
$(&quot;.persist-area&quot;).each(function() {
clonedHeaderRow = $(&quot;.persist-header&quot;, this);
clonedHeaderRow
.before(clonedHeaderRow.clone())
.css(&quot;width&quot;, clonedHeaderRow.width())
.addClass(&quot;floatingHeader&quot;);
});

$(window)
.scroll(UpdateTableHeaders)
.trigger(&quot;scroll&quot;);
});</pre>
<p><strong>56. Make the whole item clickable</strong><br />
Often you will create menus in a list. If a user clicks the list instead of the anchor inside (especially if you have lots of padding) it would be nice to still execute the link (you could also use CSS to do this).</p>
<p><strong>In this snippet &#8220;find&#8221; is used to located the anchor inside the element clicked and the link is opened using &#8220;window.location&#8221;.</strong></p>
<pre class="brush: javascript; gutter: true">$(&quot;ul li&quot;).click(function(){
//get the url from href attribute and launch the url
window.location=$(this).find(&quot;a&quot;).attr(&quot;href&quot;); return false;
});</pre>
<p><strong>57. Makes Images Grey Scale</strong><br />
Want to make your pictures gray scale without having to open up PhotoShop, jQuery and some HTML5 can do that.</p>
<pre class="brush: javascript; gutter: true">function grayscale(src){
var canvas = document.createElement(&#039;canvas&#039;);
var ctx = canvas.getContext(&#039;2d&#039;);
var imgObj = new Image();
imgObj.src = src;
canvas.width = imgObj.width;
canvas.height = imgObj.height;
ctx.drawImage(imgObj, 0, 0);
var imgPixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
for(var y = 0; y &lt; imgPixels.height; y++){
for(var x = 0; x &lt; imgPixels.width; x++){
var i = (y * 4) * imgPixels.width + x * 4;
var avg = (imgPixels.data[i] + imgPixels.data[i + 1] + imgPixels.data[i + 2]) / 3;
imgPixels.data[i] = avg;
imgPixels.data[i + 1] = avg;
imgPixels.data[i + 2] = avg;
}
}
ctx.putImageData(imgPixels, 0, 0, 0, 0, imgPixels.width, imgPixels.height);
return canvas.toDataURL();
}

//Make all images on page Greyscale!
$(&#039;img&#039;).each(function(){
var el = $(this);
el.css({&quot;position&quot;:&quot;absolute&quot;}).wrap(&quot;&lt;div class=&#039;img_wrapper&#039; style=&#039;display: inline-block&#039;&gt;&quot;).clone().addClass(&#039;img_grayscale&#039;).css({&quot;position&quot;:&quot;absolute&quot;,&quot;z-index&quot;:&quot;998&quot;,&quot;opacity&quot;:&quot;0&quot;}).insertBefore(el).queue(function()
{
var el = $(this);
el.parent().css({&quot;width&quot;:this.width,&quot;height&quot;:this.height});
el.dequeue();
});
this.src = grayscale(this.src);
});</pre>
<p><strong>58. Shorten Links With Bit.ly</strong><br />
Often its useful to be able to shorten links, here&#8217;s a function that will do just that.</p>
<pre class="brush: javascript; gutter: true">function get_short_link($url)
{
$bitly_login=&quot;yourloginname&quot;;
$bitly_apikey=&quot;yourapikey&quot;;
$api_call = file_get_contents(&quot;http://api.bit.ly/shorten?version=2.0.1&amp;amp;amp;longUrl=&quot;.$url.&quot;&amp;amp;amp;login=&quot;.$bitly_login.&quot;&amp;amp;amp;apiKey=&quot;.$bitly_apikey);
$bitlyinfo=json_decode(utf8_encode($api_call),true);
if ($bitlyinfo[&#039;errorCode&#039;]==0)
{
return $bitlyinfo[&#039;results&#039;][urldecode($url)][&#039;shortUrl&#039;];
}
else
{
return false;
}
}</pre>
<p><strong>59. Refresh an image</strong></p>
<p>Sometimes its useful to update an image with client-side technology to ensure its the latest version, by appending a random number to the end you can easily achieve this.  The snippet below will add a random number to the end of every single image source on the page.</p>
<pre class="brush: javascript; gutter: true">$(&quot;img&quot;).attr(&#039;src&#039;, $(&quot;img&quot;).attr(&#039;src&#039;) + &#039;?&#039; + Math.random());</pre>
<p><strong>60. Remove selected text with a double click</strong></p>
<p>In some circumstances you may want a user to be able to delete selected text by double clicking the selection, this can easily be made to happen.</p>
<pre class="brush: javascript; gutter: true">function clearSelection()  {&lt;br /&gt;    if(document.selection &amp;amp;&amp;amp; document.selection.empty) {&lt;br /&gt;           document.selection.empty();&lt;br /&gt;  } else if(window.getSelection) {&lt;br /&gt;    var sel = window.getSelection();&lt;br /&gt;          sel.removeAllRanges();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$(element).bind(&#039;dblclick&#039;,function(event){&lt;br /&gt;    //do something&lt;br /&gt;    clearSelection();&lt;br /&gt;});</pre>
<p><strong>61.  Easy sequential fade</strong><br />
Using jQuery&#8217;s each command you can sequential fade in images (well increase their fade time) with jut a simple piece of math.</p>
<p>The below snippet works by using the curren index of the each loop. It will times the index number (starting at one) by a thousand. So the first image will wait 1 second to fade in, the second image 2 seconds and so on&#8230;this creates a faux delayed fade effect.</p>
<pre class="brush: javascript; gutter: true">$(&quot;img&quot;).each(function(i) {&lt;br /&gt;$(this).delay(i*1000).fadeIn();&lt;br /&gt;});</pre>
<p><strong>62. Cancel an AJAX request</strong><br />
Did you know much like timers, you can also cancel AJAX events, the below snippet will abort the request assigned to the object called &#8220;reg&#8221;,this can be used in any way you see fit &#8211; its useful to combine it with a page on unload event.</p>
<pre class="brush: javascript; gutter: true">var req = $.ajax({&lt;br /&gt;type:     &quot;POST&quot;,&lt;br /&gt;url:     &quot;someurl&quot;,&lt;br /&gt;data:     &quot;id=1&quot;,&lt;br /&gt;success: function(){&lt;br /&gt;//something&lt;br /&gt;}&lt;br /&gt;});&lt;br /&gt;//Cancel the Ajax Request&lt;br /&gt;req.abort()</pre>
<p><strong>63. Detect iPad orientation </strong><br />
Using the built in orientation change in the Safari browser for iPad, you can detect the change from landscape to portrait and vice-versa and make changes appropriately.</p>
<pre class="brush: javascript; gutter: true">window.onorientationchange = detectIPadOrientation;
function detectIPadOrientation () {
    if ( orientation == 0 ) {&gt;
alert (&#039;Portrait Mode, Home Button bottom&#039;);
} else if ( orientation == 90 ) {
alert (&#039;Landscape Mode, Home Button right&#039;);
} else if ( orientation == -90 ) {
alert (&#039;Landscape Mode, Home Button left&#039;);
} else if ( orientation == 180 ) {
alert (&#039;Portrait Mode, Home Button top&#039;);
}</pre>
<p><strong>64. Specifically detect Apple devices</strong><br />
Using the built-in navigator user agent you can detect the presence of iPhone, iPod or iPad. This isn&#8217;t 100% reliable but in nearly all cases will work fine.</p>
<pre class="brush: javascript; gutter: true">jQuery(document).ready(function($){
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
if (agentID) {
// mobile code here
}});</pre>
<p>Well that&#8217;s it from me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewriches.com/blog/2012/11/13/64-useful-jquery-snippets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Finally&#8230;a change</title>
		<link>http://www.matthewriches.com/blog/2012/11/12/finally-a-change/</link>
		<comments>http://www.matthewriches.com/blog/2012/11/12/finally-a-change/#comments</comments>
		<pubDate>Mon, 12 Nov 2012 15:27:44 +0000</pubDate>
		<dc:creator>matthew</dc:creator>
				<category><![CDATA[Rant]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[AtMail]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[OpenSSL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plesk]]></category>

		<guid isPermaLink="false">http://www.matthewriches.com/blog/?p=6</guid>
		<description><![CDATA[I finally got around to updating my site, but it hasn&#8217;t been easy. You know how changing one thing creates two problems and then trying to fix those two problems creates four problems and so on, well changing my site &#8230; <a href="http://www.matthewriches.com/blog/2012/11/12/finally-a-change/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I finally got around to updating my site, but it hasn&#8217;t been easy. You know how changing one thing creates two problems and then trying to fix those two problems creates four problems and so on, well changing my site was a bit like that.</p>
<p>By the way I hope you like the new feel, I&#8217;ve essentially trimmed it down and made the content the focus, placing all the content in a single column so its easy to consume &#8211; and don&#8217;t worry, a mobile version will be arriving for the site as well, bespoke of course as I don&#8217;t want to make things too easy.<br />
<span id="more-6"></span><br />
Anyway, I went to update WordPress to the latest version, and problem one occurred  the version of PHP I was running wasn&#8217;t compatible with the latest version of WordPress. Fine, so I ran yum update PHP &#8211; that was a bad idea. Don&#8217;t get me wrong it worked, PHP was running the latest flavour but other stuff started falling over. In for a penny in for a pound I decided to run a global yum update, boy almost 300 packages (which reminded me of <a href="http://www.youtube.com/watch?v=mgVwv0ZuPhM" target="_blank">this video</a>).</p>
<p>So anywho a lot of things got updated and some of the updating actually solved most of the problems I had, but two pieces of software refused to work, these being the important Plesk software and &#8216;AtMail&#8217; the email software I used on one of my domains.</p>
<p>It turns out that updating everything also updated OpenSSL, and Plesk didn&#8217;t like this, downloading an RPM fix from Parallax and installing this cured that problem quiet quickly. The AtMail problem was more serious however, as it was dependant on legacy PHP functions, so the best solution I came up with was to dump AtMail and switch over the Horde instead, it was only one site using this software anyway &#8211; and I didn&#8217;t lose any email, awesome.</p>
<p>So lesson to be learnt, backup everything (as I always do, honest) and don&#8217;t expect simple tasks to have simple solutions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.matthewriches.com/blog/2012/11/12/finally-a-change/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
