<?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>Richard O&#039;Neill &#187; Programming</title>
	<atom:link href="http://richardoneill.com.au/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://richardoneill.com.au</link>
	<description>Design, Develepment and Photography</description>
	<lastBuildDate>Thu, 29 Dec 2011 09:05:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>My LOLCode Interpreter</title>
		<link>http://richardoneill.com.au/2007/10/my-lolcode-interpreter/</link>
		<comments>http://richardoneill.com.au/2007/10/my-lolcode-interpreter/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 15:35:33 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I had 2 hours to kill so I thought I&#8217;d write a LOLCode interpreter. I know there&#8217;s already a few LOLCode interpreters around, but I couldn&#8217;t help myself. Plus I&#8217;ve always been interested in interpreter design. It&#8217;s still a work in progress at this stage, so a lot of the language hasn&#8217;t been fully implemented. [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img src="/img/articles/lolcodebook.jpg" style="float: right;" alt="LOLCode Book" />
<p>I had 2 hours to kill so I thought I&#8217;d write a <a href="http://lolcode.com">LOLCode</a> <a href="http://en.wikipedia.org/wiki/Interpreter_(computing)">interpreter</a>.</p>
<p>I know there&#8217;s already a few LOLCode interpreters around, but I couldn&#8217;t help myself. Plus I&#8217;ve always been interested in <a href="http://en.wikipedia.org/wiki/Interpreter_(computing)">interpreter</a> design.</p>
<p>It&#8217;s still a work in progress at this stage, so a lot of the language hasn&#8217;t been fully implemented.</p>
<p>Here are two working programs&#8230;</p>
<h3>Hello World</h3>
<p><code><br />
BTW the classic hello world program<br />
HAI<br />
	VISIBLE "Hello world!"<br />
KTHXBAI<br />
</code>
<p>Output:</p>
<p><img src="/img/articles/lolcode1.jpg" alt="LOLCode Hello World" /><br />
<h3>Accepting User Input</h3>
<p><code><br />
HAI<br />
	VISIBLE "Hello there, what is your name?!"<br />
	I HAS A NAME ""</p>
<p>	BTW ask for the users name<br />
	GIMMEH NAME</p>
<p>	BTW welcome the user<br />
	VISIBLE "Welcome to LOLCode " N NAME N "!"<br />
KTHXBAI</code>
<p>Output:</p>
<p><img src="/img/articles/lolcode2.jpg" alt="LOLCode Accepting User Input" /></p>
]]></content:encoded>
			<wfw:commentRss>http://richardoneill.com.au/2007/10/my-lolcode-interpreter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ron Paul Filter for Reddit</title>
		<link>http://richardoneill.com.au/2007/10/ron-paul-filter-for-reddit/</link>
		<comments>http://richardoneill.com.au/2007/10/ron-paul-filter-for-reddit/#comments</comments>
		<pubDate>Tue, 30 Oct 2007 14:54:28 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[If you&#8217;re addicted to reddit.com like me, you&#8217;ll understand my frustration with all those Ron Paul links. Especially if you don&#8217;t live in the US, and don&#8217;t really know who the guy is. If anyone is interested, I&#8217;ve written a small Greasemonkey script which hides all reddit links that include the text &#8220;Ron Paul&#8221;. To [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>If you&#8217;re addicted to <a href="http://reddit.com">reddit.com</a> like me, you&#8217;ll understand my frustration with all those Ron Paul links. Especially if you don&#8217;t live in the US, and don&#8217;t really know who the guy is.</p>
<p>If anyone is interested, I&#8217;ve written a small <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a> script which hides all reddit links that include the text &#8220;Ron Paul&#8221;.</p>
<p>To install, download the <a href="/misc/ronpaul.user.js">Greasemonkey file</a> and drag it onto your firefox window.</p>
<p><strong><a href="/misc/ronpaul.user.js">ronpaul.user.js</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://richardoneill.com.au/2007/10/ron-paul-filter-for-reddit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Command Line Tip</title>
		<link>http://richardoneill.com.au/2007/09/php-command-line-tip/</link>
		<comments>http://richardoneill.com.au/2007/09/php-command-line-tip/#comments</comments>
		<pubDate>Tue, 11 Sep 2007 13:43:47 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Here&#8217;s a quick tip for working with the command line in PHP. If you&#8217;ve ever run a PHP script via the command line, you would have noticed that output from the script is not printed until the script has finished. If you need your output displayed in real time, you can open a stream to [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Here&#8217;s a quick tip for working with the command line in PHP.</p>
<p>If you&#8217;ve ever run a PHP script via the command line, you would have noticed that output from the script is not printed until the script has finished.</p>
<p>If you need your output displayed in real time, you can open a stream to the command line&#8230;</p>
<p><code>$stdout = fopen('php://stdout', 'w');</code>
<p>Simply write any output to the stream and it will be printed on the command line in real time&#8230;</p>
<p><code>fwrite($stdout, "Hello CLIn");</code></p>
]]></content:encoded>
			<wfw:commentRss>http://richardoneill.com.au/2007/09/php-command-line-tip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Background Noise in CAPTCHAS</title>
		<link>http://richardoneill.com.au/2007/08/background-noise-in-captchas/</link>
		<comments>http://richardoneill.com.au/2007/08/background-noise-in-captchas/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 18:12:09 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[One thing I keep noticing is the use of background noise or clutter in CAPTCHAS. It&#8217;s now well known in the OCR (Optical Character recognition) field that background noise can be easily removed by computers. It&#8217;s basically useless at hindering spam bots. It&#8217;s so easy that I was able to clean the following CAPTCHA up [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>One thing I keep noticing is the use of background noise or clutter in <a href="http://en.wikipedia.org/wiki/Captcha">CAPTCHAS</a>. It&#8217;s now well known in the OCR (<a href="http://en.wikipedia.org/wiki/Optical_character_recognition">Optical Character recognition</a>) field that background noise can be easily removed by computers. It&#8217;s basically useless at hindering spam bots.</p>
