<?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>Krio Media &#187; Blog &amp; Tutorials</title>
	<atom:link href="http://www.krio.me/category/development-info/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.krio.me</link>
	<description></description>
	<lastBuildDate>Wed, 01 Jun 2011 16:24:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Sort &amp; Remove Duplicates in JavaScript Arrays</title>
		<link>http://www.krio.me/sorting-and-removing-duplicates-in-javascript-arrays/</link>
		<comments>http://www.krio.me/sorting-and-removing-duplicates-in-javascript-arrays/#comments</comments>
		<pubDate>Mon, 28 Feb 2011 06:21:22 +0000</pubDate>
		<dc:creator>Kevin Rio</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.krio.me/?p=1312</guid>
		<description><![CDATA[JavaScript arrays can be somewhat intimidating. They tend to not have all the available functions/methods that other languages like PHP and Ruby have for manipulating arrays.  Making a JS array unique isn&#8217;t a simple one-liner. This short article is for developers trying to make a JavaScript array unique without leaving holes in your array. Sorting [...]]]></description>
			<content:encoded><![CDATA[<p>JavaScript arrays can be somewhat intimidating. They tend to not have all the available functions/methods that other languages like PHP and Ruby have for manipulating arrays. <span id="more-1312"></span></p>
<p>Making a JS array unique isn&#8217;t a simple one-liner. This short article is for developers trying to make a JavaScript array unique without leaving holes in your array. Sorting an array in JavaScript is simple in most cases. Just call the sort() method on the array like so.</p>
<pre class="brush: php; title: ;">
var my_array = [5, 2, 4, 6, 9];
my_array.sort();
</pre>
<p>One caveat to be aware of with this method of sorting is that it performs a non-lexicographical sort, which might be confusing for human users if you display it on screen. Depending on your requirements, you might want to change your sorting algorithm. Check out Brian Huisman&#8217;s <a title="Lexicographical sorting in javascript" href="http://my.opera.com/GreyWyvern/blog/show.dml/1671288" target="_blank">article on the subject</a>. </p>
<p>After sorting the array, the following snippet will remove any duplicate entries</p>
<pre class="brush: php; title: ;">
for ( var i = 1; i &lt; my_array.length; i++ ) {
    if ( my_array[i] === my_array[ i - 1 ] ) {
        my_array.splice( i--, 1 );
    }
}
</pre>
<p>This will iterate over each element in the array, attempting to find elements where the value is equal to the previous value. If they are equal, we have found a duplicate so we remove it using splice.</p>
<p>A complete function for sorting and making an array unique in JavaScript would look like the following</p>
<pre class="brush: php; title: ;">
function sort_and_unique( my_array ) {
	my_array.sort();
	for ( var i = 1; i &lt; my_array.length; i++ ) {
		if ( my_array[i] === my_array[ i - 1 ] ) {
					my_array.splice( i--, 1 );
		}
	}
	return my_array;
};
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.krio.me/sorting-and-removing-duplicates-in-javascript-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Image Loader Plugin</title>
		<link>http://www.krio.me/jquery-image-loader-plugin/</link>
		<comments>http://www.krio.me/jquery-image-loader-plugin/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 04:20:23 +0000</pubDate>
		<dc:creator>Kevin Rio</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.krio.me/?p=1297</guid>
		<description><![CDATA[This is a JavaScript file released as a jQuery plugin that loads images in a visually appealing way. Instead of the typical block loading that HTML employs while loading images, this plugin waits until the entire image is downloaded then fades it in. This plugin simplifies the process of loading images. It is easily applied [...]]]></description>
			<content:encoded><![CDATA[<p>This is a JavaScript file released as a jQuery plugin that loads images in a visually appealing way. Instead of the typical block loading that HTML employs while loading images, this plugin waits until the entire image is downloaded then fades it in. <span id="more-1297"></span>This plugin simplifies the process of loading images. It is easily applied to wrappers so that it will load all of the images within it. Its main purpose is to assist web developers and designers in improving their user interfaces.</p>
<h3>Image Loading Instructions</h3>
<ul>
<li>Include jQuery</li>
<li>Include jquery.krioImageLoader.js</li>
<li>Instantiate the plugin on the wrapper</li>
<li>$(&#8220;#test&#8221;).krioImageLoader();</li>
<li>Watch it load</li>
</ul>
<p><a href="http://krio.me/scripttest/imgLoader/" target="_blank">View the Demo</a><br />
<a href="http://github.com/krio/jquery-image-loader-plugin" target="_blank">Download or fork on GitHub</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.krio.me/jquery-image-loader-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PayPal Direct Recurring Payments Script</title>
		<link>http://www.krio.me/paypal-recurring-payments-php-script-free/</link>
		<comments>http://www.krio.me/paypal-recurring-payments-php-script-free/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 23:58:12 +0000</pubDate>
		<dc:creator>Kevin Rio</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://www.krio.me/?p=1270</guid>
		<description><![CDATA[This is an open source script for accepting direct recurring credit card payments on your website. Users select a length of subscription for your products and will be billed monthly for that amount. Credit cards are entered on your website, but billed through PayPal. View the demo here. The PayPal script will accept the users [...]]]></description>
			<content:encoded><![CDATA[<p>This is an open source script for accepting direct recurring credit card payments on your website. Users select a length of subscription for your products and will be billed monthly for that amount. Credit cards are entered on your website, but billed through PayPal. <span id="more-1270"></span>View the demo <a title="Direct Recurring PayPal Payments &amp; Subscriptions" href="http://krio.me/scripttest/subs" target="_blank">here</a>.</p>
<p>The PayPal script will accept the users credentials on your website and send a request to PayPal to verify and bill the users information. From the script you can enter the amount to be billed, the timeframe, and any setup fees for the services.</p>
<p>Downloads, specific instructions and requirements for the script can be found on its GitHub page <a title="Direct Recurring Payments" href="http://github.com/krio/paypal-recurring-subscriptions" target="_blank">here</a>.</p>
<p>For testing purposes you should setup a PayPal <a href="https://developer.paypal.com/" target="_blank">sandbox</a> account. This will allow you to test your scripts. PayPal will verify the cards, however it will not attempt to charge them. PayPal will also provide dummy feedback into your PayPal user account page.</p>
<h3>Download the script on <a href="http://github.com/krio/paypal-recurring-subscriptions" target="_blank">GitHub</a>.</h3>
]]></content:encoded>
			<wfw:commentRss>http://www.krio.me/paypal-recurring-payments-php-script-free/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Encrypting / Decrypting Data and Strings in Ruby</title>
		<link>http://www.krio.me/encrypting-decrypting-data-strings-in-ruby/</link>
		<comments>http://www.krio.me/encrypting-decrypting-data-strings-in-ruby/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 06:11:31 +0000</pubDate>
		<dc:creator>Kevin Rio</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[internet security]]></category>

		<guid isPermaLink="false">http://www.krio.me/?p=1250</guid>
		<description><![CDATA[Encrypting data is often a necessity in any software application, especially those dealing with sensitive data. Continue reading to learn how to easily encrypt sensitive data.  The Crypt library provides classes and methods that help software/web developers to easily and securely encrypt data. The steps involved in encrypting data are detailed below. Choose which library you want [...]]]></description>
			<content:encoded><![CDATA[<p>Encrypting data is often a necessity in any software application, especially those dealing with sensitive data. Continue reading to learn how to easily encrypt sensitive data. <span id="more-1250"></span></p>
<p>The <a href="http://crypt.rubyforge.org/" target="_blank">Crypt</a> library provides classes and methods that help software/web developers to easily and securely encrypt data. The steps involved in encrypting data are detailed below.</p>
<ol>
<li>Choose which library you want to use. The Rijndael is currently considered to be the most secure.</li>
<li>Create a new key that is used to decrypt the data later.</li>
<li>Encrypt the string/data.</li>
<li>Transfer the encrypting data.</li>
<li>Decrypt using the original key.</li>
</ol>
<div style="width: 625px; margin-top: 10px;"><script src="http://gist.github.com/571459.js"></script></div>
]]></content:encoded>
			<wfw:commentRss>http://www.krio.me/encrypting-decrypting-data-strings-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending a POST Request / Scrape Page in Ruby</title>
		<link>http://www.krio.me/how-to-send-post-request-return-contents-ruby/</link>
		<comments>http://www.krio.me/how-to-send-post-request-return-contents-ruby/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 05:46:28 +0000</pubDate>
		<dc:creator>Kevin Rio</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Scraping]]></category>

		<guid isPermaLink="false">http://www.krio.me/?p=1233</guid>
		<description><![CDATA[Making a POST request in Ruby is simple. You can very easily load the data returned from the web service to parse or do whatever is necessary with it. This tutorial is the cornerstone for users who might be interested in developing their own web scraper in Ruby.  First, make sure to require the appropriate [...]]]></description>
			<content:encoded><![CDATA[<p>Making a POST request in Ruby is simple. You can very easily load the data returned from the web service to parse or do whatever is necessary with it. This tutorial is the cornerstone for users who might be interested in developing their own web scraper in Ruby. <span id="more-1233"></span></p>
<p>First, make sure to require the appropriate Ruby libraries net/http and uri. Next we will utilize the post_form method from HTTP, using the websites URL and a hash comprised of the POST key/value that you want to send in. You can use multiple values in the hash if necessary.</p>
<p>Running the parse method from URI will automatically format the URL you pass to the post_form method for easy manipulation.</p>
<div style="width: 625px;"><script src="http://gist.github.com/571070.js"></script></div>
<p>The value returned and placed into the postData variable is a string representation of the source returned after your post request. This is a simple solution to a question that web developers often have.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krio.me/how-to-send-post-request-return-contents-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use Tor to make a C# HttpWebRequest</title>
		<link>http://www.krio.me/use-tor-to-make-a-c-sharp-httpwebrequest/</link>
		<comments>http://www.krio.me/use-tor-to-make-a-c-sharp-httpwebrequest/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 06:19:18 +0000</pubDate>
		<dc:creator>Kevin Rio</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.krio.me/?p=1226</guid>
		<description><![CDATA[Want to use Tor so that you can make annoymous and secure web requests while coding in C#? Use this easy technique. Typically when making an HttpWebRequest with C# you would write something to this effect: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(&#34;http://URL.org&#34;); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); This will work fine, however your connection will not be anonymous. Using [...]]]></description>
			<content:encoded><![CDATA[<p>Want to use Tor so that you can make annoymous and secure web requests while coding in C#? Use this easy technique.</p>
<p><span id="more-1226"></span>
<p>Typically when making an HttpWebRequest with C# you would write something to this effect:</p>
<pre class="brush: plain; title: ;">
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(&quot;http://URL.org&quot;);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
</pre>
<p>This will work fine, however your connection will not be anonymous. Using Tor, you can effectively create an anonymous connection. First, make sure to install Tor and run it. The typical Tor Windows install will install Privoxy along with Vidalia. To make your C# web request run through Tor, you need to override the default proxy property to contact Prioxy.</p>
<pre class="brush: plain; title: ;">
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(&quot;http://URL.org&quot;);
request.Proxy = new WebProxy(&quot;127.0.0.1:8118&quot;); // default privoxy port for tor
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
</pre>
<p>127.0.0.1:8118 is the default address for Privoxy. Your HttpWebRequest will now be routed through Tor. Make sure that you do not have any firewalls blocking this default port.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krio.me/use-tor-to-make-a-c-sharp-httpwebrequest/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Loop twice through a PHP / MySQL result set</title>
		<link>http://www.krio.me/loop-twice-through-a-php-mysql-result-set/</link>
		<comments>http://www.krio.me/loop-twice-through-a-php-mysql-result-set/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 22:39:29 +0000</pubDate>
		<dc:creator>Kevin Rio</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP Tutorials]]></category>

		<guid isPermaLink="false">http://www.krio.me/?p=1125</guid>
		<description><![CDATA[I get asked all the time if it is possible to loop multiple times through a MySQL result set in PHP. Here&#8217;s the answer. First, you&#8217;ll need a MySQL result set. To do that you&#8217;ll need to select something from your database and loop through it like so: $result = mysql_query(&#34;SELECT * FROM my_table&#34;); while($row [...]]]></description>
			<content:encoded><![CDATA[<p>I get asked all the time if it is possible to loop multiple times through a MySQL result set in PHP. Here&#8217;s the answer.</p>
<p><span id="more-1125"></span></p>
<p>First, you&#8217;ll need a MySQL result set. To do that you&#8217;ll need to select something from your database and loop through it like so:</p>
<pre class="brush: php; title: ;">

$result = mysql_query(&quot;SELECT * FROM my_table&quot;);

while($row = mysql_fetch_assoc($result)) {

// inside the loop

}
</pre>
<p>The problem is, if you want to loop through the same result set again, you will get an error because the internal pointer is currently at the end of the result. You will need to put the pointer back at the beginning of the result set so that you can loop through it again.</p>
<p>You can do it with a helpful php function named mysql_data_seek.</p>
<pre class="brush: php; title: ;">

mysql_data_seek($result, 0); // set the pointer of the result set back to the beginning.

while($row2 = mysql_fetch_assoc($result)) {

// inside the loop

}
</pre>
<p>This demonstrates how, as a PHP website developer, you can reset the pointer of a MySQL result set, which will allow you to iterate through the result set for a second time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krio.me/loop-twice-through-a-php-mysql-result-set/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ternary Operators in PHP: Shorthand If Else Statements</title>
		<link>http://www.krio.me/ternary-operators-in-php-shorthand-if-else-statements/</link>
		<comments>http://www.krio.me/ternary-operators-in-php-shorthand-if-else-statements/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 19:08:09 +0000</pubDate>
		<dc:creator>Kevin Rio</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>

		<guid isPermaLink="false">http://www.krio.me/?p=1106</guid>
		<description><![CDATA[If-Else statements are a vital part of programming, however sometimes all the code that goes into writing are not required, especially if only only simple condition is needed. This is what the ternary operator is used for. The ternary operator is a shorthand if/else statement. It allows developers to form conditions quickly and in a [...]]]></description>
			<content:encoded><![CDATA[<p>If-Else statements are a vital part of programming, however sometimes all the code that goes into writing are not required, especially if only only simple condition is needed. This is what the ternary operator is used for.<span id="more-1106"></span></p>
<p>The ternary operator is a shorthand if/else statement. It allows developers to form conditions quickly and in a very readable fashion.</p>
<h3>Here is the ternary syntax</h3>
<pre class="brush: php; title: ;">

(condition) ? true-stuff-here : false-stuff-here;
</pre>
<p>Here is an example of the ternary operator</p>
<pre class="brush: php; title: ;">

$age = 20;

$response = ($age &gt; 29) ? &quot;He's in his thirties&quot; : &quot;He's not&quot;;

echo $response; // He's not
</pre>
<p>I hope you can see the usefulness in the ability for the ternary operator to easily perform conditional comparisons. Please however, refrain from using &#8216;nested ternary comparisons&#8217; as the are very difficult to  so read. It is so frowned upon by web developers that I&#8217;m not even going to post an example.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krio.me/ternary-operators-in-php-shorthand-if-else-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sort an Array in PHP by Date</title>
		<link>http://www.krio.me/sort-an-array-in-php-by-date/</link>
		<comments>http://www.krio.me/sort-an-array-in-php-by-date/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 18:45:41 +0000</pubDate>
		<dc:creator>Kevin Rio</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>

		<guid isPermaLink="false">http://www.krio.me/?p=1104</guid>
		<description><![CDATA[Sorting an array in PHP is not as difficult as many people make it out to be. This quick tutorial will walk you through the steps necessary to sort a date array. Sorting a PHP Array by Date The first step is ensuring that the dates are placed into the array in proper format. When [...]]]></description>
			<content:encoded><![CDATA[<p>Sorting an array in PHP is not as difficult as many people make it out to be. This quick tutorial will walk you through the steps necessary to sort a date array. <span id="more-1104"></span></p>
<h3>Sorting a PHP Array by Date</h3>
<p>The first step is ensuring that the dates are placed into the array in proper format. When you add the date to the array, the best and most compatible way to do do is to run the PHP date function on the date value. This function works no matter what format the date is in, including a MySQL datetime column or a PHP timestamp.</p>
<p>So to enter dates into your array you can do something like:</p>
<pre class="brush: php; title: ;">
$dateArray[] = date('Y-m-d');

//If you are iterating through something like a database with date's you could do something like:

$dateArray[] = date('Y-m-d', $row['date']);
</pre>
<h3>One you have your date array set</h3>
<p>All you need to do is run a  sorting function on the array.</p>
<h3>Most recent date first</h3>
<pre class="brush: php; title: ;">

rsort($dateArray);
</pre>
<h3>Oldest date first</h3>
<pre class="brush: php; title: ;">
sort($dateArray);
</pre>
<p>I hope this quick tutorial will help you in your website development and design endeavors!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krio.me/sort-an-array-in-php-by-date/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apache rewrite entire domain to a single page</title>
		<link>http://www.krio.me/redirect-everything-domain-server-specific-page-apache-rewrite/</link>
		<comments>http://www.krio.me/redirect-everything-domain-server-specific-page-apache-rewrite/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 19:30:51 +0000</pubDate>
		<dc:creator>Kevin Rio</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://www.krio.me/?p=1094</guid>
		<description><![CDATA[Whenever I need to bring a page down quickly for maintenance I use this Apache Rewrite snippet of code to redirect everything on the server to a specific page that usually holds some kind of maintenance or error message. The Apache Rewrite Code RewriteEngine on RewriteCond %{REQUEST_URI} !/theTempPage.php$ RewriteRule $ /theTempPage.php [R=307,L] First we turn [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever I need to bring a page down quickly for maintenance I use this Apache Rewrite snippet of code to redirect everything on the server to a specific page that usually holds some kind of maintenance or error message. <span id="more-1094"></span></p>
<h3>The Apache Rewrite Code</h3>
<pre class="brush: plain; title: ;">

RewriteEngine on

RewriteCond %{REQUEST_URI} !/theTempPage.php$

RewriteRule $ /theTempPage.php [R=307,L]
</pre>
<p>First we turn on the Rewrite engine (depending on your configuration .htaccess file it may already be on, however it won&#8217;t hurt Apache to include this if it is).</p>
<p>We then tell Apache to find pretty much everything after the domain name in a URL that is not equal to the maintenance page (in this case it is theTempPage.php).</p>
<p>If the URL is not equal to the condition, the user is forwarded to the maintenance page.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krio.me/redirect-everything-domain-server-specific-page-apache-rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

