<?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>Bill Richards</title>
	<atom:link href="http://www.wrichards.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wrichards.com/blog</link>
	<description>a developer&#039;s blog</description>
	<lastBuildDate>Tue, 20 Jul 2010 16:32:44 +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>PHP base_convert() in AS3</title>
		<link>http://www.wrichards.com/blog/2010/07/php-base_convert-in-as3/</link>
		<comments>http://www.wrichards.com/blog/2010/07/php-base_convert-in-as3/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 16:10:39 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[base_convert()]]></category>

		<guid isPermaLink="false">http://www.wrichards.com/blog/?p=109</guid>
		<description><![CDATA[Here is a quick example of how to use PHP&#8217;s base convert function in AS3. A lot of people use this function for shorter masked URLs like YouTube. Easy enough but took me a minute to find the equivalent in actionscript. PHP: function encode36($x){ return base_convert($x, 10, 36); } function decode36($x){ return base_convert($x, 36, 10); [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick example of how to use PHP&#8217;s base convert function in AS3. A lot of people use this function for shorter masked URLs like YouTube. Easy enough but took me a minute to find the equivalent in actionscript.</p>
<p>PHP:</p>
<pre name="code" class="php">
function encode36($x){
    return base_convert($x, 10, 36);
}
function decode36($x){
    return base_convert($x, 36, 10);
}
</pre>
<p>Actionscript 3:</p>
<pre name="code" class="javascript">
function encode36(x:Number):String{
    return x.toString(36);
}
function decode36(x:String):int {
    return parseInt(x,36);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.wrichards.com/blog/2010/07/php-base_convert-in-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Check if a URL exists with cURL</title>
		<link>http://www.wrichards.com/blog/2009/05/php-check-if-a-url-exists-with-curl/</link>
		<comments>http://www.wrichards.com/blog/2009/05/php-check-if-a-url-exists-with-curl/#comments</comments>
		<pubDate>Wed, 27 May 2009 11:44:34 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cURL]]></category>

		<guid isPermaLink="false">http://www.wrichards.com/blog/?p=90</guid>
		<description><![CDATA[In my previous post about email validation one user pointed out that this will not actually validate if a website&#8217;s domain actually exists. Here is a simple function that will do just that, determine if a website exists using PHP and cURL. Edit: After searching a bit, I found another similar cURL solution that checks [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post about <a href="http://www.wrichards.com/blog/2009/02/php-email-validation/">email validation</a> one user pointed out that this will not actually validate if a website&#8217;s domain actually exists. Here is a simple function that will do just that, determine if a website exists using PHP and cURL.</p>
<p>Edit: After searching a bit, I found another <a href="http://www.jellyandcustard.com/2006/05/31/determining-if-a-url-exists-with-curl/">similar cURL solution</a> that checks the actual headers. Since cURL can return HTTP code I don&#8217;t think all that extra code is necessary? I could be wrong!</p>
<pre name="code" class="php">
function urlExists($url=NULL)
	{
		if($url == NULL) return false;
		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_TIMEOUT, 5);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		$data = curl_exec($ch);
		$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
		curl_close($ch);
		if($httpcode>=200 &#038;&#038; $httpcode<300){
			return true;
		} else {
			return false;
		}
	}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.wrichards.com/blog/2009/05/php-check-if-a-url-exists-with-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Upcoming Birthdays From MySQL</title>
		<link>http://www.wrichards.com/blog/2009/03/getting-upcoming-birthdays-from-mysql/</link>
		<comments>http://www.wrichards.com/blog/2009/03/getting-upcoming-birthdays-from-mysql/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 23:51:52 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[birthday]]></category>
		<category><![CDATA[usort()]]></category>

		<guid isPermaLink="false">http://www.wrichards.com/blog/?p=85</guid>
		<description><![CDATA[Assuming you have a table called `users` with birthday as `bday` for the column name, this will pull all users who are having a birthday in the next 7 days. This is very useful if you want to showcase your member&#8217;s birthdays on your website. SELECT * FROM `users` WHERE DAYOFYEAR(curdate()) = dayofyear(`bday`) LIMIT 30; [...]]]></description>
			<content:encoded><![CDATA[<p>Assuming you have a table called `users` with birthday as `bday` for the column name, this will pull all users who are having a birthday in the next 7 days. This is very useful if you want to showcase your member&#8217;s birthdays on your website.</p>
<pre name="code" class="php">
SELECT * FROM `users` WHERE  DAYOFYEAR(curdate()) <= dayofyear(`bday`) AND DAYOFYEAR(curdate()) +7 >= dayofyear(`bday`) LIMIT 30;
</pre>
<p>There is of course one small problem with this, it&#8217;s not sorted. If we sort by `bday` ASC it&#8217;ll still be off since user&#8217;s are born on different years. What we really want is to sort by month and day only. I&#8217;m sure this can be done in MySQL but here is a PHP solution to take care of it.</p>
<pre name="code" class="php">
$sql = "SELECT * FROM `users` WHERE  DAYOFYEAR(curdate()) <= dayofyear(`bday`) AND DAYOFYEAR(curdate()) +7 >= dayofyear(`bday`) LIMIT 30;";
$query = mysql_query($sql);
$rows = mysql_num_rows($query);
if(!empty($rows)){
	while($resultFind = mysql_fetch_array($query)){
		$arr[] = array('bday' => $resultFind['bday'], 'bday2' => date("md", strtotime($resultFind['bday'])));
	}
}

function compare($x, $y) {
	if ( $x["bday2"] == $y["bday2"] )
	 return 0;
	else if ( $x["bday2"] < $y["bday2"] )
	 return -1;
	else
	 return 1;
}

usort($arr, "compare");
</pre>
<p>Using usort() we can sort based on the month and day. You now have your list sorted <img src='http://www.wrichards.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrichards.com/blog/2009/03/getting-upcoming-birthdays-from-mysql/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Goodbye MTV API</title>
		<link>http://www.wrichards.com/blog/2009/02/goodbye-mtv-api/</link>
		<comments>http://www.wrichards.com/blog/2009/02/goodbye-mtv-api/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 04:54:23 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[MTV]]></category>
		<category><![CDATA[MTVN]]></category>

		<guid isPermaLink="false">http://www.wrichards.com/blog/?p=77</guid>
		<description><![CDATA[About 7 months ago MTV released a promising API MTVN which opened up a ton of artist metadata and the ability to embed videos from MTV, VH1, CMT and Logo. Looks like they&#8217;re pulling the plug come March. As a developer and someone who uses the API, I am pretty upset about this. Thanks MTV [...]]]></description>
			<content:encoded><![CDATA[<p>About 7 months ago MTV released a promising API <a href="http://developer.mtvnservices.com/">MTVN</a> which opened up  a ton of artist metadata and the ability to embed videos from MTV, VH1, CMT and Logo. Looks like they&#8217;re <a href="http://www.techcrunch.com/2009/02/14/mtv-pulls-the-plug-on-embeddable-videos/">pulling the plug</a> come March. As a developer and someone who uses the API, I am pretty upset about this. Thanks MTV :/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrichards.com/blog/2009/02/goodbye-mtv-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Error calling method on NPObject!</title>
		<link>http://www.wrichards.com/blog/2009/02/error-calling-method-on-npobject/</link>
		<comments>http://www.wrichards.com/blog/2009/02/error-calling-method-on-npobject/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 21:56:41 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[Actionscript 2.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[Flash 8]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[NPObject]]></category>

		<guid isPermaLink="false">http://www.wrichards.com/blog/?p=73</guid>
		<description><![CDATA[Have you seen this error? If you work with Flash actionscript and Javascript, you probably have. It can be pretty frustrating the first time you see this error since it&#8217;s not very informative. In my experience, this happened when I was trying to communicate with actionscript via Javascript using ExternalInterface call. The problem was sure [...]]]></description>
			<content:encoded><![CDATA[<p>Have you seen this error? If you work with Flash actionscript and Javascript, you probably have. It can be pretty frustrating the first time you see this error since it&#8217;s not very informative. In my experience, this happened when I was trying to communicate with actionscript via Javascript using <a href="http://www.google.com/url?sa=U&#038;start=1&#038;q=http://livedocs.adobe.com/flash/8/main/00002200.html&#038;ei=vpqUSY6yBqCImQfy7Nz_CQ&#038;usg=AFQjCNESo87OXey_CGP4Q6qDF3vmjSSc1Q">ExternalInterface</a> call. The problem was sure enough a security issue with Flash. The solution for &#8220;Error calling method on NPObject!&#8221; is to add:</p>
<p><code>System.security.allowDomain("mydomain.com");</code> </p>
<p>Add this to the Flash file you&#8217;re communicating with. Keep in mind that <strong><em>www.mydomain.com</em></strong> is different from <strong><em>mydomain.com</em></strong> to Flash.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrichards.com/blog/2009/02/error-calling-method-on-npobject/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customize your Amazon S3 Url</title>
		<link>http://www.wrichards.com/blog/2009/02/customize-your-amazon-s3-url/</link>
		<comments>http://www.wrichards.com/blog/2009/02/customize-your-amazon-s3-url/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 19:23:25 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[Amazon S3]]></category>
		<category><![CDATA[bucket url]]></category>
		<category><![CDATA[CNAME]]></category>
		<category><![CDATA[custom domain]]></category>

		<guid isPermaLink="false">http://www.wrichards.com/blog/?p=58</guid>
		<description><![CDATA[I see a lot of sites still using the long default Amazon S3 url so I thought this might be helpful to someone. Lets say I setup a bucket for images on this domain at images.wrichards.com.s3.amazonaws.com to serve all my images. I don&#8217;t really want to type out the extra s3.amazonaws.com bit everytime I link [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.wrichards.com/blog/wp-content/uploads/2009/02/amazon_aws_logo.jpg" alt="Amazon s3" title="Amazon s3" width="300" height="122" class="alignleft size-full wp-image-106" />I see a lot of sites still using the long default <a href="http://aws.amazon.com/s3/">Amazon S3</a> url so I thought this might be helpful to someone. Lets say I setup a bucket for images on this domain at <strong>images.wrichards.com.s3.amazonaws.com</strong> to serve all my images. I don&#8217;t really want to type out the extra <strong>s3.amazonaws.com</strong> bit everytime I link to an image. <img src='http://www.wrichards.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  There is a quick and easy solution to change your domain with <a href="http://en.wikipedia.org/wiki/CNAME#CNAME">CNAME</a>:</p>
<p><code>images.wrichards.com CNAME images.wrichards.com.s3.amazonaws.com</code></p>
<p>Just add a CNAME record with that information and you should be good to go (obviously change my domain to yours). You can add your CNAME in your DNS entry <a href="http://www.google.com/support/a/bin/answer.py?hl=en&#038;answer=47283">More Info here</a>. I can now access my bucket via the custom domain <strong>images.wrichards.com</strong>.The bucket name must match and be lowercase for this to work properly. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrichards.com/blog/2009/02/customize-your-amazon-s3-url/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>JQuery sort()</title>
		<link>http://www.wrichards.com/blog/2009/02/jquery-sorting-elements/</link>
		<comments>http://www.wrichards.com/blog/2009/02/jquery-sorting-elements/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 16:38:43 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[innerHTML]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.wrichards.com/blog/?p=48</guid>
		<description><![CDATA[Today I was trying to figure out how to sort a set of list item elements alphabetically using JQuery. Seems simple enough but after searching around I couldn&#8217;t find any ready made solution. The best I could find was JQuery Table Sort (which is a nice sorting package but not what I was looking for). [...]]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_103" class="wp-caption alignleft" style="width: 252px"><img src="http://www.wrichards.com/blog/wp-content/uploads/2009/02/logo_jquery.png" alt="JQuery. Write less, do more" title="JQuery Logo" width="242" height="76" class="size-full wp-image-103" /><p class="wp-caption-text">JQuery. Write less, do more</p></div>Today I was trying to figure out how to sort a set of list item elements alphabetically using <a title="JQuery" href="http://jquery.com/">JQuery</a>. Seems simple enough but after searching around I couldn&#8217;t find any ready made solution. The best I could find was <a href="http://tablesorter.com/docs/">JQuery Table Sort</a> (which is a nice sorting package but not what I was looking for). After playing around for a bit, this is what I came up with:</p>
<pre name="code" class="js">jQuery.fn.sort = function() {
   return this.pushStack( [].sort.apply( this, arguments ), []);
 };

function sortAlpha(a,b){
    return a.innerHTML &gt; b.innerHTML ? 1 : -1;
};

$('ol li').sort(sortAlpha).appendTo('ol');</pre>
<p>Short and sweet. The result is a in place sort based off the innerHTML alphabetically.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrichards.com/blog/2009/02/jquery-sorting-elements/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>PHP5 Email Validation</title>
		<link>http://www.wrichards.com/blog/2009/02/php-email-validation/</link>
		<comments>http://www.wrichards.com/blog/2009/02/php-email-validation/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 01:44:20 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[email validation]]></category>

		<guid isPermaLink="false">http://www.wrichards.com/blog/?p=26</guid>
		<description><![CDATA[In prior version of PHP you had to use some regex solution to validate an email address, now in PHP5 it&#8217;s as simple as: function isValidEmail($email){ return filter_var(filter_var($email, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL); } if(isValidEmail('email@domain.com')){ //valid } else { //not valid } I&#8217;ve been using PHP5 ever since it was released but didn&#8217;t look into the PECL Filter [...]]]></description>
			<content:encoded><![CDATA[<p>In prior version of PHP you had to use some regex solution to validate an email address, now in PHP5 it&#8217;s as simple as:</p>
<pre name="code" class="php">function isValidEmail($email){
 return filter_var(filter_var($email, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL);
}

if(isValidEmail('email@domain.com')){
//valid
} else {
//not valid
}</pre>
<p>I&#8217;ve been using PHP5 ever since it was released but didn&#8217;t look into the PECL Filter extension until recently. Pretty handy.</p>
<p>Please note that I also added the <a title="FILTER_SANITIZE_EMAIL filter" href="http://www.w3schools.com/php/filter_sanitize_email.asp" target="_blank">FILTER_SANITIZE_EMAIL</a> filter which removes all illegal e-mail characters from a string. This is not needed if you only want to validate and not clean the input. <img src='http://www.wrichards.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrichards.com/blog/2009/02/php-email-validation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Sphinx : A MySQL full-text search engine</title>
		<link>http://www.wrichards.com/blog/2009/02/sphinx-mysql-php/</link>
		<comments>http://www.wrichards.com/blog/2009/02/sphinx-mysql-php/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 01:00:39 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://www.wrichards.com/blog/?p=19</guid>
		<description><![CDATA[This has got to be one of the coolest things I have come across in a long time. Sphinx a standalone MySQL full-text search engine. I&#8217;ve been working with it for a couple weeks now and I must say, this thing is blazin&#8217; fast. I was most impressed by performance on large data sets (60+ [...]]]></description>
			<content:encoded><![CDATA[<p><a title="http://www.sphinxsearch.com/" href="http://www.sphinxsearch.com/" target="_blank"><img src="http://www.sphinxsearch.com/g/sphinx.jpg" alt="Sphinx - Standalone MySQL Full-text search" style="float:left" /></a> This has got to be one of the coolest things I have come across in a long time. <a href="http://www.sphinxsearch.com/">Sphinx</a> a standalone MySQL full-text search engine. I&#8217;ve been working with it for a couple weeks now and I must say, this thing is blazin&#8217; fast. I was most impressed by performance on large data sets (60+ million rows). Even when preforming sorts, it&#8217;s really fast. Oh, they have a <a title="PHP API" href="http://www.sphinxsearch.com/wiki/doku.php?id=php_api_docs" target="_blank">PHP API</a> too! If you&#8217;re looking to super charge your mysql search, give it a shot!</p>
<p>More on this with examples later.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrichards.com/blog/2009/02/sphinx-mysql-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lighttpd, Flash and Crossdomain.xml</title>
		<link>http://www.wrichards.com/blog/2009/02/lighttpd-flash-and-crossdomainxml/</link>
		<comments>http://www.wrichards.com/blog/2009/02/lighttpd-flash-and-crossdomainxml/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 22:39:11 +0000</pubDate>
		<dc:creator>Bill</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[crossdomain.xml]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[lighty]]></category>

		<guid isPermaLink="false">http://wrichards.com/blog/?p=3</guid>
		<description><![CDATA[A few weeks back I ran into a rather odd situation when trying to load an xml file via Actionscript across multiple domains. No matter what I did, it would not load! Typical way to resolve this is to put a crossdomain.xml granting access to the swf host location right? Well, if you&#8217;re planning on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.wrichards.com/blog/2009/02/lighttpd-flash-and-crossdomainxml/"><img src="http://img11.imageshack.us/img11/2079/lighttpdnh9.png" alt="Lighty" style="float:left" /></a>A few weeks back I ran into a rather odd situation when trying to load an xml file via Actionscript across multiple domains. No matter what I did, it would not load! Typical way to resolve this is to put a crossdomain.xml granting access to the swf host location right? Well, if you&#8217;re planning on using <a title="Lighty" href="http://www.lighttpd.net/" target="_blank">Lighty</a>, a good thing to keep in mind when installing is to set the proper <a title="mimetype.assign options" href="http://redmine.lighttpd.net/projects/lighttpd/wiki/Mimetype.assignDetails" target="_blank">mimetype.assign options</a> in the configuration file. If you do not set this it will default to &#8220;application/octet-stream&#8221; which for some reason Flash (actionscript) does NOT like and will ignore crossdomain.xml. I know it&#8217;s kind of a newbie mistake but I&#8217;m sure one of you will come across the same issue when using it for the first time like I did.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wrichards.com/blog/2009/02/lighttpd-flash-and-crossdomainxml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
