<?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>Dean Vaughan &#187; Code</title>
	<atom:link href="http://thevedic.net/wordpress/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://thevedic.net/wordpress</link>
	<description>Lobster Madness</description>
	<lastBuildDate>Fri, 07 May 2010 19:00:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to save a PHP object to a database</title>
		<link>http://thevedic.net/wordpress/2010/02/11/how-to-save-a-php-object-to-a-database/</link>
		<comments>http://thevedic.net/wordpress/2010/02/11/how-to-save-a-php-object-to-a-database/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 14:55:12 +0000</pubDate>
		<dc:creator>Deano</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://thevedic.net/wordpress/?p=305</guid>
		<description><![CDATA[This is an example from a class that deals with user accounts. &#160; function save&#40;&#41; &#123; if&#40;!$this-&#62;id&#41; &#123; &#160; ### DUPE PREVENTION $sql = &#34;SELECT id FROM users WHERE username = '&#34; . $this-&#62;username . &#34;' LIMIT 1&#34;; $db2 = mysql_query&#40;$sql&#41;; $db3 = mysql_fetch_array&#40;$db2&#41;; if&#40;$db3&#91;'id'&#93;&#41; &#123; return&#40;0&#41;; &#125; &#160; ### INSERT AND GET THE NEW [...]]]></description>
			<content:encoded><![CDATA[<p>This is an example from a class that deals with user accounts.</p>
<p><code></p>
<pre class="php">&nbsp;
  <span style="color: #000000; font-weight: bold;">function</span> save<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!<span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">id</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">### DUPE PREVENTION</span>
      <span style="color: #0000ff;">$sql</span> = <span style="color: #ff0000;">&quot;SELECT id FROM users WHERE username = '&quot;</span> . <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">username</span> . <span style="color: #ff0000;">&quot;' LIMIT 1&quot;</span>;
      <span style="color: #0000ff;">$db2</span> = <a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$sql</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #0000ff;">$db3</span> = <a href="http://www.php.net/mysql_fetch_array"><span style="color: #000066;">mysql_fetch_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$db2</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$db3</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'id'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #b1b100;">return</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">### INSERT AND GET THE NEW ID</span>
      <span style="color: #0000ff;">$sql</span> = <span style="color: #ff0000;">&quot;INSERT INTO users(`name`, `username`) &quot;</span> .
                  <span style="color: #ff0000;">&quot;VALUES('&quot;</span> . <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">name</span> . <span style="color: #ff0000;">&quot;', '&quot;</span> . <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">username</span> . <span style="color: #ff0000;">&quot;')&quot;</span>;
      <a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$sql</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
      <span style="color: #0000ff;">$sql</span> = <span style="color: #ff0000;">&quot;SELECT id FROM users WHERE name = '&quot;</span> . <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">name</span> . <span style="color: #ff0000;">&quot;' &quot;</span> .
             <span style="color: #ff0000;">&quot;AND username = '&quot;</span> . <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">username</span> . <span style="color: #ff0000;">&quot;' ORDER by username DESC LIMIT 1&quot;</span>;
      <span style="color: #0000ff;">$db2</span> = <a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$sql</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #0000ff;">$db3</span> = <a href="http://www.php.net/mysql_fetch_array"><span style="color: #000066;">mysql_fetch_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$db2</span><span style="color: #66cc66;">&#41;</span>;
      <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">id</span> = <span style="color: #0000ff;">$db3</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'id'</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">$to_set</span> = <span style="color: #ff0000;">''</span>;
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$this</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$key</span> =&gt; <span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$key</span> == <span style="color: #ff0000;">'id'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #b1b100;">continue</span>;
      <span style="color: #66cc66;">&#125;</span>
&nbsp;
      <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$key</span> != <span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$to_set</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
          <span style="color: #0000ff;">$to_set</span> .= <span style="color: #ff0000;">', '</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #000066;">is_array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
          <span style="color: #0000ff;">$value</span> = <a href="http://www.php.net/serialize"><span style="color: #000066;">serialize</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #0000ff;">$to_set</span> .= <span style="color: #ff0000;">&quot;$key = '&quot;</span> . <a href="http://www.php.net/mysql_real_escape_string"><span style="color: #000066;">mysql_real_escape_string</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">&quot;'&quot;</span>;
      <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://thevedic.net/wordpress/2010/02/11/how-to-save-a-php-object-to-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Log Tail Revisitied</title>
		<link>http://thevedic.net/wordpress/2009/02/17/php-log-tailhttpthevedicnetwordpresswp-adminpost-newphp/</link>
		<comments>http://thevedic.net/wordpress/2009/02/17/php-log-tailhttpthevedicnetwordpresswp-adminpost-newphp/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 19:31:27 +0000</pubDate>
		<dc:creator>Deano</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://thevedic.net/wordpress/?p=134</guid>
		<description><![CDATA[The brilliance of programming... Last year I needed to tail a file in PHP. I whipped this out. Today I needed to do it and came up with this: $output = `tail -n 150 /var/log/messages`; $tail_str = "&#60;pre&#62;$output&#60;/pre&#62;"; Weee... don't know what the hell I was thinking last time.]]></description>
			<content:encoded><![CDATA[<p>The brilliance of programming...</p>
<p>Last year I needed to tail a file in PHP. <a href="/wordpress/2008/06/18/quick-and-dirty-file-tail-in-php/">I whipped this out.</a></p>
<p>Today I needed to do it and came up with this:</p>
<p>$output = `tail -n 150 /var/log/messages`;<br />
$tail_str = "&lt;pre&gt;$output&lt;/pre&gt;";</p>
<p>Weee... don't know what the hell I was thinking last time.</p>
]]></content:encoded>
			<wfw:commentRss>http://thevedic.net/wordpress/2009/02/17/php-log-tailhttpthevedicnetwordpresswp-adminpost-newphp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free Online PDF to JPG Converter</title>
		<link>http://thevedic.net/wordpress/2009/02/07/free-online-pdf-to-jpg-converter/</link>
		<comments>http://thevedic.net/wordpress/2009/02/07/free-online-pdf-to-jpg-converter/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 21:23:54 +0000</pubDate>
		<dc:creator>Deano</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://thevedic.net/wordpress/?p=124</guid>
		<description><![CDATA[I had the need to convert a PDF to a JPG today. I searched around on Google and everything was pay to play. This is pure exploitation since this sort of conversion is a one liner for most Linux systems. I wrote my own. File: Depending on your connection speed, this may take a while. [...]]]></description>
			<content:encoded><![CDATA[<p>I had the need to convert a PDF to a JPG today. I searched around on Google and everything was pay to play. This is pure exploitation since this sort of conversion is a one liner for most Linux systems.</p>
<p>I wrote my own.</p>
<form enctype="multipart/form-data" method=POST action="/wordpress/wp-content/uploads/2009/02/pdf_2_jpg.php">
<table border=0>
<tr>
<td><b>File:</b></td>
<td>
<input name="uploadedfile" type="file" /></td>
</tr>
<tr>
<td></td>
<td><INPUT TYPE=SUBMIT NAME="Go" VALUE="Go"></td>
</tr>
</table>
</form>
<p><b>Depending on your connection speed, this may take a while.</b></p>
<p>If you provide a single page PDF you will get a JPG back. If you provide a multi-page PDF you will get a zip file back, inside of the zip file will be a JPG of each page of the PDF.</p>
<p><a href=/wordpress/wp-content/uploads/2009/02/pdf_2_jpg.phps>Click Here to Download the Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://thevedic.net/wordpress/2009/02/07/free-online-pdf-to-jpg-converter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building pdftk (PDF Toolkit) on FC9 and FC10</title>
		<link>http://thevedic.net/wordpress/2008/12/02/building-pdftk-pdf-toolkit-on-fc9/</link>
		<comments>http://thevedic.net/wordpress/2008/12/02/building-pdftk-pdf-toolkit-on-fc9/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 15:08:29 +0000</pubDate>
		<dc:creator>Deano</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://thevedic.net/wordpress/?p=70</guid>
		<description><![CDATA[The PDF toolkit is command line app for manipulating PDFs. I use it to split faxes received in Hylafax into one file per page. I recently upgraded a server to x86 64 Fedora Core 9 and found that all of the precompiled versions of pdftk wouldn't work. I tried to build my own and got [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.pdfhacks.com/pdftk/">PDF toolkit</a> is command line app for manipulating PDFs. I use it to split faxes received in Hylafax into one file per page. I recently upgraded a server to x86 64 Fedora Core 9 and found that all of the precompiled versions of pdftk wouldn't work. I tried to build my own and got some awesome errors:</p>
<blockquote><p>Exception in thread "main" java.io.IOException: can't find class file java_local/security/Provider.class in java.net.URLClassLoader</p></blockquote>
<p>After much Googling I stumbled on a source RPM for Fedora Core 7 and I went to work. The procedure is pretty simple, grab the source RPM, run:</p>
<blockquote><p>rpmbuild --rebuild pdftk-1.41-5.fc7.src.rpm</p></blockquote>
<p>Then wait out all of the warnings and run:</p>
<blockquote><p>rpm -ivh /usr/src/redhat/RPMS/x86_64/pdftk-1.41-5.fc9.x86_64.rpm</p></blockquote>
<p>The built RPMs filename will probably be different on your system.</p>
<p><strong>Downloads:</strong></p>
<ul>
<li><a href="/wordpress/wp-content/uploads/2008/12/pdftk-1.41-5.fc7.src.rpm">Source RPM pdftk-1.41-5.fc7.src.rpm</a></li>
<li><a href="/wordpress/wp-content/uploads/2008/12/pdftk-1.41-5.fc9.x86_64.rpm">Built x86 64 Fedora 9 RPM pdftk-1.41-5.fc9.x86_64.rpm</a></li>
<li><a href="/wordpress/wp-content/uploads/2008/12/pdftk-1.41-5.fc10.i386.rpm">Built i386 Fedora 10 RPM pdftk-1.41-5.fc10.i386.rpm</a></li>
</ul>
<p><strong>UPDATE 3/6/09</strong></p>
<p>I'm getting a lot of reports that the source RPM works for Fedora Core 10 too.  Tom of comment fame was nice enough to send me a copy he built for i386. It's linked above for your downloading pleasure.</p>
<p>A note about the warnings... Indeed there are a lot, and they take forever. I've used my copy of pdftk for about four months in a production enviroment on something like 60K faxes by now. I have never had a problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://thevedic.net/wordpress/2008/12/02/building-pdftk-pdf-toolkit-on-fc9/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Learning Flash</title>
		<link>http://thevedic.net/wordpress/2008/11/12/learning-flash/</link>
		<comments>http://thevedic.net/wordpress/2008/11/12/learning-flash/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 19:22:27 +0000</pubDate>
		<dc:creator>Deano</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://thevedic.net/wordpress/?p=66</guid>
		<description><![CDATA[I've decided to learn flash. I don't know why, I don't know what I am planning on using it for, but I am going to do it. Here is some example code I wrote up to play around with, it can read in XML outputted from a PHP script and display it, it can also [...]]]></description>
			<content:encoded><![CDATA[<p>I've decided to learn flash. I don't know why, I don't know what I am planning on using it for, but I am going to do it.</p>
<p>Here is some example code I wrote up to play around with, it can read in XML outputted from a PHP script and display it, it can also display a digital clock.</p>
<p>	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="500" height="300" id="ip_addy" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="/wordpress/wp-content/uploads/2008/11/flash//wordpress/wp-content/uploads/2008/11/flash/ip_addy.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="/wordpress/wp-content/uploads/2008/11/flash/ip_addy.swf" quality="high" bgcolor="#ffffff" width="500" height="300" name="ip_addy" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /><br />
	</object></p>
<p><a href="/wordpress/wp-content/uploads/2008/11/flash/count.phps">PHP Source</a><br />
<a href="/wordpress/wp-content/uploads/2008/11/flash/ip_addy.fla">Flash Source</a></p>
<p>I find the MySQL -&gt; PHP -&gt; XML -&gt; Flash route to be interesting and surely there are some possibilities to be found.</p>
]]></content:encoded>
			<wfw:commentRss>http://thevedic.net/wordpress/2008/11/12/learning-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Write String to a Jpeg</title>
		<link>http://thevedic.net/wordpress/2008/10/27/php-write-string-to-a-jpeg/</link>
		<comments>http://thevedic.net/wordpress/2008/10/27/php-write-string-to-a-jpeg/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 15:44:30 +0000</pubDate>
		<dc:creator>Deano</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://thevedic.net/wordpress/?p=61</guid>
		<description><![CDATA[This function will dynamically create a jpeg from the string you provide. It even handles multi-line strings. &#160; function str_to_jpg&#40;$str, $file&#41; &#123; $lines = explode&#40;&#34;\n&#34;, $str&#41;; $number_lines = count&#40;$lines&#41;; &#160; $image = imagecreate&#40;1000, &#40;$number_lines * 16&#41;&#41;; &#160; $background = imagecolorallocate&#40;$image, 0, 0, 0&#41;; $text = imagecolorallocate&#40;$image, 255, 255, 255&#41;; &#160; $pos = 2; foreach&#40;$lines as [...]]]></description>
			<content:encoded><![CDATA[<p>This function will dynamically create a jpeg from the string you provide. It even handles multi-line strings.</p>
<p><code></p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> str_to_jpg<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$str</span>, <span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0000ff;">$lines</span> = <a href="http://www.php.net/explode"><span style="color: #000066;">explode</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, <span style="color: #0000ff;">$str</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #0000ff;">$number_lines</span> = <a href="http://www.php.net/count"><span style="color: #000066;">count</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$lines</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
  <span style="color: #0000ff;">$image</span> = imagecreate<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1000</span>, <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$number_lines</span> * <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
  <span style="color: #0000ff;">$background</span> = imagecolorallocate<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #0000ff;">$text</span> = imagecolorallocate<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span>, <span style="color: #cc66cc;">255</span>, <span style="color: #cc66cc;">255</span>, <span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
  <span style="color: #0000ff;">$pos</span> = <span style="color: #cc66cc;">2</span>;
  <span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$lines</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$line</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    imagestring<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span>, <span style="color: #cc66cc;">4</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #0000ff;">$pos</span>, <span style="color: #0000ff;">$line</span>, <span style="color: #0000ff;">$text</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0000ff;">$pos</span> += <span style="color: #cc66cc;">16</span>;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  imagejpeg<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span>, <span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
  imagedestroy<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$image</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://thevedic.net/wordpress/2008/10/27/php-write-string-to-a-jpeg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Controlling Alpha LED Signs with Perl or PHP in Windows</title>
		<link>http://thevedic.net/wordpress/2008/10/13/controlling-alpha-led-signs-with-perl-or-php-in-windows/</link>
		<comments>http://thevedic.net/wordpress/2008/10/13/controlling-alpha-led-signs-with-perl-or-php-in-windows/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 03:02:41 +0000</pubDate>
		<dc:creator>Deano</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Me]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://thevedic.net/wordpress/?p=59</guid>
		<description><![CDATA[I acquired an Alpha LED sign in a '$1 it's broke' Ebay action. Using my undergrad EE skills, I replaced the fuse and had a working sign. (Also note some of my totally awesome collection of Internet Appliances) Thing is, I have nothing to use it for. I was going to make it web accessible [...]]]></description>
			<content:encoded><![CDATA[<p>I acquired an Alpha LED sign in a '$1 it's broke' Ebay action. Using my undergrad EE skills, I replaced the fuse and had a working sign.</p>

<a href="http://thevedic.net/wordpress/wp-content/gallery/random/led_sign.jpg" title="" class="thickbox" rel="singlepic193" >
	<img class="ngg-singlepic" src="http://thevedic.net/wordpress/wp-content/plugins/nextgen-gallery/nggshow.php?pid=193&amp;width=700&amp;height=440&amp;mode=" alt="led_sign.jpg" title="led_sign.jpg" />
</a>
<br />
(Also note some of my totally awesome collection of Internet Appliances)</p>
<p>Thing is, I have nothing to use it for. I was going to make it web accessible so random people could change the message, but that would require me to leave my computer on all of the time and my bandwidth free.</p>
<p>It's a easy project really. You need a form to collect the messages and place them in a database. Then you need another script that runs every X minutes, grabs the oldest unsent message from the DB and sends it to the sign. Then you snap a webcam photo. %90 of that code is in the PHP script below.</p>
<p><a href="http://wls.wwco.com/ledsigns/alpha/AlphaLinux.html">All of the real work for sending messages to the sign was done by this guy.</a> He even has instructions on how to make the serial cable for the sign. All I did was figure out how to get at the serial port in Windows. It took a bit of mad Googling.</p>
<p>Perl:<br />
<code></p>
<pre class="perl">&nbsp;
<span style="color: #808080; font-style: italic;">#!C:\Perl\bin\wperl.exe</span>
&nbsp;
<span style="color: #0000ff;">$com_port</span> = <span style="color: #ff0000;">'COM1'</span>;
&nbsp;
<span style="color: #0000ff;">$style</span> = <span style="color: #0000ff;">$ARGV</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$style</span> eq <span style="color: #ff0000;">'flash'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0000ff;">$stlye</span> = <span style="color: #ff0000;">'c'</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">elsif</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$style</span> eq <span style="color: #ff0000;">'random'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0000ff;">$style</span> = <span style="color: #ff0000;">'d'</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">elsif</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$style</span> eq <span style="color: #ff0000;">'scroll'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0000ff;">$style</span> = <span style="color: #ff0000;">'a'</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">elsif</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$style</span> eq <span style="color: #ff0000;">'random'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0000ff;">$style</span> = <span style="color: #ff0000;">'d'</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">elsif</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$style</span> eq <span style="color: #ff0000;">'shrink'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0000ff;">$style</span> = <span style="color: #ff0000;">'t'</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0000ff;">$style</span> = <span style="color: #ff0000;">'a'</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">$message</span> = <span style="color: #0000ff;">$ARGV</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;
<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!<span style="color: #0000ff;">$message</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  <span style="color: #0000ff;">$message</span> = <span style="color: #ff0000;">&quot;Dude, my balls are freakin' huge.&quot;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># LINUX: open( PORT, &quot;&gt;/dev/ttyS0&quot; )</span>
<a href="http://perldoc.perl.org/functions/open.html"><span style="color: #000066;">open</span></a><span style="color: #66cc66;">&#40;</span> PORT, <span style="color: #ff0000;">&quot;+&gt;COM1&quot;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span style="color: #000066;">die</span></a> <span style="color: #ff0000;">&quot;Can't open COM1: $!&quot;</span>;
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> PORT <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span>&quot;</span>;
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> PORT <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\0</span>01&quot;</span> . <span style="color: #ff0000;">&quot;Z&quot;</span> . <span style="color: #ff0000;">&quot;00&quot;</span> . <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\0</span>02&quot;</span> . <span style="color: #ff0000;">&quot;AA&quot;</span> . <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1B&quot;</span> . <span style="color: #ff0000;">&quot; $style &quot;</span> . <span style="color: #0000ff;">$message</span> . <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\0</span>04&quot;</span>;
<a href="http://perldoc.perl.org/functions/close.html"><span style="color: #000066;">close</span></a><span style="color: #66cc66;">&#40;</span>PORT<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Sent: $message<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
&nbsp;</pre>
<p></code></p>
<p>PHP:</p>
<p>If you're the brave sort, you can call this from a browser. It uses <a href="http://www.naughter.com/vfwgrab.htm">VFW Grab</a> to snap a webcam picture after the message is displayed.</p>
<p><code></p>
<pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?PHP</span>
<span style="color: #0000ff;">$style</span> = <span style="color: #ff0000;">'w'</span>;
<span style="color: #0000ff;">$message</span> = <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'message'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> ? <span style="color: #0000ff;">$_GET</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'message'</span><span style="color: #66cc66;">&#93;</span> : <span style="color: #ff0000;">'Boobs?'</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// LINUX: $fh = fopen(&quot;/dev/ttyS0&quot;, &quot;wb&quot;) or die(&quot;can't open port&quot;);</span>
<span style="color: #0000ff;">$fh</span> = <a href="http://www.php.net/fopen"><span style="color: #000066;">fopen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;COM1&quot;</span>, <span style="color: #ff0000;">&quot;wb&quot;</span><span style="color: #66cc66;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #000066;">die</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;can't open port&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/fwrite"><span style="color: #000066;">fwrite</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fh</span>, <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\0</span>&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/fwrite"><span style="color: #000066;">fwrite</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fh</span>, <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\0</span>01&quot;</span> . <span style="color: #ff0000;">&quot;Z&quot;</span> . <span style="color: #ff0000;">&quot;00&quot;</span> . <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\0</span>02&quot;</span> . <span style="color: #ff0000;">&quot;AA&quot;</span> . <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1B&quot;</span> . <span style="color: #ff0000;">&quot; $style &quot;</span> . <span style="color: #0000ff;">$message</span> . <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\0</span>04&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/fclose"><span style="color: #000066;">fclose</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fh</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<a href="http://www.php.net/system"><span style="color: #000066;">system</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;VFWGrab.exe&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.php.net/print"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;Sent: $message&quot;</span>;
<a href="http://www.php.net/print"><span style="color: #000066;">print</span></a> <span style="color: #ff0000;">&quot;&lt;br&gt;&lt;img src=capture.jpg&gt;&quot;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p></code></p>
<p>On another note, a stick bug was being sticky in my garden this morning.<br />

<a href="http://thevedic.net/wordpress/wp-content/gallery/random/stick_bug.jpg" title="" class="thickbox" rel="singlepic194" >
	<img class="ngg-singlepic" src="http://thevedic.net/wordpress/wp-content/plugins/nextgen-gallery/nggshow.php?pid=194&amp;width=700&amp;height=440&amp;mode=" alt="stick_bug.jpg" title="stick_bug.jpg" />
</a>

]]></content:encoded>
			<wfw:commentRss>http://thevedic.net/wordpress/2008/10/13/controlling-alpha-led-signs-with-perl-or-php-in-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dibrova &#8211; Updated!</title>
		<link>http://thevedic.net/wordpress/2008/09/22/dibrova-updated/</link>
		<comments>http://thevedic.net/wordpress/2008/09/22/dibrova-updated/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 01:32:11 +0000</pubDate>
		<dc:creator>Deano</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://thevedic.net/wordpress/?p=55</guid>
		<description><![CDATA[Craig Russell updated Dibrova to work with modern compilers, sweet! Dibrova was built on a RedHat 5 system back in the day, apparently the code wouldn't compile with newer versions of GCC. Craig was good enough to fix that and send me his changes. Viva la open source. http://thevedic.net/mud/new/]]></description>
			<content:encoded><![CDATA[<p>Craig Russell updated Dibrova to work with modern compilers, sweet!</p>
<p>Dibrova was built on a RedHat 5 system back in the day, apparently the code wouldn't compile with newer versions of GCC. Craig was good enough to fix that and send me his changes. Viva la open source.</p>
<p><a href="http://thevedic.net/mud/new/">http://thevedic.net/mud/new/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://thevedic.net/wordpress/2008/09/22/dibrova-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jquery: Selected Drop Down Entry Shows/Hides Other Fields</title>
		<link>http://thevedic.net/wordpress/2008/09/09/jquery-selected-drop-down-entry-showshides-other-fields/</link>
		<comments>http://thevedic.net/wordpress/2008/09/09/jquery-selected-drop-down-entry-showshides-other-fields/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 14:26:45 +0000</pubDate>
		<dc:creator>Deano</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://thevedic.net/wordpress/?p=52</guid>
		<description><![CDATA[&#160; // type is the dropdown that controls what get displayed. // folder_drop, radiologist_drop, and resend_box // get displayed based on the selected value of type. // This mapping is done in the if/else statements. // The first time is for when the page loads, // the second time is when type changes. // // [...]]]></description>
			<content:encoded><![CDATA[<p><code></p>
<pre class="javascript">&nbsp;
<span style="color: #009900; font-style: italic;">// type is the dropdown that controls what get displayed.</span>
<span style="color: #009900; font-style: italic;">// folder_drop, radiologist_drop, and resend_box</span>
<span style="color: #009900; font-style: italic;">// get displayed based on the selected value of type.</span>
<span style="color: #009900; font-style: italic;">// This mapping is done in the if/else statements.</span>
<span style="color: #009900; font-style: italic;">// The first time is for when the page loads,</span>
<span style="color: #009900; font-style: italic;">// the second time is when type changes.</span>
<span style="color: #009900; font-style: italic;">//</span>
<span style="color: #009900; font-style: italic;">// The mapping to selected values and id should be put</span>
<span style="color: #009900; font-style: italic;">// into a function so you would only need to change it</span>
<span style="color: #009900; font-style: italic;">// in one place.</span>
<span style="color: #003366; font-weight: bold;">function</span> hide_all<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
  $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#folder_drop&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#radiologist_drop&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#resend_box&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
$<span style="color: #66cc66;">&#40;</span>document<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
  hide_all<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#type&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;Folder&quot;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #CC0000;">-1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#folder_drop&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#type&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;Radiologist&quot;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #CC0000;">-1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#radiologist_drop&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#type&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;ReSend&quot;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #CC0000;">-1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#resend_box&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#type&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">change</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
    hide_all<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;Folder&quot;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #CC0000;">-1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#folder_drop&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;Radiologist&quot;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #CC0000;">-1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#radiologist_drop&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">val</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;ReSend&quot;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #CC0000;">-1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#resend_box&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://thevedic.net/wordpress/2008/09/09/jquery-selected-drop-down-entry-showshides-other-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Return a percentage based hex color between two other colors. (FADE!)</title>
		<link>http://thevedic.net/wordpress/2008/09/05/php-return-a-percentage-based-hex-color-between-two-other-colors-fade/</link>
		<comments>http://thevedic.net/wordpress/2008/09/05/php-return-a-percentage-based-hex-color-between-two-other-colors-fade/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 15:25:25 +0000</pubDate>
		<dc:creator>Deano</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://thevedic.net/wordpress/?p=51</guid>
		<description><![CDATA[&#160;function get_color&#40;$start, $end, $percent&#41; &#123;&#160; $r1=hexdec&#40;substr&#40;$start, 0, 2&#41;&#41;; $g1=hexdec&#40;substr&#40;$start, 2, 2&#41;&#41;; $b1=hexdec&#40;substr&#40;$start, 4, 2&#41;&#41;;&#160; $r2=hexdec&#40;substr&#40;$end, 0, 2&#41;&#41;; $g2=hexdec&#40;substr&#40;$end, 2, 2&#41;&#41;; $b2=hexdec&#40;substr&#40;$end, 4, 2&#41;&#41;;&#160; $pc = $percent/100;&#160; $r = floor&#40;$r1+&#40;$pc*&#40;$r2-$r1&#41;&#41; + .5&#41;; $g = floor&#40;$g1+&#40;$pc*&#40;$g2-$g1&#41;&#41; + .5&#41;; $b = floor&#40;$b1+&#40;$pc*&#40;$b2-$b1&#41;&#41; + .5&#41;;&#160; return&#40;sprintf&#40;'#%02X%02X%02X', $r, $g, $b&#41;&#41;;&#125;&#160;// Shows all of the colors between $start and $end at [...]]]></description>
			<content:encoded><![CDATA[<p><code></p>
<pre class="php"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> get_color<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$start</span>, <span style="color: #0000ff;">$end</span>, <span style="color: #0000ff;">$percent</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$r1</span>=<a href="http://www.php.net/hexdec"><span style="color: #000066;">hexdec</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$start</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$g1</span>=<a href="http://www.php.net/hexdec"><span style="color: #000066;">hexdec</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$start</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$b1</span>=<a href="http://www.php.net/hexdec"><span style="color: #000066;">hexdec</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$start</span>, <span style="color: #cc66cc;">4</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$r2</span>=<a href="http://www.php.net/hexdec"><span style="color: #000066;">hexdec</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$end</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$g2</span>=<a href="http://www.php.net/hexdec"><span style="color: #000066;">hexdec</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$end</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$b2</span>=<a href="http://www.php.net/hexdec"><span style="color: #000066;">hexdec</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #000066;">substr</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$end</span>, <span style="color: #cc66cc;">4</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$pc</span> = <span style="color: #0000ff;">$percent</span>/<span style="color: #cc66cc;">100</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$r</span> = <a href="http://www.php.net/floor"><span style="color: #000066;">floor</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$r1</span>+<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pc</span>*<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$r2</span>-<span style="color: #0000ff;">$r1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> + .<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$g</span> = <a href="http://www.php.net/floor"><span style="color: #000066;">floor</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$g1</span>+<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pc</span>*<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$g2</span>-<span style="color: #0000ff;">$g1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> + .<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$b</span> = <a href="http://www.php.net/floor"><span style="color: #000066;">floor</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$b1</span>+<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$pc</span>*<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$b2</span>-<span style="color: #0000ff;">$b1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> + .<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #b1b100;">return</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/sprintf"><span style="color: #000066;">sprintf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'#%02X%02X%02X'</span>, <span style="color: #0000ff;">$r</span>, <span style="color: #0000ff;">$g</span>, <span style="color: #0000ff;">$b</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Shows all of the colors between $start and $end at ten percent intervals.</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> color_scale<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$start</span>, <span style="color: #0000ff;">$end</span>, <span style="color: #0000ff;">$max</span> = <span style="color: #ff0000;">'red'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$i</span> = <span style="color: #cc66cc;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$str</span> = <span style="color: #ff0000;">&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&lt;table border=0&gt;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&lt;tr&gt;&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$i</span> = <span style="color: #cc66cc;">0</span>; <span style="color: #0000ff;">$i</span> &lt; <span style="color: #cc66cc;">101</span>; <span style="color: #0000ff;">$i</span> += <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #0000ff;">$color</span> = get_color<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$start</span>, <span style="color: #0000ff;">$end</span>, <span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #0000ff;">$str</span> .= <span style="color: #ff0000;">&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&lt;td bgcolor=$color&gt;$i&lt;/td&gt;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$str</span> .= <span style="color: #ff0000;">&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&lt;td bgcolor=$max&gt;M&lt;/td&gt;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #0000ff;">$str</span> .= <span style="color: #ff0000;">&quot;&lt;/tr&gt;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&lt;/table&gt;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&quot;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  <span style="color: #b1b100;">return</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$str</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://thevedic.net/wordpress/2008/09/05/php-return-a-percentage-based-hex-color-between-two-other-colors-fade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
