<?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/"
	
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Dented Reality &#187; code</title>
	<atom:link href="http://dentedreality.com.au/tags/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://dentedreality.com.au</link>
	<description>Beau Lebens throws down his opinion on all sorts of things he doesn&#039;t know too much about.</description>
	<lastBuildDate>Tue, 07 Feb 2012 20:48:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19719</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Slinky, a PHP class for URL shortening/lengthening</title>
		<link>http://dentedreality.com.au/2009/08/php-class-url-shortener-slinky/</link>
		<comments>http://dentedreality.com.au/2009/08/php-class-url-shortener-slinky/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 04:11:48 +0000</pubDate>
		<dc:creator>Beau Lebens</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Techn(ical|ology)]]></category>
		<category><![CDATA[bitly]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[isgd]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[slinky]]></category>
		<category><![CDATA[tinyurl]]></category>
		<category><![CDATA[trim]]></category>
		<category><![CDATA[url shortener]]></category>

		<guid isPermaLink="false">http://dentedreality.com.au/?p=1112</guid>
		<description><![CDATA[A few weeks ago, I tweeted that I was writing a PHP library for shortening/lengthening URLs using some of the common/popular services. I said it was going to be called Slinky, and that it&#8217;d support a bunch of different services. Well, it&#8217;s now available for download and I think it&#8217;s pretty cool, even if I [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago, I tweeted that I was <a href="http://twitter.com/beaulebens/status/2636875528">writing a PHP library</a> for shortening/lengthening URLs using some of the common/popular services. I said it was going to be called Slinky, and that it&#8217;d support a bunch of different services. Well, it&#8217;s now <a href="http://dentedreality.com.au/projects/slinky/">available for download</a> and I think it&#8217;s pretty cool, even if I do say so myself <img src='http://dentedreality.com.au/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Please grab a copy, try it out and let me know what you think. It hasn&#8217;t actually been used for anything useful yet, so I&#8217;m also interested to hear what you&#8217;re using it for!</p>
]]></content:encoded>
			<wfw:commentRss>http://dentedreality.com.au/2009/08/php-class-url-shortener-slinky/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
	</item>
		<item>
		<title>Resizing Browser Windows With JavaScript</title>
		<link>http://dentedreality.com.au/2005/12/resizing-browser-windows-with-javascript/</link>
		<comments>http://dentedreality.com.au/2005/12/resizing-browser-windows-with-javascript/#comments</comments>
		<pubDate>Wed, 14 Dec 2005 01:03:00 +0000</pubDate>
		<dc:creator>Beau Lebens</dc:creator>
				<category><![CDATA[Techn(ical|ology)]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[browser window]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[resize]]></category>

		<guid isPermaLink="false">http://wiggin.local/dev/dentedreality.com.au/2005/12/resizing-browser-windows-with-javascript/</guid>
		<description><![CDATA[So here&#8217;s an annoying one &#8211; I wanted to resize my browser window automatically, after the page had loaded (in a dynamic pop-up), to meet certain size requirements (namely to match a background image). The problem that I had was that all the different browsers support different methods and properties in relation to the &#8216;viewport&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>So here&#8217;s an annoying one &#8211; I wanted to resize my browser window automatically, after the page had loaded (in a dynamic pop-up), to meet certain size requirements (namely to match a background image). The problem that I had was that all the different browsers support different methods and properties in relation to the &#8216;viewport&#8217; (visible area of the browser), so I was having trouble finding a reliable way to do this.</p>
<p>I found a <a title="View article on 'Viewport Properties'" href="http://www.quirksmode.org/viewport/compatibility.html">great breakdown</a> over at <a title="Go to quirksmode.org" href="http://www.quirksmode.org/">quirksmode.org</a>, but it didn&#8217;t actually work in Safari (2.0.2), so I found that out pretty quickly, because that&#8217;s what I&#8217;m working in. After a little playing around, I came up with the following modifications, which calculates the amount of chrome visible in the currrent window, and then takes that into account when resizing the entire window size.</p>
<p>I haven&#8217;t tested this on too much other than Safari and Firefox on a Mac, but I think it should be reasonably compatible with others.</p>
<pre>// Viewable size you want once resized
x = 600;
y = 400;

// Now set the window size for different browser types
// all except Explorer
if (self.innerHeight) {
	// Figure out the measurements
	iX = self.innerWidth;
	iY = self.innerHeight;
	oX = self.outerWidth;
	oY = self.outerHeight;

	// And resize to match the desired target
	gX = oX - iX;
	gY = oY - iY;
	window.resizeTo(x + gX, y + gY)
}
// Explorer 6 Strict Mode
else if (document.documentElement &amp;&amp; document.documentElement.clientHeight) {
	document.documentElement.clientWidth = x;
	document.documentElement.clientHeight = y;
}
// other Explorers
else if (document.body) {
	document.body.clientWidth = x;
	document.body.clientHeight = y;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://dentedreality.com.au/2005/12/resizing-browser-windows-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>PHP Blogger API License Updated</title>
		<link>http://dentedreality.com.au/2005/10/php-blogger-api-license-updated/</link>
		<comments>http://dentedreality.com.au/2005/10/php-blogger-api-license-updated/#comments</comments>
		<pubDate>Mon, 10 Oct 2005 02:49:00 +0000</pubDate>
		<dc:creator>Beau Lebens</dc:creator>
				<category><![CDATA[Techn(ical|ology)]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[blogger]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[license]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpbloggerapi]]></category>

		<guid isPermaLink="false">http://wiggin.local/dev/dentedreality.com.au/2005/10/php-blogger-api-license-updated/</guid>
		<description><![CDATA[With a little prompting from someone who needed to known what license the PHP Blogger API code was available under so he could develop something based on it, I&#8217;ve finally added a license in with all 3 downloads available. With confirmation from the other 2 authors involved, all 3 packages are now available under a [...]]]></description>
			<content:encoded><![CDATA[<p>With a little prompting from someone who needed to known what license the <a href="/bloggerapi/">PHP Blogger API</a> code was available under so he could develop something based on it, I&#8217;ve finally added a license in with all 3 downloads available. With confirmation from the other 2 authors involved, all 3 packages are now available under a BSD-style license. Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://dentedreality.com.au/2005/10/php-blogger-api-license-updated/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
	</item>
		<item>
		<title>Better Random Hex</title>
		<link>http://dentedreality.com.au/2005/04/better-random-hex/</link>
		<comments>http://dentedreality.com.au/2005/04/better-random-hex/#comments</comments>
		<pubDate>Fri, 15 Apr 2005 05:54:00 +0000</pubDate>
		<dc:creator>Beau Lebens</dc:creator>
				<category><![CDATA[Techn(ical|ology)]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[eric scheid]]></category>
		<category><![CDATA[hex]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[random hex]]></category>
		<category><![CDATA[randomizer]]></category>

		<guid isPermaLink="false">http://wiggin.local/dev/dentedreality.com.au/2005/04/better-random-hex/</guid>
		<description><![CDATA[Eric Scheid (founder of the excellent IAWiki) shot me a line with a more efficient and much sleeker version of my random hex code straight after I posted it, so here it is! function random_hex() { $color = ''; for ($c = 0; $c &#60; 6; $c++) { $i = rand(0, 15); $color .= substr("0123456789ABCDEF", [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Eric on IAWiki.net" href="http://iawiki.net/EricScheid">Eric Scheid</a> (founder of the excellent <a title="Go to iawiki.net" href="http://iawiki.net/IAwiki">IAWiki</a>) shot me a line with a more efficient and much sleeker version of my random hex code straight after I posted it, so here it is!</p>
<pre>function random_hex() {
	$color = '';
	for ($c = 0; $c &lt; 6; $c++) {
		$i = rand(0, 15);
		$color .= substr("0123456789ABCDEF", $i, 1)
	}
	$color = '#' . $color;
	return $color;
}</pre>
<p>Thanks Eric!</p>
]]></content:encoded>
			<wfw:commentRss>http://dentedreality.com.au/2005/04/better-random-hex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>Random Hex</title>
		<link>http://dentedreality.com.au/2005/04/random-hex/</link>
		<comments>http://dentedreality.com.au/2005/04/random-hex/#comments</comments>
		<pubDate>Mon, 11 Apr 2005 23:13:00 +0000</pubDate>
		<dc:creator>Beau Lebens</dc:creator>
				<category><![CDATA[Techn(ical|ology)]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[random hex]]></category>
		<category><![CDATA[randomizer]]></category>

		<guid isPermaLink="false">http://wiggin.local/dev/dentedreality.com.au/2005/04/random-hex/</guid>
		<description><![CDATA[I needed some PHP code to randomly generate me a hex value for use as a color in a webpage. Here&#8217;s what I came up with (WARNING: Some colors are UGLY!) function random_hex() { $color = ''; for ($c = 0; $c &#60; 6; $c++) { $i = rand(0, 15); switch ($i) { case 10 [...]]]></description>
			<content:encoded><![CDATA[<p>I needed some PHP code to randomly generate me a hex value for use as a color in a webpage. Here&#8217;s what I came up with (WARNING: Some colors are UGLY!)</p>
<pre>function random_hex() {
	$color = '';
	for ($c = 0; $c &lt; 6; $c++) {
		$i = rand(0, 15);
		switch ($i) {
			case 10 :
				$i = 'A';
				break;
			case 11 :
				$i = 'B';
				break;
			case 12 :
				$i = 'C';
				break;
			case 13 :
				$i = 'D';
				break;
			case 14 :
				$i = 'E';
				break;
			case 15 :
				$i = 'F';
				break;
			default :
				$i = $i;
				break;
		}
		$color .= $i;
	}
	$color = '#' . $color;
	return $color;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://dentedreality.com.au/2005/04/random-hex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>File Append Function</title>
		<link>http://dentedreality.com.au/2004/02/file-append-function/</link>
		<comments>http://dentedreality.com.au/2004/02/file-append-function/#comments</comments>
		<pubDate>Fri, 06 Feb 2004 01:09:00 +0000</pubDate>
		<dc:creator>Beau Lebens</dc:creator>
				<category><![CDATA[Techn(ical|ology)]]></category>
		<category><![CDATA[append]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[file append]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://wiggin.local/dev/dentedreality.com.au/2004/02/file-append-function/</guid>
		<description><![CDATA[Here&#8217;s a useful function that I wrote for PHP &#8211; it just opens a specified file and appends a string to it. It&#8217;s very good for logging things. &#60;?php /** * @return boolean * @param $file FileNameToWriteTo * @param $string StringToWriteToFile * @desc Writes specified string to the end of the file with a linefeed [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a useful function that I wrote for PHP &#8211; it just opens a specified file and appends a string to it. It&#8217;s very good for logging things.</p>
<pre>&lt;?php
/**
 * @return boolean
 * @param $file FileNameToWriteTo
 * @param $string StringToWriteToFile
 * @desc Writes specified string to the end of the file with a linefeed attached
 */
function file_append($file, $string) {
	if (is_file($file) &amp;&amp; is_writable($file)) {
		$fh = fopen($file, 'a');
		if ($fh) {
			fwrite($fh, $string . "\n");
			fclose($fh);
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}
?&gt;</pre>
<p>You might want to consider making the fopen() flags &#8216;ab&#8217; for binary-safe (now reccommended on <a title="Go to php.net" href="http://www.php.net/">php.net</a>) and also changing the &#8216;\n&#8217; part to the appropriate line-endings for your operating system (\n = *NIX, \r\n = Windows, \r = Mac).</p>
]]></content:encoded>
			<wfw:commentRss>http://dentedreality.com.au/2004/02/file-append-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>Useful JavaScript Snippet</title>
		<link>http://dentedreality.com.au/2004/01/useful-javascript-snippet/</link>
		<comments>http://dentedreality.com.au/2004/01/useful-javascript-snippet/#comments</comments>
		<pubDate>Wed, 14 Jan 2004 11:48:00 +0000</pubDate>
		<dc:creator>Beau Lebens</dc:creator>
				<category><![CDATA[Techn(ical|ology)]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[in_array]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://wiggin.local/dev/dentedreality.com.au/2004/01/useful-javascript-snippet/</guid>
		<description><![CDATA[One of the coolest things in the PHP programming language is its excellent handling of arrays. The same, sadly, cannot be said for JavaScript This small JavaScript function implements one of the cool functions available in PHP, making it easier to store things in an array, and then check to see if they&#8217;re in there [...]]]></description>
			<content:encoded><![CDATA[<p>One of the coolest things in the PHP programming language is its excellent handling of arrays. The same, sadly, cannot be said for JavaScript <img src='http://dentedreality.com.au/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This small JavaScript function implements one of the cool functions available in PHP, making it easier to store things in an array, and then check to see if they&#8217;re in there later.</p>
<pre>// Returns true or false based on whether the specified string is found
// in the array. This is based on the PHP function of the same name.
// Written by Beau Lebens
function in_array(stringToSearch, arrayToSearch) {
	for (s = 0; s &lt; arrayToSearch.length; s++) {
		thisEntry = arrayToSearch[s].toString();
		if (thisEntry == stringToSearch) {
			return true;
		}
	}
	return false;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://dentedreality.com.au/2004/01/useful-javascript-snippet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
	</channel>
</rss>