<p>
<p>It&#8217;s so easy that I was able to clean the following CAPTCHA up in only 20 lines of PHP code.</p>
<div style="text-align: center;"><img src="/img/articles/captcha.jpg" style="border: 10px solid #e9eef2;" alt="CAPTCHA" /></div>
<p>Here&#8217;s how&#8230;</p>
<p>At a glance, you can see the CAPTCHA&#8217;s background noise has a blue tint. <img src="/img/articles/captchargb.jpg" style="float: right; margin: 5px;" alt="CAPTCHA RGB" />Looking at the RGB value of the image in Photoshop, I can see that all parts of the background have a blue value higher than 180.</p>
<p>That&#8217;s the only piece of information needed to remove the background.</p>
<p>The code simply loops through every pixel of the image and checks the RGB value of it. If the blue (B) value is higher than 180, color it white.</p>
<p>Here&#8217;s the final image. The characters can now be easily separated and identified using OCR software.</p>
<div style="text-align: center;"><img style="border: 10px solid #e9eef2;" src="/img/articles/captcha2.jpg" alt="CAPTCHA" /></div>
<p>So you can see why most background noise is basically useless in CAPTCHAS.</p>
]]></content:encoded>
			<wfw:commentRss>http://richardoneill.com.au/2007/08/background-noise-in-captchas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic 3D Engine Design</title>
		<link>http://richardoneill.com.au/2007/08/basic-3d-engine-design/</link>
		<comments>http://richardoneill.com.au/2007/08/basic-3d-engine-design/#comments</comments>
		<pubDate>Thu, 23 Aug 2007 13:50:16 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Ray Casting is a extremely fast method of generating 3D images using high-school level mathematics. Remember playing Wolfenstein 3-D? This was one of the first games made using the ray casting technique. The graphics in Wolfenstein don&#8217;t even come close to today&#8217;s gaming standards; but it was still impressive for it&#8217;s time. It was also [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Ray Casting is a extremely fast method of generating 3D images using high-school level mathematics.
