<?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/"
	>

<channel>
	<title>Dawn of the Geeks</title>
	<atom:link href="http://blog.dawnofthegeeks.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dawnofthegeeks.com</link>
	<description></description>
	<pubDate>Wed, 26 Aug 2009 07:21:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySQL Memory Allocation Error</title>
		<link>http://blog.dawnofthegeeks.com/?p=549</link>
		<comments>http://blog.dawnofthegeeks.com/?p=549#comments</comments>
		<pubDate>Wed, 26 Aug 2009 07:21:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.dawnofthegeeks.com/?p=549</guid>
		<description><![CDATA[Using the MySQL Odbc 5.1 connector I came across a strange error: memory allocation error.  It&#8217;s like the &#8220;pc load letter&#8221; of MySQL.  In my case the issue was that certain parameters were being set to null values.  Once I defaulted the strings to an empty string rather than null the next [...]]]></description>
			<content:encoded><![CDATA[<p>Using the MySQL Odbc 5.1 connector I came across a strange error: memory allocation error.  It&#8217;s like the &#8220;pc load letter&#8221; of MySQL.  In my case the issue was that certain parameters were being set to null values.  Once I defaulted the strings to an empty string rather than null the next error to pop up was that the parameters count wasn&#8217;t the expected amount.  Meaning I had too few or too many parameters added with value.   And once that was corrected it worked just fine.</p>
<p>So apparently in some cases Odbc doesn&#8217;t like null parameter values.  My guess is that the table column was set to not allow null and so it kicked back an obcure error.  Either way it works now.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dawnofthegeeks.com/?feed=rss2&amp;p=549</wfw:commentRss>
		</item>
		<item>
		<title>Memcached and You</title>
		<link>http://blog.dawnofthegeeks.com/?p=547</link>
		<comments>http://blog.dawnofthegeeks.com/?p=547#comments</comments>
		<pubDate>Fri, 14 Aug 2009 23:20:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.dawnofthegeeks.com/?p=547</guid>
		<description><![CDATA[Tweemotional.com was not doing so well.  It had too much information in the database which was also missing an index on the date causing the SELECT to do a file sort on millions of rows.
So I took the opportunity to flush the database since raw tweet data that is more than 24 hours old [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tweemotional.com">Tweemotional.com</a> was not doing so well.  It had too much information in the database which was also missing an index on the date causing the SELECT to do a file sort on millions of rows.</p>
<p>So I took the opportunity to flush the database since raw tweet data that is more than 24 hours old is ignored anyway and added in the index.</p>
<p>However, I also plugged in Memcached support.  With Memcached you can do the query on the database once, take the result and stuff it in memcached.  The next time you need the data you simply query memcached which returns the result instantly.</p>
<p>So now when the backend scripts for Tweemotional.com are gather information from Twitter they also update the Memcached versions of what the site needs to display the data.  So now the site itself runs very quickly since it&#8217;s not hitting the database nearly as much.</p>
<p>If you want to make use of Memcached for your site you&#8217;ll need pretty much any computer you can get.  I have it running on a PIII 533Mhz system with 512MB of memory.  Obviously if you have a site that could make use of more space to store cached objects then you&#8217;ll need a system with more RAM or diskspace.  For best performance you want enough memory that memcached doesn&#8217;t have to pull information from the disk before sending it over.</p>
<p>There are Windows binaries available but they are for an older version.  If you want to run the latest version you&#8217;ll probably want to just use some version of Linux.  I prefer Ubuntu.  The 8.04 version installed and ran just fine on my system.  I turned off the graphical flair for the GUI and it runs rather smoothly.</p>
<p>There are existing libraries for Memcached for PHP and C# as well as other languages.  Enyim.Caching is what I use with C#.  I then wrote a simple static class wrapper around that so I can just use memcached.get, memcached.set and memcached.remove and not have to deal with any initialization.</p>
<p>Another reason for using a wrapper is that memcached doesn&#8217;t like keys with certain characters.  To avoid this problem the wrapper automatically MD5&#8217;s the key I pass in before it passed it along to memcached.  In my code I can then use whatever key I want.</p>
<p>The other thing you have to remember with C# is that you must explicity make your classes Serializable or they cannot be cached through memcached.  I don&#8217;t believe PHP has this issue.  I&#8217;m not sure if there&#8217;s anything in PHP that isn&#8217;t serializable by default.</p>
<p>If you&#8217;re running any sort of website that is doing some heavy lifting with queries it would be to your benefit to take a look at memcached to see what it can do for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dawnofthegeeks.com/?feed=rss2&amp;p=547</wfw:commentRss>
		</item>
		<item>
		<title>Winning at Superheroes Alliance on Facebook</title>
		<link>http://blog.dawnofthegeeks.com/?p=545</link>
		<comments>http://blog.dawnofthegeeks.com/?p=545#comments</comments>
		<pubDate>Tue, 11 Aug 2009 18:23:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.dawnofthegeeks.com/?p=545</guid>
		<description><![CDATA[There are two key things you need to do in Superheroes Alliance on Facebook: win fights and complete missions.  Completing missions in a reasonable amount of time requires having plenty of energy.  Winning battles requires attack strength with a supporting alliance and quality items for each person in your team including yourself.
Defense is [...]]]></description>
			<content:encoded><![CDATA[<p>There are two key things you need to do in Superheroes Alliance on Facebook: win fights and complete missions.  Completing missions in a reasonable amount of time requires having plenty of energy.  Winning battles requires attack strength with a supporting alliance and quality items for each person in your team including yourself.</p>
<p>Defense is used mainly when defending yourself against other people&#8217;s attacks.  In the event you lose a battle you lose HP and money.  If you don&#8217;t keep cash on hand there&#8217;s no financial incentive for others to attack you and so they don&#8217;t.  They hit you once and if they win they see they get nothing for it so they move on to the next target.  The first step to avoid being attacked is to keep your money in the vault.  It costs you 10% but that&#8217;s better than losing it all from being attacked constantly.  Don&#8217;t worry about defense points and instead focus on increasing attack points.</p>
<p>HP are your &#8220;hit points.&#8221;  You lose them every time you get hit.  The only thing you need to worry about is losing more than you have in a single hit.  Once you go below 25 you can no longer be attacked.  This is why, at least for awhile, you don&#8217;t need to waste points increasing your HP.</p>
<p>You need one stamina point for each attack.  You don&#8217;t really need to increase this since you can always go back and attack someone again after recovering your stamina and HP.</p>
<p>Completing missions gets you money, better items and experience which moves you through the levels.  You also get extra points for the lab.  Use them to get hired heros.  The more people you have on your team the better chance you have of winning battles.</p>
<p>The second and most important thing to do to avoid being attacked is to win more battles than you lose.  Generally people are going to attack the weaker players so if you win more than you lose other players will for the most part avoid you.</p>
<p>So above all else, increase your attack points the most, then energy.  As you progress through the levels you can start to increase other stats as well.  But you need to win battles and complete missions before you can really start rounding out your character.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dawnofthegeeks.com/?feed=rss2&amp;p=545</wfw:commentRss>
		</item>
		<item>
		<title>Superheroes Alliance on Facebook</title>
		<link>http://blog.dawnofthegeeks.com/?p=543</link>
		<comments>http://blog.dawnofthegeeks.com/?p=543#comments</comments>
		<pubDate>Thu, 06 Aug 2009 19:30:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.dawnofthegeeks.com/?p=543</guid>
		<description><![CDATA[I used to play Heroes vs Villians on Facebook until I discovered Superheroes Alliance.  Superheroes Alliance is a very well polished game that plays much like HvV but looks significantly better and has better features.  For example you can see how many wins and loses another player has which makes it easier to [...]]]></description>
			<content:encoded><![CDATA[<p>I used to play Heroes vs Villians on Facebook until I discovered Superheroes Alliance.  Superheroes Alliance is a very well polished game that plays much like HvV but looks significantly better and has better features.  For example you can see how many wins and loses another player has which makes it easier to figure out who you&#8217;d like to attack.  You can also battle rivals which means you can keep track of how many wins and loses you have against specific players and keep battling them if you beat them most of the time.</p>
<p>I&#8217;ve been looking for tips and tricks for this game and havn&#8217;t found any so I&#8217;m going to offer a few.</p>
<p>Prior to the complete reworking of missions they were pretty much useless.  Now you need them to get better sidekicks.  However, your focus, especially early on, should be only on attack and defense.  The real money and experience comes not from missions, but from attacking and winning battles against other players.</p>
<p>Money is important in this game.  If you want better sidekicks you needs income to support them.  If an abilitity is available to get more money from winning battles, take advantage of it.  Use most of your skill points to magnify attack and defense where possible but don&#8217;t neglect the money train.</p>
<p>Only buy land and property in blocks of 10.  The price goes up significantly with each purchase so the more you buy all at once the more money you save.  To save the most money buy 10 blocks of land when you can.  Buy no more than 10.  You will start earning money on the land.  Then buy 10 blocks of property to go on the land when you can.  The price of the land will drop back down to the lowest price and you can repeat the process.</p>
<p>Keep track of the amount of money you earn vs the cost of the land + property.  You want to maximize your return so buy the land+property combo that results in the greatest earnings for the cost no matter how little the earnings are.  It all adds up quickly when you consider the amount you will earn over several days.</p>
<p>By the time you own 30 of a property it takes about a week to recoup the cost.  When you&#8217;re at that point it&#8217;s time to start saving up for the big ticket items.</p>
<p>Again high defense and attack stats and top of the line sidekicks, you can quickly bring in millions by battling.</p>
<p>Use the vault often.  Yes it costs you 10% but that&#8217;s significantly less than it costs when someone beats you in a battle.  I typically vault the money until I&#8217;m within 5-10 million of my goal.  Once I have the last 5-10mil on hand I withdraw just enough to cover my purchase.  Make sure you&#8217;ve regenerated all your health before sinking all the money you have into your purchase.</p>
<p>Once you have millions of dollars coming in every hour it&#8217;s time to stop focusing so much on making money and focus more on completing missions.  That means using some of your skill points to up your maximum energy. </p>
<p>As you progress in the game the goal is to depend less on your character and more on your alliance and sidekicks.  You don&#8217;t need maxed out attack and defense because your multipliers, sidekicks and alliance take care of that.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dawnofthegeeks.com/?feed=rss2&amp;p=543</wfw:commentRss>
		</item>
		<item>
		<title>The Emotional State of the Internet</title>
		<link>http://blog.dawnofthegeeks.com/?p=540</link>
		<comments>http://blog.dawnofthegeeks.com/?p=540#comments</comments>
		<pubDate>Fri, 03 Jul 2009 16:50:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.dawnofthegeeks.com/?p=540</guid>
		<description><![CDATA[The Emotional State of the Internet is a website which analyzes Twitter messages and calculates how the internet is feeling.  It&#8217;s updated every 10 minutes.  You can also see a historical chart of the current top emotion.  
It&#8217;s interesting to see the difference between what emotion people twitter about the most in [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://internet.dawnofthegeeks.com/">The Emotional State of the Internet</a> is a website which analyzes Twitter messages and calculates how the internet is feeling.  It&#8217;s updated every 10 minutes.  You can also see a historical chart of the current top emotion.  </p>
<p>It&#8217;s interesting to see the difference between what emotion people twitter about the most in various languages.  French speakers talk about how lonely they are.  Germans by a wide margin talk about &#8220;angst&#8221; the most.  While Google Translate tells me it means &#8220;frightened&#8221; in English, according to Wikipedia it more accurately translates to &#8220;anxiety.&#8221;  This is why I keep the original word listed and put the English translation in parantheses.</p>
<p>Italians tend to talk most about being &#8220;triste&#8221; which means sad while Spanish speakers talk by a slightly wider margin about being happy.</p>
<p>Maybe Spanish speakers are happier than everyone else or maybe they use Twitter mostly to express happiness and tend to keep other emotions to themselves.</p>
<p>If you want to what people are getting emotional about you can click on &#8220;keywords&#8221; at the top of the page.  That will list all the current keywords for all the various emotions the site is tracking.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dawnofthegeeks.com/?feed=rss2&amp;p=540</wfw:commentRss>
		</item>
		<item>
		<title>Running on Flash</title>
		<link>http://blog.dawnofthegeeks.com/?p=538</link>
		<comments>http://blog.dawnofthegeeks.com/?p=538#comments</comments>
		<pubDate>Thu, 02 Jul 2009 21:23:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.dawnofthegeeks.com/?p=538</guid>
		<description><![CDATA[Solid state drives are finally becoming large enough that computers can be built without a conventional hard drive.  Any modern OS can be installed on a solid state drive now.  However, they&#8217;re very expensive and can&#8217;t hold as much as the conventional drives.  The basic idea is that you use a solid [...]]]></description>
			<content:encoded><![CDATA[<p>Solid state drives are finally becoming large enough that computers can be built without a conventional hard drive.  Any modern OS can be installed on a solid state drive now.  However, they&#8217;re very expensive and can&#8217;t hold as much as the conventional drives.  The basic idea is that you use a solid state drive for your OS to speed up your system but continue using large conventional drives for all your personal data.  It&#8217;s generally a good idea to keep your personal data on one drive and your OS on another regardless of what type of hard drives you use.</p>
<p>What I&#8217;m finding flash drives to be very useful for is running web sites off of them.  I&#8217;ve been running my own servers for years and end up having to buy new hard drives every year which gets expensive.  I realized that the majority of my web-sites are essentially static and they&#8217;re small.</p>
<p>So for $5 I can store all my web-sites on a 1-2GB flash drive.  If the drive dies I can replace it for $5 instead of $35-100.</p>
<p>The advantage of using a flash drive is that the sites load much faster.  The hard drive is no longer a limiting factor for the site itself.  Just the database which of course still uses a regular hard drive since flash drives die quickly with heavy writing.</p>
<p>My server used to have a hard drive for the OS and web apps, the database, the logs and the web-sites themselves.  I stopped bothering with logging since it&#8217;s too much useless information and there are better ways to log errors and visits without being limited to the server app (Apache or IIS).  So now my server is down to two conventional drives and as many flash drives as I need.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dawnofthegeeks.com/?feed=rss2&amp;p=538</wfw:commentRss>
		</item>
		<item>
		<title>Using Apache as a Proxy for Server 2003</title>
		<link>http://blog.dawnofthegeeks.com/?p=536</link>
		<comments>http://blog.dawnofthegeeks.com/?p=536#comments</comments>
		<pubDate>Mon, 29 Jun 2009 17:09:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.dawnofthegeeks.com/?p=536</guid>
		<description><![CDATA[Putting the &#8220;geek&#8221; in Dawn of the Geeks are two servers I have set up.  The first server is running Windows XP with Apache, MySQL, PHP and Subversion.  Recently I began developing .Net web sites using C#.   Namely the bank site which is used for managing and tracking personal finances.  Windows XP only allows a [...]]]></description>
			<content:encoded><![CDATA[<p>Putting the &#8220;geek&#8221; in Dawn of the Geeks are two servers I have set up.  The first server is running Windows XP with Apache, MySQL, PHP and Subversion.  Recently I began developing .Net web sites using C#.   Namely the bank site which is used for managing and tracking personal finances.  Windows XP only allows a single web-site to run and only has IIS 5.1.  Since I have a copy of Windows Server 2003 I decided to put it to use and installed it on another server.  That server just has Windows 2003 with II6.</p>
<p>Now the issue is that all port 80 requests go through Apache.  So the first step was to install mod_proxy and mod_proxy_html.  Now I can point various hosts to the second server.  However mod_proxy doesn&#8217;t pass along the original host header.  It was sending it to the internal IP.  Well, IIS 6 needs to know what host it&#8217;s serving for as well if you want to run multiple sites.</p>
<p>The trick is to modify your hosts file on the Apache server so that the host name maps to the internal server.</p>
<p>The flow is</p>
<p>bank.dawnofthegeeks.com hits the DNS server and points to the public IP of my router.  The router sends the port 80 request to the apache server.  The apache server sees that it&#8217;s dealing with bank.dawnofthegeeks.com and reverse proxy&#8217;s it to bank.dawnofthegeeks.com, however when Windows XP tries to resolve that host name it gets the internal IP from the hosts file rather than the public IP of the router from the DNS servers.  So the request gets sent to the IIS server which sees the hostname bank.dawnofthegeeks.com and serves up the correct web back through the proxy.</p>
<p>Through the magic of the hosts file Apache reverse proxies a host to the same host.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dawnofthegeeks.com/?feed=rss2&amp;p=536</wfw:commentRss>
		</item>
		<item>
		<title>Using JavaScript to Track Visitors</title>
		<link>http://blog.dawnofthegeeks.com/?p=535</link>
		<comments>http://blog.dawnofthegeeks.com/?p=535#comments</comments>
		<pubDate>Wed, 17 Jun 2009 02:03:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://blog.dawnofthegeeks.com/?p=535</guid>
		<description><![CDATA[This is log.js that goes in a central location
log.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if &#40;typeof&#40;km_scripts&#41; == 'undefined'&#41; 
	var km_scripts = new Object&#40;&#41;;
&#160;
km_myclass_import&#40;'http://js.dawnofthegeeks.com/hitlog.php?REQUEST_URI=' + document.location + '&#38;HTTP_REFERER=' + document.referrer&#41;;
&#160;
function km_myclass_import&#40;jsFile&#41; 
&#123;
	if &#40;km_scripts&#91;jsFile&#93; != null&#41; 
		return;
	var scriptElt = document.createElement&#40;'script'&#41;;
	scriptElt.type = 'text/javascript';
	scriptElt.src = jsFile;
	document.getElementsByTagName&#40;'head'&#41;&#91;0&#93;.appendChild&#40;scriptElt&#41;;
	km_scripts&#91;jsFile&#93; = jsFile;
&#125;

This line of HTML goes at the bottom of every page that I want to track

1
&#60;SCRIPT LANGUAGE=&#34;JavaScript&#34; SRC=&#34;http://js.dawnofthegeeks.com/log.js&#34;&#62;&#60;/SCRIPT&#62;

hitlog.php [...]]]></description>
			<content:encoded><![CDATA[<p>This is log.js that goes in a central location</p>
<p><b>log.js</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><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>km_scripts<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: #003366; font-weight: bold;">var</span> km_scripts <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Object<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
km_myclass_import<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://js.dawnofthegeeks.com/hitlog.php?REQUEST_URI='</span> <span style="color: #339933;">+</span> document.<span style="color: #660066;">location</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&amp;HTTP_REFERER='</span> <span style="color: #339933;">+</span> document.<span style="color: #660066;">referrer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> km_myclass_import<span style="color: #009900;">&#40;</span>jsFile<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>km_scripts<span style="color: #009900;">&#91;</span>jsFile<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> 
		<span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> scriptElt <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	scriptElt.<span style="color: #660066;">type</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'text/javascript'</span><span style="color: #339933;">;</span>
	scriptElt.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> jsFile<span style="color: #339933;">;</span>
	document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>scriptElt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	km_scripts<span style="color: #009900;">&#91;</span>jsFile<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> jsFile<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This line of HTML goes at the bottom of every page that I want to track</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot; SRC=&quot;http://js.dawnofthegeeks.com/log.js&quot;&gt;&lt;/SCRIPT&gt;</pre></td></tr></table></div>

<p>hitlog.php does the hard work of logging the various information to a MySQL database.  I can then go to my stats page and see the unique visitors and page view count for every domain that line of HTML appears on.  I could break it down by pages as well but for now I&#8217;m not that interested in that level of detail in my reports.</p>
<p>In order to avoid having massive unmanagable tables (GoDaddy limits you to 200MB per database) each month has its own table.  If I&#8217;m running out of space in the database I can export the older tables and delete them from the GoDaddy servers.</p>
<p><b>hitlog.php</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">// define: $dbhost, $dbuser, $dbpass, $dbbase;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> ConnectToJS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">global</span> <span style="color: #000088;">$dbhost</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbuser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbpass</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbbase</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$dbhost</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$dbuser</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$dbpass</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$dbbase</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$db</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> ConnectToJS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;logs_&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y_m&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;
CREATE TABLE IF NOT EXISTS `<span style="color: #006699; font-weight: bold;">$table</span>` (
  `id` bigint(20) NOT NULL auto_increment,
  `hash` varchar(255) NOT NULL,
  `ip` varchar(255) NOT NULL,
  `ip_int` bigint(20) NOT NULL,
  `ip_host` varchar(255) NOT NULL,
  `ip_country_id` int(10) NOT NULL,
  `created_at` datetime NOT NULL,
  `path` varchar(255) NOT NULL,
  `referer` varchar(255) NOT NULL,
  `referer_host` varchar(255) NOT NULL,
  `query_str` varchar(255) NOT NULL,
  `agent` varchar(255) NOT NULL,
  `host` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `hash` (`hash`),
  KEY `host` (`host`),
  KEY `ip_country_id` (`ip_country_id`),
  KEY `referer` (`referer`),
  KEY `agent` (`agent`),
  KEY `created_at` (`created_at`),
  KEY `referer_host` (`referer_host`)
) ENGINE=MyISAM 
&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ip_host</span> <span style="color: #339933;">=</span> <span style="color: #990000;">gethostbyaddr</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$parts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$ip_int</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ip_int</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ip_int</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">256</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">256</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">256</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$ip_int</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">256</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">256</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$ip_int</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">256</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$ip_int</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;
	SELECT
		id
	FROM
		ip_to_country
	WHERE
		<span style="color: #006699; font-weight: bold;">$ip_int</span> &gt;= ip_start AND <span style="color: #006699; font-weight: bold;">$ip_int</span> &lt;= ip_end
&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$r</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ip_country_id</span> <span style="color: #339933;">=</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$r</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$r</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$created_at</span> <span style="color: #339933;">=</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$referer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_REFERER'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ref_parts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$referer</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$referer_host</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ref_parts</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$query_str</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ref_parts</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'query'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$agent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_USER_AGENT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$host</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parts</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$hash</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$created_at</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$path</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$referer</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$agent</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$host</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;
INSERT INTO 
	<span style="color: #006699; font-weight: bold;">$table</span>
SET
	hash = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hash</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>,
	ip = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>,
	ip_host = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip_host</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>,
	ip_int = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip_int</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>,
	ip_country_id = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip_country_id</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>,
	created_at = NOW(),
	path = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>,
	referer = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$referer</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>,
	referer_host = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$referer_host</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>,
	query_str = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query_str</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>,
	agent = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$agent</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>,
	host = <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$host</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>
&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.dawnofthegeeks.com/?feed=rss2&amp;p=535</wfw:commentRss>
		</item>
		<item>
		<title>A-Star Path Finding</title>
		<link>http://blog.dawnofthegeeks.com/?p=534</link>
		<comments>http://blog.dawnofthegeeks.com/?p=534#comments</comments>
		<pubDate>Fri, 15 May 2009 21:02:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.dawnofthegeeks.com/?p=534</guid>
		<description><![CDATA[A-Star (A*) Implementation in C# is an excellent implementation of A* in C#.  It plugged neatly into Bunnies 3.0 which will soon have a sequal &#8220;Zombies.&#8221;  The AI in Bunnies consists of stupid bunnies that just bounce around and multiply and slightly more intelligent enemies that will come at you and shoot at [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.codeguru.com/csharp/csharp/cs_misc/designtechniques/article.php/c12527/">A-Star (A*) Implementation in C#</a> is an excellent implementation of A* in C#.  It plugged neatly into Bunnies 3.0 which will soon have a sequal &#8220;Zombies.&#8221;  The AI in Bunnies consists of stupid bunnies that just bounce around and multiply and slightly more intelligent enemies that will come at you and shoot at you if they see you.  In &#8220;Zombies&#8221; you can run but you can&#8217;t hide.  The game will be slow moving but difficult to kill hordes of enemies with limited ammo and various weapons.  The A* algorithm is being used by the zombies to always keep them moving towards you no matter where you go.</p>
<p>This isn&#8217;t my first use of the A* algorithm and the flaws with it are still there.  My first use of A* was for a simulator that had tanks and flying vehicals moving around complex 3D terrain that was created using DEM data (geological survey data of real life locations).  One of the test paths took a helicopter over Mount Saint Helens.  The helicopter would fly up the side of the mountain at the maximum pitch, fly down into the mountain, fly up out of the mountain and then fly down the side of the mountain to the destination.</p>
<p>The reason it did this is because A* always wants to be close to the final destination which was at the base of the other side of the mountain.  So if it got a chance to lower the altitude to be close to the base it did.  But that&#8217;s obviously not the optimum path.  The fix for flying vehicals is to find the farthest point in the list of destinations which can be seen with a simple line of sight check.  So from the base of the mountain the helicopter can see the top of the mountain so it heads straight there.  From there it can see the other side of the rim so it flies straight there.  And from there it can see it&#8217;s destination so it flies straight there.   A path that was dozens of points is reduced to less than 10.</p>
<p>The technique is basically just doing intelligent post processing on the A* path to cut out unnecessary steps.  Land vehicals had limits on the angle of the terrain they were going over.  Sometimes A* would come up with tangled paths that didn&#8217;t go anywhere.  So to fix that I found the farthest point along the A* path that the vehical could see and travel to without violating the steepness rule.  That easily cut out knots that A* had created and simplified paths significantly.</p>
<p>Because the Bunnies Engine deals with flat terrain the line of sight algorithm can be used on the zombies to simplify their movement.  Once I start putting together an actual tutorial on A* I&#8217;ll give visual examples of how post processing helps clean up A*.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dawnofthegeeks.com/?feed=rss2&amp;p=534</wfw:commentRss>
		</item>
		<item>
		<title>Real Time Software Rendering is Moving</title>
		<link>http://blog.dawnofthegeeks.com/?p=533</link>
		<comments>http://blog.dawnofthegeeks.com/?p=533#comments</comments>
		<pubDate>Fri, 01 May 2009 00:38:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://blog.dawnofthegeeks.com/?p=533</guid>
		<description><![CDATA[The original software rendering location will remain up for now while I slowly transition each of the lessons to the new Real Time Software Rendering Blog.
I found that it was quite the pain to update the old site since it was all static HTML and any syntax highlighted code was highlighted by hand.  WordPress [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.dawnofthegeeks.com/software_rendering/">original software rendering</a> location will remain up for now while I slowly transition each of the lessons to the new <a href="http://code.dawnofthegeeks.com">Real Time Software Rendering Blog</a>.</p>
<p>I found that it was quite the pain to update the old site since it was all static HTML and any syntax highlighted code was highlighted by hand.  WordPress has a handy dandy plugin that automatically does the syntax highlighting.  So this move will hopefully motivate me to continue adding new lessons on more topics.</p>
<p>There is certainly no shortage of lesson ideas that I&#8217;d like to cover.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dawnofthegeeks.com/?feed=rss2&amp;p=533</wfw:commentRss>
		</item>
	</channel>
</rss>
