<?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>spechal.com &#187; Internet</title>
	<atom:link href="http://spechal.com/category/internet/feed/" rel="self" type="application/rss+xml" />
	<link>http://spechal.com</link>
	<description>[spesh-uhl]</description>
	<lastBuildDate>Mon, 23 Apr 2012 01:30:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Installing php-ffmpeg on CentOS 5.x</title>
		<link>http://spechal.com/2011/07/25/installing-php-ffmpeg-on-centos-5-x/</link>
		<comments>http://spechal.com/2011/07/25/installing-php-ffmpeg-on-centos-5-x/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 16:24:58 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Commands]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[phpize]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=305</guid>
		<description><![CDATA[This can be a pain due to a bug in the ffpmeg_frame.c file &#8230; here are the commands to get up and going yum -y install ffmpeg ffmpeg-devel wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download tar jxvf ffmpeg-php-0.6.0.tbz2 sed -i 's/PIX_FMT_RGBA32/PIX_FMT_RGBA/g' ffmpeg-php-0.6.0/ffmpeg_frame.c cd ffmpeg-php-0.6.0 &#038;&#038; &#8230; <a href="http://spechal.com/2011/07/25/installing-php-ffmpeg-on-centos-5-x/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This can be a pain due to a bug in the ffpmeg_frame.c file &#8230; here are the commands to get up and going</p>
<pre>yum -y install ffmpeg ffmpeg-devel
wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download
tar jxvf ffmpeg-php-0.6.0.tbz2
sed -i 's/PIX_FMT_RGBA32/PIX_FMT_RGBA/g' ffmpeg-php-0.6.0/ffmpeg_frame.c
cd ffmpeg-php-0.6.0 &#038;&#038; phpize
./configure &#038;&#038; make &#038;&#038; make install
echo 'extension=ffmpeg.so' > /etc/php.d/ffmpeg.ini &#038;&#038; /etc/init.d/httpd restart
php -v &#038;&#038; php -m | grep ffmpeg
</pre>
<p>In this process you:<br />
use yum to install ffmpeg and the ffmpeg development files<br />
download php-ffmepg from sourceforge and extract it<br />
apply the bug fix to the ffmpeg_frace.c file<br />
change directories to the php-ffmpeg directory and phpize the module<br />
configure, make and install the shared object (extension)<br />
add the extension to the loaded php extensions<br />
restart apache and verify no errors are shown on php startup and that ffmepg is loaded</p>
<p>If all is well, you should see your version of PHP with the copyrights on 3 lines and the last line showing ffmpeg</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/07/25/installing-php-ffmpeg-on-centos-5-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Plaintext Offender : BidVertiser</title>
		<link>http://spechal.com/2011/07/04/plaintext-offender-bidvertiser/</link>
		<comments>http://spechal.com/2011/07/04/plaintext-offender-bidvertiser/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 19:09:07 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[plaintext]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=298</guid>
		<description><![CDATA[If you have an account with BidVertiser, your password is stored in plain text and emailed back to you when you request it. This also means customer service can look up your account and get your password. I informed them &#8230; <a href="http://spechal.com/2011/07/04/plaintext-offender-bidvertiser/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you have an account with BidVertiser, your password is stored in plain text and emailed back to you when you request it. This also means customer service can look up your account and get your password.</p>
<p>I informed them of this and their response was:</p>
<p>Done by: Customer Service, Publishers &amp; Referral Status: Closed Action Date: Monday, 07/04/2011 03:30 PM<br />
Respond:<br />
Dear Travis,</p>
<p>The option to include login information in our contact emails is available through your control panel, through Account Management &#8211; Edit Profile. I have disabled the option for you.</p>
<p>Best Regards,<br />
BidVertiser Support Team</p>
<p>To which I replied:</p>
<p>Done by: customer Status: Follow Up Action Date: Monday, 07/04/2011 02:03 PM<br />
Customer Comment:<br />
You&#8217;ve missed the point. Passwords are not to be stored in plain text and emailed out to your users over insecure connections. Passwords should be reset, not sent. If someone were to get into your database without your knowledge, they would also be able to compromise each account without any sort of password attack, since you guys would just show the passwords to them.</p>
<p>We&#8217;ll see if they even care.</p>
<p>### edit ###</p>
<p>Response:</p>
<p>Dear Travis,</p>
<p>Noted.</p>
<p>Best Regards,<br />
BidVertiser Support Team</p>
<p>###</p>
<p>I guess they do not care.</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/07/04/plaintext-offender-bidvertiser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use HackIt and Revolution ROM to sexify your HTC Inspire</title>
		<link>http://spechal.com/2011/05/15/use-hackit-and-revolution-rom-to-sexify-your-htc-inspire/</link>
		<comments>http://spechal.com/2011/05/15/use-hackit-and-revolution-rom-to-sexify-your-htc-inspire/#comments</comments>
		<pubDate>Sun, 15 May 2011 07:21:19 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[HTC]]></category>
		<category><![CDATA[root]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=282</guid>
		<description><![CDATA[Got an HTC Inspire 4G? Tired of all the bloatware and running apps. Tired of have to kill those apps over and over? Root your phone (root is the superuser account in Linux, which Android runs on)! This voids all &#8230; <a href="http://spechal.com/2011/05/15/use-hackit-and-revolution-rom-to-sexify-your-htc-inspire/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Got an HTC Inspire 4G?  Tired of all the bloatware and running apps.  Tired of have to kill those apps over and over?  Root your phone (root is the superuser account in Linux, which Android runs on)!  This voids all warranties, but it is worth it.  Use HackIt to permanently root your HTC, then download the HTC Revolution ROM and flash your phone with it.  Then install Terminal Emulator to access your phones root shell.  You&#8217;ll also want Gemini App Manager (Free), hit Menu to go into Expert Mode and you can uninstall ANYTHING, even your keyboard (which you should NOT do).</p>
<p>All you need to know is located at this web site: http://www.addictivetips.com/mobile/install-android-revolution-4g-rom-on-htc-inspire-4g/</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/05/15/use-hackit-and-revolution-rom-to-sexify-your-htc-inspire/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Node.js Trademarked &#8212; Next Up: Buyout (Sellout)</title>
		<link>http://spechal.com/2011/04/29/node-js-trademarked-next-up-buyout-sellout/</link>
		<comments>http://spechal.com/2011/04/29/node-js-trademarked-next-up-buyout-sellout/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 15:18:48 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Node.js / Socket.io]]></category>
		<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=276</guid>
		<description><![CDATA[Well, Node.js has been trademarked to &#8220;protect the brand&#8221;. What does that usually mean? &#8220;We need a nice brand to sell.&#8221; http://blog.nodejs.org/2011/04/29/trademark/]]></description>
			<content:encoded><![CDATA[<p>Well, Node.js has been trademarked to &#8220;protect the brand&#8221;.  What does that usually mean?  &#8220;We need a nice brand to sell.&#8221;</p>
<p>http://blog.nodejs.org/2011/04/29/trademark/</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/04/29/node-js-trademarked-next-up-buyout-sellout/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross Browser Gradient Shadowed Buttons</title>
		<link>http://spechal.com/2011/03/29/cross-browser-gradient-shadowed-buttons/</link>
		<comments>http://spechal.com/2011/03/29/cross-browser-gradient-shadowed-buttons/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 20:54:23 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=268</guid>
		<description><![CDATA[This is the CSS I use to make grey and blue buttons for fun. .shadow &#123; -moz-box-shadow: 3px 3px 4px #969696; -webkit-box-shadow: 3px 3px 4px #969696; box-shadow: 3px 3px 4px #969696; /* For IE 8 */ -ms-filter: &#34;progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#969696')&#34;; &#8230; <a href="http://spechal.com/2011/03/29/cross-browser-gradient-shadowed-buttons/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is the CSS I use to make grey and blue buttons for fun.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.shadow</span> <span style="color: #00AA00;">&#123;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span> <span style="color: #933;">3px</span> <span style="color: #933;">4px</span> <span style="color: #cc00cc;">#969696</span><span style="color: #00AA00;">;</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span> <span style="color: #933;">3px</span> <span style="color: #933;">4px</span> <span style="color: #cc00cc;">#969696</span><span style="color: #00AA00;">;</span>
	box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span> <span style="color: #933;">3px</span> <span style="color: #933;">4px</span> <span style="color: #cc00cc;">#969696</span><span style="color: #00AA00;">;</span>
	<span style="color: #808080; font-style: italic;">/* For IE 8 */</span>
	-ms-filter<span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#969696')&quot;</span><span style="color: #00AA00;">;</span>
	<span style="color: #808080; font-style: italic;">/* For IE 5.5 - 7 */</span>
	filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.Shadow<span style="color: #00AA00;">&#40;</span>Strength<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">4</span><span style="color: #00AA00;">,</span> Direction<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">135</span><span style="color: #00AA00;">,</span> Color<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#969696'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.button-grey</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
	filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.gradient<span style="color: #00AA00;">&#40;</span>startColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#5E5E5E'</span><span style="color: #00AA00;">,</span> endColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#333333'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for IE */</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -webkit-gradient<span style="color: #00AA00;">&#40;</span>linear<span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> from<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#5E5E5E</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> to<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#333333</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for webkit browsers */</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span>  <span style="color: #cc00cc;">#5E5E5E</span><span style="color: #00AA00;">,</span>  <span style="color: #cc00cc;">#333333</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for firefox 3.6+ */</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#666</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
.button-<span style="color: #000000; font-weight: bold;">blue</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
	filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.gradient<span style="color: #00AA00;">&#40;</span>startColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#51A9C6'</span><span style="color: #00AA00;">,</span> endColorstr<span style="color: #00AA00;">=</span><span style="color: #ff0000;">'#1375AE'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for IE */</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -webkit-gradient<span style="color: #00AA00;">&#40;</span>linear<span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> from<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#51A9C6</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> to<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#1375AE</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for webkit browsers */</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span>  <span style="color: #cc00cc;">#51A9C6</span><span style="color: #00AA00;">,</span>  <span style="color: #cc00cc;">#1375AE</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* for firefox 3.6+ */</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#1480BE</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/03/29/cross-browser-gradient-shadowed-buttons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Node.js MVC &#8211; Starting an MVC setup for Node.js</title>
		<link>http://spechal.com/2011/03/24/node-js-mvc-starting-an-mvc-setup-for-node-js/</link>
		<comments>http://spechal.com/2011/03/24/node-js-mvc-starting-an-mvc-setup-for-node-js/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 03:44:05 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Node.js / Socket.io]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=247</guid>
		<description><![CDATA[server.js var http = require&#40;'./lib/http'&#41; var router = require&#40;'./lib/router'&#41; var fs = require&#40;'fs'&#41; &#160; http.serve&#40;router.dispatch&#41; http.js var http = require&#40;'http'&#41; &#160; exports.serve = function&#40;handleRequest&#41; &#123; http.createServer&#40;function &#40;request, response&#41; &#123; handleRequest&#40;request, response&#41; &#125;&#41;.listen&#40;parseInt&#40;process.env.PORT&#41; &#124;&#124; 8001&#41; &#125; lib/router.js var http = require&#40;'./http'&#41;; &#8230; <a href="http://spechal.com/2011/03/24/node-js-mvc-starting-an-mvc-setup-for-node-js/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>server.js</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> http <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./lib/http'</span><span style="color: #009900;">&#41;</span>
<span style="color: #003366; font-weight: bold;">var</span> router <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./lib/router'</span><span style="color: #009900;">&#41;</span>
<span style="color: #003366; font-weight: bold;">var</span> fs <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fs'</span><span style="color: #009900;">&#41;</span>
&nbsp;
http.<span style="color: #660066;">serve</span><span style="color: #009900;">&#40;</span>router.<span style="color: #660066;">dispatch</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>http.js</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> http <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http'</span><span style="color: #009900;">&#41;</span>
&nbsp;
exports.<span style="color: #660066;">serve</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>handleRequest<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  http.<span style="color: #660066;">createServer</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    handleRequest<span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">listen</span><span style="color: #009900;">&#40;</span>parseInt<span style="color: #009900;">&#40;</span>process.<span style="color: #660066;">env</span>.<span style="color: #660066;">PORT</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">8001</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>lib/router.js</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> http <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./http'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> sys <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;sys&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> path <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'path'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
exports.<span style="color: #660066;">dispatch</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>request.<span style="color: #660066;">url</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> tmpvar <span style="color: #339933;">=</span> request.<span style="color: #660066;">url</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>tmpvar<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>
			tmpvar.<span style="color: #660066;">splice</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>tmpvar.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;=</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	      request.<span style="color: #660066;">controller</span> <span style="color: #339933;">=</span> tmpvar<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	      <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>tmpvar.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	    	request.<span style="color: #660066;">action</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'index'</span><span style="color: #339933;">;</span>
	      <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
	    	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>tmpvar<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// sometimes the action is just / which causes issues</span>
	    		request.<span style="color: #660066;">action</span> <span style="color: #339933;">=</span> tmpvar<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	    	<span style="color: #000066; font-weight: bold;">else</span>
	    		request.<span style="color: #660066;">action</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'index'</span><span style="color: #339933;">;</span>
	      <span style="color: #009900;">&#125;</span>
	    <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
	  <span style="color: #006600; font-style: italic;">// requested / ... the index</span>
	  request.<span style="color: #660066;">controller</span> <span style="color: #339933;">=</span> request.<span style="color: #660066;">action</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'index'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Controller = '</span> <span style="color: #339933;">+</span> request.<span style="color: #660066;">controller</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' :: Action = '</span> <span style="color: #339933;">+</span> request.<span style="color: #660066;">action</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>request.<span style="color: #660066;">controller</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>request.<span style="color: #660066;">action</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	  <span style="color: #003366; font-weight: bold;">var</span> thePath <span style="color: #339933;">=</span> path.<span style="color: #660066;">resolve</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'controllers/'</span> <span style="color: #339933;">+</span> request.<span style="color: #660066;">controller</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.js'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  path.<span style="color: #660066;">exists</span><span style="color: #009900;">&#40;</span>thePath<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>exists<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>exists<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	      <span style="color: #003366; font-weight: bold;">var</span> controller <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span>thePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	      <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>controller.<span style="color: #660066;">run</span><span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	    	  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	      <span style="color: #000066; font-weight: bold;">else</span>
	    	  error404<span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  	<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> 
	  	  error404<span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  	<span style="color: #009900;">&#125;</span>
	  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>      	
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> error404 <span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  response.<span style="color: #660066;">writeHead</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">404</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'Content-Type'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'text/html'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  response.<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;p&gt;The page you requested was not found!&lt;/p&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>controllers/index.js</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> fs <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fs'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
	path <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'path'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
exports.<span style="color: #660066;">run</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	response.<span style="color: #660066;">writeHead</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">200</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'Content-Type'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'text/html'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> encoding <span style="color: #339933;">=</span> <span style="color: #3366CC;">'utf8'</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> viewfile <span style="color: #339933;">=</span> request.<span style="color: #660066;">action</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'.html'</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> theFile <span style="color: #339933;">=</span> path.<span style="color: #660066;">resolve</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'views/'</span> <span style="color: #339933;">+</span> request.<span style="color: #660066;">controller</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'/'</span> <span style="color: #339933;">+</span> viewfile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	path.<span style="color: #660066;">exists</span><span style="color: #009900;">&#40;</span>theFile<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>exists<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>exists<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> output <span style="color: #339933;">=</span> fs.<span style="color: #660066;">readFileSync</span><span style="color: #009900;">&#40;</span>theFile<span style="color: #339933;">,</span> encoding<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			response.<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span>output<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> 
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>views/index.html</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">Hello World!</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/03/24/node-js-mvc-starting-an-mvc-setup-for-node-js/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Set static IP address in Ubuntu</title>
		<link>http://spechal.com/2011/03/20/set-static-ip-address-in-ubuntu/</link>
		<comments>http://spechal.com/2011/03/20/set-static-ip-address-in-ubuntu/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 06:05:42 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[ip]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=238</guid>
		<description><![CDATA[You will need to edit your /etc/network/interfaces file sudo nano /etc/network/interfaces auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.1.10 netmask 255.255.255.0 gateway 192.168.1.1 network 192.168.1.0 broadcast 192.168.1.255 Restart networking via sudo /etc/init.d/networking restart]]></description>
			<content:encoded><![CDATA[<p>You will need to edit your /etc/network/interfaces file</p>
<pre>sudo nano /etc/network/interfaces</pre>
<pre>auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255</pre>
<p>Restart networking via</p>
<pre>sudo /etc/init.d/networking restart</pre>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/03/20/set-static-ip-address-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Node.js and Socket.io on Ubuntu</title>
		<link>http://spechal.com/2011/03/19/installing-node-js-and-socket-io-on-ubuntu/</link>
		<comments>http://spechal.com/2011/03/19/installing-node-js-and-socket-io-on-ubuntu/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 13:15:42 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Commands]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Node.js / Socket.io]]></category>
		<category><![CDATA[Operating Systems]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[socketio]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=235</guid>
		<description><![CDATA[Issue the following on the command line: cd ~ sudo apt-get install libv8-2.0.3 libv8-dev libv8-dbg libssl-dev curl wget http://nodejs.org/dist/node-v0.4.3.tar.gz tar zxvf node-v0.4.3.tar.gz cd node-v0.4.3 ./configure &#038;&#038; make &#038;&#038; make install sudo curl http://npmjs.org/install.sh &#124; sudo sh sudo npm install socket.io &#8230; <a href="http://spechal.com/2011/03/19/installing-node-js-and-socket-io-on-ubuntu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Issue the following on the command line:</p>
<pre>cd ~
sudo apt-get install libv8-2.0.3 libv8-dev libv8-dbg libssl-dev curl
wget http://nodejs.org/dist/node-v0.4.3.tar.gz
tar zxvf node-v0.4.3.tar.gz
cd node-v0.4.3
./configure &#038;&#038; make &#038;&#038; make install
sudo curl http://npmjs.org/install.sh | sudo sh
sudo npm install socket.io
</pre>
<p>First we change to our home directory via cd ~ &#8230; even though the tilda in the code above looks like a hyphen.  Then we install Google V8, SSL development files and cURL.  Next we grab Node.js, configure and install it.  Nearly last, we download and install npm.  Finally, we tell npm to install socket.io for us.</p>
<p>fin.</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/03/19/installing-node-js-and-socket-io-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Super Simple Node.js Chatroom</title>
		<link>http://spechal.com/2011/03/19/super-simple-node-js-chatroom/</link>
		<comments>http://spechal.com/2011/03/19/super-simple-node-js-chatroom/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 13:08:47 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Node.js / Socket.io]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[socketio]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=232</guid>
		<description><![CDATA[Updated: Fixed an issue in the HTML code where node.js would create a malformed URL. Note: Don&#8217;t use a port in the FQDN, specify the port in the io.Socket options. Node.js Code var http = require&#40;'http'&#41;, // HTTP server io &#8230; <a href="http://spechal.com/2011/03/19/super-simple-node-js-chatroom/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Updated: Fixed an issue in the HTML code where node.js would create a malformed URL.<br />
Note: Don&#8217;t use a port in the FQDN, specify the port in the io.Socket options.<br />
<strong>Node.js Code</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> http <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// HTTP server</span>
  io <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'socket.io'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// Socket.io</span>
  fs <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fs'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// File System</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// make a standard server</span>
server <span style="color: #339933;">=</span> http.<span style="color: #660066;">createServer</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>req<span style="color: #339933;">,</span> res<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    res.<span style="color: #660066;">writeHead</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">200</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'Content-Type'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'text/html'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// read index.html and send it to the client</span>
    <span style="color: #003366; font-weight: bold;">var</span> output <span style="color: #339933;">=</span> fs.<span style="color: #660066;">readFileSync</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'./index.html'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'utf8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    res.<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span>output<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// run on port 8080</span>
server.<span style="color: #660066;">listen</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">8080</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// listen to the server</span>
<span style="color: #003366; font-weight: bold;">var</span> socket <span style="color: #339933;">=</span> io.<span style="color: #660066;">listen</span><span style="color: #009900;">&#40;</span>server<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// on a connection, do stuff</span>
socket.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'connection'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>client<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// broadcast the connection</span>
	client.<span style="color: #660066;">broadcast</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>message<span style="color: #339933;">:</span> client.<span style="color: #660066;">sessionId</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' is now available'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">// when the server gets a message, during a connection, broadcast the message</span>
	client.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'message'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> client.<span style="color: #660066;">broadcast</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> message<span style="color: #339933;">:</span> client.<span style="color: #660066;">sessionId</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">': '</span> <span style="color: #339933;">+</span> msg.<span style="color: #660066;">message</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">// when the server gets a disconnect, during a connection, broadcast the disconnection</span>
	client.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'disconnect'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> client.<span style="color: #660066;">broadcast</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> message<span style="color: #339933;">:</span> client.<span style="color: #660066;">sessionId</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' is no longer available'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>HTML Code</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
  &lt;title&gt;Chatroom&lt;/title&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;http://127.0.0.1:8080/socket.io/socket.io.js&quot;&gt;&lt;/script&gt; 
  &lt;script&gt; 
    // make a connection to the server
    var socket = new io.Socket('127.0.0.1', {port:8080, connectTimeout:3000});
    // make a message buffer in case things get congested
    var buffer = [];
    socket.connect();
&nbsp;
    socket.on('connection', function(client){
          // on connection, send the buffer and tell broadcast, to the server, the connection
  	  client.send({buffer: buffer});
  	  client.broadcast({ announcement: client.sessionId + ' connected' });
    });
&nbsp;
    socket.on('connect_failed', function(){
          alert('The connection to the server failed.');
    });
&nbsp;
    socket.on('message', function(message){
          // when the client gets a message from the server, 
          // add it to the buffer and display the message
  	  buffer.push(message);
  	  if(buffer.length &gt; 15)
  		  buffer.shift();	  
  	  appendMessage(message.message);
    });
&nbsp;
    socket.on('disconnect', function(client){ 
      // on disconnect, broadcast it to the server
      client.broadcast({ announcement: client.sessionId + ' disconnected' });
    });
&nbsp;
    // send a message to the server
    function sendMessage(message){
  	  if(!message){
                // get the message from the input field
  	  	var msg = $(&quot;input#message&quot;).val(); 
  	  	$(&quot;input#message&quot;).val('');
  	  } else {
  		var msg = message; 
  	  }
  	  if(msg.length &gt; 0){ // stop annoying empty messages
  	  	if(socket.send({message:msg})) // send the message
      	  	    appendMessage('You: ' + msg); // show the message
  	  }
    }
&nbsp;
    // show the message on the screen
    function appendMessage(message){
  	  $('div#chat-box').append('&lt;div class=&quot;msg&quot;&gt;' + message + '&lt;/div&gt;'); 
    }
  &lt;/script&gt; 
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;chat-box&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;chat-field&quot;&gt;
  &lt;form method=&quot;post&quot; action=&quot;&quot; onsubmit=&quot;return false;&quot; /&gt;
    &lt;input type=&quot;text&quot; name=&quot;message&quot; id=&quot;message&quot; value=&quot;&quot; /&gt;&lt;input id=&quot;client&quot; name=&quot;client&quot; value=&quot;&quot; type=&quot;hidden&quot; /&gt;&lt;input type=&quot;submit&quot; class=&quot;button&quot; name=&quot;send&quot; id=&quot;send&quot; value=&quot;Send&quot; onclick=&quot;sendMessage();&quot; /&gt;
  &lt;/form&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>Save the Node.js code as chatroom.js or something and the HTML as index.html.  Start node on chatroom.js (execute node chatroom.js on the CLI).  Fire up your browser and view 127.0.0.1:8080.  Open up another tab and go to the same address to start talking to yourself.  You can also put the script on a public IP and have your friends connect to it.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/03/19/super-simple-node-js-chatroom/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>jQuery UI Modal Box plugin</title>
		<link>http://spechal.com/2011/03/11/jquery-ui-modal-box-plugin/</link>
		<comments>http://spechal.com/2011/03/11/jquery-ui-modal-box-plugin/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 10:21:56 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=214</guid>
		<description><![CDATA[I needed a modal box. You might too. You can have mine. I hope it helps. The image in the HTML is the famfamfam cross.png from the silk icon set. See http://www.famfamfam.com HTML &#60;div id=&#34;modal-window&#34; class=&#34;ui-widget ui-corner-all&#34;&#62; &#60;div id=&#34;modal-window-title&#34; class=&#34;ui-widget-header &#8230; <a href="http://spechal.com/2011/03/11/jquery-ui-modal-box-plugin/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I needed a modal box.  You might too.  You can have mine.  I hope it helps. <img src='http://spechal.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The image in the HTML is the famfamfam cross.png from the silk icon set.  See http://www.famfamfam.com</p>
<p>HTML</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;modal-window&quot; class=&quot;ui-widget ui-corner-all&quot;&gt;
  &lt;div id=&quot;modal-window-title&quot; class=&quot;ui-widget-header ui-corner-tr ui-corner-tl&quot;&gt;&lt;span id=&quot;modal-window-title-body&quot;&gt;&lt;/span&gt;
    &lt;img id=&quot;modal-window-close&quot; class=&quot;ui-icon&quot; src=&quot;/img/cross.png&quot; alt=&quot;Close&quot; onclick=&quot;$().modalHide();&quot; /&gt;
  &lt;/div&gt;
&lt;div id=&quot;modal-window-content&quot; class=&quot;ui-widget-content&quot;&gt;&lt;p id=&quot;modal-window-content-body&quot;&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;</pre></div></div>

<p>CSS</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #cc00cc;">#modal-window</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">1000</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">50%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
div<span style="color: #cc00cc;">#modal-window</span> <span style="color: #00AA00;">&gt;</span> div <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
div<span style="color: #cc00cc;">#modal-window</span> span <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">580px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">25px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
div<span style="color: #cc00cc;">#modal-window-title</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">25px</span><span style="color: #00AA00;">;</span>	
<span style="color: #00AA00;">&#125;</span>
img<span style="color: #cc00cc;">#modal-window-close</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
div<span style="color: #cc00cc;">#modal-window-</span><span style="color: #000000; font-weight: bold;">content</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
p<span style="color: #cc00cc;">#modal-window-content-body</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>	
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>JS</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">modalCenter</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;position&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;absolute&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;top&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">scrollTop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;left&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">scrollLeft</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">modalTitle</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>title<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span#modal-window-title-body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>title<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">modalContent</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>content<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'p#modal-window-content-body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>content<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">modalShow</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div#modal-window'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">modalCenter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">modalHide</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div#modal-window'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">modalClose</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div#modal-window'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">modalTitle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">modalContent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">modalLoad</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span> params<span style="color: #339933;">,</span> method<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>method<span style="color: #009900;">&#41;</span> method <span style="color: #339933;">=</span> <span style="color: #3366CC;">'POST'</span><span style="color: #339933;">;</span>
	$.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
		data<span style="color: #339933;">:</span> params<span style="color: #339933;">,</span> 
		type<span style="color: #339933;">:</span> method<span style="color: #339933;">,</span> 
		dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">'json'</span><span style="color: #339933;">,</span> 
		success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">modalTitle</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">modalContent</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'content'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">modalShow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Usage</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;button&quot; value=&quot;Click Me!&quot; onclick=&quot;$().modalLoad('/some/url', {id:123});&quot; /&gt;</pre></div></div>

<p>Expected ajax return</p>

<div class="wp_syntax"><div class="code"><pre class="json" style="font-family:monospace;">{&quot;title&quot;:&quot;The title&quot;,&quot;content&quot;:&quot;&lt;p&gt;The content&lt;/p&gt;&quot;}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/03/11/jquery-ui-modal-box-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

