<?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>Dancing Mammoth &#187; Lab</title>
	<atom:link href="http://dancingmammoth.com/category/lab/feed/" rel="self" type="application/rss+xml" />
	<link>http://dancingmammoth.com</link>
	<description>Cleaner Websites for a Cleaner Future</description>
	<lastBuildDate>Mon, 11 Jan 2010 20:21:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>An Interactive US Map Without Flash.</title>
		<link>http://dancingmammoth.com/2009/09/24/an-interactive-us-map-without-flash/</link>
		<comments>http://dancingmammoth.com/2009/09/24/an-interactive-us-map-without-flash/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 15:47:56 +0000</pubDate>
		<dc:creator>Brian Kieffer</dc:creator>
				<category><![CDATA[Case Studies]]></category>
		<category><![CDATA[Lab]]></category>

		<guid isPermaLink="false">http://dancingmammoth.com/?p=252</guid>
		<description><![CDATA[A client recently requested a feature for their website that would allow users to access state by state data by rolling over a map of the US. At first, I considered using one of the available Flash packages, but the design took a couple of twists that made that much more difficult. So I opted [...]]]></description>
			<content:encoded><![CDATA[<p>A client recently requested a feature for their website that would allow users to access state by state data by rolling over a map of the US. At first, I considered using one of the available Flash packages, but the design took a couple of twists that made that much more difficult. So I opted to implement the map with plain old HTML, CSS and Javascript.</p>
<p><a href="/wp-content/demos/usmap/">Here is the map</a>.</p>
<p>The benefit of using HTML, CSS and Javascript instead of Flash, is that the map will function in just about any browser without having to install additional components. Mobile browsers such as Safari on iPhone, older browsers, or browsers without Javascript enabled, can still use the map. Here is how it works.</p>
<p>The map consists of three layers.</p>
<p align="center"><img class="size-full wp-image-253   aligncenter" title="layers" src="http://dancingmammoth.com/wp-content/uploads/layers.jpg" alt="layers" width="509" height="203" /></p>
<p>The bottom layer contains the full map as a background image. This loads when the page is opened, along with the top layer which contains the maparea linked to a transparent GIF that matches the size of the map. The layers are positioned over one another with CSS.</p>
<pre class="brush: css;">
div#usmap{
position: absolute;
top: 0px;
left: 0px;
}

div#mapareas{
position: absolute;
top: 0px;
left: 0px;
z-index: 99;
}
</pre>
<p>The middle layer is where all of the animation takes place. When a user mouses over one of the mapareas, jQuery prepends the preloaded image for an individual state and positions it in the middle layer. Some images also have a corresponding mask to maintain the illusion that the state is popping up away from the page. The individual state images were created by cutting apart the main US image, and the positioning is done with jQuery&#8217;s css method. This can be somewhat time consuming for complex maps.</p>
<pre class="brush: jscript;">
$(&quot;#usmap&quot;).prepend(img);
$(&quot;#usmap&quot;).prepend(imgmask);
positionimage();
</pre>
<pre class="brush: css;">
.state-copy {
position: absolute;
z-index:2;
}
.state-mask {
position: absolute;
z-index:1;
}
</pre>
<p>Then jQuery calcuates the current size and zoomed size, and executes the animation.</p>
<pre class="brush: jscript;">
$(&quot;.state-copy&quot;).each(function(){
var width = $(this).width();
var height = $(this).height();

var zoomheight = height * 1.2;
var zoomwidth = width * 1.2;

var	centerheight = (zoomheight - height)/2;
var	centerwidth = (zoomwidth - width)/2;

$(this).animate({
top: '-=' + centerheight,
left: '-=' + centerwidth,
width: zoomwidth,
height: zoomheight
}, 100);

});
</pre>
<p>This method will work for just about any similar image that you want to animate.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancingmammoth.com/2009/09/24/an-interactive-us-map-without-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Stream Filters: Unchunking HTTP Streams</title>
		<link>http://dancingmammoth.com/2009/08/29/php-stream-filters-unchunking-http-streams/</link>
		<comments>http://dancingmammoth.com/2009/08/29/php-stream-filters-unchunking-http-streams/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 05:13:35 +0000</pubDate>
		<dc:creator>Francis Avila</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://dancingmammoth.com/?p=223</guid>
		<description><![CDATA[Slinging php code to and fro one day, I found myself needing to process a potentially large result from a url&#8211;a result too large to fit within PHP&#8217;s memory limit.  However, I could process this result a line at a time, so I could avoid buffering the entire thing in memory.  I couldn&#8217;t use cURL, [...]]]></description>
			<content:encoded><![CDATA[<p>Slinging php code to and fro one day, I found myself needing to process a potentially large result from a url&#8211;a result too large to fit within PHP&#8217;s memory limit.  However, I could process this result a line at a time, so I could avoid buffering the entire thing in memory.  I couldn&#8217;t use cURL, since it buffers everything, but I could use PHP&#8217;s handy file-like stream interface, fetch the url with an <code>fopen('http://my-url.n.e.t/', 'r');</code> and then use <code>fgets()</code> to keep only a line in memory at a time.</p>
<p>It was a great plan, but I noticed that I occasionally got garbage lines or bogus input.  Using http cli tools like wget and curl revealed nothing out of the ordinary, until I realized that those garbage lines were the uninterpreted length markers for <code>Transfer-Encoding: chunked</code>.  PHP&#8217;s http stream handler does not decode chunked transfers.</p>
<p>There is a pecl function <a href="http://php.net/manual/en/function.http-chunked-decode.php"><code>http_chunked_decode()</code></a>, but it operates on strings, not streams, so I would still have to buffer the entire input first.</p>
<p>PHP&#8217;s streams allow you to attach a chain of <a href="http://php.net/manual/en/stream.filters.php">stream filters</a> to a stream to process input and output (it&#8217;s the same mechanism <code>ob_gzhandler()</code> uses).  My plan was to create a stream filter to transparently unchunk the stream.  Unfortunately, the documentation on writing your own stream filter is pretty sparse, and the examples I could find on the web were all very trivial.</p>
<p>After a few false starts, however, I was able to create an http stream unchunker:</p>
<pre class="brush: php;">
/**
* A stream filter for removing the 'chunking' of a 'Transfer-Encoding: chunked'
* http response
*
* The http stream wrapper on php does not support chunked transfer
* encoding, making this filter necessary.
*
* Add to a file resource with &lt;code&gt;stream_filter_append($fp, 'http_unchunk_filter',
* STREAM_FILTER_READ);&lt;/code&gt;
*
* If the wrapper metadata for $fp does not contain a &lt;code&gt;transfer-encoding:
* chunked&lt;/code&gt; header, this filter passes data through unchanged.
*
* @license BSD
* @author Francis Avila
*/
// Stream filters must subclass php_user_filter
class http_unchunk_filter extends php_user_filter {
	protected $chunkremaining = 0; //bytes remaining in the current chunk
	protected $ischunked = null; //whether the stream is chunk-encoded. null=not sure yet

	// this is the meat of the filter.
	// The class must have a function with this name and prototype
	// It must return a status--one of the PSFS_* constants;
	function filter($in, $out, &amp;$consumed, $closing) {
		if ($this-&gt;ischunked===null) {
			$this-&gt;ischunked = self::ischunked($this-&gt;stream);
		}
		// $in and $out are opaque &quot;bucket brigade&quot; objects which consist of a
		// sequence of opaque &quot;buckets&quot;, which contain the actual stream data.
		// The only way to use these objects is the stream_bucket_* functions.
		// Unfortunately, there doesn't seem to be any way to access a bucket
		// without turning it into a string using stream_bucket_make_writeable(),
		// even if you want to pass the bucket along unmodified.

		// Each call to this pops a bucket from the bucket brigade and
		// converts it into an object with two properties: datalen and data.
		// This same object interface is accepted by stream_bucket_append().
		while ($bucket = stream_bucket_make_writeable($in)) {
			if (!$this-&gt;ischunked) {
				$consumed += $bucket-&gt;datalen;
				stream_bucket_append($out, $bucket);
				continue;
			}
			$outbuffer = '';
			$offset = 0;
			// Loop through the string.  For efficiency, we don't advance a character
			// at a time but try to zoom ahead to where we think the next chunk
			// boundary should be.

			// Since the stream filter divides the data into buckets arbitrarily,
			// we have to maintain state ($this-&gt;chunkremaining) across filter() calls.
			while ($offset &lt; $bucket-&gt;datalen) {
				if ($this-&gt;chunkremaining===0) { // start of new chunk, or the start of the transfer
					$firstline = strpos($bucket-&gt;data, &quot;\r\n&quot;, $offset);
					$chunkline = substr($bucket-&gt;data, $offset, $firstline-$offset);
					$chunklen = current(explode(';', $chunkline, 2)); // ignore MIME-like extensions
					$chunklen = trim($chunklen);
					if (!ctype_xdigit($chunklen)) {
					// There should have been a chunk length specifier here, but since
					// there are non-hex digits something must have gone wrong.
						return PSFS_ERR_FATAL;
					}
					$this-&gt;chunkremaining = hexdec($chunklen);
					// $firstline already includes $offset in it
					$offset = $firstline+2; // +2 is CRLF
					if ($this-&gt;chunkremaining===0) { //end of the transfer
						break;  // ignore possible trailing headers
					}
				}
				// get as much data as available in a single go...
				$nibble = substr($bucket-&gt;data, $offset, $this-&gt;chunkremaining);
				$nibblesize = strlen($nibble);
				$offset += $nibblesize; // ...but recognize we may not have got all of it
				if ($nibblesize === $this-&gt;chunkremaining) {
					$offset += 2; // skip over trailing CRLF
				}
				$this-&gt;chunkremaining -= $nibblesize;
				$outbuffer .= $nibble;
			}
			$consumed += $bucket-&gt;datalen;
			$bucket-&gt;data = $outbuffer;
			stream_bucket_append($out, $bucket);
		}
		return PSFS_PASS_ON;
	}

	protected static function ischunked($stream) {
		$metadata = stream_get_meta_data($stream);
		$headers = $metadata['wrapper_data'];
		return (bool) preg_grep('/^Transfer-Encoding:\s+chunked\s*$/i', $headers);
	}

	function onCreate() {
		if (isset($this-&gt;stream)) { // This is usually not defined until the first filter() call.
			$this-&gt;ischunked = self::ischunked($this-&gt;stream);
		}
	}
}

stream_filter_register('http_unchunk_filter', 'http_unchunk_filter');
</pre>
<p>What you are left with is a stream filter you can then use like so:</p>
<pre class="brush: php;">
$fp = fopen('http://my.url', 'r');
stream_filter_append($fp, 'http_unchunk_filter', STREAM_FILTER_READ);
</pre>
<p>If the http stream has a chunked transfer encoding, the filter will automatically unchunk it.  However, it ignores extended data (anything after the hex-encoded chunk-length) and trailing headers, both of which are in the http specification but hardly ever used.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancingmammoth.com/2009/08/29/php-stream-filters-unchunking-http-streams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bringing Site Control Out of the Admin Interface</title>
		<link>http://dancingmammoth.com/2008/11/20/bringing-site-control-out-of-the-admin-interface/</link>
		<comments>http://dancingmammoth.com/2008/11/20/bringing-site-control-out-of-the-admin-interface/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 18:20:35 +0000</pubDate>
		<dc:creator>PJ Doland</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[Diderot]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://dancingmammoth.com/?p=156</guid>
		<description><![CDATA[Sometimes it just makes more sense to put the controls right on the site. Watch this quick screencast to find out how we let one of our clients order the stories in their main content well with drag &#38; drop ease.

Bringing Site Control Out of the Admin Interface from Dancing Mammoth on Vimeo.
]]></description>
			<content:encoded><![CDATA[<p>Sometimes it just makes more sense to put the controls right on the site. Watch this quick screencast to find out how we let one of our clients order the stories in their main content well with drag &amp; drop ease.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="640" height="360" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2298531&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=c9ff23&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="640" height="360" src="http://vimeo.com/moogaloop.swf?clip_id=2298531&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=c9ff23&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object><br />
<a href="http://vimeo.com/2298531">Bringing Site Control Out of the Admin Interface</a> from <a href="http://vimeo.com/user955084">Dancing Mammoth</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancingmammoth.com/2008/11/20/bringing-site-control-out-of-the-admin-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Derived Attributes with UNION</title>
		<link>http://dancingmammoth.com/2008/08/10/derived-attributes-with-union/</link>
		<comments>http://dancingmammoth.com/2008/08/10/derived-attributes-with-union/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 16:00:06 +0000</pubDate>
		<dc:creator>Francis Avila</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[derived attribute]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[union]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://dancingmammoth.com/?p=32</guid>
		<description><![CDATA[A Story
Recently, a client of ours wanted to institute a &#8220;point&#8221; system for an existing body of users. The idea was that certain actions of the user would generate points for that user, which the client could then track as part of an incentive program.
But What are &#8220;Points&#8221;?
At the time, we had a simple &#8220;users&#8221; [...]]]></description>
			<content:encoded><![CDATA[<h4>A Story</h4>
<p>Recently, a client of ours wanted to institute a &#8220;point&#8221; system for an existing body of users. The idea was that certain actions of the user would generate points for that user, which the client could then track as part of an incentive program.</p>
<h5>But What are &#8220;Points&#8221;?</h5>
<p>At the time, we had a simple &#8220;users&#8221; table in our database which stored all our user-related data. Now we were asked, essentially, to add a new &#8220;points&#8221; attribute to the &#8220;user&#8221; entity. However, we could not simply add a &#8220;points&#8221; column to the &#8220;user&#8221; table, because the client needed to track individual point-granting actions separately, with descriptions and such.</p>
<p>But this was also not a one-to-many relationship with an abstract &#8220;point-event&#8221; entity either, since some points were inferred from information which was properly normalized into other parts of the database. For example, referring another user (information we know at user registration time) was worth a certain number of points, but to copy a &#8220;referred user&#8221; event to a &#8220;point-event&#8221; entity would mean denormalizing the database.  If a user-referral were added or changed later, we would have to make sure to do the same thing to a corresponding point-event.</p>
<p>Thus a user&#8217;s &#8220;points&#8221; are an attribute of the user, but the value of this attribute is derived from potentially many different entities or attributes.  Guess what? It&#8217;s a <a href="http://it.toolbox.com/blogs/enterprise-solutions/understanding-attributes-in-er-diagrams-14287">derived attribute</a> (scroll to the bottom).</p>
<p>So, how are we going to deal with this?</p>
<h4>Implementation</h4>
<h5>Derived Columns</h5>
<p>Some &#8220;real&#8221; databases have native support for derived attributes (e.g., SQL Server) but as far as I know they all require that the value of the derived attribute be defined as an expression, not the result of an arbitrary query.  We could get around this using a stored function which calculates the points for us, but this particular database was MySQL (which does not support derived attributes), version 4.1 (which does not support stored functions).</p>
<p>In any case, this is a bad solution for us because any changes to the point calculation algorithm would require modification of the database, yet we had been accustomed to putting this kind of logic into the application.  Additionally, a lazy <code>SELECT *</code> (many of which were unfortunately sprinkled throughout our application) would suddenly become much more expensive, requiring an additional function call per row.</p>
<h5>Application Code</h5>
<p>The other solution, of course, is that we simply put all the point-calculation code into the application.  The problem with this is that it would take multiple queries to the database for every user that interested us, and we could potentially get the wrong point value if a change were made to the database in between our queries (since MySQL MyISAM does not have transactions).  Plus, if we want to sort by points (or something more complicated), we would have to do the sorting ourselves, in the application.</p>
<h5>UNION</h5>
<p>Clearly, we wanted to handle point calculation by a single query. The solution we finally hit upon was to use a temporary table (not a view, since MySQL 4.1 doesn&#8217;t support them) filled by a <code>UNION</code>. This is quite possibly the only good use for a <code>UNION</code>. Each subquery of the <code>UNION</code> would calculate points based on a particular attribute or entity, and all the subqueries would <code>SELECT</code> to common column names.</p>
<pre class="brush: sql;">DROP TEMPORARY TABLE IF EXISTS tmp_all_points;
CREATE TEMPORARY TABLE tmp_all_points
-- Get referrer-derived points
(SELECT user.id AS user_id, COUNT(*)*5 AS points
FROM user ... INNER JOIN ... GROUP BY ...)
UNION
-- Get pointevents-derived points
(SELECT user_id AS user_id, SUM(points) AS points
FROM pointevents GROUP BY user_id HAVING points != 0);</pre>
<p>This will give us a temporary table with 0, 1, or 2 rows per user. If we want to limit this to particular users, we can add the relevant <code>WHERE</code> conditions to the individual subqueries before we send them to the database.</p>
<p>Now if we want to do any queries which involve points, we can just treat <code>tmp_all_points</code> as a &#8220;points&#8221; entity with a many-to-one relationship with the &#8220;users&#8221; entity.</p>
<p>Want the top five point-holders?</p>
<pre class="brush: sql;">SELECT users.name, SUM(tmp_all_points.points) AS points
FROM users
INNER JOIN tmp_all_points ON users.id = tmp_all_points.users_id
GROUP BY users.id
ORDER BY points DESC
LIMIT 5</pre>
<h4>Happy Ending?</h4>
<p>By using a <code>UNION</code>, we were able to neatly model the derived attribute as a table, using a single query that maps easily to the logic of the derived attribute and is easy to extend to account for any additional criteria that the client may dream up.  And we didn&#8217;t have to denormalize our database or introduce complex application code.</p>
<p>There is a caveat, however.  Tables defined by a query have no index, and probably we are going to want to join on this table, which means we&#8217;ll be doing a join without an index.  For this reason, it is pretty important to keep the result set of your UNION query as small as possible using additional <code>WHERE</code> conditions.</p>
<p>If your result set will always be large, split off the temporary table creation into a definition with keys and use a <code>INSERT INTO tmp_table SELECT ... UNION SELECT ...</code>.  <strong>Don&#8217;t</strong> use <code>CREATE INDEX</code> after filling your table, since creating an index on a full table is <em>much</em> slower than building it incrementally (except for <code>FULLTEXT</code> indexes, where the opposite is true).</p>
<h5>Don&#8217;t Try This With Views</h5>
<p>If you are using MySQL 5.0 or above, you won&#8217;t be able to mitigate this problem by using a <a href="http://dev.mysql.com/doc/refman/5.0/en/create-view.html"><code>VIEW</code></a>.  MySQL is <a href="http://www.mysqlperformanceblog.com/2007/08/12/mysql-view-as-performance-troublemaker/">not very good at optimizing views</a>. If there is not a one-to-one relationship between the rows of your view and the rows of the underlying tables, MySQL will use <code>ALGORITHM = TEMPTABLE</code> for your view. So any view with a UNION in it will be created as a temporary table anyway.</p>
<p>Thus I would not wrap a <code>UNION</code> in a view for this technique, since you can&#8217;t control the result set size for a view and you will be generating a new temporary table every time you use the view, instead of once per connection.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancingmammoth.com/2008/08/10/derived-attributes-with-union/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Please Take a Number</title>
		<link>http://dancingmammoth.com/2008/07/09/please-take-a-number/</link>
		<comments>http://dancingmammoth.com/2008/07/09/please-take-a-number/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 23:44:44 +0000</pubDate>
		<dc:creator>Brian Kieffer</dc:creator>
				<category><![CDATA[Case Studies]]></category>
		<category><![CDATA[Lab]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://dancingmammoth.com/?p=18</guid>
		<description><![CDATA[In the Internet world of seemingly endless computer resources, it&#8217;s not often that a website requires visitors to wait in line to visit, but a recent Dancing Mammoth project called for just that.
The Requirements:

Visitors will be added to a Virtual Waiting Room prior to advancing to website content.
Visitors will be advanced according to First In [...]]]></description>
			<content:encoded><![CDATA[<p>In the Internet world of seemingly endless computer resources, it&#8217;s not often that a website requires visitors to wait in line to visit, but a recent Dancing Mammoth project called for just that.</p>
<p>The Requirements:</p>
<ul>
<li>Visitors will be added to a Virtual Waiting Room prior to advancing to website content.</li>
<li>Visitors will be advanced according to First In First Out.</li>
<li>Page must indicate current position in line via a client provided Flash object.</li>
<li>An administrator must be able to control flow of traffic.</li>
</ul>
<p>The client expected light traffic to their video chat feature, so we decided that capturing queue data in a single table was the most efficient way to go. We could then poll at a some set interval to determine a visitor&#8217;s place in line, and take action based on the result.</p>
<p>The client-provided Flash object required use of a bit of javascript, so I decided to go ahead and implement the polling with the jQuery library&#8217;s ajax functionality &#8212; I ♥ jQuery. Here&#8217;s what the javascript function looks like:</p>
<pre class="brush: php;">function updatePosition()
{
	$.ajax({
		type: &quot;GET&quot;,
		url: &quot;queue/index.php&quot;,
		data: &quot;sess=&lt;?php echo $session_id ?&gt;&amp;random=&quot; + new Date().getTime(),
		dataType: &quot;xml&quot;,
		success: function(xml){
			var ky = &quot;&quot;;
			var val = &quot;&quot;;
			var action = &quot;&quot;;
			var pos = 0;
			$(&quot;response&quot;, xml).each(function(){
				$(&quot;action&quot;, this).each(function(){
					action = $(&quot;key&quot;, this).text();
					val = $(&quot;value&quot;, this).text();
					if(action == &quot;forward&quot;)
					{
						// Forward
						forwardToUrl(val);
					}else{
						//Update
						pos = val;
						thisMovie('queueCountdown').update(pos);
					}
				});
			});
		}
	});
}</pre>
<p>If you&#8217;d like to review all the sample files, you can <a href="http://dancingmammoth.com/wp-content/uploads/vwr.zip">download them here</a>, but no warranty is expressed or implied.</p>
<p>jQuery sends the visitor&#8217;s session id (as well as a random string &#8212; always send a random string when making ajax GET calls or IE will give you cached content) to a script that checks the queue and returns some XML with the action and associate value. Then the visitor is either forward to the content, or their position in line is displayed.</p>
<p>On the back end, the VirtualWaitingRoom class provides functionality to retrieve queue position, administratively advance visitors through the queue, and remove records for abandoned sessions.</p>
<p>The project was a success and while there&#8217;s nothing especially complex about it, this Virtual Waiting Room is a good short example of how various web technologies can come together to provide a unique solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancingmammoth.com/2008/07/09/please-take-a-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Your iMac as a Display</title>
		<link>http://dancingmammoth.com/2008/05/28/use-your-imac-as-a-display/</link>
		<comments>http://dancingmammoth.com/2008/05/28/use-your-imac-as-a-display/#comments</comments>
		<pubDate>Thu, 29 May 2008 01:20:46 +0000</pubDate>
		<dc:creator>Francis Avila</dc:creator>
				<category><![CDATA[Lab]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Display]]></category>
		<category><![CDATA[Mac]]></category>

		<guid isPermaLink="false">http://dancingmammoth.com/?p=14</guid>
		<description><![CDATA[I have an Intel iMac (the white kind).  It&#8217;s my personal machine.  I like it.  It&#8217;s nice.  What I especially like about it is that it has a big screen (1680&#215;1050).
I also have an Intel MacBook. It&#8217;s my work machine.  I like it.  It&#8217;s nice.  But what I [...]]]></description>
			<content:encoded><![CDATA[<p>I have an Intel iMac (the white kind).  It&#8217;s my personal machine.  I like it.  It&#8217;s nice.  What I especially like about it is that it has a big screen (1680&#215;1050).</p>
<p>I also have an Intel MacBook. It&#8217;s my work machine.  I like it.  It&#8217;s nice.  But what I don&#8217;t like about it is that the screen is a bit smaller than my iMac (1200&#215;800).  Using the smaller keyboard and mouse isn&#8217;t so nice either.</p>
<p>What to do?</p>
<p>Well, there&#8217;s VNC. OS X even has a VNC server built in.  So I could turn that on and then use a VNC client on my iMac.  But that only gives me the keyboard and mouse and a 1280&#215;800 window mirroring the MacBook screen.  Not cool.</p>
<p>The same guy who makes this <a title="JollysFastVNC" href="http://www.jinx.de/JollysFastVNC.html">excellent VNC client</a> also makes <a title="ScreenRecycler" href="http://www.screenrecycler.com/home.html">ScreenRecycler</a>.  ScreenRecycler turns your VNC client into an attached display.  The monitor of the computer your VNC client runs on looks to OS X like just another monitor, plugged in through the mini-DVI port.  So now I can work on my MacBook and have a 1680&#215;1050 screen <em>in addition</em>. Joy!</p>
<p>But ScreenRecycler ignores input from the VNC client, so I can&#8217;t use my iMac&#8217;s keyboard and mouse to control my MacBook.  No joy.</p>
<p>But some other guy on the internet makes <a href="http://www.abyssoft.com/software/teleport/">Transport</a>.  Transport lets you control other Macs using your keyboard and mouse.  Joy has returned!</p>
<p>So, the plan:</p>
<ol>
<li>Install and run ScreenRecycler and Transport on the MacBook.</li>
<li>Install and run JollysFastVNC and Transport on the iMac.</li>
<li>The VNC client finds ScreenRecycler via Bonjour.  No sweat.</li>
<li>On the MacBook, tell Teleport to &#8220;Share this Mac.&#8221;</li>
</ol>
<p>All done!  Now I can use my iMac as a second display to my MacBook <em>and</em> control my MacBook with my iMac.  (I can even make the iMac the MacBook&#8217;s main display!)  Using the power of <a href="http://www.apple.com/macosx/features/spaces.html">Spaces</a>, I can even have multiple workspaces, and keep (for example) Mail and iChat permanently displayed in the MacBook screen, no matter what workspace I&#8217;m in.</p>
<p>A caveat:  Transport doesn&#8217;t seem to recognize the ScreenRecycler display, at least when one machine is Panther (iMac) and the other Leopard (MacBook).  You have to arrange your virtual screens in Transport in such a way that they don&#8217;t share the same borders.  Otherwise your pointer will get stuck on the MacBook.</p>
]]></content:encoded>
			<wfw:commentRss>http://dancingmammoth.com/2008/05/28/use-your-imac-as-a-display/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