<p>Remember playing <a href="http://en.wikipedia.org/wiki/Wolfenstein_3D">Wolfenstein 3-D</a>? This was one of the first games made using the ray casting technique.</p>
<p><a href="http://en.wikipedia.org/wiki/Wolfenstein_3D"><img src="/img/articles/wolf3d.jpg" style="float: right; margin: 10px; border: 0px;" alt="Wolfenstein 3d" /></a>
<p>The graphics in Wolfenstein don&#8217;t even come close to today&#8217;s gaming standards; but it was still impressive for it&#8217;s time. It was also fast, considering the speed of the hardware it ran on.</p>
<p>Although ray casting is an outdated method, it&#8217;s a good introduction to 3D imagery and game design. It&#8217;s also quite easy to recreate yourself (if you can remember pythagoras theorem).</p>
<p>The basic idea of ray casting is very simple. To transform a 2d image map into a 3d representation, &#8220;rays&#8221; are projected from the viewer towards the light source. If a ray hits an object on the 2d map, a vertical line is drawn on our &#8220;3d&#8221; image to represent this section of the wall or object. Think of the image as vertical slices. </p>
<p>This diagram might do a better job of explaining.</p>
<p><img src="/img/articles/raycasting.jpg" alt="Ray Casting" />
<p>Textures can be applied using texture maps but unfortunately other effects like reflections aren&#8217;t so easy to create. They can be faked though. </p>
<p>If you&#8217;ve got nothing to do for a few hours, consider creating a simple ray cay caster in your favourite language.</p>
<p>Here&#8217;s a few resources to get you started.</p>
<ul>
<li><a href="http://student.kuleuven.be/~m0216922/CG/raycasting.html">Lode&#8217;s Computer Graphics Tutorial: Ray casting</a></li>
<li><a href="http://www.pygame.org/projects/7/337/">Rayforge: A simple and fast (for python) ray caster</a></li>
<li><a href="http://www.permadi.com/tutorial/raycast/">Ray-Casting Tutorial by by F. Permadi</a></li>
<li><a href="http://forums.bit-tech.net/showthread.php?t=116224">A PHP Ray Caster</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://richardoneill.com.au/2007/08/basic-3d-engine-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook Code Analysis</title>
		<link>http://richardoneill.com.au/2007/08/facebook-code-analysis/</link>
		<comments>http://richardoneill.com.au/2007/08/facebook-code-analysis/#comments</comments>
		<pubDate>Thu, 16 Aug 2007 13:57:18 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Most developers have now heard about Facebook&#8217;s leaked index.php source code, which was anonymously posted here. If you haven&#8217;t seen it already, there are a number of links listed on Techcrunch. I&#8217;ve seen a few bloggers criticize Facebook developers for using procedural programming rather than classes and object oriented techniques. I&#8217;m not exactly sure why [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://facebook.com"><img src="/img/articles/facebook.jpg" alt="Facebook Code Analysis" style="float: right; margin: 10px; border: 0px;" /></a>
<p>Most developers have now heard about <a href="http://facebook.com">Facebook&#8217;s</a> leaked <em>index.php</em> source code, which was anonymously posted <a href="http://facebooksecrets.blogspot.com">here</a>. If you haven&#8217;t seen it already, there are a number of links listed on <a href="http://www.techcrunch.com/2007/08/11/facebook-source-code-leaked/">Techcrunch</a>.</p>
<p>I&#8217;ve seen a few bloggers criticize Facebook developers for using procedural programming rather than classes and object oriented techniques. I&#8217;m not exactly sure why they&#8217;ve chosen to develop the site like this; but I am going to take a guess and say it was to improve speed and efficiency.</p>
<p>Object oriented programming was first introduced to PHP in version 4. However, the language wasn&#8217;t originally designed around objects and classes, so the implementation was clunky and awkward. This meant that procedural code was often much faster than object oriented code.</p>
<p>Considering the size and popularity of social networks, I&#8217;m not surprised they chose procedural code over objects. That tiny boost in performance would easily outweigh the advantages of using classes.</p>
<p>Fortunately, most (if not all) issues with objects have been solved in PHP 5, which is now closer to a truly object oriented language.</p>
]]></content:encoded>
			<wfw:commentRss>http://richardoneill.com.au/2007/08/facebook-code-analysis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check Username Availability</title>
		<link>http://richardoneill.com.au/2007/08/check-username-availability/</link>
		<comments>http://richardoneill.com.au/2007/08/check-username-availability/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 15:16:58 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[The goal of a signup form is to quickly convert visitors into registered users. The easiest way to increase your sign up form&#8217;s conversion rate is to lower the amount of time it takes to complete. One way to do that, is to add a &#8220;check username availability&#8221; feature. Users will often choose conflicting usernames, [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>The goal of a signup form is to quickly convert visitors into registered users. The easiest way to increase your sign up form&#8217;s conversion rate is to lower the amount of time it takes to complete.</p>
