<?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>theChrisWalker.net &#187; Code</title>
	<atom:link href="http://thechriswalker.net/category/code/feed" rel="self" type="application/rss+xml" />
	<link>http://thechriswalker.net</link>
	<description>I like Web Development</description>
	<lastBuildDate>Tue, 31 Aug 2010 07:42:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>C, Go and other languages</title>
		<link>http://thechriswalker.net/2010-08/c-go-and-other-languages.html</link>
		<comments>http://thechriswalker.net/2010-08/c-go-and-other-languages.html#comments</comments>
		<pubDate>Mon, 16 Aug 2010 21:15:42 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[GoLang]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=221</guid>
		<description><![CDATA[OK, so I&#8217;m a self-taught programmer. I studied maths at Uni and I really enjoyed pure maths. Not &#8220;Applied Maths&#8221;, not &#8220;Computational Maths&#8221;, but Pure Maths. Basically that means a whole lot of abstract stuff with plenty of logic mixed in. Whilst Maths has a lot in common with programming, and understanding abstract concepts and [...]]]></description>
			<content:encoded><![CDATA[<p>OK, so I&#8217;m a self-taught programmer. I studied maths at Uni and I really enjoyed pure maths. Not &#8220;Applied Maths&#8221;, not &#8220;Computational Maths&#8221;, but Pure Maths. Basically that means a whole lot of abstract stuff with plenty of logic mixed in.</p>
<p>Whilst Maths has a lot in common with programming, and understanding abstract concepts and applying logic to them easily is super-helpful when programming, knowing maths doesn&#8217;t mean your know or understand programming. Only when you start to learn programming can you apply the maths you know to it.</p>
<p><span id="more-221"></span></p>
<p>PHP is an easy starting block. It&#8217;s interpreted, so no compiling necessary. It fits with Apache very well and packages like XAMPP make setting up an environment very simple. It&#8217;s easy to code in an iterative style, simply trying new things and seeing how they work, because you can do this in 2 windows on your computer. One has code, the other your web browser.</p>
<p>So I learnt PHP. I was working in technical support for an ISP at the time and basically wrote tools to help me do that job. For instance one of the first things I wrote was a tool that you pasted in email headers, and it worked out what hops were made and the time delay between each one. As time went on I got more fluent with the language and wrote all sorts of things from a socket-level application that tested the average logon time to a mail server, to an AJAX application for choosing who should make the next Tea round (that would have been &#8220;The Next Big Thing&#8221; had I continued with it, and the &#8220;Wheel of Tea&#8221; would be on everyone&#8217;s lips like Facebook is now!).</p>
<p>And so I considered myself a programmer. I shifted most of my computer away from Windows to Linux and became a general geek. Now after 5 years or so of programming in PHP, I have just started to dabble in real programming. C is very different to PHP. I love it and hate it at the same time. OK, I mostly hate it (but I love it when a plan comes together). I was spurred on by the fact that my first ever C program (which wasn&#8217;t just a hello world I&#8217;ll have you know, but a IPv4/6 UDP listener) worked FIRST try. I&#8217;ve never written anything that worked first time before! </p>
<p>This turned out to be a fluke and I have encounter my fair share of error since, but I digress. The point is that C programming opens up a new world of possibility for me. Routers that run OpenWRT &#8211; I can write applications for. Long-standing daemons that seem to fall over in PHP are now trivial to control more finely. OK so it&#8217;s a lot harder to figure out how you need to structure your program and the pardigms are very different but the results are worth it.</p>
<p>Then I found Go. Google&#8217;s Open Source, designed for Multi-Core, Concurrent programming with automatic garbage collection and interpreter-like compile speeds, whilst remaining within 10-20% of the speed of the final program compared with C. That sounds like a win to me &#8212; if Google is to be believed. The langauge is very immature and I have read numerous articles on the web which claim it&#8217;s performance isn&#8217;t everything Google claim and only for massive (1000k+ lines of code with vastly complex dependencies) projects are compile times significantly less than gcc for C. </p>
<p>I can&#8217;t really comment. Most of the things Go claims to be able to do very well I have never needed, and my biggest application in Go so far is hello-world.go, which was &#8212; oh, I don&#8217;t know &#8212; 10 lines of code? that a generous guestimate. However I do see some of its other features to be very useful for the type of program I would write in it. I.e. horizontally scalable.</p>
<p>Horizontal Scalability is so important. Can you application perform under pressure? Of course not. Pressure is relative and every app will reach a limit. Now if you can only scale vertically, then &#8220;tu es fucked&#8221; (pardon my french). You will eventually not be able to go any higher. But if you can scale horizontally, you have no limits. And Go is desinged for concurrency and non-blocking, asynchronous communications. Using practices like that it would be easy to setup clusters of programs, scaling horizontally.</p>
<p>Of course programs like that are still tricky to build, but Go has the tools as part of it&#8217;s grammer to make it easier. C on the other hand is a basterd, but a supremely powerful one. PHP and other interpreted languages hang back, never going to have the performance of the compiled code (although Python can be pretty damn quick at certain tasks!), but being so much more accessible to the new programmer.</p>
<p>OK, so this post didn&#8217;t really go anywhere. Still I hope you found it interesting. I am learning new sides to programming all the time and am excited by new developments. Go may not be perfect (and has a rubbish name for trying to find info on using Google! Try search for &#8220;Go Program&#8221; and see if any of the results are about a program written in Go &#8212; I&#8217;ll wait &#8212; I didn&#8217;t think so&#8230;) but it has potential and show that people are tyring to think differently about how problems can be tackled and that is definitely a good thing!</p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2010-08/c-go-and-other-languages.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mongo &#8212; and the coolness of Document-Oriented Databases</title>
		<link>http://thechriswalker.net/2010-03/mongo-and-the-coolness-of-document-oriented-databases.html</link>
		<comments>http://thechriswalker.net/2010-03/mongo-and-the-coolness-of-document-oriented-databases.html#comments</comments>
		<pubDate>Tue, 09 Mar 2010 21:44:22 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[Rapid Application Development]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=173</guid>
		<description><![CDATA[I have been following a PHP Rapid Application Development Framework called Lithium with much interest (for other reasons which I fully intend to blog about later) and they are the ones I owe for turning me on to document oriented database systems. So what are they and why are they so cool, and what/who the [...]]]></description>
			<content:encoded><![CDATA[<p>I have been following a PHP Rapid Application Development Framework called <a href="http://lithify.me" title="The Most RAD PHP Framework: Lithium">Lithium</a> with much interest (for other reasons which I fully intend to blog about later) and they are the ones I owe for turning me on to document oriented database systems. </p>
<p>So what are they and why are they so cool, and what/who the hell is &#8220;Mongo&#8221;?</p>
<p>Let&#8217;s deal with the what first. &#8220;Traditional&#8221; database systems are Relational, they are characterised by strictly defined tables, strong relations between tables and their <a href="http://wikipedia.org/wiki/ACID" title="ACID on Wikipedia">ACID</a> compliance. It simple terms that means you say: </p>
<p><em>&#8220;I want a table of users and each one <strong>will</strong> have a first name, a last name and an email address, and each of those <strong>will</strong> be a &#8216;text&#8217; entry of a maximum of 255 characters&#8221;</em>.</p>
<p>If at a later date you want to add more info, then you have to go back and alter your table definition, give the old rows default values and fix any coding bugs that relied on the previous structure (not that you&#8217;d ever develop such a dependant application). Now the approach in a document oriented database is that you say:</p>
<p><em>&#8220;I want a table of users&#8221;</em></p>
<p>Then you can give each one whatever data you want. you may have one user with a name and address, another with a name and phone number only, a third might have a phone number and address but no first name. All these records can co-exist! That&#8217;s pretty different and I really didn&#8217;t know whether it was a good idea. So I played with <a href="http://mogodb.org/" title="MongoDB homepage">MongoDB</a>.</p>
<p><span id="more-173"></span></p>
<p>MongoDB is really cool. I installed it my laptop simply and fired up the shell to play. The syntax is very javascript-like, becasue it <em>is</em> javascript! So we can do this.</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">MongoDB shell version<span style="color: #339933;">:</span> 1.3.3<span style="color: #339933;">-</span><br />
url<span style="color: #339933;">:</span> test<br />
connecting to<span style="color: #339933;">:</span> test<br />
type <span style="color: #3366CC;">&quot;help&quot;</span> <span style="color: #000066; font-weight: bold;">for</span> help<br />
<span style="color: #339933;">&gt;</span> db.<span style="color: #660066;">myFirstMongoDB</span>.<span style="color: #660066;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>key<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;value&quot;</span><span style="color: #339933;">,</span> mixed<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;one&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;two&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;three&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> deep<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>has<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>another<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;object&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
ObjectId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;4b96b836ea70a136feb89c20&quot;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #339933;">&gt;</span> db.<span style="color: #660066;">myFirstMongoDB</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;_id&quot;</span> <span style="color: #339933;">:</span> ObjectId<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;4b96b836ea70a136feb89c20&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;key&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;value&quot;</span><span style="color: #339933;">,</span> &nbsp;<span style="color: #3366CC;">&quot;mixed&quot;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> <span style="color: #3366CC;">&quot;one&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;two&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;three&quot;</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp;<span style="color: #3366CC;">&quot;deep&quot;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;has&quot;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;another&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;object&quot;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span><br />
<span style="color: #339933;">&gt;</span></div></div>
<p>Notice two amazing things here.</p>
<ol>
<li>We never created the table! we simply call <tt>db.myFirstMongoDB...</tt> which creates the &#8220;collection&#8221; (as they are called in the document oriented world). We certainly never defined a schema!</li>
<li>We passed an object with nested data. Not just simple fields! We can use this in a much more useful way in the next example</li>
</ol>
<p>So why might you want to do this. Consider a website with articles. Articles are written by a person, they are published on a date and the have content, tags, comments, view counts, trackbacks, and a proprietary rating system. If this where a relational database, we are looking at the following tables:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">articles: holds the article, date, person_id, view counts, proprietary rating<br />
people: holds the writers<br />
comments: the comments, related by article_id<br />
trackbacks: link back details<br />
ratings: the info for the proprietary system.<br />
tags: tag info<br />
tags_articles: a join table linking tags to the articles</div></div>
<p>Joining all that info together is not only complex, but can be a fair amount of load on the system. As more info wants to be added by the website owners changes become more complicated and difficult. However with Mongo I can hold the article in one collection like this:</p>
<p>[</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#123;</span> <br />
&nbsp; <span style="color: #3366CC;">&quot;published&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;2010-03-09 21:21:00&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; <span style="color: #3366CC;">&quot;author&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Chris Walker&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;profile&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;/profiles/chris-walker&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;My amazing Article&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">&quot;content&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;here's the text...&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">&quot;tags&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> <span style="color: #3366CC;">&quot;wonder&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;amazement&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;mongo&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;demo&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;chris&quot;</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">&quot;comments&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;commenter&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Rosie&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;comment&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;What is this?&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;when&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;2010-03-09 22:02:00&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;commenter&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Chris&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;url&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://thechriswalker.net/&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;comment&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;it's class, that's what!&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;when&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;2010-03-09 23:12:00&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;commenter&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;anonymous&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;comment&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;I am your father.&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;when&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;2010-03-10 01:25:20&quot;</span> <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; rating<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> stars<span style="color: #339933;">:</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> tagline<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;what a monster!&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; views<span style="color: #339933;">:</span> <span style="color: #CC0000;">1024</span><span style="color: #339933;">,</span><br />
&nbsp; trackbacks<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;url&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://some.blog/some/where&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;quote&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;the text for the link&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;url&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://some.other.blog/some/where/else&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;quote&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;the text they used to link here&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #009900;">&#93;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>So that might look like a more complex entity. It is, but you can search for values in sub-documents, you can filter results on existence of certain keys, and you can pull all this info one result. Your previous 7 tables and 8 joins, just became 1 collection and no joins. guess which is quicker?</p>
<p>Try to pull articles with a certain tag: &#8220;balls&#8221;? In SQL you&#8217;d be doing this:</p>
<div class="codecolorer-container sql mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #ff0000;">`article_id`</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`tags_articles`</span> <span style="color: #ff0000;">`ta`</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`tags`</span> <span style="color: #ff0000;">`t`</span> <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #ff0000;">`ta`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`tag_id`</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">`t`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`id`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`t`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`name`</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'balls'</span></div></div>
<p>And that would just get you the list of Id&#8217;s and you&#8217;d still need to get the info for each article. In Mongo with the collection we described above, you&#8217;d do:</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">db.<span style="color: #660066;">articles</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> tags<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;balls&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></div></div>
<p>How much easier is that, and we&#8217;ve now got all the info, not just the &#8220;id&#8221;s! I was just amazed at how easy that is!</p>
<p>Of course this simplicity comes with a price, you lose the relational elements making tight relationships harder to work with. Also you some ease in aggregating things like &#8220;tags&#8221;, but MapReduce support makes this very efficient anyway.</p>
<p>In my next blog I&#8217;ll talk about Lithium, Mongo and how fast you can build a full blown web app with these tools.</p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2010-03/mongo-and-the-coolness-of-document-oriented-databases.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Xbox Live Gamercard API</title>
		<link>http://thechriswalker.net/2009-12/xbox-live-gamercard-api.html</link>
		<comments>http://thechriswalker.net/2009-12/xbox-live-gamercard-api.html#comments</comments>
		<pubDate>Thu, 31 Dec 2009 11:34:25 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[xbox]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=155</guid>
		<description><![CDATA[So, got decided to join most of my friends and I got an Xbox 360. Me being me though, I got interested in the way that all the information about your &#8220;Gamertag&#8221; is stored an accessible on the xbox.com website. Wouldn&#8217;t it be fun to do something with this data! As it turns out, I [...]]]></description>
			<content:encoded><![CDATA[<p>So, got decided to join most of my friends and I got an Xbox 360. Me being me though, I got interested in the way that all the information about your &#8220;Gamertag&#8221; is stored an accessible on the xbox.com website. Wouldn&#8217;t it be fun to do something with this data!</p>
<p>As it turns out, I was beaten to the post by Duncan MacKensie (<a href="http://duncanmackenzie.net/Blog/put-up-a-rest-api-for-xbox-gamertag-data">http://duncanmackenzie.net/Blog/put-up-a-rest-api-for-xbox-gamertag-data</a>) who hosts a webservice to retrieve gamer data from Microsoft. <del datetime="2009-12-31T11:41:44+00:00"> I could find <strong>no</strong> details about how this service works, where the data comes from or anything! Either he has a relationship with Microsoft, or he scrapes xbox.com but either way, the data seems pretty consistent and reliable.</del> <em>Actually it turns out this information was right there on his website&#8230; <a href="http://www.duncanmackenzie.net/Blog/if-you-are-wondering-where-i-get-my-xbox-live-info">http://www.duncanmackenzie.net/Blog/if-you-are-wondering-where-i-get-my-xbox-live-info</a> So he gets it as part of his membership to the Xbox Community Developer Program.</em></p>
<p>However, the webservice is great, and returns XML which is fine, but I thought it would be more useful to me to have a PHP API for this data. So I wrote one which retrieves data from Duncans webservice.</p>
<p> <span id="more-155"></span></p>
<p>Then I thought wouldn&#8217;t it be great to be able to use this dynamically in a webpage, so I wrote a service frontend which will return JSON formatted data. Then I thought wouldn&#8217;t it be useful to let other people use this as well, so I modified it and it can now cope with JSONP requests with a &#8220;_callback&#8221; parameter.</p>
<p>OK, so what does this all mean.</p>
<p><strong>The PHP</strong></p>
<p>The class is called gamertag and the usage is very simple:</p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #666666; font-style: italic;">// include the class file</span><br />
<span style="color: #b1b100;">require</span> <span style="color: #0000ff;">&quot;gamertag.php&quot;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//instantiate</span><br />
<span style="color: #000088;">$G</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Gamertag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thechriswalker'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//get data</span><br />
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$G</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$G</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>which outputs something like this:</p>
<pre class='code'>Array
(
    [Gamertag] => thechriswalker
    [AccountStatus] => Silver
    [State] => Valid
    [ProfileUrl] => http://live.xbox.com/member/thechriswalker
    [TileUrl] => http://avatar.xboxlive.com/avatar/thechriswalker/avatarpic-l.png
    [AvatarFullUrl] => http://avatar.xboxlive.com/avatar/thechriswalker/avatar-body.png
    [Country] => United Kingdom
    [Location] => Bradninch
    [Bio] =>
    [Reputation] => 58.72229
    [ReputationImageUrl] => http://live.xbox.com/xweb/lib/images/gc_repstars_external_12.gif
    [Zone] => Recreation
    [GamerScore] => 230
    [PresenceInfo] => Array
        (
            [Valid] => true
            [Info] => Last seen 12/29/09   playing Modern Warfare® 2
            [Info2] =>
            [LastSeen] => Tue, 29 Dec 2009 21:35:22 +0000
            [Online] => false
            [StatusText] => Offline
            [Title] => Modern Warfare® 2
        )

    [RecentGames] => Array
        (
            [0] => Array
                (
                    [Name] => Modern Warfare® 2
                    [TotalAchievements] => 50
                    [TotalGamerScore] => 1000
                    [Image32Url] => http://tiles.xbox.com/tiles/Z+/tF/12dsb2JgbA9ECgQJGgYfVl5UL2ljb24vMC84MDAwIAABAAAAAPhq63g=.jpg
                    [Image64Url] => http://tiles.xbox.com/tiles/CE/Vx/0Gdsb2JhbC9ECgQJGgYfVl5UL2ljb24vMC84MDAwAAAAAAAAAP9eRRc=.jpg
                    [LastPlayed] => Tue, 29 Dec 2009 21:32:52 +0000
                    [Achievements] => 9
                    [GamerScore] => 115
                    [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3a%60m%2fl%3b%7cw&amp;compareTo=thechriswalker
                )

            [1] => Array
                (
                    [Name] => PGR 4
                    [TotalAchievements] => 60
                    [TotalGamerScore] => 1250
                    [Image32Url] => http://tiles.xbox.com/tiles/Y1/qn/0Gdsb2JgbA9ECgR8GgMfWSlaL2ljb24vMC84MDAwIAABAAAAAP+IWnw=.jpg
                    [Image64Url] => http://tiles.xbox.com/tiles/DP/ST/12dsb2JhbC9ECgR8GgMfWSlaL2ljb24vMC84MDAwAAAAAAAAAPi89BM=.jpg
                    [LastPlayed] => Mon, 28 Dec 2009 16:59:25 +0000
                    [Achievements] => 5
                    [GamerScore] => 115
                    [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3a%15%18*iAq%0b&amp;compareTo=thechriswalker
                )

        )

)</pre>
<p>So now we can easily get at the data. The source code for the class (which is not fully tested, but the basics work!) is at <a href="http://thechriswalker.net/xbox360/gamertag.source.php">http://thechriswalker.net/xbox360/gamertag.source.php</a> (NB it requires either PHP5 (for json_encode) or the PEAR Services_JSON class if you want to use the &#8220;getJSON()&#8221; method).</p>
<p><strong>The JSON</strong></p>
<p>PHP is well and good but what if I want to use a JSON/JSONP (JSONP is for cross-domain information requesting and is very useful for public information services, see http://en.wikipedia.org/wiki/JSON#JSONP) request, well, that can be done at <a href="http://thechriswalker.net/xbox360/?gamertag=YOUR_GAMERTAG">http://thechriswalker.net/xbox360/?gamertag=YOUR_GAMERTAG</a> for the straight JSON or <a href="http://thechriswalker.net/xbox360/?gamertag=YOUR_GAMERTAG&#038;_callback=YOUR_CALLBACK_FUNCTION_NAME"> http://thechriswalker.net/xbox360/?gamertag=YOUR_GAMERTAG&#038;_callback=YOUR_CALLBACK_FUNCTION_NAME</a> for JSONP.</p>
<p>The first returns just JSON with a content type &#8220;application/json&#8221; and the second returns a javascript function call to your callback function with the JSON object as the only parameter and a content type of &#8220;text/javascript&#8221;.</p>
<p>These enabled me to build a simple Google Gadget to display a Gamercard:</p>
<p><center><br />
<script src="http://www.gmodules.com/ig/ifr?url=http://thechriswalker.net/xbox360/xblgamercard.xml&amp;up_gamertag=thechriswalker&amp;synd=open&amp;w=600&amp;h=200&amp;title=Xbox+Live+Gamertag+Info+for+%22chriswalker%22&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script></center></p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2009-12/xbox-live-gamercard-api.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>More WebKit Goodies &#8211; CSS Transforms and Transitions &#8211; the OSX Dock example</title>
		<link>http://thechriswalker.net/2009-03/more-webkit-goodies-css-transforms-and-transitions-the-osx-dock-example.html</link>
		<comments>http://thechriswalker.net/2009-03/more-webkit-goodies-css-transforms-and-transitions-the-osx-dock-example.html#comments</comments>
		<pubDate>Thu, 12 Mar 2009 19:44:22 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=98</guid>
		<description><![CDATA[As promised last time, I here we will discuss the transforms in WebKit, and how they can be used to create interactive applications without Javascript (for animation that is &#8211; we still need it for AJAX, etc.) Tranforms have been implemented on a few browser using proprietary syntax, and the same is true of WebKit. [...]]]></description>
			<content:encoded><![CDATA[<p>As promised last time, I here we will discuss the transforms in WebKit, and how they can be used to create interactive applications without Javascript (for animation that is &ndash; we still need it for AJAX, etc.)</p>
<p>Tranforms have been implemented on a few browser using proprietary syntax, and the same is true of WebKit. As we shall see further down the article though, the WebKit transitions make them so much more powerful.</p>
<p>But what are they? They modify an element, without displacing it&#8217;s original setting within the document, which means we can move it about and the spacing doesn&#8217;t change. </p>
<style type='text/css'>
.flip:hover { -webkit-transform:rotate(180deg); }
.transition { -webkit-transition:-webkit-transform 1s linear }
.transition-allover, .transition-left { -webkit-transform-origin:30% 50%;-webkit-transition:-webkit-transform 1s linear; }
.transition-left:hover {
 -webkit-transform:rotate(180deg);
 -webkit-transform-origin:30% 50%; 
}
.transition-allover:hover {
  -webkit-transform: rotate(180deg) scale(1.5) translate(-50%, 50%);
  -webkit-transform-origin:30% 50%; 
}
#hey-look-at-me:target pre {
  outline:2px solid red;
  color:#f0f;
}
#hey-look-at-me pre{
  -webkit-transition-property:outline, color;
  -webkit-transition-duration:500ms;
}
</style>
<blockquote style='color:#c00;'><p>Remember these will only work in WebKit based browsers, for example Safari for Mac, Chrome for Windows or Midori for Linux</p></blockquote>
<p>An example: how about rotation.</p>
<pre class='code flip'>element:hover {
  -webkit-transform:rotate(180deg);
}</pre>
<p>Not very exciting, but combine this with a transition! (Try putting you mouse in the middle of the box for best effect)</p>
<pre class='code flip transition'>element:hover {
  -webkit-transform:rotate(180deg);
}
element {
  -webkit-transition:-webkit-transform 1s linear
}</pre>
<p><span id="more-98"></span></p>
<p>Much more useful! But there&#8217;s more, we can scale, we can translate (change its position on the screen)  and also we can change the &#8220;center&#8221; for the transform. Usually the rotation happens from the center like above, but we could do it from closer to the left:</p>
<pre class='code transition-left'>element:hover {
  -webkit-transform:rotate(180deg);
  -webkit-transform-origin:30% 50%;
}
element {
  -webkit-transition:-webkit-transform 1s linear;
  -webkit-transform-origin:30% 50%;
}</pre>
<p>Or we could scale and move and rotate! (you might need to track it with you mouse to keep the animation! this is a demo after all!)</p>
<pre class='code transition-allover'>element:hover {
  -webkit-transform:rotate(180deg) scale(2) translate(-100%,0);
  -webkit-transform-origin:30% 50%;
}
element {
  -webkit-transition:-webkit-transform 1s linear;
  -webkit-transform-origin:30% 50%;
}</pre>
<div id='hey-look-at-me'>
<div id='untarget'>
<p>As the above eaxmple showed, hover is not always the best trigger for this. So lets use the <tt>:target</tt> pseudo-class. This is the pseudo-class that is applied when the element is the &#8216;target&#8217; of an anchor/url hash. e.g:</p>
<pre class='code'>&lt;div id='hey-look-at-me'&gt; &lt;div id='untarget'&gt; &lt;pre&gt;
CSS:
#hey-look-at-me:target pre {
  outline:2px solid red;
  color:#f0f;
}
#hey-look-at-me pre {
  -webkit-transition-property:outline, color;
  -webkit-transition-duration:500ms;
}
&lt;/pre&gt; &lt;/div&gt; &lt;/div&gt;

<a href='#hey-look-at-me'>target me!</a> <a href='#untarget'>untarget me!</a>
</pre>
</div>
</div>
<p><strong>NB:</strong> Notice how I nested the <tt>PRE</tt> to stop unwanted excessive screen movement.</p>
<p>So, what can we do with all this? Well, the culmination of the post, the Mac OSX style Dock menu, using no Javascript. Yes, that&#8217;s right a bulging docked menu, with no javascript.</p>
<p>Just so you remember, there <strong>no javascript</strong> in the demo.</p>
<p>Check out the <a href='/osx-dock'>Javascript free OSX Dock Menu Demo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2009-03/more-webkit-goodies-css-transforms-and-transitions-the-osx-dock-example.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Webkit CSS Transitions &#8211; pretty cool stuff</title>
		<link>http://thechriswalker.net/2009-03/webkit-css-transitions-pretty-cool-stuff.html</link>
		<comments>http://thechriswalker.net/2009-03/webkit-css-transitions-pretty-cool-stuff.html#comments</comments>
		<pubDate>Tue, 10 Mar 2009 22:11:00 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=84</guid>
		<description><![CDATA[I recently read somewhere about developing web applications for the iPhone / Android browsers that you shouldn&#8217;t use Javascript Frameworks (e.g. jQuery) for animation in your web apps but instead use CSS3 transitions. I had no idea what these where, so had to look it up. Turns out it&#8217;s pretty much a WebKit only thing, [...]]]></description>
			<content:encoded><![CDATA[<p>I recently read somewhere about developing web applications for the iPhone / Android browsers that you shouldn&#8217;t use Javascript Frameworks (e.g. jQuery) for animation in your web apps but instead use CSS3 transitions. I had no idea what these where, so had to look it up. Turns out it&#8217;s pretty much a WebKit only thing, but that&#8217;s fine for iPhone (Safari) and Android (Chrome) Browsers.  </p>
<p>But what is it? Simply put, it&#8217;s a way to create a transition between to CSS states (hope that cleared <em>everything</em> up for you!)</p>
<p>Better, an example: You have two CSS rules for an element, say a link, and for it&#8217;s <tt>:hover</tt> state. like this:</p>
<div class="codecolorer-container css mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <br />
&nbsp; &nbsp; -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <br />
&nbsp; &nbsp; -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <br />
<span style="color: #00AA00;">&#125;</span><br />
a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></div>
<p>Now usually, the browser would switch instantly between these two states, but with transitions we can slow it down into a smooth animation.</p>
<p>We can specify which propertys to transition and which to allow to change instantly. Here we can transition in the <tt>background</tt> and <tt>color</tt> properties.</p>
<div class="codecolorer-container css mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">a <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <br />
&nbsp; &nbsp; -moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <br />
&nbsp; &nbsp; -webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Add the transition properties! */</span><br />
&nbsp; &nbsp; -webkit-transition-property<span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; -webkit-transition-duration<span style="color: #00AA00;">:</span> 600ms<span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* you can control the acceleration curve here */</span><br />
&nbsp; &nbsp; -webkit-transition-timing-function<span style="color: #00AA00;">:</span> ease-in-out<span style="color: #00AA00;">;</span> <br />
<span style="color: #00AA00;">&#125;</span><br />
a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></div>
<p>Here&#8217;s two links, the they are identical except that the second has the transisions applied and if you&#8217;re using a WebKit based browser then it will fade nicely between states.</p>
<style type='text/css'>
a.tryme {
    display:inline-block;
    margin:5px 10px;
    background:#eee;
    color:#333;
    text-decoration:none;
    padding:5px 10px;
    border:2px solid #333;
    border-radius: 5px; 
    -moz-border-radius: 5px; 
    -webkit-border-radius: 5px;
}
a.trans {
    -webkit-transition-property: background-color, color;
    -webkit-transition-duration: 600ms;
    -webkit-transition-timing-function: ease-in-out;
}
a.tryme:hover {
    background:#333;
    color:#eee;
}
</style>
<p><a href='javascript:void(0);' class='tryme'>I will flick between states.</a> <a href='javascript:void(0);' class='tryme trans'>Do I fade or do I flick?</a></p>
<p>Next time I&#8217;ll go into a bit more detail and show how using CSS Transforms as well we can make an OSX Dock style menu using CSS alone!</p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2009-03/webkit-css-transitions-pretty-cool-stuff.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Multiple Drag and Drop between two lists with jQuery</title>
		<link>http://thechriswalker.net/2009-02/multiple-drag-and-drop-between-two-lists-with-jquery.html</link>
		<comments>http://thechriswalker.net/2009-02/multiple-drag-and-drop-between-two-lists-with-jquery.html#comments</comments>
		<pubDate>Tue, 10 Feb 2009 12:26:58 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=64</guid>
		<description><![CDATA[I wanted this functionality for a project a while ago. I google&#8217;d and found that lots of others did too, but no one had done it. Or at least not in a way that I could understand. In fact, I&#8217;m not sure I completely understand it anymore. It works very well, but also it could [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted this functionality for a project a while ago. I google&#8217;d and found that lots of others did too, but no one had done it. Or at least not in a way that I could understand. In fact, I&#8217;m not sure I completely understand it anymore. It works very well, but also it could have some improvement. I would like to be able to drag the mouse to create a selection, but this in itself poses the difficultly of how to distinguish a &#8220;drag-to-move&#8221; from a &#8220;drag-to-select&#8221;. </p>
<p>Still I found it an interesting proof-of-concept and maybe you will too. The test can be found here: <a href='/select-drag/' title='Select and Drag Demo'>Select and Drag Demo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2009-02/multiple-drag-and-drop-between-two-lists-with-jquery.html/feed</wfw:commentRss>
		<slash:comments>101</slash:comments>
		</item>
		<item>
		<title>DarkAuth for CakePHP</title>
		<link>http://thechriswalker.net/2009-02/darkauth-for-cakephp.html</link>
		<comments>http://thechriswalker.net/2009-02/darkauth-for-cakephp.html#comments</comments>
		<pubDate>Fri, 06 Feb 2009 10:41:49 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=56</guid>
		<description><![CDATA[I thought I&#8217;d add a page to satisfy those of you who may have arrived here from the Cookbook, or anywhere else one of the DarkAuth pages was linked from. I don&#8217;t really have much to do with this Component any more, although it still works great! I found that the built in Auth Component [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I&#8217;d add a page to satisfy those of you who may have arrived here from the Cookbook, or anywhere else one of the DarkAuth pages was linked from.</p>
<p>I don&#8217;t really have much to do with this Component any more, although it still works great! I found that the built in Auth Component is plenty powerful enough, even if it doesn&#8217;t quite work work how I would have designed it.</p>
<p>Anyway, here&#8217;s the component (tested with CakePHP 1.2 RC3) <a href='http://thechriswalker.net/wp-content/2009/02/dark_auth.zip'>DarkAuthComponent</a>. Enjoy! It&#8217;s highly commented, so hopefully you&#8217;ll be able to work out what it does and how to use it&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2009-02/darkauth-for-cakephp.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>jQuery SuperSelect</title>
		<link>http://thechriswalker.net/2009-01/jquery-superselect.html</link>
		<comments>http://thechriswalker.net/2009-01/jquery-superselect.html#comments</comments>
		<pubDate>Thu, 29 Jan 2009 13:44:43 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=53</guid>
		<description><![CDATA[A little while back I was working on a project and wanted a selectbox to look a bit more pretty, but with complete backwards compatibility with regular select boxs. I.E. If I already had a select box on the page, and it had various JavaScript events hanging off it already, I wanted that to function [...]]]></description>
			<content:encoded><![CDATA[<p>A little while back I was working on a project and wanted a selectbox to look a bit more pretty, but with complete backwards compatibility with regular select boxs. </p>
<p>I.E. If I already had a select box on the page, and it had various JavaScript events hanging off it already, I wanted that to function still but I wanted the box to be prettier.</p>
<p>The first idea was to use CSS to just style the box. But then I realised that each browser and OS has it&#8217;s own different way of rendering the controls. So I turned to JavaScript, and the always useful <a href='http://jquery.com/' title='the jQuery Homepage'>jQuery</a> library. I wrote a plugin that will immediately transform any selectboxes into prettier ones, allows icons for the options, all with valid xhtml and works completely fine with JavaScript (or the plugin) disabled. Pretty cool, eh?</p>
<p>Well, I put the original demo page I designed for it back online, so <a href='/superselect/' title='the jQuery superselect plugin'>check out the plugin!</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2009-01/jquery-superselect.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CakePHP Evangelism and T-Cake</title>
		<link>http://thechriswalker.net/2009-01/cakephp-evangelism-and-t-cake.html</link>
		<comments>http://thechriswalker.net/2009-01/cakephp-evangelism-and-t-cake.html#comments</comments>
		<pubDate>Wed, 28 Jan 2009 23:10:21 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[T-Cake]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=49</guid>
		<description><![CDATA[So I&#8217;ve had this blog for 3 posts now and none of them has a &#8220;cakephp&#8221; tag yet. Shocking. So here we go&#8230; If you don&#8217;t know what CakePHP is and you&#8217;ve ever created a web application, or even a website that did more than show a static page, then you should check it out. [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;ve had this blog for 3 posts now and none of them has a &#8220;cakephp&#8221; tag yet. Shocking. So here we go&#8230;</p>
<p>If you don&#8217;t know what <a href='http://cakephp.org' title='Visit the CakePHP website'>CakePHP</a> is and you&#8217;ve ever created a web application, or even a website that did more than show a static page, then you should check it out. CakePHP is a web application framework designed for rapid application development using the <a href='http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller#As_an_architectural_pattern' title='Wikipedia on MVC'>MVC Design Pattern</a> and with a focus on <a href='http://en.wikipedia.org/wiki/Convention_over_configuration' title='Wikipedia on Convetion over Configuration'>Convention over Configuration</a>.</p>
<p>What this means in practical terms is that you can built an access controlled, database driven, dynamic web sites/applications in a fraction of the time that it would to start from scratch. A simple blog could be built in a matter of minutes. I could go on for hours. So I won&#8217;t, but really &#8211; if you make web apps, consider using a framework and CakePHP is excellent.</p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2009-01/cakephp-evangelism-and-t-cake.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regular Expressions in MySQL</title>
		<link>http://thechriswalker.net/2009-01/regular-expressions-in-mysql.html</link>
		<comments>http://thechriswalker.net/2009-01/regular-expressions-in-mysql.html#comments</comments>
		<pubDate>Fri, 23 Jan 2009 09:40:16 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Regular Expressions]]></category>

		<guid isPermaLink="false">http://thechriswalker.net/?p=21</guid>
		<description><![CDATA[I like regular expressions. Anyone who has tried to understand them will understand the learning curve involved and in no way do I claim to be an expert. However, I use them all the time. They are possibly the most useful thing I have ever learnt to do with programming and are more powerful I [...]]]></description>
			<content:encoded><![CDATA[<p>I like regular expressions. Anyone who has tried to understand them will understand the learning curve involved and in no way do I claim to be an expert. However, I use them all the time. They are possibly the most useful thing I have ever learnt to do with programming and are more powerful I imagined at first.</p>
<h3>So what does this have to do with MySQL?</h3>
<p>Well, I was recently dealing wit a table in which there is some inline JSON serialised data. This makes sense for the situation but of course if you want to query on something within the data you have to be a bit more careful. You have two options as I saw it yesterday:</p>
<ul>
<li>Pull all the data and parse it out outside of the database <em>- which seems weak and inefficient.</em></li>
<li>Use some LIKE query to pull likely candidates and then parse out of the data base <em>- again not so good, but a bit better.</em></li>
</ul>
<p><span id="more-21"></span></p>
<h3>The solution!</h3>
<p>You can use Regular Expressions in a MySQL query! To simplify the problem I faced, suppose you have a field in the database which contains JSON data like this:</p>
<div class="codecolorer-container javascript mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;content&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #CC0000;">56</span><span style="color: #339933;">,</span><span style="color: #CC0000;">578</span><span style="color: #339933;">,</span><span style="color: #CC0000;">600</span><span style="color: #339933;">,</span><span style="color: #CC0000;">601</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;next&quot;</span><span style="color: #339933;">:</span><span style="color: #CC0000;">56</span> <span style="color: #009900;">&#125;</span></div></div>
<p>And I want to find all records which contain a specific value in the &#8220;content&#8221; array (and suppose I know which records will have the &#8220;content&#8221; array by another field/method). LIKE would not be enough as it leaves to much room for error, but Regular Expressions &#8211; easy! If I want to find the value 578 then:</p>
<div class="codecolorer-container mysql mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="mysql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> <span style="color: #008000;">`table`</span> <span style="color: #990099; font-weight: bold;">WHERE</span> <span style="color: #008000;">`json<span style="color: #008080; font-weight: bold;">_</span>data`</span> <span style="color: #CC0099; font-weight: bold;">REGEXP</span> <span style="color: #008000;">'<span style="color: #004000; font-weight: bold;">\\</span>[([0-9]*,)*578(,|<span style="color: #004000; font-weight: bold;">\\</span>])'</span><span style="color: #000033;">;</span></div></div>
<p>Would find all records with 578 as an element in an array containing only numbers. Combine this with the method for restricting the SELECT to only filed you know will contain data in the right format and you have done it!</p>
<p>This is but one example, and the technique seems most useful when you have a serialised data format in your database field, but could be useful for advanced searching in table that do not support &#8220;fulltext&#8221; searches.</p>
]]></content:encoded>
			<wfw:commentRss>http://thechriswalker.net/2009-01/regular-expressions-in-mysql.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
