<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.4" -->
<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/"
	>

<channel>
	<title>Ryan Byrd's Tech Ramblings</title>
	<link>http://www.ryanbyrd.net/techramble</link>
	<description>The Second Best Blog in Utah</description>
	<pubDate>Mon, 06 Oct 2008 15:45:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>
	<language>en</language>
			<item>
		<title>Weighted Round Robin</title>
		<link>http://www.ryanbyrd.net/techramble/2008/10/06/weighted-round-robin/</link>
		<comments>http://www.ryanbyrd.net/techramble/2008/10/06/weighted-round-robin/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 15:19:20 +0000</pubDate>
		<dc:creator>me</dc:creator>
		
	<category>software</category>
		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/2008/10/06/weighted-round-robin/</guid>
		<description><![CDATA[Here&#8217;s a quick example of weighted round robin in php. 
//weighted round robin
&#160;
define&#40;&#34;START_WEIGHT&#34;, 1&#41;;
class printer
&#123;
  private $name;
  private $weight;
  private $normalizedWeight;
  public function printer&#40;$name,$weight=START_WEIGHT&#41;
  &#123;
    $this-&#62;name=$name;
    $this-&#62;weight=$weight;
  &#125;
  public function getName&#40;&#41; &#123; return $this-&#62;name; &#125;
  public function getWeight&#40;&#41; &#123; return $this-&#62;weight; [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quick example of weighted round robin in php. </p>
<pre class="php php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//weighted round robin</span>
&nbsp;
<a href="http://www.php.net/define"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;START_WEIGHT&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">class</span> printer
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$name</span>;
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$weight</span>;
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$normalizedWeight</span>;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> printer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span><span style="color: #000088;">$weight</span><span style="color: #339933;">=</span>START_WEIGHT<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">=</span><span style="color: #000088;">$name</span>;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">weight</span><span style="color: #339933;">=</span><span style="color: #000088;">$weight</span>;
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span>; <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getWeight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">weight</span>; <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setWeight<span style="color: #009900;">&#40;</span><span style="color: #000088;">$weight</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">weight</span><span style="color: #339933;">=</span><span style="color: #000088;">$weight</span>; <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getNormalizedWeight<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">normalizedWeight</span>; <span style="color: #009900;">&#125;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setNormalizedWeight<span style="color: #009900;">&#40;</span><span style="color: #000088;">$weight</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">normalizedWeight</span><span style="color: #339933;">=</span><span style="color: #000088;">$weight</span>; <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$printerList</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$printerList</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> printer<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;printer1&quot;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$printerList</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> printer<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;printer2&quot;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$printerList</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> printer<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;printer3&quot;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$printerList</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> printer<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;printer4&quot;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$jobList</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="">&#8216;job1&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job2&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job3&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job4&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job5&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job6&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job7&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job8&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job9&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job10&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job11&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job12&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job13&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job14&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job15&#8242;</span><span style="color: #339933;">,</span><span style="">&#8216;job16&#8242;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$min</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">2147483647</span>; <span style="color: #666666; font-style: italic;">//a large number</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$printerList</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$printer</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$min</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$printer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getWeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$min</span><span style="color: #009900;">&#41;</span>?<span style="color: #000088;">$printer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getWeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000088;">$min</span>;
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$printerList</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$printer</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$printer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setNormalizedWeight</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$printer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getWeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #000088;">$min</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$jobCount</span><span style="color: #339933;">=</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$jobList</span><span style="color: #009900;">&#41;</span>;
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$jobCount</span><span style="color: #339933;">&gt;</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$printerList</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$printer</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$jobCount</span><span style="color: #339933;">=</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$jobList</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$jobCount</span><span style="color: #339933;">&gt;</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$jobList</span><span style="color: #339933;">=</span>jobPush<span style="color: #009900;">&#40;</span><span style="color: #000088;">$printer</span><span style="color: #339933;">,</span><span style="color: #000088;">$jobList</span><span style="color: #339933;">,</span><span style="color: #000088;">$jobCount</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> jobPush<span style="color: #009900;">&#40;</span><span style="color: #000088;">$printer</span><span style="color: #339933;">,</span><span style="color: #000088;">$jobList</span><span style="color: #339933;">,</span><span style="color: #000088;">$jobCount</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;<span style="color: #000088;">$x</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$printer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getNormalizedWeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;<span style="color: #000088;">$x</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$jobCount</span><span style="color: #339933;">&gt;</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$job</span><span style="color: #339933;">=</span><a href="http://www.php.net/array_shift"><span style="color: #990000;">array_shift</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$jobList</span><span style="color: #009900;">&#41;</span>;
      <span style="color: #000088;">$jobCount</span>&#8211;;
      <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$printer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; getting &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$job</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">n</span>&quot;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <a href="http://www.php.net/echo"><span style="color: #990000;">echo</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">n</span>&quot;</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$jobList</span>;
<span style="color: #009900;">&#125;</span></pre>
]]></content:encoded>
			<wfw:commentRSS>http://www.ryanbyrd.net/techramble/2008/10/06/weighted-round-robin/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Movie Tech</title>
		<link>http://www.ryanbyrd.net/techramble/2008/09/07/movie-tech/</link>
		<comments>http://www.ryanbyrd.net/techramble/2008/09/07/movie-tech/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 18:08:09 +0000</pubDate>
		<dc:creator>me</dc:creator>
		
	<category>how tos</category>
		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/2008/09/07/movie-tech/</guid>
		<description><![CDATA[Recently I helped direct and produce a biographical documentary. Here&#8217;s the equipment list I used:

Canon XHA1 video camera
Camera tripod
Boom pole
Directional mic with windscreen (dead cat)
XLR cables
MiniDV tapes
Macbook Pro w/ iMovie and iDVD
Dell Laptop with photoshop
Epson flatbed scanner
Radio Shack 3 channel audio mixer
Sennheiser condenser microphone with stand (for narration)
External 1TB drive
Mediawiki
Royalty free music (http://incompetech.com/m/c/royalty-free/)

Do I know [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I helped direct and produce a biographical documentary. Here&#8217;s the equipment list I used:</p>
<ul>
<li>Canon XHA1 video camera</li>
<li>Camera tripod</li>
<li>Boom pole</li>
<li>Directional mic with windscreen (dead cat)</li>
<li>XLR cables</li>
<li>MiniDV tapes</li>
<li>Macbook Pro w/ iMovie and iDVD</li>
<li>Dell Laptop with photoshop</li>
<li>Epson flatbed scanner</li>
<li>Radio Shack 3 channel audio mixer</li>
<li>Sennheiser condenser microphone with stand (for narration)</li>
<li>External 1TB drive</li>
<li>Mediawiki</li>
<li>Royalty free music (http://incompetech.com/m/c/royalty-free/)</li>
</ul>
<p>Do I know anything about film making? Not really. I did read a bunch of books. And I watched an awful lot of documentaries to get ideas. Special thanks to Tyler T. for the technical advice!</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.ryanbyrd.net/techramble/2008/09/07/movie-tech/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>even more Utah tech interview questions</title>
		<link>http://www.ryanbyrd.net/techramble/2008/09/03/even-more-utah-tech-interview-questions/</link>
		<comments>http://www.ryanbyrd.net/techramble/2008/09/03/even-more-utah-tech-interview-questions/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 18:17:25 +0000</pubDate>
		<dc:creator>me</dc:creator>
		
	<category>code</category>
	<category>interviews</category>
		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/2008/09/03/even-more-utah-tech-interview-questions/</guid>
		<description><![CDATA[I had a friend send me a list of these questions today. some are repeats from previous posts but there are several new ones. Enjoy!
Logic Problems
a) 8 Steel balls, 1 heavier than all the rest. Use a Balance Scale to determine the heaviest ball in the shortest number of tries.
b) Find how many trailing zeroes [...]]]></description>
			<content:encoded><![CDATA[<p>I had a friend send me a list of these questions today. some are repeats from previous posts but there are several new ones. Enjoy!</p>
<p><b>Logic Problems</b></p>
<p>a) 8 Steel balls, 1 heavier than all the rest. Use a Balance Scale to determine the heaviest ball in the shortest number of tries.</p>
<p>b) Find how many trailing zeroes are in the product of 100! (100 Factorial). </p>
<p>c) Replace each letter below with a corresponding number from 0 to 8. Each Letter can only be matched to one number (ie, all of the E&#8217;s would be a 3, and that would mean that no other Letter could be a 3). The following addition problem should work after you replace the letters.</p>
<pre>
   S  E  V  E  N
   S  E  V  E  N
+         S   I   X
-----------------------
 T W E N  T   Y
</pre>
</p>
<p><b>Programming Problems</b></p>
<p>a) Write a function that takes an array of integers from 1 to 1 million, with one number being duplicated. Determine which integer is a duplicate, accounting for speed and efficiency.</p>
<p>b) Write a function that takes an array of integers from 1 to 1 million, with one number being missing from the range. Determine the missing integer, account for speed and efficiency.</p>
<p>c) Write a function that takes an array of an number of integers. Determine the largest contiguous sum, meaning given any two integers in the array, what is the highest sum? Given an array such as Array(1, -5, 3, -3, -9, 2) the highest contiguous sum would be 5.</p>
<p>d) Write a function that takes a string as a parameter and determine the first unique character in the string. In other words, given the string &#8220;sissy&#8221; the answer would be &#8220;i&#8221;. Afterwards, how would you optimize the function.</p>
<p>e) Pseudo-code the Ball Clock problem, determining how many cycles it takes for the balls to end up in the same position in the queue tray. Afterwards, how would you optimize the process if it were to be hit thousands of times on a given interface by thousands of users. If you have come up with a pure brute-force method, how could you optimize it further to shorten the processing time?</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.ryanbyrd.net/techramble/2008/09/03/even-more-utah-tech-interview-questions/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Are You Chromed Up?</title>
		<link>http://www.ryanbyrd.net/techramble/2008/09/02/are-you-chromed-up/</link>
		<comments>http://www.ryanbyrd.net/techramble/2008/09/02/are-you-chromed-up/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 20:33:31 +0000</pubDate>
		<dc:creator>me</dc:creator>
		
	<category>software</category>
	<category>announcements</category>
		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/2008/09/02/are-you-chromed-up/</guid>
		<description><![CDATA[Google just released their new browser, Chrome. You can read all about it, comic-style, on Google Books. 
I just downloaded it. I&#8217;ll let you know how it goes
]]></description>
			<content:encoded><![CDATA[<p>Google just released their new browser, <a href="http://www.google.com/chrome">Chrome</a>. You can read all about it, comic-style, on <a href="http://www.google.com/googlebooks/chrome/">Google Books</a>. </p>
<p>I just downloaded it. I&#8217;ll let you know how it goes</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.ryanbyrd.net/techramble/2008/09/02/are-you-chromed-up/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Tech interview question of the day</title>
		<link>http://www.ryanbyrd.net/techramble/2008/06/16/tech-interview-question-of-the-day/</link>
		<comments>http://www.ryanbyrd.net/techramble/2008/06/16/tech-interview-question-of-the-day/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 02:50:41 +0000</pubDate>
		<dc:creator>me</dc:creator>
		
	<category>interviews</category>
		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/2008/06/16/tech-interview-question-of-the-day/</guid>
		<description><![CDATA[it&#8217;s not as difficult as it first looks:
Given two water faucets, one hot and one cold, and one bucket. The hot water fills the empty bucket in eight minutes. The cold water fills the bucket in seven minutes. Then I make a hole in the bucket such that the full bucket drains in four minutes. [...]]]></description>
			<content:encoded><![CDATA[<p>it&#8217;s not as difficult as it first looks:</p>
<blockquote><p>Given two water faucets, one hot and one cold, and one bucket. The hot water fills the empty bucket in eight minutes. The cold water fills the bucket in seven minutes. Then I make a hole in the bucket such that the full bucket drains in four minutes. Now take the empty bucket, with the hole, and place under both faucets together. Turn on the hot and cold water at the same time. How long does it take to fill the bucket halfway?</p></blockquote>
]]></content:encoded>
			<wfw:commentRSS>http://www.ryanbyrd.net/techramble/2008/06/16/tech-interview-question-of-the-day/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>reversing a string, the algorithms</title>
		<link>http://www.ryanbyrd.net/techramble/2008/04/03/reversing-a-string-the-algorithms/</link>
		<comments>http://www.ryanbyrd.net/techramble/2008/04/03/reversing-a-string-the-algorithms/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 16:14:02 +0000</pubDate>
		<dc:creator>me</dc:creator>
		
	<category>code</category>
		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/2008/04/03/reversing-a-string-the-algorithms/</guid>
		<description><![CDATA[reversing a string is a classic tech interview question. of course you&#8217;re not allowed to call any built-in reverse() function. A solution might look like, in my pseudocode:

someString = new string("732432424");
char temp;
int end=someString.length()-1;

for (int x=0;x&#60;end;x++)
{
	temp=someString[end];
	someString[x]=someString[end];
	someString[end]=temp;
	end--;
}

but sometimes the interviewer asks you to reverse the string in place, without using other memory, and for that, we&#8217;ll need [...]]]></description>
			<content:encoded><![CDATA[<p>reversing a string is a classic <a href="http://www.ryanbyrd.net/techramble/2007/02/28/a-programming-interview-question-posed-today/">tech interview question</a>. of course you&#8217;re not allowed to call any built-in reverse() function. A solution might look like, in my pseudocode:</p>
<pre>
someString = new string("732432424");
char temp;
int end=someString.length()-1;

for (int x=0;x&lt;end;x++)
{
	temp=someString[end];
	someString[x]=someString[end];
	someString[end]=temp;
	end--;
}
</pre>
<p>but sometimes the interviewer asks you to reverse the string in place, without using other memory, and for that, we&#8217;ll need our XOR friend</p>
<pre>
A B  XOR
----+---
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 0
</pre>
<pre>
someString = new string("732432424");
char temp;
int end=someString.length()-1; //assume zero based char arrays

for (int x=0;x&lt;end;x++)
{
	someString[x]=someString[x] XOR someString[end];
        // first loop: someString[x]=3
	someString[end]=someString[end] XOR someString[x];
        //first loop: someString[end]=7
	someString[x] = someString[x] XOR someString[end];
       //first loop: someString[x]=4
	end--;
}
</pre>
]]></content:encoded>
			<wfw:commentRSS>http://www.ryanbyrd.net/techramble/2008/04/03/reversing-a-string-the-algorithms/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Recent IM Chat&#8211; Helping a friend get a basic webserver up and running</title>
		<link>http://www.ryanbyrd.net/techramble/2008/01/17/recent-im-chat-helping-a-friend-get-a-basic-webserver-up-and-running/</link>
		<comments>http://www.ryanbyrd.net/techramble/2008/01/17/recent-im-chat-helping-a-friend-get-a-basic-webserver-up-and-running/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 23:42:35 +0000</pubDate>
		<dc:creator>me</dc:creator>
		
	<category>how tos</category>
		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/2008/01/17/recent-im-chat-helping-a-friend-get-a-basic-webserver-up-and-running/</guid>
		<description><![CDATA[ME: did you install xampp?
ME: and, in the xampp control panel, did you start apache?
ME: and, in a browser, did you go to http://localhost
ME: and, once, there, did you see a xampp welcome message?
SOMEGUY: yes, yes and yes
ME: when you go to http://www.whatismyip.com what does it say for your ip address?
SOMEGUY: [address ]
ME: is that [...]]]></description>
			<content:encoded><![CDATA[<p><b>ME:</b> did you install xampp?<br />
<b>ME:</b> and, in the xampp control panel, did you start apache?<br />
<b>ME:</b> and, in a browser, did you go to http://localhost<br />
<b>ME:</b> and, once, there, did you see a xampp welcome message?<br />
<b>SOMEGUY:</b> yes, yes and yes<br />
<b>ME:</b> when you go to http://www.whatismyip.com what does it say for your ip address?<br />
<b>SOMEGUY:</b> [address ]<br />
<b>ME:</b> is that computer running microsoft&#8217;s firewall? if so, can you shut it off?<br />
<b>SOMEGUY:</b> ok<br />
<b>ME:</b> are you using a local router/firewall? if so, you need to let/forward port 80 through to that &#8220;server&#8221;<br />
<b>ME:</b> the point is that port 80 is not responding externally, so we need to fix it. to get into your router, you just need to know your default gateway. <br />
<b>ME:</b> start->run<br />
<b>ME:</b> type &#8220;cmd&#8221;<br />
<b>ME:</b> then type &#8220;ipconfig&#8221; (no quotes) and press enter<br />
<b>ME:</b> you&#8217;re looking for the Default Gateway IP address<br />
<b>SOMEGUY:</b> it is 192.168.1.1<br />
<b>ME:</b> ok. go to that in a browser<br />
<b>ME:</b> if you use default linksys settings, there will be no username and the password is admin<br />
<b>ME:</b> ok, so there should be some provision for forwarding ports.<br />
<b>ME:</b> sometimes it&#8217;s under firewall->single port forwarding<br />
<b>ME:</b> you&#8217;ll need to forward port 80 to the ip address of that server computer<br />
<b>ME:</b> it says prot range forward<br />
<b>ME:</b> yeah, so you can forward 80 to 80 to the ip of the server at 80 to 80<br />
<b>ME:</b> you can find the ip of that server by doing the start->run, cmd, ipconfig command again<br />
<b>ME:</b> go to http://www.[sitename].com/ (i set up DNS for you)<br />
<b>ME:</b> does it work for you?<br />
<b>SOMEGUY:</b> it brings up xampp for windows<br />
<b>ME:</b> yup, that means it&#8217;s working<br />
<b>ME:</b> ok, now we need to edit us some files<br />
<b>ME:</b> step 1<br />
<b>ME:</b> in that folder create a file called index.html, and in that file put &#8220;hello world&#8221;<br />
<b>ME:</b> you could use notepad to create a new text file, but when you save it, be sure it doesn&#8217;t append a .txt to the end of index.html<br />
<b>SOMEGUY:</b> can i use word<br />
<b>ME:</b> if word allows you save in plain text format, then yes<br />
<b>ME:</b> again, make sure the file name is index.html and not index.html.txt<br />
<b>ME:</b> when you browse that folder (c:\xampp\htdocs\[sitename]) can you now see a little browser file icon called index, and if you double click it, does ie open a window with the text you typed in?<br />
<b>SOMEGUY:</b> yes<br />
<b>ME:</b> now time to edit another file<br />
<b>ME:</b> go to: C:\xampp\apache\conf\extra<br />
<b>ME:</b> and use notepad to edit httpd-vhosts.conf<br />
<b>ME:</b> delete everything out of that file, and paste in the following:<br />
<b>ME:</b> NameVirtualHost *:80<br />
<VirtualHost *:80><br />
    DocumentRoot &#8220;C:\xampp\htdocs\[sitename]&#8221;<br />
    ServerName *.[sitename].com<br />
</VirtualHost><br />
<b>ME:</b> then save that file<br />
<b>ME:</b> and then stop and start xampp<br />
<b>ME:</b> from the control panel<br />
<b>ME:</b> start and stop apache, i mean, from the control panel<br />
<b>ME:</b> go to http://www.[sitename].com/<br />
<b>SOMEGUY:</b> i stopped it and started it<br />
<b>ME:</b> what do you see?<br />
<b>SOMEGUY:</b> HELLO WORLD<br />
<b>ME:</b> that&#8217;s what I see, too. you&#8217;re hosting a webpage now for the ENTIRE WORLD!!!<br />
<b>ME:</b> you&#8217;ll probably need dreamweaver (which you can get a trial version free download) to start pimping out your site<br />
<b>ME:</b> the point is that anything you place in c:\xampp\htdocs\[sitename] will be accessable to the world on www.[sitename].com<br />
<b>ME:</b> so, if you had an mp3 called &#8220;mysong.mp3&#8243; and you copied it into c:\xampp\htdocs\[sitename] your friends could download it by going to http://www.[sitename].com/mysong.mp3<br />
<b>ME:</b> the html files are for your webpages, but the server will serve up any file you place in that folder<br />
<b>SOMEGUY:</b> how do i make links<br />
<b>ME:</b> dreamweaver is a good editor and you can get lots of cool templates free.<br />
<b>ME:</b> in dreamweaver it&#8217;s easy. if you&#8217;re editing raw html text, a link looks like this<br />
<b>SOMEGUY:</b> i now have an mp3 in that folder<br />
<b>ME:</b> obviously, you don&#8217;t want the mpaa to know you&#8217;re hosting mp3s. it&#8217;s illegal and all. i was just providing you an example<br />
<b>ME:</b> that index file is the root file that apache/xampp will serve up if the filename is not explicited stated in the URL. you should just point dreamweaver to that file to edit it.<br />
<b>ME:</b> you can, obviously, add more files to that folder, for other pages on your site. maybe a songs.html, for a list of your songs. then you just link to songs.html from your index.html<br />
<b>ME:</b> as well, because apache/xampp uses index.html as the default name, if you wanted www.[sitename].com/songs to work (instead of songs.html), you simply need to create a subfolder in c:\xampp\htdocs\[sitename] called songs and put an index.html file in that subfolder with your song list</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.ryanbyrd.net/techramble/2008/01/17/recent-im-chat-helping-a-friend-get-a-basic-webserver-up-and-running/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>two interesting PHP items for the day</title>
		<link>http://www.ryanbyrd.net/techramble/2007/11/21/two-interesting-php-items-for-the-day/</link>
		<comments>http://www.ryanbyrd.net/techramble/2007/11/21/two-interesting-php-items-for-the-day/#comments</comments>
		<pubDate>Wed, 21 Nov 2007 22:24:01 +0000</pubDate>
		<dc:creator>me</dc:creator>
		
	<category>code</category>
		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=35</guid>
		<description><![CDATA[1. http://www.php.net/manual/en/control-structures.alternative-syntax.php shows an alternative syntax for loops:

    foreach($list as $item)
    {
        echo $item;
    } 

can be done as:

    foreach($list as $item):
        echo $item;
    endforeach

2. if [...]]]></description>
			<content:encoded><![CDATA[<p>1. http://www.php.net/manual/en/control-structures.alternative-syntax.php shows an alternative syntax for loops:</p>
<pre>
    foreach($list as $item)
    {
        echo $item;
    } 

can be done as:

    foreach($list as $item):
        echo $item;
    endforeach
</pre>
<p>2. if your server has short tags enabled, you can do this:</p>
<pre>
&lt;?

$somevar="hello";

?&gt;

&lt;?=$somevar?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRSS>http://www.ryanbyrd.net/techramble/2007/11/21/two-interesting-php-items-for-the-day/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>linux shell script to monitor running program</title>
		<link>http://www.ryanbyrd.net/techramble/2007/11/01/linux-shell-script-to-monitor-running-program/</link>
		<comments>http://www.ryanbyrd.net/techramble/2007/11/01/linux-shell-script-to-monitor-running-program/#comments</comments>
		<pubDate>Thu, 01 Nov 2007 21:31:25 +0000</pubDate>
		<dc:creator>me</dc:creator>
		
	<category>how tos</category>
	<category>code</category>
	<category>hacks</category>
		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=34</guid>
		<description><![CDATA[this script checks to see if a program is running and starts it if it is not. if a certain time has passed the script will kill the running program
#!/bin/bash
&#160;
#location of script to monitor
PROGRAM=&#8216;myscript.php&#8217;
COUNTER=0
&#160;
#!/bin/bash
&#160;
date2stamp &#40;&#41; &#123;
    date &#8211;utc &#8211;date &#34;$1&#34; +%s
&#125;
&#160;
# convert a date into a UNIX timestamp
# time afterwhich script should [...]]]></description>
			<content:encoded><![CDATA[<p>this script checks to see if a program is running and starts it if it is not. if a certain time has passed the script will kill the running program</p>
<pre class="bash bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#location of script to monitor</span>
<span style="color: #007800;">PROGRAM</span>=<span style="color: #ff0000;">&#8216;myscript.php&#8217;</span>
<span style="color: #007800;">COUNTER</span>=0
&nbsp;
<span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
date2stamp <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #660033;">&#8211;utc</span> <span style="color: #660033;">&#8211;date</span> <span style="color: #ff0000;">&quot;$1&quot;</span> +<span style="color: #000000; font-weight: bold;">%</span>s
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># convert a date into a UNIX timestamp</span>
<span style="color: #666666; font-style: italic;"># time afterwhich script should not run</span>
<span style="color: #007800;">finishtime</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>date2stamp <span style="color: #ff0000;">&quot;Thu Nov  1 15:22:00 MDT 2007&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #666666; font-style: italic;">#echo $finishtime</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;
<span style="color: #000000; font-weight: bold;">do</span>
&nbsp;
<span style="color: #007800;">nowtime</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #660033;">&#8211;utc</span> +<span style="color: #000000; font-weight: bold;">%</span>s<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #666666; font-style: italic;">#echo $nowtime</span>
<span style="color: #007800;">diffTime</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>finishtime-nowtime<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>diffTime <span style="color: #000000; font-weight: bold;">&gt;</span> 0<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;still time to go&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;TIME UP!: checking if running:&quot;</span>
<span style="color: #007800;">PROG_CHECK</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> aux|<span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$PROGRAM</span>|<span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$PROG_CHECK</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;
<span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;running after time up&quot;</span>
<span style="color: #007800;">PROG_ID</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> uax|<span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$PROGRAM</span> |<span style="color: #c20cb9; font-weight: bold;">head</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">1</span>|<span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">&#8216;{print $2}&#8217;</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #666666; font-style: italic;">#echo &quot;KILLING&quot;</span>
<span style="color: #666666; font-style: italic;">#kill -9 $PROG_ID</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;not running after time up&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">65</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
&nbsp;
<span style="color: #007800;">PROG_CHECK</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> aux|<span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$PROGRAM</span>|<span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$PROG_CHECK</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;
<span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;running&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #7a0874; font-weight: bold;">let</span> <span style="color: #007800;">COUNTER</span>=COUNTER+<span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;not running: starting: new log file: $COUNTER&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$PROGRAM</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#time in seconds to sleep</span>
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">5</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">done</span></pre>
]]></content:encoded>
			<wfw:commentRSS>http://www.ryanbyrd.net/techramble/2007/11/01/linux-shell-script-to-monitor-running-program/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>latin1 to utf8 character set conversion for MySQL</title>
		<link>http://www.ryanbyrd.net/techramble/2007/10/31/latin1-to-utf8-character-set-conversion-for-mysql/</link>
		<comments>http://www.ryanbyrd.net/techramble/2007/10/31/latin1-to-utf8-character-set-conversion-for-mysql/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 16:44:22 +0000</pubDate>
		<dc:creator>me</dc:creator>
		
	<category>how tos</category>
	<category>code</category>
		<guid isPermaLink="false">http://www.ryanbyrd.net/techramble/?p=33</guid>
		<description><![CDATA[We recently upgraded from MySQL 4 to MySQL 5 and we noticed strange characters in some of the varchar and text fields. 
step 1: dump out the contents of the bad field in hex
mysql> select hex(myfieldname) from mytablename where myid=&#8217;something&#8217;;
step 2: run a php program to print out the chars one at a time
function hex2asc&#40;$temp&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>We recently upgraded from MySQL 4 to MySQL 5 and we noticed strange characters in some of the varchar and text fields. </p>
<p><strong>step 1</strong>: dump out the contents of the bad field in hex<br />
mysql> select hex(myfieldname) from mytablename where myid=&#8217;something&#8217;;</p>
<p><strong>step 2</strong>: run a php program to print out the chars one at a time</p>
<pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> hex2asc<span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$len</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp</span><span style="color: #009900;">&#41;</span>;
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color:#800080;">0</span>;<span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000088;">$len</span>;<span style="color: #000088;">$i</span><span style="color: #339933;">+=</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><a href="http://www.php.net/chr"><span style="color: #990000;">chr</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/hexdec"><span style="color: #990000;">hexdec</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp</span><span style="color: #339933;">,</span><span style="color: #000088;">$i</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;  &quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$temp</span><span style="color: #339933;">,</span><span style="color: #000088;">$i</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>;
&nbsp;
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span>;
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$str</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;HEX GOES HERE&quot;</span>;
<span style="color: #000088;">$data</span><span style="color: #339933;">=</span>hex2asc<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span>;
<a href="http://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span>;</pre>
<p><strong>step 3</strong>: once you&#8217;ve identified the bad chars and their hex values, change them in the database</p>
<p><strong>here are some bad chars I found:</strong></p>
<p>&#8211; fix apostrophe<br />
 update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(&#8217;92&#8242;),&#8221;&#8216;&#8221;);</p>
<p>&#8211; fix left single quote<br />
 update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(&#8217;93&#8242;),&#8221;&#8216;&#8221;);</p>
<p>&#8211; fix right single quote<br />
 update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(&#8217;94&#8242;),&#8221;&#8216;&#8221;);</p>
<p>&#8211; fix bullets<br />
 update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(&#8217;95&#8242;),&#8221;&#038; #8226;&#8221;);</p>
<p>&#8211; fix double dash<br />
 update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(&#8217;96&#8242;),&#8221;&#8211;&#8221;);</p>
<p>&#8211; fix triple dash<br />
 update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(&#8217;97&#8242;),&#8221;&#8212;&#8221;);</p>
<p>&#8212; fix supscripted TM<br />
 update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(&#8217;99&#8242;),&#8221;&lt;sup>TM&lt;/sup>&#8221;);</p>
<p>&#8211; replace jacked up apostrophe/single quote<br />
&#8211; delete EFs<br />
 update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(&#8217;EF&#8217;),&#8221;");<br />
&#8211; replace BFs with single quote<br />
 update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(&#8217;BF&#8217;),&#8221;&#8216;&#8221;);<br />
&#8211; delete BDs<br />
 update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(&#8217;BD&#8217;),&#8221;");</p>
<p>see also: http://www.oreillynet.com/onlamp/blog/2006/01/turning_mysql_data_in_latin1_t.html</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.ryanbyrd.net/techramble/2007/10/31/latin1-to-utf8-character-set-conversion-for-mysql/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
