<?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>Eddie On Everything &#187; code</title>
	<atom:link href="http://www.eddieoneverything.com/tag/code/feed" rel="self" type="application/rss+xml" />
	<link>http://www.eddieoneverything.com</link>
	<description>Tips &#38; tricks on things that interest me</description>
	<lastBuildDate>Wed, 11 Jan 2012 08:29:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Managing Server Load when unzipping many large files</title>
		<link>http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php</link>
		<comments>http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php#comments</comments>
		<pubDate>Fri, 22 Apr 2011 17:32:37 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[red hat]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php</guid>
		<description><![CDATA[So, I have about 500 zipped up files that I needed to unzip.&#160; 
Each of these files is about 100M when decompressed.&#160; 
I ran into a big problem when unzipping the files all at once – when I did a simple “unzip \*zip&#34;, the server load eventually skyrocketed.&#160; 
The load got so high, in fact, [...]]]></description>
			<content:encoded><![CDATA[<p>So, I have about 500 zipped up files that I needed to unzip.&#160; </p>
<p>Each of these files is about 100M when decompressed.&#160; </p>
<p>I ran into a big problem when unzipping the files all at once – when I did a simple “<a href="http://www.eddieoneverything.com/linux/caution-filename-not-matched-error-when-unzipping-multiple-files-workaround.php" target="_blank">unzip \*zip</a>&quot;, the server load eventually skyrocketed.&#160; </p>
<p>The load got so high, in fact, that mySQL and httpd couldn’t even keep up with the incoming web requests, and the mySQL database eventually crashed.  Well, it didn&#8217;t exactly crash, but the requests got so stacked up that it stopped accepting new connections, so it might as well have been crashed.</p>
<p>I assume that this is because the Linux server (Red Hat, in my case) has to do a bunch of “behind the scenes” type things when allocating large chunks of space for new files.&#160; You know, file system record keeping, delayed disk I/O, things like that.</p>
<p>&#8220;nice -n19&#8243; wasn&#8217;t doing the job, so I tried doing a simple batch file that would sleep 10 seconds before unzipping each file.&#160; This worked, for the most part, but the server load eventually got higher than I like to see. Left alone, the whole thing could have cascaded out of control again, especially given that I wasn’t taking into account the *other* things the server may have been doing at the time.  And I wanted to go to lunch, so hanging out and watching it wasn&#8217;t an attractive option.</p>
<p>I decided to write a simple script that checked the server load via /proc/loadavg, then only performed the unzip operation if the load was below a certain value. </p>
<p>Here’s my script, written in Perl.</p>
<pre name="code" class="perl">
#!/usr/bin/perl

$MAX_LOAD = .9;

open hIN, "&lt;files";

while (&lt;hIN&gt;){
   $filename = $_;
   chomp($filename);

   $cmd = "unzip \"$filename\"";

   print "$cmd\n";
   print `$cmd`;

   # Get the load average
   do {
      $load = `cat /proc/loadavg  | cut -f1 -d " "`;
      chomp($load);

      if ($load > $MAX_LOAD){
         print "Load is $load - Sleeping\n";
         sleep (5);
      }

   }while ($load > $MAX_LOAD);

}
close hIN;
</pre>
<p>I chose to keep the server load below 0.9, a nice number, IMHO.</p>
<p><b>Update:</b> I&#8217;ve done a little more <a href="http://www.commandlinefu.com/commands/view/49/run-a-command-only-when-load-average-is-below-a-certain-threshold" target="_blank">checking around</a>, and I see that there&#8217;s a Unix command that will do a lot of this for you &#8211; the &#8220;batch&#8221; command will only execute a command when the server load drops below a certain threshold.  The default is 0.8.  Good to know.</p>
<p>
The method I outline above is still useful in other instances where &#8220;batch&#8221; can&#8217;t be used.  For instance, I&#8217;m now using this method of checking the server load in a data loading script.  I parse my input files, generate sql &#038; execute it.  Then, every couple thousand queries or so I check the server load.  If it&#8217;s getting too high, the script sleeps until the load falls to an acceptable level.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php" title="The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel">The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel</a></li><li><a href="http://www.eddieoneverything.com/linux/rotating-backup-directories-using-cp-al-hardlinks-to-save-disk-space.php" title="Rotating Backup Directories using cp -al (hardlinks) to Save Disk Space">Rotating Backup Directories using cp -al (hardlinks) to Save Disk Space</a></li><li><a href="http://www.eddieoneverything.com/linux/using-rsync-ssh-to-backup-files-between-linux-machines-perl.php" title="Using rsync &#038; ssh to Backup Files Between Linux Machines (Perl)">Using rsync &#038; ssh to Backup Files Between Linux Machines (Perl)</a></li><li><a href="http://www.eddieoneverything.com/linux/argument-list-too-long-from-rm-command-a-perl-script-to-get-around-the-problem.php" title="&#8220;Argument list too long&#8221; from rm command.   A Perl Script to Get Around the Problem">&#8220;Argument list too long&#8221; from rm command.   A Perl Script to Get Around the Problem</a></li><li><a href="http://www.eddieoneverything.com/articles/linux-forward-file-not-working-make-sure-you-have-the-permissions-set-correctly.php" title="Linux .forward file not working?  Make sure you have the permissions set correctly">Linux .forward file not working?  Make sure you have the permissions set correctly</a></li><li><a href="http://www.eddieoneverything.com/linux/caution-filename-not-matched-error-when-unzipping-multiple-files-workaround.php" title="Caution: filename not matched error when unzipping multiple files workaround">Caution: filename not matched error when unzipping multiple files workaround</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php" title="How to Scan a Computer for Open Ports">How to Scan a Computer for Open Ports</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Scan a Computer for Open Ports</title>
		<link>http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php</link>
		<comments>http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php#comments</comments>
		<pubDate>Fri, 08 Apr 2011 21:27:13 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[red had]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php</guid>
		<description><![CDATA[There are a bunch of GUI utilities for conducting port scans, but I prefer to work from a command line shell.&#160; 
In the past, I’ve used a custom script for scanning a machine for open ports from the command line, but I recently needed to get a little more information from a scan than my [...]]]></description>
			<content:encoded><![CDATA[<p>There are a bunch of GUI utilities for conducting port scans, but I prefer to work from a command line shell.&#160; </p>
<p>In the past, I’ve used a custom script for scanning a machine for open ports from the command line, but I recently needed to get a little more information from a scan than my meager little script provides.</p>
<p>I did some research and found <a href="http://ubuntuforums.org/showthread.php?t=202472" target="_blank">this useful tidbit on a Ubuntu forums</a> site.</p>
<p>If you have any flavor of Linux, you should be able to use nmap to produce a map of open ports on a remote machine.</p>
<p>The command:</p>
<p>  <code>nmap -sS -sV –O&#160; &lt;IP ADDRESS&gt; </code>
<p>Where the flags mean:</p>
<p>-sS: TCP SYN (Half-open) scan</p>
<p>-sV: Probe open ports to determine service/version info</p>
<p>-O: Enable OS detection</p>
<p>And example of the output:</p>
<p>  <code><a href="mailto:root@frolicanddetour:/home/eddie/bin">root@frolicanddetour:/home/eddie/bin</a># nmap -sS -sV -O localhost</p>
<p>Starting Nmap 5.00 ( <a href="http://nmap.org">http://nmap.org</a> ) at 2011-04-08 16:40 CDT     <br />Interesting ports on localhost (127.0.0.1):     <br />Not shown: 991 closed ports     <br />PORT&#160;&#160;&#160;&#160; STATE SERVICE&#160;&#160;&#160;&#160; VERSION     <br />22/tcp&#160;&#160; open&#160; ssh&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; OpenSSH 5.3p1 Debian 3ubuntu4 (protocol 2.0)     <br />25/tcp&#160;&#160; open&#160; smtp&#160;&#160;&#160;&#160;&#160;&#160;&#160; Postfix smtpd     <br />80/tcp&#160;&#160; open&#160; http&#160;&#160;&#160;&#160;&#160;&#160;&#160; Apache httpd 2.2.14 ((Ubuntu))     <br />139/tcp&#160; open&#160; netbios-ssn Samba smbd 3.X (workgroup: GINGERALE)     <br />443/tcp&#160; open&#160; ssl/http&#160;&#160;&#160; Apache httpd 2.2.14 ((Ubuntu))     <br />445/tcp&#160; open&#160; netbios-ssn Samba smbd 3.X (workgroup: GINGERALE)     <br />631/tcp&#160; open&#160; ipp&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CUPS 1.4     <br />3306/tcp open&#160; mysql&#160;&#160;&#160;&#160;&#160;&#160; MySQL 5.1.41-3ubuntu12.6     <br />5901/tcp open&#160; tcpwrapped</code>
<p>You will have to be logged in as root to run this scan.&#160; I like to set up an alias on my standard user account that employs sudo, like so:</p>
<p>  <code>alias portscan=&quot;sudo nmap -sS -sV -O $1&quot;</code></p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php" title="The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel">The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel</a></li><li><a href="http://www.eddieoneverything.com/linux/argument-list-too-long-from-rm-command-a-perl-script-to-get-around-the-problem.php" title="&#8220;Argument list too long&#8221; from rm command.   A Perl Script to Get Around the Problem">&#8220;Argument list too long&#8221; from rm command.   A Perl Script to Get Around the Problem</a></li><li><a href="http://www.eddieoneverything.com/linux/rotating-backup-directories-using-cp-al-hardlinks-to-save-disk-space.php" title="Rotating Backup Directories using cp -al (hardlinks) to Save Disk Space">Rotating Backup Directories using cp -al (hardlinks) to Save Disk Space</a></li><li><a href="http://www.eddieoneverything.com/articles/linux-forward-file-not-working-make-sure-you-have-the-permissions-set-correctly.php" title="Linux .forward file not working?  Make sure you have the permissions set correctly">Linux .forward file not working?  Make sure you have the permissions set correctly</a></li><li><a href="http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php" title="Managing Server Load when unzipping many large files">Managing Server Load when unzipping many large files</a></li><li><a href="http://www.eddieoneverything.com/linux/caution-filename-not-matched-error-when-unzipping-multiple-files-workaround.php" title="Caution: filename not matched error when unzipping multiple files workaround">Caution: filename not matched error when unzipping multiple files workaround</a></li><li><a href="http://www.eddieoneverything.com/linux/how-to-keep-an-ssh-connection-alive-in-linux.php" title="How To Keep An SSH Connection Alive in Linux">How To Keep An SSH Connection Alive in Linux</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disabling TextArea Scrolling in Flash AS3</title>
		<link>http://www.eddieoneverything.com/articles/disabling-textarea-scrolling-in-flash-as3.php</link>
		<comments>http://www.eddieoneverything.com/articles/disabling-textarea-scrolling-in-flash-as3.php#comments</comments>
		<pubDate>Tue, 23 Nov 2010 05:48:49 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/articles/disabling-textarea-scrolling-in-flash-as3.php</guid>
		<description><![CDATA[Had a problem while working on a new Flash App today.
I have a number of dynamic text fields (TextAreas), and they scroll in-place when the user highlights the text and when the user uses the mouse wheel while hovering over them.
I searched for a way to stop this scrolling for quite a while and found [...]]]></description>
			<content:encoded><![CDATA[<p>Had a problem while working on a new Flash App today.</p>
<p>I have a number of dynamic text fields (TextAreas), and they scroll in-place when the user highlights the text and when the user uses the mouse wheel while hovering over them.</p>
<p>I searched for a way to stop this scrolling for quite a while and found a few solutions that weren’t quite up to par.  For instance, one solution had me disabling the highlight-ability of the text and also disabling the scroll wheel on the text.  This wouldn’t be ideal for my app, as I want users to be able to highlight text.  I just don’t want it to scroll!</p>
<p>Code that isn’t ideal:</p>
<pre name="code" class="javascript">
myText.mouseEnabled = false;

myText.mouseWheelEnabled = false;
</pre>
<p>Also, this code didn’t exactly “work” as expected, either – I still ran in to occasional scrolling issues.</p>
<p>I discovered that the problem is due to Action Script 3’s (AS3) TextFieldAutoSize property.  When a text area is set to “auto size,” it’s just a *little bit* small by default, and the Flash player will let a user scroll that text if he tries hard enough.</p>
<p>I found a <a href="http://www.kirupa.com/forum/showthread.php?t=288955" target="_blank">thread on kirupa</a> that pointed me in the right direction.  Though it didn’t work out of the box, I was able to create my own AS3 function that effectively disables scrolling on text areas in AS3.</p>
<p>Here is the function I wrote, along with an example of how you can use it:</p>
<pre name="code" class="javascript">
function autoSizeTF(tf:TextField){
     var tempHeight:Number;
     var padding:Number = 2;
     tf.autoSize = TextFieldAutoSize.LEFT;
     tempHeight = tf.height;

     tf.autoSize = TextFieldAutoSize.NONE;
     tf.height = tempHeight + padding;
}

autoSizeTF(ca_mc.question_txt);
</pre>
<p>What this function does is first convert the field to an Auto Size field, get the height, then set it back to a non-Auto Sized text area with the proper height, plus some padding.</p>
<p>This function has disabled mouse wheel scrolling on the text fields, and it has disabled highlighted text scrolling as well.</p>
<p>It took me about 2 hours to find/come up with this solution.  I hope it helps you.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/flash-9-as3/as3-error-1046-type-was-not-found-or-was-not-a-compile-time-constant.php" title="AS3 Error:  1046: Type was not found or was not a compile-time constant">AS3 Error:  1046: Type was not found or was not a compile-time constant</a></li><li><a href="http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php" title="Managing Server Load when unzipping many large files">Managing Server Load when unzipping many large files</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php" title="How to Scan a Computer for Open Ports">How to Scan a Computer for Open Ports</a></li><li><a href="http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php" title="The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel">The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel</a></li><li><a href="http://www.eddieoneverything.com/articles/making-yahoo-sports-fantasy-pro-football-pickem-sortable.php" title="Making Yahoo! Sports Fantasy Pro Football Pickem Sortable">Making Yahoo! Sports Fantasy Pro Football Pickem Sortable</a></li><li><a href="http://www.eddieoneverything.com/articles/mod_rewrite-in-htaccess-to-force-www-in-url-not-working.php" title="mod_rewrite in .htaccess to Force www in URL Not Working ">mod_rewrite in .htaccess to Force www in URL Not Working </a></li><li><a href="http://www.eddieoneverything.com/programming/mysql-performance-tip-on-duplicate-key-is-faster-than-insert-ignore-but-failing-with-a-duplicate-key-error-is-a-lot-faster.php" title="MySQL Performance Tip:  ON DUPLICATE KEY is faster than INSERT IGNORE, but failing with a duplicate key error is a lot faster">MySQL Performance Tip:  ON DUPLICATE KEY is faster than INSERT IGNORE, but failing with a duplicate key error is a lot faster</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/articles/disabling-textarea-scrolling-in-flash-as3.php/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel</title>
		<link>http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php</link>
		<comments>http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php#comments</comments>
		<pubDate>Fri, 22 Oct 2010 17:05:29 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[red hat]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/?p=1306</guid>
		<description><![CDATA[Saw this great article by Ted Dziuba that parallels my programming philosophy.
( In case you&#8217;re interested, here&#8217;s a reddit thread on the article. )
In short, the article states that much of what you want to accomplish with any project is possible with the standard, tried-and-true Unix tools.  When you shun these tools in favor [...]]]></description>
			<content:encoded><![CDATA[<p>Saw this <a href="http://teddziuba.com/2010/10/taco-bell-programming.html">great article by Ted Dziuba</a> that parallels my programming philosophy.</p>
<p>( In case you&#8217;re interested, here&#8217;s a <a href="http://www.reddit.com/r/programming/comments/durvk/taco_bell_programming_old_and_reliable_beats_new/">reddit thread</a> on the article. )</p>
<p>In short, the article states that much of what you want to accomplish with any project is possible with the standard, tried-and-true Unix tools.  When you shun these tools in favor of the latest-and-greatest buzzword tool or library, you&#8217;re not only introducing a lot of unnecessary complexity at the get-go, but you&#8217;re taking on the responsibility of maintaining that code.  You&#8217;re also introducing a lot of uncertainty by shunning a near-bulletproof method for a new-kid-on-the-block library that hasn&#8217;t had the benefit of being around the block a few billion times over the last 40 years.</p>
<p>I can&#8217;t tell you how many times others have looked at my code and called it &#8220;messy&#8221; because I tend to make use of standard Unix utilities rather than the newfangled libraries.  Hey, I tell them, I just wanted to write a quick script that accomplishes a simple task in as little time as possible.  I want it to be reliable, and I want it to &#8220;just work.&#8221;  If I had done it your way, it would have taken me 6 hours instead of just 20 minutes.  And it probably would have broken in a year or two.  Unix&#8217;s find, xargs, cat, sort, wget, grep, awk, et al, all work splendidly.  Why reinvent the wheel?</p>
<p>Dziuba provides an excellent example:</p>
<blockquote><p>Here&#8217;s a concrete example: suppose you have millions of web pages that you want to download and save to disk for later processing. How do you do it? The cool-kids answer is to write a distributed crawler in Clojure and run it on EC2, handing out jobs with a message queue like SQS or ZeroMQ.</p>
<p>The Taco Bell answer? xargs and wget. In the rare case that you saturate the network connection, add some split and rsync. A &#8220;distributed crawler&#8221; is really only like 10 lines of shell script.</p>
<p>Moving on, once you have these millions of pages (or even tens of millions), how do you process them? Surely, Hadoop MapReduce is necessary, after all, that&#8217;s what Google uses to parse the web, right?</p>
<p>Pfft, fuck that noise:</p>
<p>find crawl_dir/ -type f -print0 | xargs -n1 -0 -P32 ./process</p>
<p>32 concurrent parallel parsing processes and zero bullshit to manage. Requirement satisfied.</p></blockquote>
<p>Simple, yet brilliant.  </p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php" title="How to Scan a Computer for Open Ports">How to Scan a Computer for Open Ports</a></li><li><a href="http://www.eddieoneverything.com/linux/how-to-keep-an-ssh-connection-alive-in-linux.php" title="How To Keep An SSH Connection Alive in Linux">How To Keep An SSH Connection Alive in Linux</a></li><li><a href="http://www.eddieoneverything.com/linux/argument-list-too-long-from-rm-command-a-perl-script-to-get-around-the-problem.php" title="&#8220;Argument list too long&#8221; from rm command.   A Perl Script to Get Around the Problem">&#8220;Argument list too long&#8221; from rm command.   A Perl Script to Get Around the Problem</a></li><li><a href="http://www.eddieoneverything.com/articles/linux-forward-file-not-working-make-sure-you-have-the-permissions-set-correctly.php" title="Linux .forward file not working?  Make sure you have the permissions set correctly">Linux .forward file not working?  Make sure you have the permissions set correctly</a></li><li><a href="http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php" title="Managing Server Load when unzipping many large files">Managing Server Load when unzipping many large files</a></li><li><a href="http://www.eddieoneverything.com/linux/caution-filename-not-matched-error-when-unzipping-multiple-files-workaround.php" title="Caution: filename not matched error when unzipping multiple files workaround">Caution: filename not matched error when unzipping multiple files workaround</a></li><li><a href="http://www.eddieoneverything.com/linux/rotating-backup-directories-using-cp-al-hardlinks-to-save-disk-space.php" title="Rotating Backup Directories using cp -al (hardlinks) to Save Disk Space">Rotating Backup Directories using cp -al (hardlinks) to Save Disk Space</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making Yahoo! Sports Fantasy Pro Football Pickem Sortable</title>
		<link>http://www.eddieoneverything.com/articles/making-yahoo-sports-fantasy-pro-football-pickem-sortable.php</link>
		<comments>http://www.eddieoneverything.com/articles/making-yahoo-sports-fantasy-pro-football-pickem-sortable.php#comments</comments>
		<pubDate>Fri, 15 Oct 2010 00:53:21 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[fantasy football]]></category>
		<category><![CDATA[fantasy pick em]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/?p=1264</guid>
		<description><![CDATA[I play Yahoo! Fantasy Sports Pro Football Pickem.
In it, you pick the winner of each NFL game every week.
I play a version that requires you to not only pick the winner, but to assign &#8220;confidence points&#8221; to each pick as well &#8211; that is, you assign a score to each pick indicating how confident you [...]]]></description>
			<content:encoded><![CDATA[<p>I play <a href="http://football.fantasysports.yahoo.com/pickem">Yahoo! Fantasy Sports Pro Football Pickem</a>.</p>
<p>In it, you pick the winner of each NFL game every week.</p>
<p>I play a version that requires you to not only pick the winner, but to assign &#8220;confidence points&#8221; to each pick as well &#8211; that is, you assign a score to each pick indicating how confident you are about that pick.</p>
<p>The Yahoo! interface kinda sucks, though.  In order to rank your teams, you have to use drop-down menus instead of a snazzy drag-and-drop interface.  It&#8217;s kinda annoying.</p>
<p>I was inspired to create a little bit of Javascript code that allows you to arrange your picks using drag-and-drop. </p>
<p>To use my code as a bookmarket, simple drag this link to to your bookmarks bar.  (Or if you&#8217;re using IE, right click on the link and choose &#8220;Add to favorites.&#8221;  You may get a message that says &#8220;this link might not be safe.&#8221;  Ignore that.  It&#8217;s perfectly safe &#8211; IE is only popping up the message because the link you&#8217;re adding contains some javascript.)</p>
<blockquote><p>
<b>Drag or Save this Link to Favorites:</b>  <a href="javascript:var s = document.createElement('script');s.type='text/javascript';document.body.appendChild(s);s.src='http://www.eddieoneverything.com/code_archive/yahoo_fantasy_sort/sort.js';void(0);" title="y! ff sort">y! ff sort</a>
</p></blockquote>
<p>Now navigate to your weekly picks page at <a href="http://football.fantasysports.yahoo.com/pickem">Yahoo!</a> and click the bookmark.  You should get a dialog confirming that you may now make your picks by dragging and dropping them.  Magic!   (Be sure to hit &#8220;save&#8221; when you&#8217;re finished.)</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php" title="Managing Server Load when unzipping many large files">Managing Server Load when unzipping many large files</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php" title="How to Scan a Computer for Open Ports">How to Scan a Computer for Open Ports</a></li><li><a href="http://www.eddieoneverything.com/articles/disabling-textarea-scrolling-in-flash-as3.php" title="Disabling TextArea Scrolling in Flash AS3">Disabling TextArea Scrolling in Flash AS3</a></li><li><a href="http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php" title="The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel">The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel</a></li><li><a href="http://www.eddieoneverything.com/articles/mod_rewrite-in-htaccess-to-force-www-in-url-not-working.php" title="mod_rewrite in .htaccess to Force www in URL Not Working ">mod_rewrite in .htaccess to Force www in URL Not Working </a></li><li><a href="http://www.eddieoneverything.com/programming/mysql-performance-tip-on-duplicate-key-is-faster-than-insert-ignore-but-failing-with-a-duplicate-key-error-is-a-lot-faster.php" title="MySQL Performance Tip:  ON DUPLICATE KEY is faster than INSERT IGNORE, but failing with a duplicate key error is a lot faster">MySQL Performance Tip:  ON DUPLICATE KEY is faster than INSERT IGNORE, but failing with a duplicate key error is a lot faster</a></li><li><a href="http://www.eddieoneverything.com/programming/how-to-use-global-variables-from-another-file-in-a-perl-module-or-package.php" title="How To Use Global Variables From Another File In A Perl Module or Package">How To Use Global Variables From Another File In A Perl Module or Package</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/articles/making-yahoo-sports-fantasy-pro-football-pickem-sortable.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mod_rewrite in .htaccess to Force www in URL Not Working</title>
		<link>http://www.eddieoneverything.com/articles/mod_rewrite-in-htaccess-to-force-www-in-url-not-working.php</link>
		<comments>http://www.eddieoneverything.com/articles/mod_rewrite-in-htaccess-to-force-www-in-url-not-working.php#comments</comments>
		<pubDate>Mon, 14 Jun 2010 13:44:49 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[.htaccess htaccess mod_rewrite apache redirect]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/?p=1176</guid>
		<description><![CDATA[Setting up a new site today, I ran into a problem with a .htaccess not working.
It was a pretty simple solution, and was the result of a minor oversight my part.
Still, it took me about 10 minutes to realize the mistake I&#8217;d made.
I just thought I&#8217;d post here in case someone else makes the same [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up a new site today, I ran into a problem with a .htaccess not working.</p>
<p>It was a pretty simple solution, and was the result of a minor oversight my part.</p>
<p>Still, it took me about 10 minutes to realize the mistake I&#8217;d made.</p>
<p>I just thought I&#8217;d post here in case someone else makes the same mistake.  </p>
<p>I searched for a while but didn&#8217;t find the answer&#8230; until it finally dawned on me, &#8220;duh, I forgot to include the RewriteEngine on directive!&#8221;</p>
<p>So, I had this:</p>
<pre name="code" class="javascript">
Options -Indexes

<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} ^site\.com [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]
</IfModule>
</pre>
<p>But should have had this:</p>
<pre name="code" class="javascript">
Options -Indexes

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site\.com [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]
</IfModule>
</pre>
<p>Forgetting that simple line, &#8220;RewriteEngine on&#8221;, caused me all kinds of headache.  :)</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php" title="Managing Server Load when unzipping many large files">Managing Server Load when unzipping many large files</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php" title="How to Scan a Computer for Open Ports">How to Scan a Computer for Open Ports</a></li><li><a href="http://www.eddieoneverything.com/articles/disabling-textarea-scrolling-in-flash-as3.php" title="Disabling TextArea Scrolling in Flash AS3">Disabling TextArea Scrolling in Flash AS3</a></li><li><a href="http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php" title="The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel">The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel</a></li><li><a href="http://www.eddieoneverything.com/articles/making-yahoo-sports-fantasy-pro-football-pickem-sortable.php" title="Making Yahoo! Sports Fantasy Pro Football Pickem Sortable">Making Yahoo! Sports Fantasy Pro Football Pickem Sortable</a></li><li><a href="http://www.eddieoneverything.com/programming/mysql-performance-tip-on-duplicate-key-is-faster-than-insert-ignore-but-failing-with-a-duplicate-key-error-is-a-lot-faster.php" title="MySQL Performance Tip:  ON DUPLICATE KEY is faster than INSERT IGNORE, but failing with a duplicate key error is a lot faster">MySQL Performance Tip:  ON DUPLICATE KEY is faster than INSERT IGNORE, but failing with a duplicate key error is a lot faster</a></li><li><a href="http://www.eddieoneverything.com/programming/how-to-use-global-variables-from-another-file-in-a-perl-module-or-package.php" title="How To Use Global Variables From Another File In A Perl Module or Package">How To Use Global Variables From Another File In A Perl Module or Package</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/articles/mod_rewrite-in-htaccess-to-force-www-in-url-not-working.php/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL Performance Tip:  ON DUPLICATE KEY is faster than INSERT IGNORE, but failing with a duplicate key error is a lot faster</title>
		<link>http://www.eddieoneverything.com/programming/mysql-performance-tip-on-duplicate-key-is-faster-than-insert-ignore-but-failing-with-a-duplicate-key-error-is-a-lot-faster.php</link>
		<comments>http://www.eddieoneverything.com/programming/mysql-performance-tip-on-duplicate-key-is-faster-than-insert-ignore-but-failing-with-a-duplicate-key-error-is-a-lot-faster.php#comments</comments>
		<pubDate>Tue, 09 Mar 2010 15:02:52 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[database performance]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql performance]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql performance]]></category>
		<category><![CDATA[sql tuning]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/?p=1015</guid>
		<description><![CDATA[I&#8217;m working on merging a couple of pretty big MySQL databases.
Each database consists of just three tables, but each of those tables has at least 9 million rows.
Because I need to maintain and update a number of data associations, it was necessary to write a custom script to perform the merge.  (I chose to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on merging a couple of pretty big MySQL databases.</p>
<p>Each database consists of just three tables, but each of those tables has at least 9 million rows.</p>
<p>Because I need to maintain and update a number of data associations, it was necessary to write a custom script to perform the merge.  (I chose to use Perl and DBI.)</p>
<p>At one point in my script, I need to do a bunch of &#8220;insert this row from database B into database A if it doesn&#8217;t exist in database A&#8221; type operations.  Doing a separate lookup for each record would cost roughly 9 million queries.  </p>
<p>At first, I just went ahead and did the insert, allowing the single insert to fail with a unique key error if the record already existed.  This caused a bunch of DBD errors to fill the screen, none of which really concerned me, because it didn&#8217;t have any bearing on the result. Still, all of those messages printed to STDERR could bury a more serious error, so I looked into handling it another way.</p>
<p><a href="http://bogdan.org.ua/2007/10/18/mysql-insert-if-not-exists-syntax.html" target="_blank">I found this post that recommends</a> using either INSERT IGNORE or ON DUPLICATE KEY to handle these queries.  After some investigation, I found that while ON DUPLICATE KEY is a lot faster than INSERT IGNORE, <em>just allowing the thing to fail is the fastest option</em>.</p>
<p>First, some simplified pseudo-code to give you an idea of what I&#8217;m doing:</p>
<pre name="code" class="vb">
FOR EACH RECORD IN A.TABLE1
   FOR EACH RECORD IN A.TABLE2
      IF THAT RECORD NOT EXISTS IN B.TABLE2,
      DO AN INSERT INTO B.TABLE2
</pre>
<p>I wanted to avoid doing a separate SQL query at step 3, as that query would have to run 9 million+ times.  Since I have a unique key set on the columns I&#8217;m interested in, any duplicate rows will not be inserted, thus maintaining my data integrity.</p>
<p>Here are the speed benchmarks I ran for my particular script with each of the three options I tried.  The numbers are in terms of iterations of my particular loop (which does a lot more than the pseudo-code above) so the numbers should only be considered relative to each other.</p>
<p><strong>Option 1:  Let the query fail with a Unique Key error.</strong></p>
<pre name="code" class="sql">
INSERT INTO A (COL1, COL2) VALUES (val1, val2);
</pre>
<p>Loop iterations per second: 24.5  (avg)</p>
<p><strong>Option 2:  INSERT &#8230; IGNORE</strong></p>
<pre name="code" class="sql">
INSERT IGNORE INTO A (COL1, COL2) VALUES (val1, val2);
</pre>
<p>Loop iterations per second: 13.3  (avg)</p>
<p><strong>Option 3:  INSERT &#8230; ON DUPLICATE KEY</strong></p>
<pre name="code" class="sql">
INSERT INTO A (COL1, COL2) VALUES (val1, val2) ON DUPLICATE KEY UPDATE id=id;
</pre>
<p>Loop iterations per second: 18.2  (avg)</p>
<p>As you can see, the fastest of the three options is letting the query fail, followed by ON DUPLICATE KEY as the second fastest.</p>
<p>I&#8217;ll leave it to the MySQL experts to explain why this is the case. I have some guesses, but I can&#8217;t say for sure.</p>
<p>But I do know one thing:  On my setup, for my purposes, letting those queries fail is the quickest option.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php" title="Managing Server Load when unzipping many large files">Managing Server Load when unzipping many large files</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php" title="How to Scan a Computer for Open Ports">How to Scan a Computer for Open Ports</a></li><li><a href="http://www.eddieoneverything.com/articles/disabling-textarea-scrolling-in-flash-as3.php" title="Disabling TextArea Scrolling in Flash AS3">Disabling TextArea Scrolling in Flash AS3</a></li><li><a href="http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php" title="The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel">The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel</a></li><li><a href="http://www.eddieoneverything.com/articles/making-yahoo-sports-fantasy-pro-football-pickem-sortable.php" title="Making Yahoo! Sports Fantasy Pro Football Pickem Sortable">Making Yahoo! Sports Fantasy Pro Football Pickem Sortable</a></li><li><a href="http://www.eddieoneverything.com/articles/mod_rewrite-in-htaccess-to-force-www-in-url-not-working.php" title="mod_rewrite in .htaccess to Force www in URL Not Working ">mod_rewrite in .htaccess to Force www in URL Not Working </a></li><li><a href="http://www.eddieoneverything.com/programming/how-to-use-global-variables-from-another-file-in-a-perl-module-or-package.php" title="How To Use Global Variables From Another File In A Perl Module or Package">How To Use Global Variables From Another File In A Perl Module or Package</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/programming/mysql-performance-tip-on-duplicate-key-is-faster-than-insert-ignore-but-failing-with-a-duplicate-key-error-is-a-lot-faster.php/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How To Use Global Variables From Another File In A Perl Module or Package</title>
		<link>http://www.eddieoneverything.com/programming/how-to-use-global-variables-from-another-file-in-a-perl-module-or-package.php</link>
		<comments>http://www.eddieoneverything.com/programming/how-to-use-global-variables-from-another-file-in-a-perl-module-or-package.php#comments</comments>
		<pubDate>Sun, 07 Mar 2010 22:42:33 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[perl modules]]></category>
		<category><![CDATA[sharing variables]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/?p=991</guid>
		<description><![CDATA[I&#8217;ve been doing a lot of Perl development for my latest project, and I wanted to use a single config file for many scripts.
Using a single config file in a basic Perl script is pretty straightforward &#8211; you simply use a require statement to read the external file, and the variables contained within are automatically [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of Perl development for my latest project, and I wanted to use a single config file for many scripts.</p>
<p>Using a single config file in a basic Perl script is pretty straightforward &#8211; you simply use a require statement to read the external file, and the variables contained within are automatically imported.  (Though if you&#8217;re using strict, you&#8217;ll need to declare them using the &#8220;our&#8221; keyword.)</p>
<p>A problem arises when you want to use those global variables in a package file, though &#8211; because a Package has its own namespace, variables declared in your external config file are not imported into your module, even if you use the &#8220;our&#8221; keyword.</p>
<p>Fortunately, I was able to find a solution <a href="http://home.arcor.de/pangj/share_variables_between_perl_scripts.txt" target="_blank">here</a>, courtesy of Jeff Pang.</p>
<p>Here are a couple of examples.</p>
<p><strong>The simple way to share variables between Perl scripts using &#8220;require&#8221;</strong></p>
<p>File test.include.pl</p>
<pre name="code" class="perl">
#!/usr/bin/perl
$var = ".j.a.p.h.";
</pre>
<p>File test.pl</p>
<pre name="code" class="perl">
#!/usr/bin/perl
use strict;
require "test.include.pl";
our $var;
print "VAR is $var\n";
</pre>
<p>After creating the two files above and running test.pl, the output is:<br />
<code><br />
eddie@widmers:~/wrk/$ ./test.pl<br />
VAR is .j.a.p.h.<br />
</code></p>
<p><strong>The more advanced way of sharing variables with a Perl Package</strong><br />
This method involves declaring the config file as a package, and then explicitly exporting the variables you&#8217;re interested in.   Your other scripts and modules will then import those variables, making them available in that scope. </p>
<p>In this case, the config variable package will look something like this:</p>
<pre name="code" class="perl">
package SiteConfig;
require Exporter;

our @ISA = qw(Exporter);
our @EXPORT=qw($var $vare);

our $var = ".j.a.p.h.";

1;
</pre>
<p>While the package you&#8217;re looking to use the variables in will look something like this:</p>
<pre name="code" class="perl">
package TestTest;
use TestConfig;
print "Var is $var\n";

sub new
{
   my $package = shift;
   print "VAR is $var\n";
  return bless({}, $package);
}
1;
</pre>
<p>Of course, your particular needs will vary, so you&#8217;ll need to use your noodle to modify the above as necessary.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/linux/argument-list-too-long-from-rm-command-a-perl-script-to-get-around-the-problem.php" title="&#8220;Argument list too long&#8221; from rm command.   A Perl Script to Get Around the Problem">&#8220;Argument list too long&#8221; from rm command.   A Perl Script to Get Around the Problem</a></li><li><a href="http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php" title="Managing Server Load when unzipping many large files">Managing Server Load when unzipping many large files</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php" title="How to Scan a Computer for Open Ports">How to Scan a Computer for Open Ports</a></li><li><a href="http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php" title="The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel">The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel</a></li><li><a href="http://www.eddieoneverything.com/programming/getting-phps-print_r-function-to-return-a-string.php" title="Getting PHP&#8217;s print_r Function To Return A String">Getting PHP&#8217;s print_r Function To Return A String</a></li><li><a href="http://www.eddieoneverything.com/programming/calibre-recipe-for-minneapolis-star-tribune-startribune-com.php" title="Calibre Recipe for Minneapolis Star Tribune (StarTribune.com)">Calibre Recipe for Minneapolis Star Tribune (StarTribune.com)</a></li><li><a href="http://www.eddieoneverything.com/linux/rotating-backup-directories-using-cp-al-hardlinks-to-save-disk-space.php" title="Rotating Backup Directories using cp -al (hardlinks) to Save Disk Space">Rotating Backup Directories using cp -al (hardlinks) to Save Disk Space</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/programming/how-to-use-global-variables-from-another-file-in-a-perl-module-or-package.php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Block a Quote</title>
		<link>http://www.eddieoneverything.com/articles/how-to-block-a-quote.php</link>
		<comments>http://www.eddieoneverything.com/articles/how-to-block-a-quote.php#comments</comments>
		<pubDate>Tue, 02 Mar 2010 17:44:36 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[blockquote]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/?p=953</guid>
		<description><![CDATA[Blockquotes are a great way to reference others&#8217; material.
A blockquote lets your reader know that you are quoting another source, and it pays proper attribution to your quoted source.
HTML supports the &#60;blockquote&#62; tag, which does exactly what one would suspect.
To block a quote in HTML, simply use this tag.
Example:

&#60;blockquote&#62; This is quoted text &#60;/blockquote&#62;

The above [...]]]></description>
			<content:encoded><![CDATA[<p>Blockquotes are a great way to reference others&#8217; material.</p>
<p>A blockquote lets your reader know that you are quoting another source, and it pays proper attribution to your quoted source.</p>
<p>HTML supports the &lt;blockquote&gt; tag, which does exactly what one would suspect.</p>
<p>To block a quote in HTML, simply use this tag.</p>
<p><strong>Example:</strong></p>
<pre name="code" class="HTML">
&lt;blockquote&gt; This is quoted text &lt;/blockquote&gt;
</pre>
<p>The above HTML produces the following result:</p>
<blockquote><p>This is quoted text.</p></blockquote>
<p>You can control the styling of your blockquote using CSS.  For instance, the blockquotes on this site are styled using this CSS:</p>
<pre name="code" class="HTML">
blockquote {
  margin: 5px 15px;
  padding: 5px 5px;
  background: #8CB5D8;
  border: 1px solid #3A7CAC;
  clear:both;
  }
</pre>
<p>You can edit the CSS to fit the styling of your site.  Or, if you&#8217;d prefer, simply keep the blockquote undefined in your CSS &#8211; depending on your stylesheet, the default setting may work fine for you.</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/programming/how-to-set-a-class-name-using-javascript-in-ie-and-other-browsers.php" title="How To Set a Class Name using Javascript in IE and Other Browsers">How To Set a Class Name using Javascript in IE and Other Browsers</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-set-the-window-size-and-position-of-a-chrome-application-shortcut.php" title="How to Set the Window Size and Position of a Chrome Application Shortcut">How to Set the Window Size and Position of a Chrome Application Shortcut</a></li><li><a href="http://www.eddieoneverything.com/articles/managing-server-load-when-unzipping-many-large-files.php" title="Managing Server Load when unzipping many large files">Managing Server Load when unzipping many large files</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php" title="How to Scan a Computer for Open Ports">How to Scan a Computer for Open Ports</a></li><li><a href="http://www.eddieoneverything.com/articles/disabling-textarea-scrolling-in-flash-as3.php" title="Disabling TextArea Scrolling in Flash AS3">Disabling TextArea Scrolling in Flash AS3</a></li><li><a href="http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php" title="The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel">The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel</a></li><li><a href="http://www.eddieoneverything.com/articles/making-yahoo-sports-fantasy-pro-football-pickem-sortable.php" title="Making Yahoo! Sports Fantasy Pro Football Pickem Sortable">Making Yahoo! Sports Fantasy Pro Football Pickem Sortable</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/articles/how-to-block-a-quote.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting PHP&#8217;s print_r Function To Return A String</title>
		<link>http://www.eddieoneverything.com/programming/getting-phps-print_r-function-to-return-a-string.php</link>
		<comments>http://www.eddieoneverything.com/programming/getting-phps-print_r-function-to-return-a-string.php#comments</comments>
		<pubDate>Thu, 25 Feb 2010 22:41:42 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[print_r]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/?p=895</guid>
		<description><![CDATA[PHP&#8217;s print_r function is invaluable.  It prints a human-readable string representation of a variable.
It&#8217;s one of the most useful debugging features I&#8217;ve seen in any language.
I like it so much that I&#8217;ve actually written print_r mimic functions for other languages.
By default, print_r literally prints a variable to the screen.  Sometimes it&#8217;s useful to [...]]]></description>
			<content:encoded><![CDATA[<p>PHP&#8217;s print_r function is invaluable.  It prints a human-readable string representation of a variable.</p>
<p>It&#8217;s one of the most useful debugging features I&#8217;ve seen in any language.</p>
<p>I like it so much that I&#8217;ve actually written print_r mimic functions for other languages.</p>
<p>By default, print_r literally <i>prints</i> a variable to the screen.  Sometimes it&#8217;s useful to have that info not printed though.  For instance, you might want to include the print_r result in an email, or an error log, or in a special debugging frame.</p>
<p>Fortunately, print_r has this functionality built in &#8211; the function accepts an optional second argument that specifies whether you want the data printed or returned as a string.</p>
<p>To have print_r return the data as a string, include the second argument &#8220;true&#8221;:</p>
<pre name="code" class="php">
$message = print_r($myObject,true);
</pre>
<p>If you&#8217;re doing anything programmatic with the output, you may want to consider using var_export instead.  This function is largely identical to print_r, except that its output is machine parsable rather than human readable.  The usage is identical to print_r.</p>
<pre name="code" class="php">
$message = var_export($myObject,true);
</pre>
<p>All without using ob_start.  Nice!</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/programming/php-programming-us-state-list-functions-state-abbreviation-to-state-name-function.php" title="PHP Programming: U.S. State list functions / State abbreviation to State name function">PHP Programming: U.S. State list functions / State abbreviation to State name function</a></li><li><a href="http://www.eddieoneverything.com/articles/validating-an-email-address-with-phps-filter_var-isnt-perfect.php" title="Validating an Email Address with PHP&rsquo;s filter_var isn&rsquo;t perfect">Validating an Email Address with PHP&rsquo;s filter_var isn&rsquo;t perfect</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php" title="How to Scan a Computer for Open Ports">How to Scan a Computer for Open Ports</a></li><li><a href="http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php" title="The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel">The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-make-phpbb3-forum-links-automatically-relnofollow.php" title="How to Make phpbb3 Forum Links Automatically rel=&#8221;nofollow&#8221;">How to Make phpbb3 Forum Links Automatically rel=&#8221;nofollow&#8221;</a></li><li><a href="http://www.eddieoneverything.com/programming/how-to-use-global-variables-from-another-file-in-a-perl-module-or-package.php" title="How To Use Global Variables From Another File In A Perl Module or Package">How To Use Global Variables From Another File In A Perl Module or Package</a></li><li><a href="http://www.eddieoneverything.com/articles/optimizing-the-google-syntax-highlighter-wordpress-plugin-even-further.php" title="Optimizing the Google Syntax Highlighter Wordpress Plugin Even Further">Optimizing the Google Syntax Highlighter Wordpress Plugin Even Further</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/programming/getting-phps-print_r-function-to-return-a-string.php/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

