<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>damonparker.org</title>
	
	<link>http://damonparker.org</link>
	<description>code / ecommerce / life</description>
	<lastBuildDate>Thu, 24 Feb 2011 21:29:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/damonparkerorg" /><feedburner:info uri="damonparkerorg" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>damonparkerorg</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>MySQL Error Function Wrapper for PHP</title>
		<link>http://feedproxy.google.com/~r/damonparkerorg/~3/jjtNmkMxUCs/</link>
		<comments>http://damonparker.org/blog/2011/02/07/mysql-error-function-wrapper-for-php/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 00:01:32 +0000</pubDate>
		<dc:creator>damonp</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://damonparker.org/?p=634</guid>
		<description><![CDATA[I was recently asked to supply some development and debugging functionality to a web application built for a client. The following function can be configured to popup for only your IP, and gives an error message containing the SQL, line number and file for easy debugging of the error. I like this function over my [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I was recently asked to supply some development and debugging functionality to a web application built for a client.  The following function can be configured to popup for only your IP, and gives an error message containing the SQL, line number and file for easy debugging of the error.</p>
<p>I like this function over my current hobbled together debug kit because the display is positioned top center of the page via CSS no matter where the error occurs.  Plus it includes a hide button to hide the majority of the error output and remove button to remove the error display altogether.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> mysql_error_wrapper<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$q</span>, <span style="color: #0000ff;">$sql</span>=<span style="color: #ff0000;">''</span>, <span style="color: #0000ff;">$line</span>=<span style="color: #ff0000;">''</span>, <span style="color: #0000ff;">$file</span>=<span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$_SERVER</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'REMOTE_ADDR'</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff0000;">'YOUR LOCAL IP'</span><span style="color: #66cc66;">&#41;</span>&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">false</span>;<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;&lt;!--<br />
function showhide(d) {<br />
&nbsp; &nbsp; if(document.getElementById(d).style.display == &quot;none&quot;) { <br />
&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(d).style.display = &quot;block&quot;; <br />
&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById('shde').innerHTML = &quot;hide&quot;;<br />
&nbsp; &nbsp; } &nbsp; else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(d).style.display = &quot;none&quot;; <br />
&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById('shde').innerHTML = &quot;show&quot;; &nbsp; &nbsp; <br />
&nbsp; &nbsp; }<br />
}<br />
<br />
function remove() &nbsp; {<br />
&nbsp; &nbsp; document.getElementById('errorblock').style.display = &quot;none&quot;;<br />
}<br />
//--&gt;&lt;/script&gt;<br />
<br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;div id=&quot;errorblock&quot; style=&quot;display:block;position:absolute;top:10px;left:10%;width:80%;background:#efefef;text-align:left;border:1px solid #CD0000;padding:10px;&quot;&gt;'</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;a href=&quot;#&quot; onclick=&quot;showhide(<span style="color: #000099; font-weight: bold;">\'</span>sqlerror<span style="color: #000099; font-weight: bold;">\'</span>)&quot;&gt;&lt;span id=&quot;shde&quot;&gt;hide&lt;/span&gt;&lt;/a&gt; - &lt;a href=&quot;#&quot; onclick=&quot;remove();&quot;&gt;remove&lt;/a&gt;'</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;h3 style=&quot;color:#CD0000;&quot;&gt;MySQL error: '</span>.<a href="http://www.php.net/mysql_errno"><span style="color: #000066;">mysql_errno</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">' &lt;small style=&quot;font-weight:normal;&quot;&gt;Line: #'</span>.<span style="color: #0000ff;">$line</span>.<span style="color: #ff0000;">' '</span>.<a href="http://www.php.net/basename"><span style="color: #000066;">basename</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #ff0000;">'&lt;/small&gt;&lt;/h3&gt;'</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;pre id=&quot;sqlerror&quot; style=&quot;height:250px;overflow:auto;padding:10px;&quot;&gt;'</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <a href="http://www.php.net/wordwrap"><span style="color: #000066;">wordwrap</span></a><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/mysql_error"><span style="color: #000066;">mysql_error</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$sql</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>&nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;h4&gt;SQL&lt;/h4&gt;'</span>.<a href="http://www.php.net/wordwrap"><span style="color: #000066;">wordwrap</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$sql</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$line</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;h4&gt;Line&lt;/h4&gt;'</span>.<span style="color: #0000ff;">$line</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$file</span> <span style="color: #66cc66;">!</span>= <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;h4&gt;File&lt;/h4&gt;'</span>.<span style="color: #0000ff;">$file</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;/pre&gt;'</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">'&lt;/div&gt;'</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>Usage example:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">$sql</span> = <span style="color: #ff0000;">&quot;YOUR SQL STATEMENT&quot;</span>;<br />
&nbsp; &nbsp; <span style="color: #0000ff;">$q</span> = <a href="http://www.php.net/mysql_query"><span style="color: #000066;">mysql_query</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$sql</span>, <span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #0000ff;">$q</span><span style="color: #66cc66;">&#41;</span> mysql_error_wrapper<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$q</span>, <span style="color: #0000ff;">$sql</span>, <span style="color: #000000; font-weight: bold;">__LINE__</span>, <span style="color: #000000; font-weight: bold;">__FILE__</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
 <img src="http://damonparker.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=634" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/damonparkerorg/~4/jjtNmkMxUCs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://damonparker.org/blog/2011/02/07/mysql-error-function-wrapper-for-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://damonparker.org/blog/2011/02/07/mysql-error-function-wrapper-for-php/</feedburner:origLink></item>
		<item>
		<title>Download a Remote File Using PHP and cURL</title>
		<link>http://feedproxy.google.com/~r/damonparkerorg/~3/otjw3SJq8nY/</link>
		<comments>http://damonparker.org/blog/2011/02/03/download-remote-file-using-php-and-curl/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 17:02:51 +0000</pubDate>
		<dc:creator>damonp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[cURL]]></category>

		<guid isPermaLink="false">http://damonparker.org/?p=619</guid>
		<description><![CDATA[Some years back, I posted a function to download a remote file with PHP. The function was useful when cURL and other URL/remote file functions had been disabled for security reasons. At the time, cURL on PHP was relatively new and many hosting setups didn&#8217;t include the cURL PHP module. Support for PHP-cURL is pretty [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Some years back, I posted a function to <a href="http://damonparker.org/blog/2005/09/29/download-a-remote-file-using-php/">download a remote file with PHP</a>.  The function was useful when <a href="http://curl.haxx.se/">cURL</a> and other URL/remote file functions had been disabled for security reasons.  At the time, cURL on PHP was relatively new and many hosting setups didn&#8217;t include the cURL PHP module.  </p>
<p>Support for <a href="http://php.net/manual/en/book.curl.php">PHP-cURL</a> is pretty standard now, so I thought I&#8217;d update the the function to use cURL now.  In addition, the function no longer returns a buffer containing the file data which can cause memory issues in PHP when dealing with large files.  Pass this updated function a remote URL and local file path and it will download the file and save it to the local path.</p>
<p>This function is useful to retrieve remote images, download HTML pages and download any remote files.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> http_get_file<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$remote_url</span>, <span style="color: #0000ff;">$local_file</span><span style="color: #66cc66;">&#41;</span>&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$fp</span> = <a href="http://www.php.net/fopen"><span style="color: #000066;">fopen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$local_file</span>, <span style="color: #ff0000;">'w'</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$cp</span> = curl_init<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$remote_url</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; curl_setopt<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$cp</span>, CURLOPT_FILE, <span style="color: #0000ff;">$fp</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">$buffer</span> = curl_exec<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$cp</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; curl_close<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$cp</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/fclose"><span style="color: #000066;">fclose</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fp</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
 <img src="http://damonparker.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=619" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/damonparkerorg/~4/otjw3SJq8nY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://damonparker.org/blog/2011/02/03/download-remote-file-using-php-and-curl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://damonparker.org/blog/2011/02/03/download-remote-file-using-php-and-curl/</feedburner:origLink></item>
		<item>
		<title>Hardcode WordPress Site URL</title>
		<link>http://feedproxy.google.com/~r/damonparkerorg/~3/2dO5zdnxd2w/</link>
		<comments>http://damonparker.org/blog/2011/01/11/hardcode-wordpress-site-url/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 20:13:16 +0000</pubDate>
		<dc:creator>damonp</dc:creator>
				<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://damonparker.org/?p=617</guid>
		<description><![CDATA[I&#8217;m working on a project for mobile devices and need to be able to setup the same WordPress install on both the .mobi and the .com domain. This snippet lets you hardcode the URL and home configurables in wp_config.php. We use one setup of configurables for the .mobi side and another set for the .com. [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I&#8217;m working on a project for mobile devices and need to be able to setup the same WordPress install on both the .mobi and the .com domain.  This snippet lets you hardcode the URL and home configurables in wp_config.php.  We use one setup of configurables for the .mobi side and another set for the .com.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define"><span style="color: #000066;">define</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'WP_HOME'</span>,<span style="color: #ff0000;">'http://example.com'</span><span style="color: #66cc66;">&#41;</span>;<br />
<a href="http://www.php.net/define"><span style="color: #000066;">define</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'WP_SITEURL'</span>,<span style="color: #ff0000;">'http://example.com'</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p>Thanks to the <a href="http://codex.wordpress.org/Changing_The_Site_URL">WordPress Codex</a>.</p>
 <img src="http://damonparker.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=617" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/damonparkerorg/~4/2dO5zdnxd2w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://damonparker.org/blog/2011/01/11/hardcode-wordpress-site-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://damonparker.org/blog/2011/01/11/hardcode-wordpress-site-url/</feedburner:origLink></item>
		<item>
		<title>Linux Grep Tips</title>
		<link>http://feedproxy.google.com/~r/damonparkerorg/~3/FM0Lvv8r9jU/</link>
		<comments>http://damonparker.org/blog/2010/11/17/linux-grep-tips/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 21:04:33 +0000</pubDate>
		<dc:creator>damonp</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://damonparker.org/?p=553</guid>
		<description><![CDATA[Search for red OR green: grep 'red\&#124;green' files Search for searchtext at the beginning of a line in files: grep '^searchtext' files Search for searchtext at the end of a line in files: grep 'searchtext$' files Search files for blank lines: grep '^$' files Search files for US formatted phone numbers (###-###-####): grep '[0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]' files [...]]]></description>
			<content:encoded><![CDATA[<p></p><div style="padding:2px 0 30px 0;">Search for <em>red</em> OR <em>green</em>:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep <span style="color: #ff0000;">'red<span style="color: #000099; font-weight: bold;">\|</span>green'</span> files</div></div>
</div>
<div style="padding:2px 0 30px 0;">Search for <em>searchtext</em> at the beginning of a line in <em>files</em>:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep <span style="color: #ff0000;">'^searchtext'</span> files</div></div>
</div>
<div style="padding:2px 0 30px 0;">Search for <em>searchtext</em> at the end of a line in <em>files</em>:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep <span style="color: #ff0000;">'searchtext$'</span> files</div></div>
</div>
<div style="padding:2px 0 30px 0;">Search <em>files</em> for blank lines:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep <span style="color: #ff0000;">'^$'</span> files</div></div>
</div>
<div style="padding:2px 0 30px 0;">Search <em>files</em> for US formatted phone numbers (###-###-####):</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep <span style="color: #ff0000;">'[0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'</span> files</div></div>
<p>or:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep <span style="color: #ff0000;">'[0-9]<span style="color: #000099; font-weight: bold;">\{</span>3<span style="color: #000099; font-weight: bold;">\}</span>-[0-9]<span style="color: #000099; font-weight: bold;">\{</span>3<span style="color: #000099; font-weight: bold;">\}</span>-[0-9]<span style="color: #000099; font-weight: bold;">\{</span>4<span style="color: #000099; font-weight: bold;">\}</span>'</span> files</div></div>
</div>
<div style="padding:2px 0 30px 0;">Search for <em>e-commerce</em> or <em>ecommerce</em> in <em>files</em>:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep e-<span style="color: #66cc66;">*</span>commerce files</div></div>
</div>
<div style="padding:2px 0 30px 0;">Search for <em>searchtext</em> case-insenstively in <em>files</em>:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep -i searchtext files</div></div>
</div>
<div style="padding:2px 0 30px 0;">Search for <em>searchtext</em> at the beginning of a line in <em>files</em>:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep <span style="color: #ff0000;">'^searchtext'</span> files</div></div>
</div>
<div style="padding:2px 0 30px 0;">Chain two grep commands together for more advanced searches.  Search for lines in <em>files</em> that contain both <em>partial_name</em> and <em>function</em>:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grep partial_name files <span style="color: #66cc66;">|</span> grep <span style="color: #b1b100;">function</span></div></div>
<p>That one is great for searching source directories for a function definition when you can&#8217;t remember the completely function name.</p></div>
 <img src="http://damonparker.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=553" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/damonparkerorg/~4/FM0Lvv8r9jU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://damonparker.org/blog/2010/11/17/linux-grep-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://damonparker.org/blog/2010/11/17/linux-grep-tips/</feedburner:origLink></item>
		<item>
		<title>HTML Image Caption</title>
		<link>http://feedproxy.google.com/~r/damonparkerorg/~3/kxYc2qVyg5I/</link>
		<comments>http://damonparker.org/blog/2010/11/10/html-image-caption/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 04:53:09 +0000</pubDate>
		<dc:creator>damonp</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://damonparker.org/?p=535</guid>
		<description><![CDATA[&#60;div id=&#34;image-caption&#34;&#62;&#60;img style=&#34;border: 1px solid black; float: right; margin: 0 0 10px 10px;&#34; src=&#34;/images/imagename.jpg&#34; border=&#34;0&#34; alt=&#34;&#34; width=&#34;175&#34; height=&#34;132&#34; /&#62; &#60;p class=&#34;caption&#34;&#62;HTML Image Caption&#60;/p&#62; &#60;/div&#62; &#60;!-- #image-caption { position: relative; } #image-caption p.caption { text-align:center; position: relative; bottom: 0px; left: 0px; margin: 0; padding: 5px 3%; background-color: #555; color: #fff; font-weight: bold; font-size:.75em; } --&#62;]]></description>
			<content:encoded><![CDATA[<p></p><div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3Ediv.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;image-caption&quot;</span>&gt;<a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3Eimg.html"><span style="color: #000000; font-weight: bold;">&lt;img</span></a> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;border: 1px solid black; float: right; margin: 0 0 10px 10px;&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/images/imagename.jpg&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;175&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;132&quot;</span> <span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/%26amp%3Bgt%3CSEMI%3E.html"><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><br />
<span style="color: #009900;"><a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3Ep.html"><span style="color: #000000; font-weight: bold;">&lt;p</span></a> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;caption&quot;</span><a href="http://december.com/html/4/element/%26amp%3Bgt%3CSEMI%3E.html"><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>HTML Image Caption<span style="color: #009900;"><a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3E%2Fp%26amp%3Bgt%3CSEMI%3E.html"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></a></span><br />
<br />
<span style="color: #009900;"><a href="http://december.com/html/4/element/%26amp%3Blt%3CSEMI%3E%2Fdiv%26amp%3Bgt%3CSEMI%3E.html"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></a></span><br />
<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--</span><br />
<span style="color: #009900;">#image-caption {</span><br />
<span style="color: #009900;">position: relative;</span><br />
<span style="color: #009900;">}</span><br />
<span style="color: #009900;">#image-caption p.caption {</span><br />
<span style="color: #009900;">text-align:center;</span><br />
<span style="color: #009900;">position: relative;</span><br />
<span style="color: #009900;">bottom: 0px;</span><br />
<span style="color: #009900;">left: 0px;</span><br />
<span style="color: #009900;">margin: 0;</span><br />
<span style="color: #009900;">padding: 5px 3%;</span><br />
<span style="color: #009900;">background-color: #555;</span><br />
<span style="color: #009900;">color: #fff;</span><br />
<span style="color: #009900;">font-weight: bold;</span><br />
<span style="color: #009900;">font-size:.75em;</span><br />
<span style="color: #009900;">}</span><br />
<span style="color: #009900;">--&gt;</span></span></div></div>
 <img src="http://damonparker.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=535" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/damonparkerorg/~4/kxYc2qVyg5I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://damonparker.org/blog/2010/11/10/html-image-caption/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://damonparker.org/blog/2010/11/10/html-image-caption/</feedburner:origLink></item>
		<item>
		<title>Cannot find terminfo entry for ‘xterm-256color’</title>
		<link>http://feedproxy.google.com/~r/damonparkerorg/~3/g8NHPjPFXTY/</link>
		<comments>http://damonparker.org/blog/2010/11/10/cannot-find-terminfo-entry-for-xterm-256color/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 14:16:14 +0000</pubDate>
		<dc:creator>damonp</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://damonparker.org/?p=543</guid>
		<description><![CDATA[Check if you have the terminfo file installed. find /lib/terminfo /usr/share/terminfo -name &#34;*256*&#34; No results? Install ncurses-term. sudo apt-get install ncurses-term]]></description>
			<content:encoded><![CDATA[<p></p><p>Check if you have the terminfo file installed.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">find <span style="color: #66cc66;">/</span>lib<span style="color: #66cc66;">/</span>terminfo <span style="color: #66cc66;">/</span>usr<span style="color: #66cc66;">/</span>share<span style="color: #66cc66;">/</span>terminfo -name <span style="color: #ff0000;">&quot;*256*&quot;</span></div></div>
<p>No results?  Install <em>ncurses-term</em>.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sudo apt-get install ncurses-term</div></div>
 <img src="http://damonparker.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=543" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/damonparkerorg/~4/g8NHPjPFXTY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://damonparker.org/blog/2010/11/10/cannot-find-terminfo-entry-for-xterm-256color/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://damonparker.org/blog/2010/11/10/cannot-find-terminfo-entry-for-xterm-256color/</feedburner:origLink></item>
		<item>
		<title>Debugging Wifi Connectivity and Routing</title>
		<link>http://feedproxy.google.com/~r/damonparkerorg/~3/wxF18dBYXro/</link>
		<comments>http://damonparker.org/blog/2010/06/12/debugging-wifi-connectivity-and-routing/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 21:33:32 +0000</pubDate>
		<dc:creator>damonp</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://damonparker.org/?p=525</guid>
		<description><![CDATA[Sometimes wifi connectivity issues can be massaged a little by getting a little pushy with it&#8230; turn your internal airport card off. Leave it off for a minute then turn it back on and see if by forcing it to attempt to re-connect to your local network.  Oftentimes this will clear up minor issues. Check [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Sometimes wifi connectivity issues can be massaged a little by getting a little pushy with it&#8230; turn your internal airport card off. Leave it off for a minute then turn it back on and see if by forcing it to attempt to re-connect to your local network.  Oftentimes this will clear up minor issues.</p>
<p>Check your routing tables:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">netstat -nr</div></div>
<p>Get just the default route:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">netstat -nr <span style="color: #66cc66;">|</span> grep default</div></div>
<p>In action:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#91;</span>root<span style="color: #66cc66;">@</span>howie ~<span style="color: #66cc66;">&#93;</span>$ netstat -nr <span style="color: #66cc66;">|</span> grep default<br />
<span style="color: #cc66cc;">5</span>:default &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;192.168.1.1 &nbsp; &nbsp; &nbsp; &nbsp;UGSc &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">11</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #cc66cc;">5</span> &nbsp; &nbsp; en1</div></div>
 <img src="http://damonparker.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=525" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/damonparkerorg/~4/wxF18dBYXro" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://damonparker.org/blog/2010/06/12/debugging-wifi-connectivity-and-routing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://damonparker.org/blog/2010/06/12/debugging-wifi-connectivity-and-routing/</feedburner:origLink></item>
		<item>
		<title>Cloudy Costa Rican Sunset</title>
		<link>http://feedproxy.google.com/~r/damonparkerorg/~3/zxaFZJ3X_uQ/</link>
		<comments>http://damonparker.org/blog/2010/06/02/cloudy-costa-rican-sunset/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 23:21:02 +0000</pubDate>
		<dc:creator>damonp</dc:creator>
				<category><![CDATA[Travel]]></category>

		<guid isPermaLink="false">http://damonparker.org/blog/2010/06/02/cloudy-costa-rican-sunset/</guid>
		<description><![CDATA[Looks like it&#8217;s going to rain tonight.]]></description>
			<content:encoded><![CDATA[<p></p><p>Looks like it&#8217;s going to rain tonight. </p>
<p><a href="http://cdn.damonparker.org/wp-content/uploads/2010/06/l_2048_1536_94356E4E-840E-403F-983E-8ECF9ACB9476.jpeg"><img src="http://cdn.damonparker.org/wp-content/uploads/2010/06/l_2048_1536_94356E4E-840E-403F-983E-8ECF9ACB9476.jpeg" alt="" class="alignnone size-full" /></a></p>
 <img src="http://damonparker.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=503" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/damonparkerorg/~4/zxaFZJ3X_uQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://damonparker.org/blog/2010/06/02/cloudy-costa-rican-sunset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://damonparker.org/blog/2010/06/02/cloudy-costa-rican-sunset/</feedburner:origLink></item>
		<item>
		<title>iPhone Goodreader and Email</title>
		<link>http://feedproxy.google.com/~r/damonparkerorg/~3/-E7i3X_va8c/</link>
		<comments>http://damonparker.org/blog/2010/04/28/iphone-goodreader-and-email/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 23:19:30 +0000</pubDate>
		<dc:creator>damonp</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://purple.damonparker.org/?p=499</guid>
		<description><![CDATA[Goodreader is simply the best PDF / document reader around for the iPad. It allows you to download documents in a dozen different ways and store them locally on your device. Another great feature is the ability to directly email these as attachments from inside Goodreader. Unfortunately, said feature is limited somewhat by the limitations [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Goodreader is simply the best PDF / document reader around for the iPad. It allows you to download documents in a dozen different ways and store them locally on your device. Another great feature is the ability to directly email these as attachments from inside Goodreader.</p>
<p>Unfortunately, said feature is limited somewhat by the limitations of the device. Trying to compose a message in the tiny popup box is a pain&#8230; especially when the box starts jumping around on every keypress as the tiny window tries to alternately flow the text and show the attachment. </p>
<p>Good thing there is a fix for any app using the iPhone/iPad built-in mail functionality. Simply type something in the text field to put something in the message body.  I use a couple of returns or set the To: address. Then close the message. When the app asks if you would like to save the draft, hit Yes and the message along with attachment will be saved in your Mail Drafts folder. You can retrieve it there any time to finish writing your message and send the attachment. </p>
<p>If you fail to type something in the new message pop up, the mail app wont ask you if you want to save the draft. It will exit and trash your message.<br />
<img src="http://cdn.damonparker.org/wp-content/uploads/2010/05/cap.ipad_.goodreader.mail_-300x225.jpg" alt="Sending File Attachment in Goodreader" /></p>
 <img src="http://damonparker.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=499" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/damonparkerorg/~4/-E7i3X_va8c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://damonparker.org/blog/2010/04/28/iphone-goodreader-and-email/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://damonparker.org/blog/2010/04/28/iphone-goodreader-and-email/</feedburner:origLink></item>
		<item>
		<title>Enable Sendmail for PHP mail() in OSX</title>
		<link>http://feedproxy.google.com/~r/damonparkerorg/~3/cv6Z1r4ekrg/</link>
		<comments>http://damonparker.org/blog/2010/02/25/enable-sendmail-for-php-mail-in-osx/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 22:05:41 +0000</pubDate>
		<dc:creator>damonp</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[sendmail]]></category>

		<guid isPermaLink="false">http://damonparker.org/blog/?p=468</guid>
		<description><![CDATA[Since this didn&#8217;t dawn on me for thirty minutes while I pursued other avenues&#8230; In /etc/hostconfig add/edit a line like: MAILSERVER=-YES- Note to self: Look for more OSX server administration clients.]]></description>
			<content:encoded><![CDATA[<p></p><p>Since this didn&#8217;t dawn on me for thirty minutes while I pursued other avenues&#8230;</p>
<p>In /etc/hostconfig add/edit a line like:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">MAILSERVER=</span>-YES-</div></div>
<p>Note to self: Look for more OSX server administration clients.  </p>
 <img src="http://damonparker.org/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=468" width="1" height="1" style="display: none;" /><img src="http://feeds.feedburner.com/~r/damonparkerorg/~4/cv6Z1r4ekrg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://damonparker.org/blog/2010/02/25/enable-sendmail-for-php-mail-in-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://damonparker.org/blog/2010/02/25/enable-sendmail-for-php-mail-in-osx/</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using xcache
Database Caching 79/92 queries in 0.010 seconds using xcache
Content Delivery Network via cdn.damonparker.org

Served from: damonparker.org @ 2013-05-23 01:35:07 -->
