<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://www.bytemycode.com/rssformat.xsl"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>byteMyCode: Snippets for the dohpaz</title>
		<link>http://www.bytemycode.com</link>
		<description>Snippets for this member.</description>
		<pubDate>Tue, 07 Oct 2008 04:29:20 +0000</pubDate>
		<copyright>1998-2008 </copyright>
		<language>en-us</language>
		<image>
		      <link>http://www.bytemycode.com</link>
		      <url>http://www.bytemycode.com/img/rss_title.gif</url>
		      <title>byteMyCode</title>
		</image>

	<item>
	<title>Javascript web-safe color generator</title>
	<link>http://www.bytemycode.com/snippets/snippet/585/</link>
	<comments>http://www.bytemycode.com/snippets/snippet/585/comments/</comments>
	<pubDate>Thu, 08 Feb 2007 10:05:26 +0000</pubDate>
	<dc:creator>dohpaz</dc:creator>
	<category>"web safe colors", JavaScript</category>
	<guid isPermaLink="false">http://www.bytemycode.com/snippets/snippet/585/</guid>
	<description>
		<![CDATA[

			<img src="http://www.bytemycode.com/img/icon_calendar.gif" align="middle" class="icon" alt="Date Submitted" /> Thu. Feb. 8th, 2007  10:05 AM			<br />
			<img src="http://www.bytemycode.com/img/icon_revision.gif" align="middle" class="icon" alt="Revision" /> <a href="http://www.bytemycode.com/snippets/snippet/585/revisions/">1</a>
			<br />
			<img src="http://www.bytemycode.com/img/rank_helper.gif" align="middle" class="icon" alt="Helper" /> <a href="http://www.bytemycode.com/members/member/dohpaz/" title="Helper">dohpaz</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_tag.gif" align="middle" class="icon" alt="Tags" /> <a href="http://www.bytemycode.com/tags/tag/%22web+safe+colors%22">"web safe colors"</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/JavaScript">JavaScript</a>			<br />
			<img src="http://www.bytemycode.com/img/icon_comments.gif" align="middle" class="icon" alt="Comments" /> <a href="http://www.bytemycode.com/snippets/snippet/585/comments/">0 comments</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_ranking.gif" align="middle" class="icon" alt="Ranking" /> 9
			<p>I had searched high and low for a way to generate a palette of web-safe colors. Despite Google's best efforts, what I had found was lacking for my needs. So, I decided to write a library that would generate all 216 web safe colors, and then allow me to manipulate those colors in any way that I chose. <br /><br />If anybody is curious as to why I would want to do something so... simple, it is because I needed a very light-weight color picker, and didn't want to mess with any fancy options.</p>
		]]>
	</description>
