<?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>Shawn Hogan Fan Club &#187; Coding</title>
	<atom:link href="http://www.shawnhogan.com/category/tech-stuff/coding/feed" rel="self" type="application/rss+xml" />
	<link>http://www.shawnhogan.com</link>
	<description>What the hell??!? (blah, blah of a wannabe alien)</description>
	<lastBuildDate>Wed, 15 May 2013 09:22:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>Maybe Steve Jobs Was Right About Flash?</title>
		<link>http://www.shawnhogan.com/2011/03/maybe-steve-jobs-was-right-about-flash.html</link>
		<comments>http://www.shawnhogan.com/2011/03/maybe-steve-jobs-was-right-about-flash.html#comments</comments>
		<pubDate>Thu, 03 Mar 2011 22:17:30 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.shawnhogan.com/?p=872</guid>
		<description><![CDATA[I was building a website for Digital Point Ads, and for what I wanted it to do, I figured Flash would be the way to go.  So it was built, and worked fine in Flash.
The problem is that I&#8217;m an anal perfectionist and the Flash object was eating 80-90% of a computer&#8217;s CPU when being viewed&#8230; and me  [...]]]></description>
			<content:encoded><![CDATA[<p>I was building a website for <a href="http://www.digitalpointads.com/">Digital Point Ads</a>, and for what I wanted it to do, I figured Flash would be the way to go.  So it was built, and worked fine in Flash.</p>
<p>The problem is that I&#8217;m an anal perfectionist and the Flash object was eating 80-90% of a computer&#8217;s CPU when being viewed&#8230; and me being me, I couldn&#8217;t just be okay with that.</p>
<p>&#8230;so I rebuilt it with CSS3/HTML5/jQuery.  It turned out much nicer in my opinion, only uses about 1% of the resources that Flash needed and as an unintentional bonus, it works on things like iPad and phones/computers without Flash support.</p>
<p>I&#8217;m not anti-Flash (as I said, I *wanted* to do the site with Flash), but I AM anti-inefficient.  There are still some things you can&#8217;t do with HTML5 that you can do with Flash, but those things are becoming fewer and fewer it seems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2011/03/maybe-steve-jobs-was-right-about-flash.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>strace</title>
		<link>http://www.shawnhogan.com/2006/10/strace.html</link>
		<comments>http://www.shawnhogan.com/2006/10/strace.html#comments</comments>
		<pubDate>Wed, 25 Oct 2006 00:42:43 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Server Admin]]></category>

		<guid isPermaLink="false">http://www.shawnhogan.com/2006/10/strace.html</guid>
		<description><![CDATA[Yay, more server admin fun!     Here&#8217;s a useful *nix command that will let you determine what system calls a program uses&#8230;  For example, I wanted to double check that libevent calls within memcached were using epoll() and select() or poll() calls (epoll scales better) on my SuSE Linux  [...]]]></description>
			<content:encoded><![CDATA[<p>Yay, more server admin fun!  <img src='http://www.shawnhogan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Here&#8217;s a useful *nix command that will let you determine what system calls a program uses&#8230;  For example, I wanted to double check that libevent calls within memcached were using epoll() and select() or poll() calls (epoll scales better) on my SuSE Linux machines&#8230;</p>
<div style="margin:10px"><tt>server:~ # <strong>strace memcached -u root</strong></p>
<p>...clipped...<br />
epoll_ctl(5, EPOLL_CTL_ADD, 3, {EPOLLIN, {u32=5313904, u64=5313904}}) = 0<br />
epoll_ctl(5, EPOLL_CTL_ADD, 4, {EPOLLIN, {u32=5313920, u64=5313920}}) = 0<br />
epoll_ctl(5, EPOLL_CTL_ADD, 7, {EPOLLIN, {u32=5313968, u64=5313968}}) = 0<br />
epoll_wait(5, {}, 1024, 1000)           = 0</tt></div>
<p>Sure enough!  <img src='http://www.shawnhogan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2006/10/strace.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Server-Side Caching When Possible (memcached)</title>
		<link>http://www.shawnhogan.com/2006/10/use-server-side-caching-when-possible-memcached.html</link>
		<comments>http://www.shawnhogan.com/2006/10/use-server-side-caching-when-possible-memcached.html#comments</comments>
		<pubDate>Tue, 24 Oct 2006 09:59:42 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Server Admin]]></category>

		<guid isPermaLink="false">http://www.shawnhogan.com/2006/10/use-server-side-caching-when-possible.html</guid>
		<description><![CDATA[Purely out of necessity, I&#8217;ve become a system administrator/architect for digitalpoint.com servers&#8230; and a few people have been asking me for general admin tips to make things stable and scalable, so here&#8217;s a good one for you&#8230;
Use memcached&#8230; no really, use it.
memcached is a distributed memory  [...]]]></description>
			<content:encoded><![CDATA[<p>Purely out of necessity, I&#8217;ve become a system administrator/architect for digitalpoint.com servers&#8230; and a few people have been asking me for general admin tips to make things stable and scalable, so here&#8217;s a good one for you&#8230;</p>
<p>Use <strong><a href="http://www.danga.com/memcached/" target="_blank" rel="nofollow">memcached</a></strong>&#8230; no really, use it.</p>
<p>memcached is a distributed memory caching system that allows multiple servers to access the same shared memory (you can use it just for single local server too of course).  You can cache pretty much anything&#8230; SQL query results (especially ones that can&#8217;t hit indexes), dynamically generated web pages, dynamic RSS feeds, etc.</p>
<p>If you compile the <a href="http://www.php.net/memcache" target="_blank" rel="nofollow">memcache()</a> functions/class directly into PHP, you have a an easy (yet powerful) way to incorporate it.</p>
<p>For example, let&#8217;s say I have some existing code that makes a call to some sort of API (I use memcached for the <a href="http://www.digitalpoint.com/tools/suggestion/">keyword suggestion tool</a> in this way)&#8230; you can add a couple lines of code to cache the results.</p>
<p>[code=php]$data = @file_get_contents ("http://some_api_call_url?keywords=$keywords");[/code]</p>
<p>could become this:</p>
<p>[code=php]$memcache = new Memcache;<br />
$memcache->addServer('192.168.1.1');<br />
$memcache->addServer('192.168.1.2');<br />
if (!$data = $memcache->get($keywords)) {<br />
	$data = @file_get_contents ("http://some_api_call_url?keywords=$keywords");<br />
	$memcache->set($keywords, $data, false, 86400); // 24 hour cache<br />
}<br />
$memcache->close();[/code]</p>
<p>Now we are only hitting the API for the same keywords once every 24 hours&#8230; that setup utilizes 2 memcached servers working as a single entity for pooling and failover.</p>
<p>I use memcache for all sorts of things (this blog&#8217;s pages are cached for 60 seconds as another example because <a href="http://www.shawnhogan.com/2006/04/wordpress-is-not-scaleable.html">WordPress sucks</a>, and protects against a massive influx of traffic [front-page digg for example]).</p>
<p>Here&#8217;s some things I personally use it for&#8230;</p>
<ul>
<li>Caching this blog&#8217;s pages (for 60 seconds)
<li>Caching <a href="http://www.digitalpoint.com/tools/suggestion/" target="_blank">Keyword Suggestion Tool</a> queries (for 7 days)
<li>Caching <a href="http://www.digitalpoint.com/tools/adsense-sandbox/" target="_blank">AdSense Sandbox</a> queries (for 24 hours)
<li>Temporary counters in <a href="http://www.php.net/manual/en/function.memcache-decrement.php" target="_blank">Keyword Tracker</a> (using <a href="http://www.php.net/manual/en/function.memcache-decrement.php" target="_blank" rel="nofollow">decrement()</a> for displaying remaining keywords on a &#8220;Check All&#8221;)
<li>Recent forum topics that show on all the webmaster tools
<li>vBulletin forum datastore
</ul>
<p>Any high-traffic site that is dynamically generated (especially if it includes SQL queries) could benefit from it&#8230; you could manage which memcache items need to be updated when you insert/update to the database, or an easy way to do it is just check the cache for the pages that potentially have high traffic&#8230; if they aren&#8217;t in the cache, put them in the cache with a certain expiration date.  Then the page is dynamically generated no more often than the cache expiration time (in the case of this blog, the pages are generated no more than once every 60 seconds).</p>
<p><strong>P.S. -</strong> Make sure you block outside access to your memcached port since there&#8217;s no authentication used!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2006/10/use-server-side-caching-when-possible-memcached.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Google Code Search</title>
		<link>http://www.shawnhogan.com/2006/10/google-code-search.html</link>
		<comments>http://www.shawnhogan.com/2006/10/google-code-search.html#comments</comments>
		<pubDate>Thu, 12 Oct 2006 17:22:55 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.shawnhogan.com/?p=714</guid>
		<description><![CDATA[Did I miss this somehow, or is this new?
Google&#8217;s Code Search is *really* handy for programmers.  For example, say I wanted to see sample code that uses the preg_match() function in PHP, I could do this query:
preg_match lang:php
Neat!
]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.google.com/intl/en/images/codesearch_logo_sm.gif" align="right">Did I miss this somehow, or is this new?</p>
<p>Google&#8217;s Code Search is *really* handy for programmers.  For example, say I wanted to see sample code that uses the <a href="http://www.php.net/preg_match" target="_blank" rel="nofollow">preg_match()</a> function in PHP, I could do this query:</p>
<p><a href="http://www.google.com/codesearch?as_q=preg_match&#038;as_lang=php" target="_blank" rel="nofollow">preg_match lang:php</a></p>
<p>Neat!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2006/10/google-code-search.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>The $10,000 Space</title>
		<link>http://www.shawnhogan.com/2006/09/the-10000-space.html</link>
		<comments>http://www.shawnhogan.com/2006/09/the-10000-space.html#comments</comments>
		<pubDate>Wed, 27 Sep 2006 05:44:18 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.shawnhogan.com/2006/09/the-10000-space.html</guid>
		<description><![CDATA[If you are a programmer, have you ever had one of those bizarre situations where you know something is not working, but you aren&#8217;t getting an error or anything else that would make debugging easy?
A couple days ago I migrated a cluster of web servers to PHP 5.1.x (they were running PHP 4.4.x  [...]]]></description>
			<content:encoded><![CDATA[<p>If you are a programmer, have you ever had one of those bizarre situations where you know something is not working, but you aren&#8217;t getting an error or anything else that would make debugging easy?</p>
<p>A couple days ago I migrated a cluster of web servers to PHP 5.1.x (they were running PHP 4.4.x before).  One of the things I run on them is a geo targeting mechanism, and in the case where my screw-up was, a function to block a subnet of IP addresses.</p>
<p>[code=php]echo sprintf("%u", ip2long(' 80.1.2.3'));[/code]</p>
<p>That little bit of code was my fuck up&#8230; PHP 4.4.x returns &#8220;<strong>1342243331</strong>&#8221; (as expected), but PHP 5.1.x would return &#8220;<strong>0</strong>&#8220;.  PHP4 was more forgiving of the stray leading space before the IP address, while PHP5 was not.  The end result was that every IP address before 81.1.2.3 was blocked, instead of blocking FROM that IP address to an end IP address (that was not very many IPs away).</p>
<p>Awesome&#8230; so what happened here?  I ended up blocking about 40% of the potential traffic for awhile, which equated out to probably about $10,000 in lost revenue.</p>
<p>The lesson learned?  Don&#8217;t fuck around with spaces, because they will cost you many hours of debugging/tracing as well as ~$10,000.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2006/09/the-10000-space.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Google Gmail API</title>
		<link>http://www.shawnhogan.com/2006/09/google-gmail-api.html</link>
		<comments>http://www.shawnhogan.com/2006/09/google-gmail-api.html#comments</comments>
		<pubDate>Fri, 15 Sep 2006 22:55:26 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.shawnhogan.com/2006/09/google-gmail-api.html</guid>
		<description><![CDATA[I was just thinking&#8230; Google needs to build an API for Gmail.  Then we could do things like POP our email into an email client, and then run a script from within the email client that is able to go back to Gmail and tag stuff as spam, apply a label, etc.
That would be handy&#8230; can someone please make  [...]]]></description>
			<content:encoded><![CDATA[<p>I was just thinking&#8230; Google needs to build an API for Gmail.  Then we could do things like POP our email into an email client, and then run a script from within the email client that is able to go back to Gmail and tag stuff as spam, apply a label, etc.</p>
<p>That would be handy&#8230; can someone please make it so?  <img src='http://www.shawnhogan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<fieldset>
<legend>Update</legend>
<p>Oh, speaking of Gmail, it&#8217;s been awhile since I poked around in it&#8217;s settings, and I noticed you can now send email from within Gmail as a different address (before it would only let you set the &#8220;Reply To&#8221; address).  Nice&#8230; this was a suggestion I sent to them (probably along with a lot of other people) a long time ago.  Now I&#8217;ll actually use their web interface for sending mail sometimes.</p>
<p>The other thing I noticed if you can use their SSL SMTP servers for sending email as your non-Gmail address.  Double nice!  <img src='http://www.shawnhogan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </fieldset>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2006/09/google-gmail-api.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Canon VB-50i PHP Control Class</title>
		<link>http://www.shawnhogan.com/2006/08/canon-vb-50i-php-control-class.html</link>
		<comments>http://www.shawnhogan.com/2006/08/canon-vb-50i-php-control-class.html#comments</comments>
		<pubDate>Thu, 31 Aug 2006 05:09:14 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.shawnhogan.com/2006/08/canon-vb-50i-php-class.html</guid>
		<description><![CDATA[I tried to find a PHP class to control the new camera, and I couldn&#8217;t find one&#8230; so a little packet sniffing later, I was able to figure out how it&#8217;s little Java applet communicates with the camera.  Anyway, I spent a few minutes to make a PHP class to control the camera, so if you need one, here  [...]]]></description>
			<content:encoded><![CDATA[<p>I tried to find a PHP class to control the new camera, and I couldn&#8217;t find one&#8230; so a little packet sniffing later, I was able to figure out how it&#8217;s little Java applet communicates with the camera.  Anyway, I spent a few minutes to make a PHP class to control the camera, so if you need one, here you go (it hasn&#8217;t been extensively tested, so it probably has problems&#8230; if it does, leave a comment)&#8230;</p>
<p>So here&#8217;s a basic PHP script that uses the class to take control of the camera, set the pan/tilt/zoom to a certain position, capture the image and save it to a file&#8230;  handy for uhm&#8230; I dunno&#8230; a cron job to take time lapse photography.  <img src='http://www.shawnhogan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>[code=php]<?php<br />
	include ('class_camera.php');</p>
<p>	$cam =&#038; new Camera();</p>
<p>	$cam->connect('your.camera.ip.address');<br />
	$cam->get_control();<br />
	$cam->goto( -7463, -548, 4126);<br />
	sleep(5);  // Wait for movement to finish and lens to focus</p>
<p>	$handle = fopen('images/' . time() . '.jpg', 'w');<br />
	fwrite ($handle, $cam->image());<br />
	fclose ($handle);</p>
<p>	$cam->disconnect();<br />
?>[/code]</p>
<p><strong>class_camera.php:</strong>[code=php]<?php</p>
<p>// #############################################################################<br />
// Canon Camera Control Class<br />
// http://www.shawnhogan.com/2006/08/canon-vb-50i-php-control-class.html</p>
<p>/**<br />
*<br />
* Class to interface with a Canon VB-C50i or VB-C50iR<br />
*<br />
*/</p>
<p>class Camera<br />
{<br />
	/**<br />
	* Connects to the specified camera<br />
	*<br />
	* @param	string	Hostname or IP address of the camera<br />
	*<br />
	* @return	connection_id<br />
	*/<br />
	function connect($host)<br />
	{<br />
		$this->host = $host;<br />
		return $this->connection_id = substr(file_get_contents ('http://' . $host . '/-wvhttp-01-/OpenCameraServer?client_version=LiveApplet_4125&#038;image_size=640x480'), 14, 9);<br />
	}</p>
<p>	/**<br />
	* Disconnects from the camera<br />
	*<br />
	* @return	none<br />
	*/<br />
	function disconnect()<br />
	{<br />
		file_get_contents ('http://' . $this->host . '/-wvhttp-01-/CloseCameraServer?connection_id=' . $this->connection_id);<br />
	}</p>
<p>	/**<br />
	* Attempts to get control of camera<br />
	*<br />
	* @return	none<br />
	*/<br />
	function get_control()<br />
	{<br />
		file_get_contents ('http://' . $this->host . '/-wvhttp-01-/GetCameraControl?connection_id=' . $this->connection_id);<br />
	}</p>
<p>	/**<br />
	* Get camera info<br />
	*<br />
	* @return	array of camera info variables<br />
	*/<br />
	function get_info()<br />
	{<br />
		preg_match_all ('#(.*?)=(.*)#', file_get_contents ('http://' . $this->host . '/-wvhttp-01-/GetCameraInfo?connection_id=' . $this->connection_id), $matches);<br />
		foreach ($matches[1] as $key => $value) {<br />
			$this->camera_info[$value] = $matches[2][$key];<br />
		}<br />
		return($this->camera_info);<br />
	}</p>
<p>	/**<br />
	* Move camera<br />
	*<br />
	* @param	string	Movement type (pan | tilt | zoom)<br />
	* @param	number	Position to move to<br />
	*<br />
	* @return	none<br />
	*/<br />
	function move($operation, $position = 0)<br />
	{<br />
		file_get_contents ('http://' . $this->host . '/-wvhttp-01-/OperateCamera?' . $operation . '=' . $position . '&#038;connection_id=' . $this->connection_id);<br />
	}</p>
<p>	/**<br />
	* Set pan/tilt/zoom on camera with one call<br />
	*<br />
	* @param	number	pan position<br />
	* @param	number	tilt position<br />
	* @param	number	zoom position<br />
	*<br />
	* @return	none<br />
	*/<br />
	function goto($pan, $tilt, $zoom)<br />
	{<br />
		$this->move('pan', $pan);<br />
		$this->move('tilt', $tilt);<br />
		$this->move('zoom', $zoom);<br />
	}</p>
<p>	/**<br />
	* Set parameter<br />
	*<br />
	* @param	string	paramter to set<br />
	* @param	string	value<br />
	*<br />
	* @return	none<br />
	*/<br />
	function set_value($parameter, $value)<br />
	{<br />
		$mapping = array (<br />
						'back_light' => 'B',<br />
					);</p>
<p>		$parameter = $mapping[$parameter];</p>
<p>		file_get_contents ('http://' . $this->host . '/-wvhttp-01-/OperateCamera?' . $parameter . '=' . $value . '&#038;connection_id=' . $this->connection_id);<br />
	}</p>
<p>	/**<br />
	* Get current image<br />
	*<br />
	* @return	none<br />
	*/<br />
	function image()<br />
	{<br />
		return file_get_contents ('http://' . $this->host . '/-wvhttp-01-/GetOneShot?image_size=640x480');<br />
	}</p>
<p>}<br />
?>[/code]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2006/08/canon-vb-50i-php-control-class.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Moving HTML With JavaScript</title>
		<link>http://www.shawnhogan.com/2006/08/moving-html-with-javascript.html</link>
		<comments>http://www.shawnhogan.com/2006/08/moving-html-with-javascript.html#comments</comments>
		<pubDate>Mon, 21 Aug 2006 23:36:27 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.shawnhogan.com/2006/08/moving-html-with-javascript.html</guid>
		<description><![CDATA[Someone asked me why I hide the sidebar on this blog by default, then show it in a different part of the HTML, so here&#8217;s the explanation&#8230;
Most blog themes float the main body to the left, and make the sidebar on the right &#8220;static&#8221;.  I did the opposite when creating my custom WordPress theme&#8230; My  [...]]]></description>
			<content:encoded><![CDATA[<p>Someone asked me why I hide the sidebar on this blog by default, then show it in a different part of the HTML, so here&#8217;s the explanation&#8230;</p>
<p>Most blog themes float the main body to the left, and make the sidebar on the right &#8220;static&#8221;.  I did the opposite when creating my custom WordPress theme&#8230; My sidebar is a DIV that is floated to the right.  The reason for this then the content below the bottom of the sidebar wrap around it, which I just think looks better.  So here&#8217;s the problem&#8230; Google weighs content at the beginning of a page higher than content at the bottom, so Google was seeing 99% of my pages as &#8220;similar content&#8221; because my sidebar needed to be at the top of the HTML source.</p>
<p>So to solve that problem, I just put the sidebar at the bottom of the page in a hidden (with CSS) DIV, then call a simple script to set the contents of an empty DIV (<strong>&lt;div id=&#8221;sidebar&#8221;&gt;&lt;/div&gt;</strong>) at the top of the page, where the sidebar needs to be, to the contents of whatever is in the hidden DIV at the bottom&#8230;</p>
<div class="code"><tt>&lt;script language="javascript"&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.getElementById('sidebar').innerHTML = document.getElementById('sidebar_content').innerHTML<br />
&lt;/script&gt;</tt></div>
<p>For web browsers, the sidebar renders at the beginning of the HTML source, but Google sees the sidebar at the end of the HTML and pages no longer are seen as 99% similar.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2006/08/moving-html-with-javascript.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Forum Spy</title>
		<link>http://www.shawnhogan.com/2006/06/forum-spy.html</link>
		<comments>http://www.shawnhogan.com/2006/06/forum-spy.html#comments</comments>
		<pubDate>Tue, 27 Jun 2006 14:10:47 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.digitalpoint.com/~shawn/?p=555</guid>
		<description><![CDATA[I decided I didn&#8217;t have enough to do (that&#8217;s a joke BTW), so this morning I made a &#8220;spy&#8221; system for my forum (the general idea of course was borrowed from Digg).  It&#8217;s &#8220;extra&#8221; slick in Firefox because of the fades and opacity ability Firefox has, but it still works in IE, Safari, etc&#8230;
It more or  [...]]]></description>
			<content:encoded><![CDATA[<p>I decided I didn&#8217;t have enough to do (that&#8217;s a joke BTW), so this morning I made a &#8220;spy&#8221; system for my forum (the general idea of course was borrowed from Digg).  It&#8217;s &#8220;extra&#8221; slick in Firefox because of the fades and opacity ability Firefox has, but it still works in IE, Safari, etc&#8230;</p>
<p>It more or less lets you see what&#8217;s going on in the forum in realtime.</p>
<p>Check it out:  <a href="http://forums.digitalpoint.com/spy.php">http://forums.digitalpoint.com/spy.php</a></p>
<p>Unfortunately it also means that I&#8217;m still up right now and haven&#8217;t gone to bed yet.  Goodnight!  <img src='http://www.shawnhogan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2006/06/forum-spy.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>APC Datastore Class For vBulletin</title>
		<link>http://www.shawnhogan.com/2006/05/apc-datastore-class-for-vbulletin.html</link>
		<comments>http://www.shawnhogan.com/2006/05/apc-datastore-class-for-vbulletin.html#comments</comments>
		<pubDate>Tue, 09 May 2006 06:32:16 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Server Admin]]></category>

		<guid isPermaLink="false">http://www.digitalpoint.com/~shawn/2006/05/apc-datastore-class-for-vbulletin.html</guid>
		<description><![CDATA[On one of my ultra-high traffic web servers, I switched from eAccelerator to APC today (an opcode/caching system for PHP).  So far it seems pretty nice&#8230; Especially the ability to disable stat for each PHP request.
I ended up making a datastore class for vBulletin also so I could use it for the  [...]]]></description>
			<content:encoded><![CDATA[<p>On one of my ultra-high traffic web servers, I switched from eAccelerator to APC today (an opcode/caching system for PHP).  So far it seems pretty nice&#8230; Especially the ability to disable stat for each PHP request.</p>
<p>I ended up making a datastore class for vBulletin also so I could use it for the forum, so if anyone else is using vBulletin on a server with APC, here you go (if you know what this is for, you will know where it goes <img src='http://www.shawnhogan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
<p>[code=php]// #############################################################################<br />
// APC</p>
<p>/**<br />
* Class for fetching and initializing the vBulletin datastore from APC<br />
*<br />
* @package	vBulletin<br />
* @version	$Revision: 0.0.0.1 $<br />
* @date		$Date: 2006/05/08 16:51:06 $<br />
*/<br />
class vB_Datastore_APC extends vB_Datastore<br />
{<br />
	/**<br />
	* Fetches the contents of the datastore from APC<br />
	*<br />
	* @param	array	Array of items to fetch from the datastore<br />
	*<br />
	* @return	void<br />
	*/<br />
	function fetch($itemarray)<br />
	{<br />
		if (!function_exists('apc_fetch'))<br />
		{<br />
			trigger_error('APC not installed', E_USER_ERROR);<br />
		}</p>
<p>		foreach ($this->defaultitems AS $item)<br />
		{<br />
			$this->do_fetch($item);<br />
		}</p>
<p>		if (is_array($itemarray))<br />
		{<br />
			foreach ($itemarray AS $item)<br />
			{<br />
				$this->do_fetch($item);<br />
			}<br />
		}</p>
<p>		$this->check_options();</p>
<p>		// set the version number variable<br />
		$this->registry->versionnumber =&#038; $this->registry->options['templateversion'];<br />
	}</p>
<p>	/**<br />
	* Fetches the data from shared memory and detects errors<br />
	*<br />
	* @param	string	title of the datastore item<br />
	*<br />
	* @return	void<br />
	*/<br />
	function do_fetch($title)<br />
	{<br />
		$ptitle = $this->prefix . $title;</p>
<p>		if (($data = apc_fetch($ptitle)) === false)<br />
		{ // appears its not there, lets grab the data and put it in memory<br />
			$data = '';<br />
			if ($dataitem = $this->dbobject->query_first("<br />
				SELECT title, data FROM " . TABLE_PREFIX . "datastore<br />
				WHERE title = '" . $this->dbobject->escape_string($title) ."'<br />
			"))<br />
			{<br />
				$data =&#038; $dataitem['data'];<br />
			}<br />
			$this->build($title, $data);<br />
		}<br />
		$this->register($title, $data);<br />
	}</p>
<p>	/**<br />
	* Updates the appropriate cache file<br />
	*<br />
	* @param	string	title of the datastore item<br />
	*<br />
	* @return	void<br />
	*/<br />
	function build($title, $data)<br />
	{<br />
		$title = $this->prefix . $title;</p>
<p>		if (!function_exists('apc_store'))<br />
		{<br />
			trigger_error('APC not installed', E_USER_ERROR);<br />
		}<br />
		$check = apc_store($title, $data);<br />
	}<br />
}[/code]</p>
<fieldset>
<legend>Update</legend>
<p>I just found out APC datastore support was added to the yet unreleased vBulletin 3.6.  Nice!</fieldset>
<fieldset>
<legend>Update 2</legend>
<p>I&#8217;ve since switched back to eAccelerator.  APC was causing Apache segfaults under ultra-high loads.</fieldset>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2006/05/apc-datastore-class-for-vbulletin.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>I Need To Be More Dorky</title>
		<link>http://www.shawnhogan.com/2005/12/i-need-to-be-more-dorky.html</link>
		<comments>http://www.shawnhogan.com/2005/12/i-need-to-be-more-dorky.html#comments</comments>
		<pubDate>Wed, 28 Dec 2005 09:06:26 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.digitalpoint.com/~shawn/2005/12/i-need-to-be-more-dorky.html</guid>
		<description><![CDATA[I just realized that it&#8217;s been weeks since I had something dorky to say (like programming or something to do with MySQL for example).
Just so you know that I am still dorky, here&#8217;s some PHP code for you (from my post over here)&#8230;
This will put the keywords that someone searched on to reach your site  [...]]]></description>
			<content:encoded><![CDATA[<p>I just realized that it&#8217;s been weeks since I had something dorky to say (like programming or something to do with MySQL for example).</p>
<p>Just so you know that I am still dorky, here&#8217;s some PHP code for you (from <a href="http://forums.digitalpoint.com/showthread.php?t=46764" target="_blank">my post over here</a>)&#8230;</p>
<p>This will put the keywords that someone searched on to reach your site (works with Yahoo, AOL, MSN and Google) into the <strong>$keywords</strong> variable.</p>
<p>[code=php]$parse = parse_url($_SERVER['HTTP_REFERER']);<br />
$se = $parse["host"];<br />
$raw_var = explode("&#038;", $parse["query"] );<br />
foreach ($raw_var as $one_var) {<br />
	$raw = explode("=", $one_var);<br />
	$var[$raw[0]] = urldecode ($raw[1]);<br />
}<br />
$se = explode (".", $se);<br />
switch ($se[1]) {<br />
	case 'yahoo':<br />
		$keywords = $var['p'];<br />
		break;<br />
	case 'aol':<br />
		$keywords = $var['query'];<br />
		break;<br />
	default:<br />
		$keywords = $var['q'];<br />
}<br />
unset($parse, $se, $raw_var, $one_var, $var);[/code]</p>
<p>Weeeeeeeeeee!  Can I go to bed now?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2005/12/i-need-to-be-more-dorky.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google API (Web Search) Needs Updating</title>
		<link>http://www.shawnhogan.com/2005/12/google-api-web-search-needs-updating.html</link>
		<comments>http://www.shawnhogan.com/2005/12/google-api-web-search-needs-updating.html#comments</comments>
		<pubDate>Wed, 14 Dec 2005 16:36:35 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.digitalpoint.com/~shawn/?p=274</guid>
		<description><![CDATA[Yahoo&#8217;s APIs are really nice (and there are a ton of them).  Google&#8217;s API for web search is about 15x slower than Yahoo&#8217;s (no joke) and has less features.  I really wish Google would bring out a new revision for it (its been stagnant for about 3 years now).
Google&#8217;s Map API is still better than  [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.shawnhogan.com/2005/03/yahoo-api.html">Yahoo&#8217;s APIs</a> are really nice (and there are a ton of them).  Google&#8217;s API for web search is about 15x slower than Yahoo&#8217;s (no joke) and has less features.  I really wish Google would bring out a new revision for it (its been stagnant for about 3 years now).</p>
<p><a href="http://www.shawnhogan.com/2005/11/google-maps-api-is-pimp.html">Google&#8217;s Map API</a> is still better than Yahoo&#8217;s IMO, but that&#8217;s about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2005/12/google-api-web-search-needs-updating.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross-Database JOIN With MySQL</title>
		<link>http://www.shawnhogan.com/2005/12/cross-database-join-with-mysql.html</link>
		<comments>http://www.shawnhogan.com/2005/12/cross-database-join-with-mysql.html#comments</comments>
		<pubDate>Wed, 14 Dec 2005 05:38:15 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.digitalpoint.com/~shawn/2005/12/cross-database-join-with-mysql.html</guid>
		<description><![CDATA[You ever wish you could have done something for years, only to realize one day you could have done it this whole time?
I have a couple tables that I was replicating across 3 or 4 MySQL databases because I didn&#8217;t think I could reference a table from database A while working with database B.
Today I  [...]]]></description>
			<content:encoded><![CDATA[<p>You ever wish you could have done something for years, only to realize one day you could have done it this whole time?</p>
<p>I have a couple tables that I was replicating across 3 or 4 MySQL databases because I didn&#8217;t think I could reference a table from database A while working with database B.</p>
<p>Today I accidentally tried to do a SELECT on a table from a database I wasn&#8217;t even working with and instead of getting an error, it worked.  As long as the user you are connected to MySQL as has the proper privileges (duh), it works.  You just prefix your table/column name with the database name.</p>
<p>For example:<br />
[code=sql]SELECT database1.tablename.a_column,database2.another_table.another_column<br />
	FROM database1.tablename<br />
		LEFT JOIN database2.another_table ON(database1.tablename.some_id = database2.another_table.some_id)[/code]</p>
<p>You can do anything you can do with tables in the same database (INSERT SELECT, JOINS, sub-queries, etc.)</p>
<p>Wow, I&#8217;m an idiot&#8230; its probably been a feature since version 1.0 too.  <img src='http://www.shawnhogan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Now if you could just do the same thing across different MySQL servers (something like <strong>ipaddress.database.table.field</strong>), that would be really handy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2005/12/cross-database-join-with-mysql.html/feed</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Track AdSense Clicks With Google Analytics</title>
		<link>http://www.shawnhogan.com/2005/11/track-adsense-clicks-with-google-analytics.html</link>
		<comments>http://www.shawnhogan.com/2005/11/track-adsense-clicks-with-google-analytics.html#comments</comments>
		<pubDate>Fri, 18 Nov 2005 18:23:05 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.digitalpoint.com/~shawn/2005/11/track-adsense-clicks-with-google-analytics.html</guid>
		<description><![CDATA[It would be cool if Google automatically tracked AdSense clicks into Google Analytics&#8230; But until they do, here&#8217;s a little bit of JavaScript code you can use to do it.  You can then setup an AdSense click as a &#8220;goal&#8221; within the Analytics interface.

[code=javascript]
// by Shawn -  [...]]]></description>
			<content:encoded><![CDATA[<p>It would be cool if Google automatically tracked AdSense clicks into Google Analytics&#8230; But until they do, here&#8217;s a little bit of JavaScript code you can use to do it.  You can then setup an AdSense click as a &#8220;goal&#8221; within the Analytics interface.</p>
<p><center><img src="/images/adsense_funnel.gif"></center></p>
<p>[code=javascript]<script type="text/javascript">
// by Shawn - http://www.shawnhogan.com/2005/11/track-adsense-clicks-with-google-analytics.html
// Put this at the bottom of the page (after the last AdSense block)</p>
<p>function adsense_click() {
	if(window.status.indexOf('go to') == 0) {
		urchinTracker ('/AdSenseClick');
	}
}</p>
<p>var elements;
if(document.getElementsByTagName) {
	elements = document.body.getElementsByTagName("IFRAME");
} else if (document.body.all) {
	elements = document.body.all.tags("IFRAME");
} else {
	elements = Array();
}</p>
<p>for(var i = 0; i < elements.length; i++) {
	if(elements[i].src.indexOf('googlesyndication.com') > -1) {
		elements[i].onfocus = adsense_click;
	}
}
</script>[/code]<br />
This only works with Internet Explorer because of some limitations/bug with Mozilla.  I&#8217;m too lazy to code a complicated workaround for other browsers (which would involve running JavaScript code whenever the mouse moves which seems really inefficient to me).  Hopefully Mozilla will fix <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=131784" target="_blank" rel="nofollow">the bug</a> (although it&#8217;s been pending for 2 1/2 years now).</p>
<p>Basically it will log an AdSense click as a pageview to a non-existent page (<strong>http://www.digitalpoint.com/AdSenseClick</strong> in my case).</p>
<fieldset>
<legend>Update</legend>
<p>I made a version of the code that will work with AdSense and/or Yahoo Publisher Network.  You can find it <a href="http://forums.digitalpoint.com/showthread.php?p=451170#post451170" target="_blank">over here</a>.</fieldset>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2005/11/track-adsense-clicks-with-google-analytics.html/feed</wfw:commentRss>
		<slash:comments>79</slash:comments>
		</item>
		<item>
		<title>Roadway Speeds In Google Local/Maps</title>
		<link>http://www.shawnhogan.com/2005/11/freeway-traffic-in-google-local-maps.html</link>
		<comments>http://www.shawnhogan.com/2005/11/freeway-traffic-in-google-local-maps.html#comments</comments>
		<pubDate>Thu, 17 Nov 2005 06:22:43 +0000</pubDate>
		<dc:creator>Shawn</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.digitalpoint.com/~shawn/2005/11/freeway-traffic-in-google-localmaps.html</guid>
		<description><![CDATA[I really don&#8217;t get why Google hasn&#8217;t added live traffic data for major cities yet.  The information is out there and freely available for anyone to use.  It only took me a few minutes of digging around to realtime traffic data for all of California, so why can&#8217;t Google find/use it?  For example,  [...]]]></description>
			<content:encoded><![CDATA[<p>I really don&#8217;t get why Google hasn&#8217;t added live traffic data for major cities yet.  The information is out there and freely available for anyone to use.  It only took me a few minutes of digging around to realtime traffic data for all of California, so why can&#8217;t Google find/use it?  For example, Caltrans breaks down the data by district&#8230; San Diego is included in District 11:</p>
<p><a href="http://www.dot.ca.gov/dist11/d11tmc/sdmap/sdmap/labels.txt" rel="nofollow" target="_blank">Labels (descriptions, freeway, direction, etc.)</a><br />
<a href="http://www.dot.ca.gov/dist11/d11tmc/sdmap/sdmap/realtmap.txt" rel="nofollow" target="_blank">Current Highway Speeds (cross referenced by ID to the Labels file)</a></p>
<p>Would be nice if they gave you the longitude/latitude of each location, but hey&#8230; assign some intern to look them all up.  <img src='http://www.shawnhogan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So let&#8217;s see if I could stick the data on Google Maps myself (via API)&#8230;  I&#8217;m fairly lazy, and would rather programatically do something that would otherwise require manual labor (looking up longitude/latitude for a zillion points).  Thankfully, I remembered that I looked at Yahoo Maps Beta a few weeks ago, and saw it had live traffic data that was overlayed on the map graphic (which means they probably are making a separate HTTP request for just the traffic data).  Sure enough&#8230; a packet sniffer reveals this URL for getting traffic data for San Diego:</p>
<p><a href="http://xml.maps.yahoo.com/traffic.xml?lat=32.8568064731924&#038;lon=-117.209529876709&#038;mag=8&#038;wpx=855&#038;hpx=710&#038;sfmt=3'" target="_blank" rel="nofollow">XML Feed</a></p>
<p>Okay, that&#8217;s not bad, but doesn&#8217;t include longitude and latitude.  Instead it appears the speed data is relative to the current view of the Yahoo map you are looking at.  Hmmm&#8230; rather than decode their little proprietary system, let&#8217;s see what <strong>sfmt</strong> is.  With some luck, it&#8217;s &#8220;speed format&#8221;.  Sure enough&#8230; change it to sfmt=0, and you get longitude/latitude of the points!  <img src='http://www.shawnhogan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   So now we have a nice XML feed with longitude and latitude:</p>
<p><a href="http://xml.maps.yahoo.com/traffic.xml?lat=32.8568064731924&#038;lon=-117.209529876709&#038;mag=8&#038;wpx=855&#038;hpx=710&#038;sfmt=0" target="_blank" rel="nofollow">XML Feed</a></p>
<p>Once you have that data, it takes 2 minutes to make a Google Map with the data&#8230;</p>
<p><a href="http://www.shawnhogan.com/jungle_gym/san_diego_traffic.php" target="_blank">Traffic In San Diego</a></p>
<p>Of course it doesn&#8217;t really answer my original question&#8230; why doesn&#8217;t Google already have this data on Google Local/Maps?  If I worked at Google, this would be my 2nd &#8220;20% time project&#8221; (<a href="http://www.shawnhogan.com/2005/11/the-google-car-stereo.html">this was the other one</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shawnhogan.com/2005/11/freeway-traffic-in-google-local-maps.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