<p>One way to do that, is to add a &#8220;check username availability&#8221; feature. Users will often choose conflicting usernames, especially on large community websites. </p>
<p>Rather than reporting the error on the next page, give the user a quick and easy way to check their username availability. This will speed up the sign up process.</p>
<p>As always, start with your interface. A simple form with a text box, a div, and a &#8220;Check Availability&#8221; button is all that&#8217;s needed. You can copy the HTML from the demo.</p>
<p><a href="/misc/checkuser.html"><img src="/img/articles/checkuser.jpg" alt="Check username availability" /></a></p>
<p>Using the prototype javascript library, we will send an AJAX request to a seperate <em>checkuser.php</em> page, which will print either 1 for &#8220;available&#8221;, or 0 for &#8220;not available&#8221;. Our javascript function will print the appropriate message in our div, then highlight the textbox with green (available), or red (not available).</p>
<p>Here is the <em>checkUser()</em> javascript function. Don&#8217;t forget to include the Prototype Javascript file.</p>
<p><code><br />
function checkUser(user)<br />
{</p>
<p>&nbsp;&nbsp;var url = encodeURIComponent('checkuser.php');<br />
&nbsp;&nbsp;var params = 'user=' + escape(user);</p>
<p>&nbsp;&nbsp;new Ajax.Request(url, {<br />
&nbsp;&nbsp;&nbsp;&nbsp;method: 'get', parameters: params,<br />
&nbsp;&nbsp;&nbsp;&nbsp;onSuccess: function(transport) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(transport.responseText == 1){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$('userstatus').innerHTML = 'Your username is available.',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$('user').style.backgroundColor = '#caffd5'<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$('userstatus').innerHTML = 'Sorry, that username is already taken.',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$('user').style.backgroundColor = '#ffd4ca';<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}}});<br />
}<br />
</code>
<p><a href="/misc/checkuser.html"><strong>View the Demo</strong></a>.</p>
<p>This is only a small way you can increase the effectiveness of your sign up form. I will be writing about other methods in the near future.</p>
]]></content:encoded>
			<wfw:commentRss>http://richardoneill.com.au/2007/08/check-username-availability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a Website for your Application</title>
		<link>http://richardoneill.com.au/2007/08/building-a-website-for-your-application/</link>
		<comments>http://richardoneill.com.au/2007/08/building-a-website-for-your-application/#comments</comments>
		<pubDate>Thu, 02 Aug 2007 13:39:07 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[So your project is nearly finished, now all you need is a website to get the word out. Unfortunately this stage of the project is often neglected, which is understandable. Programmers want to work on the actual application rather then the website. However, your visitors aren&#8217;t going to download your application if they can&#8217;t find [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>So your project is nearly finished, now all you need is a website to get the word out. <a href="http://pownce.com" style="float: right; margin: 10px;"><img src="/img/articles/pownce.jpg" alt="Pownce" /></a>Unfortunately this stage of the project is often neglected, which is understandable. Programmers want to work on the actual application rather then the website. However, your visitors aren&#8217;t going to download your application if they can&#8217;t find the download page.</p>
<p>As a developer (and as a consumer), I see lots of software websites that could be improved. Here are a few tips for making a good application website.</p>
<ul>
<li><strong>Show a screenshot of your application on the homepage</strong>
<p>Most of the time, this is what I look for first. At a quick glance I can see if the application is going to do the job I want. I often download software based solely on the screenshot.</p>
</li>
<li><strong>Make sure the user can get to the download/purchase page within 1 click</strong>
<p><a href="http://mozilla.com/firefox/">Firefox</a> has done this part right. Nothing works better than an eye-catching &#8220;Download Now&#8221; button. The goal of your website is to convert visitors into downloads, so it&#8217;s wise to get your users to the downloads page as soon as possible.
</li>
<li><strong>Explain in 2-3 sentences what your program is and how it helps people</strong>
<p>This should be the first thing your visitor reads. Make it short and to the point. <a href="http://crimsoneditor.com">Crimson editor</a> has an excellent description on it&#8217;s homepage&#8230;</p>
<blockquote><p>&#8220;Crimson Editor is a professional source code editor for Windows.This program is not only fast in loading time, but also small in size (so small that it can be copied in one floppy disk). While it can serve as a good replacement for Notepad, it also offers many powerful features for programming languages such as HTML, C/C++, Perl and Java.&#8221;</p></blockquote>
</li>
<li><strong>Host a demo of the application or the application&#8217;s admin section</strong>
<p>Dont make your visitors type &#8216;admin&#8217; and &#8216;demo&#8217; on the demo login form, it&#8217;s annoying, auto fill the fields.</p>
</li>
<li><strong>Don&#8217;t use bad stock photography</strong>
<p>Personally, I prefer software websites without any photos. But if you have to use them, don&#8217;t include cliche photos of people in suits or talking on cell phones.</p>
<p>People associate these type of photos with faceless corporations.</p>
</li>
<li><strong>Include a news bit</strong>
<p>Often one of the first things I do when looking at an application&#8217;s website is scan for the latest news to see how active the project is.</p>
</li>
<li><strong>Screenshots and gallery</strong>
<p>If possible, have a screenshots page with at least 5 &#8211; 10 good screenshots of your application.</p>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://richardoneill.com.au/2007/08/building-a-website-for-your-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Draggable Windows with Javascript</title>
		<link>http://richardoneill.com.au/2007/07/draggable-windows-with-javascript/</link>
		<comments>http://richardoneill.com.au/2007/07/draggable-windows-with-javascript/#comments</comments>
		<pubDate>Fri, 27 Jul 2007 16:22:35 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[A window is essentially just a floating div. We can make the div draggable using the Script.aculo.us Javascript library. First, we need to create the window div. Here is the CSS I used. .window { &#160;&#160;background: #d8e7fe; &#160;&#160;position: absolute; &#160;&#160;top: 200px; &#160;&#160;left: 200px; &#160;&#160;width: 350px; &#160;&#160;padding: 1px; &#160;&#160;-moz-border-radius: 7px; &#160;&#160;border: 2px solid #21416d; } .window [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="/misc/jswindow.html"><img src="/img/articles/jswindow.jpg" alt="Javascript Window" /></a>
<p>A window is essentially just a floating div. We can make the div draggable using the <a href="http://script.aculo.us">Script.aculo.us</a> Javascript library.</p>
<p>First, we need to create the window div. Here is the CSS I used.</p>
<p><code><br />
.window {<br />
&nbsp;&nbsp;background: #d8e7fe;<br />
&nbsp;&nbsp;position: absolute;<br />
&nbsp;&nbsp;top: 200px;<br />
&nbsp;&nbsp;left: 200px;<br />
&nbsp;&nbsp;width: 350px;<br />
&nbsp;&nbsp;padding: 1px;<br />
&nbsp;&nbsp;-moz-border-radius: 7px;<br />
&nbsp;&nbsp;border: 2px solid #21416d;</p>
<p>}<br />
.window h1 {<br />
&nbsp;&nbsp;-moz-border-radius-topleft: 5px;<br />
&nbsp;&nbsp;-moz-border-radius-topright: 5px;<br />
&nbsp;&nbsp;padding: 6px;<br />
&nbsp;&nbsp;display: block;<br />
&nbsp;&nbsp;background-color: #9cc6ff;<br />
&nbsp;&nbsp;font-size: 13px;<br />
&nbsp;&nbsp;margin: 0px;<br />
}<br />
</code>
<p>And here is the HTML markup.</p>
<p><code><br />
&lt;div id="mywindow" class="window"&gt;<br />
&nbsp;&nbsp;&lt;h1&gt;Example Window&lt;/h1&gt;<br />
&nbsp;&nbsp;&lt;p&gt;Click and drag this window around the webpage.&lt;/p&gt;<br />
&lt;/div&gt;<br />
</code>
<p>I&#8217;ve used &#8216;<a href="http://developer.mozilla.org/en/docs/CSS:-moz-border-radius">-moz-border-radius</a>&#8216; for rounded corners because I&#8217;m lazy. You&#8217;ll need to use corner images if you want rounded corners that work in more than one browser.</p>
<p>Now all that&#8217;s left to do is the javascript. As I said before, we&#8217;ll use the <a href="http://script.aculo.us">Script.aculo.us</a> library which includes a handy Draggable function. Theres a quick guide on how to install the library <a href="http://wiki.script.aculo.us/scriptaculous/show/Usage">here</a>.</p>
<p>Once you&#8217;ve got the library installed, add this short Javascript snippet to the <em>head</em> section of your document.</p>
<p><code><br />
&lt;script type="text/javascript"&gt;</p>
<p>	function init(){<br />
	&nbsp;&nbsp;new Draggable('mywindow');<br />
	}</p>
<p>	Event.observe(window, 'load', init, false);</p>
<p>&lt;/script&gt;</code>
<p>When the page loads, the init() function is called, which tells the library to make the div &#8216;mywindow&#8217; draggable!</p>
<p><strong><a href="/misc/jswindow.html">View the finished product.</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://richardoneill.com.au/2007/07/draggable-windows-with-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Password Strength Meter</title>
		<link>http://richardoneill.com.au/2007/07/password-strength-meter/</link>
		<comments>http://richardoneill.com.au/2007/07/password-strength-meter/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 16:38:19 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Making a password strength meter is simple, there&#8217;s no tricky Javascript or AJAX needed, just a simple function and a few divs. Click to view demo. I&#8217;ve decided to design the function around a scoring system, the stronger the password the higher the score. We can accomplish this with just a few simple IF statements. [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Making a password strength meter is simple, there&#8217;s no tricky Javascript or AJAX needed, just a simple function and a few divs.</p>
<p><a href="/misc/passwordstrengthmeter.html"><img src="/img/articles/passwordstrengthmeter.jpg" alt="Password Strength Meter" /><br />Click to view demo.</p>
<p></a>
<p>I&#8217;ve decided to design the function around a scoring system, the stronger the password the higher the score. We can accomplish this with just a few simple IF statements.</p>
<p><code>function passwordStrength(pass)<br />
{</p>
<p>	var score = 0;</p>
<p>	if(pass.length &gt; 2)<br />
		score++;</p>
<p>	if(pass.length &gt; 4)<br />
		score++;</p>
<p>	if(pass.length &gt; <img src='http://richardoneill.com.au/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /><br />
		score += 2;</p>
<p>	if(/w/.test(pass) &#038;&#038; /d/.test(pass))<br />
		score++;</p>
<p>	return score * 2 * 10;</p>
<p>}</code>
<p>The code is fairly self explanatory, the last IF statement checks if the password contains both characters and symbols. The function returns a percentage of the password&#8217;s score out of 5, which is the maximum score it can be awarded.</p>
<p>Next, we need a form with a text box and 2 divs for our meter.</p>
<p><code><br />
&lt;input type="text" onkeyup="document.getElementById('passmeter').style.width = passwordStrength(this.value) + '%';" /&gt;<br />
&lt;br /&gt;<br />
Password Strength:&lt;br /&gt;<br />
&lt;div id="passmeterbg"&gt;&lt;div id="passmeter"&gt;&lt;/div&gt;&lt;/div&gt;<br />
</code>
<p>The &#8216;onkeyup&#8217; event calls the passwordStrength() function every time a key is pressed. The &#8216;width&#8217; property of our meter div is then given the password&#8217;s score.</p>
<p>Finally, we need some CSS to style the meter&#8230;</p>
<p><code><br />
			#passmeter {<br />
				width: 0px;<br />
				background: #629d48;<br />
				height: 3px;<br />
			}</p>
<p>			#passmeterbg {<br />
				height: 3px;<br />
				background: #f1f1f1;<br />
				width: 200px;<br />
			}<br />
</code>
<p><a href="/misc/passwordstrengthmeter.html" style="font-weight: bold;">View the finished product.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://richardoneill.com.au/2007/07/password-strength-meter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