</item><item>
	<title>Zip Codes</title>
	<link>http://www.bytemycode.com/snippets/snippet/489/</link>
	<comments>http://www.bytemycode.com/snippets/snippet/489/comments/</comments>
	<pubDate>Tue, 24 Oct 2006 20:13:13 +0000</pubDate>
	<dc:creator>dohpaz</dc:creator>
	<category>mysql, mysqli, PHP</category>
	<guid isPermaLink="false">http://www.bytemycode.com/snippets/snippet/489/</guid>
	<description>
		<![CDATA[

			<img src="http://www.bytemycode.com/img/icon_calendar.gif" align="middle" class="icon" alt="Date Submitted" /> Tue. Oct. 24th, 2006  8:13 PM			<br />
			<img src="http://www.bytemycode.com/img/icon_revision.gif" align="middle" class="icon" alt="Revision" /> <a href="http://www.bytemycode.com/snippets/snippet/489/revisions/">1</a>
			<br />
			<img src="http://www.bytemycode.com/img/rank_helper.gif" align="middle" class="icon" alt="Helper" /> <a href="http://www.bytemycode.com/members/member/dohpaz/" title="Helper">dohpaz</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_tag.gif" align="middle" class="icon" alt="Tags" /> <a href="http://www.bytemycode.com/tags/tag/mysql">mysql</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/mysqli">mysqli</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/PHP">PHP</a>			<br />
			<img src="http://www.bytemycode.com/img/icon_comments.gif" align="middle" class="icon" alt="Comments" /> <a href="http://www.bytemycode.com/snippets/snippet/489/comments/">4 comments</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_ranking.gif" align="middle" class="icon" alt="Ranking" /> 21
			<p>If you've ever wanted to build an application that can both find the distance between two zip codes, and find zip codes within a specific radius of another zip code, then this is the snippet for you.<br /><br />I've tried to build this before using PHP4 and MySQL 4 and have found it to be painfully slow for a one-user connection over a Local Area Network (LAN). So, before you continue reading, I must make it abundantly clear that this method <i>requires</i> <b>PHP 5</b> and <b>MySQL 5</b>.<br /><br />This is because in PHP5, we will need the MySQL-Improved interfaces, and in MySQL 5, we will need functions and procedures.<br /><br />Using functions and procedures in MySQL puts the weight of the calculations on MySQL, where they will run hundreds of times faster than if PHP were to attempt to do the work. In addition, using functions and procedures is still hundreds of times faster than carefully crafted SQL statements (one benchmark took over 10 seconds using a WHERE clause, while the function + procedure method took around .12 seconds--note the dot).<br /><br />Since I am not a mathematician by trade, I found the necessary calculations using Google.<br /><br />For the "Great Circle Distance" formula, I used <a href='http://www.meridianworlddata.com/Distance-Calculation.asp' target="_blank">Meridian Word Data</a>'s website. For the radius finder, I used another that unfortunately I do not have off the top of my head right now. I will look for it again and repost it for proper accreditation.<br /><br />For the zip code database, I am using the free zip code database from <a href='http://www.cfdynamics.com/cfdynamics/zipbase/index.cfm' target="_blank">CFDynamics</a>.<br /><br />Below, you will find the database and table schema, the functions and procedures, and also a demo PHP script to see all of this put into action. As a courtesy, you may download a dump of this database from <a href='http://www.kennethpaul.com/zipcodes-2006-10-24.sql.bz2' target="_blank">my website</a>. It's uncompressed size is 3.4M, and it's compressed size is 537K. The checksum is available <a href='http://www.kennethpaul.com/zipcodes-2006-10-24.sql.asc' target="_blank">here</a>.<br /><br />Please leave me comments, suggestions, questions, and/or rants about this snippet. I feel this is a very useful bit of code, and hope that others out there may find as much use from it as I will be.</p>
		]]>
	</description>
</item><item>
	<title>Code Counter</title>
	<link>http://www.bytemycode.com/snippets/snippet/362/</link>
	<comments>http://www.bytemycode.com/snippets/snippet/362/comments/</comments>
	<pubDate>Thu, 14 Sep 2006 13:45:16 +0000</pubDate>
	<dc:creator>dohpaz</dc:creator>
	<category>bash, Code, Comments, Grep, Sed</category>
	<guid isPermaLink="false">http://www.bytemycode.com/snippets/snippet/362/</guid>
	<description>
		<![CDATA[

			<img src="http://www.bytemycode.com/img/icon_calendar.gif" align="middle" class="icon" alt="Date Submitted" /> Thu. Sep. 14th, 2006  1:45 PM			<br />
			<img src="http://www.bytemycode.com/img/icon_revision.gif" align="middle" class="icon" alt="Revision" /> <a href="http://www.bytemycode.com/snippets/snippet/362/revisions/">1</a>
			<br />
			<img src="http://www.bytemycode.com/img/rank_helper.gif" align="middle" class="icon" alt="Helper" /> <a href="http://www.bytemycode.com/members/member/dohpaz/" title="Helper">dohpaz</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_tag.gif" align="middle" class="icon" alt="Tags" /> <a href="http://www.bytemycode.com/tags/tag/bash">bash</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/Code">Code</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/Comments">Comments</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/Grep">Grep</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/Sed">Sed</a>			<br />
			<img src="http://www.bytemycode.com/img/icon_comments.gif" align="middle" class="icon" alt="Comments" /> <a href="http://www.bytemycode.com/snippets/snippet/362/comments/">1 comments</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_ranking.gif" align="middle" class="icon" alt="Ranking" /> 7
			<p>I found this script online, and decided that I would modify it for my needs. As a developer, I like to know how many actual lines of code I have written--not including any comments.<br /><br />It outputs in a very simple way:<br /><br />Including Comments:   NNN<br />Without Comments:    NNN<br /><br />One very practical, and quick, way to determine how many lines of code a project has is to pipe it through a find:<br /><br /><br />find /usr/share/php -name "*.php" -o -name "*.inc" | xargs count-code<br /><br /><br />If your code is in files of another type (i.e., .c, .h, .cpp, etc), then simply change the extensions and add more '-o -name "*.ext"' tags. If you have directories that you don't want to be counted, simple throw a "| grep -v [path/to/excluded/directory] |" inbetween the find and the xargs, and they will not be counted.</p>
		]]>
	</description>
