<?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>Craig Koster &#187; Development</title>
	<atom:link href="http://www.craigkoster.com/blog/category/dev/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.craigkoster.com/blog</link>
	<description>Design, Develop, &#38; Deliver</description>
	<lastBuildDate>Wed, 07 Jul 2010 14:12:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Solving Large Scale Web Operations</title>
		<link>http://www.craigkoster.com/blog/solving-large-scale-web-operations/</link>
		<comments>http://www.craigkoster.com/blog/solving-large-scale-web-operations/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 14:12:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/blog/?p=457</guid>
		<description><![CDATA[What is DevOps? &#8211; Blog &#8211; dev2ops &#8211; Solving Large Scale Web Operations and DevOps Problems

DevOps is, in many ways, an umbrella concept that refers to anything that smoothes out the interaction between development and operations. However, the ideas behind DevOps run much deeper than that.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://dev2ops.org/blog/2010/2/22/what-is-devops.html">What is DevOps? &#8211; Blog &#8211; dev2ops &#8211; Solving Large Scale Web Operations and DevOps Problems</a></p>
<p>
<blockquote>DevOps is, in many ways, an umbrella concept that refers to anything that smoothes out the interaction between development and operations. However, the ideas behind DevOps run much deeper than that.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/solving-large-scale-web-operations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Beginner’s Guide to Design Patterns</title>
		<link>http://www.craigkoster.com/blog/a-beginner%e2%80%99s-guide-to-design-patterns/</link>
		<comments>http://www.craigkoster.com/blog/a-beginner%e2%80%99s-guide-to-design-patterns/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 14:08:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/blog/?p=455</guid>
		<description><![CDATA[A Beginner’s Guide to Design Patterns &#124; Nettuts+

Design patterns are optimized, reusable solutions to the programming problems that we encounter every day. A design pattern is not a class or a library that we can simply plug into our system; it’s much more than that. It is a template that has to be implemented in [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://net.tutsplus.com/articles/general/a-beginners-guide-to-design-patterns/">A Beginner’s Guide to Design Patterns | Nettuts+</a></p>
<p>
<blockquote>Design patterns are optimized, reusable solutions to the programming problems that we encounter every day. A design pattern is not a class or a library that we can simply plug into our system; it’s much more than that. It is a template that has to be implemented in the correct situation.</p></blockquote>
<p>Pretty good article for beginner&#8217;s on using design patterns in PHP and how they can make your life easier.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/a-beginner%e2%80%99s-guide-to-design-patterns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Classic Dilbert</title>
		<link>http://www.craigkoster.com/blog/classic-dilbert/</link>
		<comments>http://www.craigkoster.com/blog/classic-dilbert/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 22:07:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[dilbert]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=413</guid>
		<description><![CDATA[Hilarious Dilbert today.  They&#8217;re always pretty funny but this one hits home.

]]></description>
			<content:encoded><![CDATA[<p>Hilarious Dilbert today.  They&#8217;re always pretty funny but this one hits home.</p>
<div class="thumbnail"><a href="http://dilbert.com/dyn/str_strip/000000000/00000000/0000000/000000/50000/9000/500/59570/59570.strip.gif" rel="lightbox"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/07/59570.strip-150x150.gif" border="0" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/classic-dilbert/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build Your Own Captcha and Contact Form</title>
		<link>http://www.craigkoster.com/blog/build-your-own-captcha-and-contact-form/</link>
		<comments>http://www.craigkoster.com/blog/build-your-own-captcha-and-contact-form/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 18:30:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=392</guid>
		<description><![CDATA[Build Your Own Captcha and Contact Form

Ever get hit with spam through the contact form on your personal site? Well, here is a short tutorial on how to build a custom captcha to keep the bad guys out.
Nice tutorial on building a contact for with a captcha in PHP.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://net.tutsplus.com/tutorials/php/build-your-own-captcha-and-contact-form/">Build Your Own Captcha and Contact Form</a></p>
<p>
<blockquote>Ever get hit with spam through the contact form on your personal site? Well, here is a short tutorial on how to build a custom captcha to keep the bad guys out.</p></blockquote>
<p>Nice tutorial on building a contact for with a captcha in PHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/build-your-own-captcha-and-contact-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Authentication / Authorization</title>
		<link>http://www.craigkoster.com/blog/php-authentication-authorization/</link>
		<comments>http://www.craigkoster.com/blog/php-authentication-authorization/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 20:41:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=349</guid>
		<description><![CDATA[One of the big things I needed to do when switching from ASP.NET to PHP was to figure out how to do authentication and authorization.  ASP.NET is pretty strong in this area as it&#8217;s very easy to set up forms authentication and authorization rules for a site.  I found that things weren&#8217;t so [...]]]></description>
			<content:encoded><![CDATA[<p>One of the big things I needed to do when switching from ASP.NET to PHP was to figure out how to do authentication and authorization.  ASP.NET is pretty strong in this area as it&#8217;s very easy to set up forms authentication and authorization rules for a site.  I found that things weren&#8217;t so straightforward with PHP so I took it upon myself to put together a simple example to show how to accomplish this.</p>
<div class="thumbnail"><a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/authentication.png" rel="lightbox"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/authentication-150x150.png" border="0" /><br />
</a></div>
<p>The example has a basic premise:  we have a log in page and a secured page.  The user cannot view the secured page until he authenticates via the log in page.  Conversely, the user cannot view the log in page if he has already been authenticated.  If he logs out then he will be taken back to the login page.</p>
<p>A working example of this can be found <a href="http://www.craigkoster.com/blog/playground/login-example.php" target="_blank">right here</a>.  You can also download the code for this example <a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/php-auth.zip">right here</a>.  You&#8217;ll need a local web server that will run PHP 5 and MySQL.</p>
<p>The example will try to authenticate a user against the database.  If the authentication is successful a session key is written and the user is redirected to the secured page.  Most of the code is self explanatory but I wanted to highlight the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
&nbsp;
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//check if person is already logged in and if so redirect to index page</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location: login-example-index.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This code is on our log in page.  It&#8217;s basically checking to see if the person has already authenticated.  If so we want to forward them to the secured page.</p>
<p>A similar snippet is on the secured page and it checks to make sure the user has been authenticated.  If not it&#8217;ll send them back to the login page.</p>
<p>Hope this simple example will help anyone trying to put together some basic authentication.  Please note that this is a <strong>very</strong> simple example and something a little more secure and robust should be used in a production setting that has sensitive data.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/php-authentication-authorization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Six Useful Tips for Web Designers and Developers</title>
		<link>http://www.craigkoster.com/blog/six-useful-tips-for-web-designers-and-developers/</link>
		<comments>http://www.craigkoster.com/blog/six-useful-tips-for-web-designers-and-developers/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 14:37:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=335</guid>
		<description><![CDATA[Six Useful Tips for Web Designers and Developers

We’ve compiled six useful tips for all you web designers and developers out there. They cover various topics including: accessibility, SQL, web developer plugins for Firefox, HTML emails, design and jQuery.
Nice compilation of tips here from Think Vitamin.  I&#8217;m going to check out FirePHP for FireFox PHP [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://thinkvitamin.com/dev/six-useful-tips-for-web-designers-and-developers/">Six Useful Tips for Web Designers and Developers</a></p>
<p>
<blockquote>We’ve compiled six useful tips for all you web designers and developers out there. They cover various topics including: accessibility, SQL, web developer plugins for Firefox, HTML emails, design and jQuery.</p></blockquote>
<p>Nice compilation of tips here from <a href="http://thinkvitamin.com/">Think Vitamin</a>.  I&#8217;m going to check out FirePHP for FireFox PHP debugging.  Wish they made the same thing for Safari.</p>
<p>Also a good tip on creating boxes with nice lighting effects via gradients.  Going to put this into practice today.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/six-useful-tips-for-web-designers-and-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Showcase of HTML 5 Sites</title>
		<link>http://www.craigkoster.com/blog/a-showcase-of-html-5-sites/</link>
		<comments>http://www.craigkoster.com/blog/a-showcase-of-html-5-sites/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 12:47:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=329</guid>
		<description><![CDATA[html5 Gallery

A showcase of sites using html5 markup
Nice compilation of sites that have adopted HTML 5.  I haven&#8217;t looked at the spec yet but certainly will sometime in the near future.  From what I&#8217;ve read there are a lot of great new features.
(via www.zeldman.com)
]]></description>
			<content:encoded><![CDATA[<p><a href="http://html5gallery.com/">html5 Gallery</a></p>
<p>
<blockquote>A showcase of sites using html5 markup</p></blockquote>
<p>Nice compilation of sites that have adopted HTML 5.  I haven&#8217;t looked at the spec yet but certainly will sometime in the near future.  From what I&#8217;ve read there are a lot of great new features.</p>
<p>(via <a href="http://www.zeldman.com">www.zeldman.com</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/a-showcase-of-html-5-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using AJAX &amp; JSON With PHP</title>
		<link>http://www.craigkoster.com/blog/using-ajax-json-with-php/</link>
		<comments>http://www.craigkoster.com/blog/using-ajax-json-with-php/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 19:37:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=294</guid>
		<description><![CDATA[I&#8217;ve used AJAX plenty of times before but it&#8217;s always been in an ASP.NET setting.  I&#8217;m starting to do more and more with PHP and one of the first things I tried to figure out was how to incorporate AJAX into my PHP sites.  After a quick search, it seemed that the Prototype [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve used AJAX plenty of times before but it&#8217;s always been in an ASP.NET setting.  I&#8217;m starting to do more and more with PHP and one of the first things I tried to figure out was how to incorporate AJAX into my PHP sites.  After a quick search, it seemed that the <a href="http://www.prototypejs.org/">Prototype</a> Javascript framework would be a good candidate to work with.  It proved to be a great choice as it was easy to use and well documented.</p>
<p>I&#8217;ve created a simple example that shows how to make an AJAX request to a PHP page and return results using the Prototype library.  The first step is to <a href="http://www.prototypejs.org/download">download the latest version</a> of Prototype (for this example it&#8217;s 1.6.0.3).  It should be a single file that you can drop into a directory to use for this tutorial.</p>
<p>Next, create a file named get-person.php in the same directory as the Prototype file you downloaded.  Open up your favorite editor and paste the following into the file:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
&nbsp;
  	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>PHP / AJAX / JSON / PROTOTYPE<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
&nbsp;
  	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;prototype-1.6.0.3.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
  	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
&nbsp;
		function getPerson(id, target)
		{
			//create new ajax request from prototype library
			new Ajax.Request(&quot;get-person-handler.php&quot;, 
			{
				//inline function to handle success
				onSuccess: function(transport) 
				{
					//get json object from transport
					var person = transport.responseJSON;
&nbsp;
					//use object properties to populate element
					$(target).innerHTML = person.name;
				},
				parameters: { personId: id }
			});
		}
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
 	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;id&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;id&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width:35px;&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
 	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Get Person&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;getPerson($('id').value, 'personDisplay');&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;personDisplay&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>This is a simple file that has one Javascript method we&#8217;ll use to invoke Prototype&#8217;s Ajax object.  The Ajax.Request method will send a POST containing an ID to our PHP file and it will handle the request and return a response formatted in JSON.</p>
<p>Create another file in the same directory called get-person-handler.php and drop the following code into it:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #666666; font-style: italic;">#this needs to be first!
</span><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: application/json'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#create array of person objects
</span><span style="color: #000088;">$people</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'John Doe'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$people</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Jane Smith'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$people</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Steve Johnson'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#get the id from the post
</span><span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'personId'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//create return array and populate with id and name</span>
<span style="color: #000088;">$return</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$return</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$people</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#return json string
</span><span style="color: #b1b100;">echo</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>As you can see, this file handles the POST request, get&#8217;s the ID from the posted data, looks up the person in the array we&#8217;ve created, and returns the data formatted in JSON.</p>
<p>You should be able to load the get-person.php file into your browser, enter an ID (either 1, 2, or 3) into the text box, and click &#8216;Get Person&#8217; to populate the screen with the person&#8217;s name.  Note that since these are PHP files, you&#8217;ll need a local web server running on your machine.</p>
<p>It&#8217;s a pretty simple setup, but I&#8217;ve found that you need to start simple when working with new languages and frameworks.  The next step might be to create a Person class in PHP and return person objects to the client via JSON.  We could also put in some database code to fetch the data from MySQL instead of using our static array.</p>
<p>You can download an archive with the three files in the example <a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/example.zip" title="Example.zip">by clicking here</a>.</p>
<p>A working example of this tutorial is <a href="http://www.craigkoster.com/blog/playground/get-person.php">right here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/using-ajax-json-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Locking Your Desktop</title>
		<link>http://www.craigkoster.com/blog/locking-your-desktop/</link>
		<comments>http://www.craigkoster.com/blog/locking-your-desktop/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 22:24:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=253</guid>
		<description><![CDATA[One of the first things I looked for when I switched to Mac was a way to quickly lock my desktop when I stepped away from my desk.  Unfortunately I had a hard time finding a solid solution.  Through reading various blogs and trying my own things I came up with the following [...]]]></description>
			<content:encoded><![CDATA[<p>One of the first things I looked for when I switched to Mac was a way to quickly lock my desktop when I stepped away from my desk.  Unfortunately I had a hard time finding a solid solution.  Through reading various blogs and trying my own things I came up with the following that works pretty well.</p>
<p>The first step is to enable fast user switching in your System Preferences | Accounts panel.</p>
<p><div class="thumbnail"><a href="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/sys-prefs.png" rel="lightbox[253]"><img src="http://www.craigkoster.com/blog/wp-content/uploads/2009/06/sys-prefs-150x150.png" alt="Account Preferences" border="0"/></a></div>
</p>
<p>Next, fire up script editor and create the following script:</p>

<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #0066ff;">do shell script</span> <span style="color: #009900;">&quot;/System/Library/CoreServices/Menu<span style="color: #000000; font-weight: bold;">\\</span> Extras/User.menu/Contents/Resources/CGSession -suspend&quot;</span></pre></div></div>

<p>Once you have this entered, save the script to your Applications directory with the name &#8216;Lock Desktop&#8217; or something similar.  Make sure that in the save dialog you select a File Format of &#8216;Application&#8217; as we&#8217;ll be running this script as an app.</p>
<p>Now, just double click this file to lock your desktop.  I use LaunchBar on my Mac to launch things and whenever I want to lock my desktop all I have to do is hit the appropriate hot keys and I&#8217;m set.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/locking-your-desktop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Formatter</title>
		<link>http://www.craigkoster.com/blog/code-formatter/</link>
		<comments>http://www.craigkoster.com/blog/code-formatter/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 20:14:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.craigkoster.com/?p=238</guid>
		<description><![CDATA[I&#8217;ve been wanting to be able to post code snippets here and have been looking for a good code formatter/highlighter that integrates with Wordpress.  I found this plugin that looks like it&#8217;ll do the trick nicely.
Here is an example of some PHP

&#60; ?php
/**
 * Front to the WordPress application.
 * wp-blog-header.php which does
 *
 [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been wanting to be able to post code snippets here and have been looking for a good code formatter/highlighter that integrates with Wordpress.  I found <a href="http://wordpress.org/extend/plugins/wp-syntax/">this plugin</a> that looks like it&#8217;ll do the trick nicely.</p>
<p>Here is an example of some PHP</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #009933; font-style: italic;">/**
 * Front to the WordPress application.
 * wp-blog-header.php which does
 *
 * @package WordPress
 */</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Tells WordPress to load the WordPress
 *
 * @var bool
 */</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_USE_THEMES'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/** Loads the WordPress Environment and Template */</span>
<span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp-blog-header.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Here is some C#</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> SqlConnection GetConnection<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">//create connection</span>
    SqlConnection connection <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SqlConnection<span style="color: #000000;">&#40;</span>DataAccess.<span style="color: #0000FF;">ConnectionString</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">//open it</span>
    connection.<span style="color: #0000FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">//send back</span>
    <span style="color: #0600FF;">return</span> connection<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>So far I&#8217;ve been pretty pleased with the output that I&#8217;ve seen from this plugin.  Hopefully this&#8217;ll light a fire under me to post more coding examples here.</p>
<p><i>Update:  If you try this plugin stick with version 0.95 as the latest version (0.96) sometimes throws a preg_match() error when you try to format PHP code.</i></p>
]]></content:encoded>
			<wfw:commentRss>http://www.craigkoster.com/blog/code-formatter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