</item><item>
	<title>Quick Variable Dump (HTML-friendly)</title>
	<link>http://www.bytemycode.com/snippets/snippet/341/</link>
	<comments>http://www.bytemycode.com/snippets/snippet/341/comments/</comments>
	<pubDate>Thu, 31 Aug 2006 13:36:59 +0000</pubDate>
	<dc:creator>dohpaz</dc:creator>
	<category>debug, HTML, PHP, Variable</category>
	<guid isPermaLink="false">http://www.bytemycode.com/snippets/snippet/341/</guid>
	<description>
		<![CDATA[

			<img src="http://www.bytemycode.com/img/icon_calendar.gif" align="middle" class="icon" alt="Date Submitted" /> Thu. Aug. 31st, 2006  1:36 PM			<br />
			<img src="http://www.bytemycode.com/img/icon_revision.gif" align="middle" class="icon" alt="Revision" /> <a href="http://www.bytemycode.com/snippets/snippet/341/revisions/">1</a>
			<br />
			<img src="http://www.bytemycode.com/img/rank_helper.gif" align="middle" class="icon" alt="Helper" /> <a href="http://www.bytemycode.com/members/member/dohpaz/" title="Helper">dohpaz</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_tag.gif" align="middle" class="icon" alt="Tags" /> <a href="http://www.bytemycode.com/tags/tag/debug">debug</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/HTML">HTML</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/PHP">PHP</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/Variable">Variable</a>			<br />
			<img src="http://www.bytemycode.com/img/icon_comments.gif" align="middle" class="icon" alt="Comments" /> <a href="http://www.bytemycode.com/snippets/snippet/341/comments/">0 comments</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_ranking.gif" align="middle" class="icon" alt="Ranking" /> 21
			<p>A quick and simple function to dump a variable (array, object, string, int, etc) out into -formatted output for a web browser.<br /><br />If the variable is an array or an object, you can have it returned into the another variable for later processing (i.e., through templates or e-mail). Due to lack of free time, if the variable is not an array or an object, it will ignore the $return value and print directly to output. <br /><br />Future revisions will add the above mentioned functionality.</p>
		]]>
	</description>
</item><item>
	<title>HTML Entitize any string</title>
	<link>http://www.bytemycode.com/snippets/snippet/335/</link>
	<comments>http://www.bytemycode.com/snippets/snippet/335/comments/</comments>
	<pubDate>Wed, 30 Aug 2006 05:06:20 +0000</pubDate>
	<dc:creator>dohpaz</dc:creator>
	<category>entities, HTML, PHP</category>
	<guid isPermaLink="false">http://www.bytemycode.com/snippets/snippet/335/</guid>
	<description>
		<![CDATA[

			<img src="http://www.bytemycode.com/img/icon_calendar.gif" align="middle" class="icon" alt="Date Submitted" /> Wed. Aug. 30th, 2006  5:06 AM			<br />
			<img src="http://www.bytemycode.com/img/icon_revision.gif" align="middle" class="icon" alt="Revision" /> <a href="http://www.bytemycode.com/snippets/snippet/335/revisions/">1</a>
			<br />
			<img src="http://www.bytemycode.com/img/rank_helper.gif" align="middle" class="icon" alt="Helper" /> <a href="http://www.bytemycode.com/members/member/dohpaz/" title="Helper">dohpaz</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_tag.gif" align="middle" class="icon" alt="Tags" /> <a href="http://www.bytemycode.com/tags/tag/entities">entities</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/HTML">HTML</a>&nbsp;|&nbsp;<a href="http://www.bytemycode.com/tags/tag/PHP">PHP</a>			<br />
			<img src="http://www.bytemycode.com/img/icon_comments.gif" align="middle" class="icon" alt="Comments" /> <a href="http://www.bytemycode.com/snippets/snippet/335/comments/">2 comments</a>
			<br />
			<img src="http://www.bytemycode.com/img/icon_ranking.gif" align="middle" class="icon" alt="Ranking" /> 12
			<p>This function is useful in helping to deter spam bots by obfuscating things such as e-mail addresses and URLs that are displayed on a web page. While it's not 100% fool proof, it does offer some protection.<br /><br />Example:<br />$email = html_entitize('foo@baz.org');<br />/*<br />Outputs &amp;#x66;&amp;#111;&amp;#111;&amp;#x40;&amp;#98;&amp;#x61;&amp;#x7a;&amp;#x2e;&amp;#99;&amp;#111;&amp;#109;<br />*/</p>
		]]>
	</description>
</item>
	</channel>
</rss>