<?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>Beaver6813.com &#187; Notes</title>
	<atom:link href="http://beaver6813.com/category/notes/feed/" rel="self" type="application/rss+xml" />
	<link>http://beaver6813.com</link>
	<description>Web Developer Extraordinaire!</description>
	<lastBuildDate>Thu, 05 Jan 2012 20:33:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-20304</generator>
		<item>
		<title>Selectors in Infinite-Scroll</title>
		<link>http://beaver6813.com/2012/01/selectors-in-infinite-scroll/</link>
		<comments>http://beaver6813.com/2012/01/selectors-in-infinite-scroll/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 20:33:26 +0000</pubDate>
		<dc:creator>Beaver6813</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://beaver6813.com/?p=310</guid>
		<description><![CDATA[I get asked a lot how/what the selectors are in infinite-scroll and how to figure them out. So lets start from the beginning.. infinite-scroll uses jQuery selectors (which are based on CSS selectors) to find content and posts in order &#8230; <a href="http://beaver6813.com/2012/01/selectors-in-infinite-scroll/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://beaver6813.com/2011/05/selectinvite-all-friends-on-facebook-automatically/' rel='bookmark' title='Select/Invite all friends on Facebook automatically'>Select/Invite all friends on Facebook automatically</a></li>
<li><a href='http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/' rel='bookmark' title='GoDaddy mod_rewrite Hell'>GoDaddy mod_rewrite Hell</a></li>
<li><a href='http://beaver6813.com/2010/06/phpgsb-php-google-safe-browsing/' rel='bookmark' title='phpGSB &#8211; PHP Google Safe Browsing'>phpGSB &#8211; PHP Google Safe Browsing</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I get asked a lot how/what the selectors are in infinite-scroll and how to figure them out. So lets start from the beginning.. infinite-scroll uses jQuery selectors (which are based on CSS selectors) to find content and posts in order to load the content from the next page. Because web pages are different, we need to define ourselves what selectors infinite-scroll should use.</p>
<p>Infinite-Scroll uses four selectors, these are:</p>
<ul>
<li>nextSelector</li>
<li>navSelector</li>
<li>contentSelector</li>
<li>itemSelector</li>
</ul>
<p>It&#8217;s probably easiest<span id="more-310"></span> if you check out my beautiful diagram below to see what they relate to:</p>
<p><a href="http://beaver6813.com/wp-content/uploads/2012/01/bananasint.png"><img class="aligncenter size-full wp-image-312" title="Bananas International Diagram" src="http://beaver6813.com/wp-content/uploads/2012/01/bananasint.png" alt="" width="640" height="480" /></a></p>
<p>And now finally we get to some code (its kind of unavoidable..), you need to look at your site. (easiest way is by going to the homepage, right click and choose view source).</p>
<p>We&#8217;re looking for something like this:</p>
<pre>&lt;div id="content"&gt;
&lt;div class="post"&gt;This is my post 1, it has a lot of content in it about Bananas...&lt;/div&gt;
&lt;div class="post"&gt;This is my post 2, it has a lot of content in it about Bananas...&lt;/div&gt;
&lt;div class="post"&gt;This is my post 3, it has a lot of content in it about Bananas...&lt;/div&gt;
&lt;div class="post"&gt;This is my post 4, it has a lot of content in it about Bananas...&lt;/div&gt;
&lt;/div&gt;
&lt;div id="navigation"&gt;
&lt;div class='next'&gt;
&lt;a href='/page/2/'&gt;Next Page&lt;/a&gt;
&lt;/div&gt;
&lt;/div&gt;</pre>
<p>In jQuery/CSS if we want to select something by its ID we use &#8216;#&#8217;, if we want to select something by its class we use &#8216;.&#8217;. And finally if we want to drill into something we leave a space&#8230; see my selectors below and hopefully you&#8217;ll get it! Selectors for above:</p>
<ul>
<li>nextSelector: #navigation .next a:first</li>
<li>navSelector: #navigation</li>
<li>contentSelector: #content</li>
<li>itemSelector: #content .post</li>
</ul>
<p>Hope you enjoyed reading my self-help guide on getting to know your selectors! If you need any help just leave a comment or (preferably) open a ticket in the <a href="http://wordpress.org/tags/infinite-scroll?forum_id=10">wordpress forums</a> or <a href="https://github.com/paulirish/infinite-scroll/issues?sort=created&amp;direction=desc&amp;state=open">infinite-scroll site</a>.</p>
<p>Related posts:<ol>
<li><a href='http://beaver6813.com/2011/05/selectinvite-all-friends-on-facebook-automatically/' rel='bookmark' title='Select/Invite all friends on Facebook automatically'>Select/Invite all friends on Facebook automatically</a></li>
<li><a href='http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/' rel='bookmark' title='GoDaddy mod_rewrite Hell'>GoDaddy mod_rewrite Hell</a></li>
<li><a href='http://beaver6813.com/2010/06/phpgsb-php-google-safe-browsing/' rel='bookmark' title='phpGSB &#8211; PHP Google Safe Browsing'>phpGSB &#8211; PHP Google Safe Browsing</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://beaver6813.com/2012/01/selectors-in-infinite-scroll/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP: unset() not freeing memory fully on objects</title>
		<link>http://beaver6813.com/2011/06/php-unset-not-freeing-memory-fully-on-objects/</link>
		<comments>http://beaver6813.com/2011/06/php-unset-not-freeing-memory-fully-on-objects/#comments</comments>
		<pubDate>Sun, 05 Jun 2011 20:35:00 +0000</pubDate>
		<dc:creator>Beaver6813</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://beaver6813.com/?p=290</guid>
		<description><![CDATA[I spent a while trying to figure this out; but it&#8217;s quite simple (though I find rather counter-intuitive). Essentially when you create an object in PHP you are allocating memory to that object. When you want to remove that object &#8230; <a href="http://beaver6813.com/2011/06/php-unset-not-freeing-memory-fully-on-objects/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://beaver6813.com/2009/11/case-of-the-missinghidden-ie8-developer-tools-window/' rel='bookmark' title='Case of the missing/hidden IE8 Developer Tools window'>Case of the missing/hidden IE8 Developer Tools window</a></li>
<li><a href='http://beaver6813.com/2009/10/bash-bad-interpreter/' rel='bookmark' title='Bash, Bad Interpreter'>Bash, Bad Interpreter</a></li>
<li><a href='http://beaver6813.com/2010/05/decor-scene/' rel='bookmark' title='Decor Scene'>Decor Scene</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I spent a while trying to figure this out; but it&#8217;s quite simple (though I find rather counter-intuitive). Essentially when you create an object in PHP you are allocating memory to that object. When you want to remove that object you can use the unset() function (just like on most things in PHP). The problem occurs when there are variables stored inside the object &#8212; unset() doesn&#8217;t delete these from memory. This is because unset() doesn&#8217;t trigger the object&#8217;s destructor. A simple way around it is to explicitly call the destructor and then unset the object like so:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p290code2'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2902"><td class="code" id="p290code2"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$myobject</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CrazySystem<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myobject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">LargeVariable</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;VeryLargeFile.txt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Now we want to delete the object and everything it contains</span>
<span style="color: #000088;">$myobject</span><span style="color: #339933;">-&gt;</span>__destruct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$myobject</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//It's now all gone!</span></pre></td></tr></table></div>

<p>Hope that helps anyone who was wondering why unsetting object still wasn&#8217;t freeing memory!</p>
<p>Related posts:<ol>
<li><a href='http://beaver6813.com/2009/11/case-of-the-missinghidden-ie8-developer-tools-window/' rel='bookmark' title='Case of the missing/hidden IE8 Developer Tools window'>Case of the missing/hidden IE8 Developer Tools window</a></li>
<li><a href='http://beaver6813.com/2009/10/bash-bad-interpreter/' rel='bookmark' title='Bash, Bad Interpreter'>Bash, Bad Interpreter</a></li>
<li><a href='http://beaver6813.com/2010/05/decor-scene/' rel='bookmark' title='Decor Scene'>Decor Scene</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://beaver6813.com/2011/06/php-unset-not-freeing-memory-fully-on-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Select/Invite all friends on Facebook automatically</title>
		<link>http://beaver6813.com/2011/05/selectinvite-all-friends-on-facebook-automatically/</link>
		<comments>http://beaver6813.com/2011/05/selectinvite-all-friends-on-facebook-automatically/#comments</comments>
		<pubDate>Tue, 10 May 2011 21:05:44 +0000</pubDate>
		<dc:creator>Beaver6813</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://beaver6813.com/?p=283</guid>
		<description><![CDATA[Facebook recently updated the way they allow you to invite friends. Purposely or, as a side effect, it means that the popular javascript code that lets you select all friends no longer works. The following code courtesy of John P. &#8230; <a href="http://beaver6813.com/2011/05/selectinvite-all-friends-on-facebook-automatically/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://beaver6813.com/2012/01/selectors-in-infinite-scroll/' rel='bookmark' title='Selectors in Infinite-Scroll'>Selectors in Infinite-Scroll</a></li>
<li><a href='http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/' rel='bookmark' title='GoDaddy mod_rewrite Hell'>GoDaddy mod_rewrite Hell</a></li>
<li><a href='http://beaver6813.com/2010/07/php-compilation-cannot-find-lltdl/' rel='bookmark' title='PHP Compilation (Cannot find -lltdl)'>PHP Compilation (Cannot find -lltdl)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Facebook recently updated the way they allow you to invite friends. Purposely or, as a side effect, it means that the popular javascript code that lets you select all friends no longer works. The following code courtesy of <a href="http://onemansblog.com/2009/08/30/how-to-invite-all-facebook-friends-to-a-group-event-or-page/">John P</a>. allows you to select all friends on the new version. (Yay!)</p>
<p>There is one catch. Because Facebook now only loads a few of your friends at a time, you have to scroll all the way down the invite list until you hit the very bottom (all your friends are displayed). You then just paste the following into the URL bar and hit enter:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p283code4'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2834"><td class="code" id="p283code4"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span> check_all_in_document<span style="color: #009900;">&#40;</span>doc<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #003366; font-weight: bold;">var</span> c<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>c<span style="color: #339933;">=</span>doc.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>for<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>c.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">type</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'checkbox'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>c<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span>check_all_in_document<span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">document</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>for<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> j<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>j<span style="color: #339933;">&lt;</span>window.<span style="color: #660066;">frames</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>check_all_in_document<span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">frames</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">document</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Happy inviting! (If the code doesn&#8217;t work then make sure you click &#8220;View Code&#8221; in the box above.)</p>
<p>Related posts:<ol>
<li><a href='http://beaver6813.com/2012/01/selectors-in-infinite-scroll/' rel='bookmark' title='Selectors in Infinite-Scroll'>Selectors in Infinite-Scroll</a></li>
<li><a href='http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/' rel='bookmark' title='GoDaddy mod_rewrite Hell'>GoDaddy mod_rewrite Hell</a></li>
<li><a href='http://beaver6813.com/2010/07/php-compilation-cannot-find-lltdl/' rel='bookmark' title='PHP Compilation (Cannot find -lltdl)'>PHP Compilation (Cannot find -lltdl)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://beaver6813.com/2011/05/selectinvite-all-friends-on-facebook-automatically/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Regular Expression for Passwords</title>
		<link>http://beaver6813.com/2011/01/regular-expression-for-passwords/</link>
		<comments>http://beaver6813.com/2011/01/regular-expression-for-passwords/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 15:49:40 +0000</pubDate>
		<dc:creator>Beaver6813</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://beaver6813.com/?p=266</guid>
		<description><![CDATA[This is just a note to myself really, below is the regular expression for a string or in my case password where you require it to have at least one letter, one number, a limited selection of special characters (optional) &#8230; <a href="http://beaver6813.com/2011/01/regular-expression-for-passwords/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://beaver6813.com/2011/05/selectinvite-all-friends-on-facebook-automatically/' rel='bookmark' title='Select/Invite all friends on Facebook automatically'>Select/Invite all friends on Facebook automatically</a></li>
<li><a href='http://beaver6813.com/2009/11/email-to-sms-email-to-mobile-free-database/' rel='bookmark' title='Email to SMS / Email to Mobile, Free Database'>Email to SMS / Email to Mobile, Free Database</a></li>
<li><a href='http://beaver6813.com/2009/10/php-get-current-time-in-milliseconds/' rel='bookmark' title='[PHP] Get current time in milliseconds'>[PHP] Get current time in milliseconds</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This is just a note to myself really, below is the regular expression for a string or in my case password where you require it to have at least one letter, one number, a limited selection of special characters (optional) and a minimum of 8 characters in length:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p266code6'); return false;">View Code</a> REGEX</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2666"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p266code6"><pre class="regex" style="font-family:monospace;">^(?=.{8,})(?=.*\d)(?=.*[a-zA-Z])[a-zA-Z0-9@#$%^&amp;+=\*]*$</pre></td></tr></table></div>

<p>Related posts:<ol>
<li><a href='http://beaver6813.com/2011/05/selectinvite-all-friends-on-facebook-automatically/' rel='bookmark' title='Select/Invite all friends on Facebook automatically'>Select/Invite all friends on Facebook automatically</a></li>
<li><a href='http://beaver6813.com/2009/11/email-to-sms-email-to-mobile-free-database/' rel='bookmark' title='Email to SMS / Email to Mobile, Free Database'>Email to SMS / Email to Mobile, Free Database</a></li>
<li><a href='http://beaver6813.com/2009/10/php-get-current-time-in-milliseconds/' rel='bookmark' title='[PHP] Get current time in milliseconds'>[PHP] Get current time in milliseconds</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://beaver6813.com/2011/01/regular-expression-for-passwords/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Compilation (Cannot find -lltdl)</title>
		<link>http://beaver6813.com/2010/07/php-compilation-cannot-find-lltdl/</link>
		<comments>http://beaver6813.com/2010/07/php-compilation-cannot-find-lltdl/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 18:15:10 +0000</pubDate>
		<dc:creator>Beaver6813</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[php php5 mcrypt lltdl source compile]]></category>

		<guid isPermaLink="false">http://beaver6813.com/?p=234</guid>
		<description><![CDATA[When compiling PHP from source (in my case version 5.3.2) on CentOS 5.4 I kept getting the following error when trying to compile with mcrypt: "/usr/bin/ld: cannot find -lltdl" This seems to be due to a missing development library with &#8230; <a href="http://beaver6813.com/2010/07/php-compilation-cannot-find-lltdl/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://beaver6813.com/2009/11/case-of-the-missinghidden-ie8-developer-tools-window/' rel='bookmark' title='Case of the missing/hidden IE8 Developer Tools window'>Case of the missing/hidden IE8 Developer Tools window</a></li>
<li><a href='http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/' rel='bookmark' title='GoDaddy mod_rewrite Hell'>GoDaddy mod_rewrite Hell</a></li>
<li><a href='http://beaver6813.com/2010/03/jokepants/' rel='bookmark' title='Jokepants'>Jokepants</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>When compiling PHP from source (in my case version 5.3.2) on CentOS 5.4 I kept getting the following error when trying to compile with mcrypt:</p>
<p><code>"/usr/bin/ld: cannot find -lltdl"</code></p>
<p>This seems to be due to a missing development library with the obscure name of <span style="font-family: Courier New;">libtool-ltdl-devel</span> to fix this simply use:</p>
<p><code>yum install libtool-ltdl-devel</code></p>
<p>Which should include the package along with several dependencies.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">libltdl3-dev</div>
<p>Related posts:<ol>
<li><a href='http://beaver6813.com/2009/11/case-of-the-missinghidden-ie8-developer-tools-window/' rel='bookmark' title='Case of the missing/hidden IE8 Developer Tools window'>Case of the missing/hidden IE8 Developer Tools window</a></li>
<li><a href='http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/' rel='bookmark' title='GoDaddy mod_rewrite Hell'>GoDaddy mod_rewrite Hell</a></li>
<li><a href='http://beaver6813.com/2010/03/jokepants/' rel='bookmark' title='Jokepants'>Jokepants</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://beaver6813.com/2010/07/php-compilation-cannot-find-lltdl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Search and Replace Directory Recursively</title>
		<link>http://beaver6813.com/2010/04/php-search-and-replace-directory-recursively/</link>
		<comments>http://beaver6813.com/2010/04/php-search-and-replace-directory-recursively/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 16:04:11 +0000</pubDate>
		<dc:creator>Beaver6813</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[find and replace]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[recurse]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[search and replace]]></category>

		<guid isPermaLink="false">http://beaver6813.com/?p=207</guid>
		<description><![CDATA[On a message forum I regularily visit a member was having issues with code being placed in multiple files that he wanted to remove or change without having to edit each and every file manually. For this I created a &#8230; <a href="http://beaver6813.com/2010/04/php-search-and-replace-directory-recursively/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://beaver6813.com/2009/10/bash-bad-interpreter/' rel='bookmark' title='Bash, Bad Interpreter'>Bash, Bad Interpreter</a></li>
<li><a href='http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/' rel='bookmark' title='GoDaddy mod_rewrite Hell'>GoDaddy mod_rewrite Hell</a></li>
<li><a href='http://beaver6813.com/2009/10/fetchmp3-com/' rel='bookmark' title='FetchMP3.com'>FetchMP3.com</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>On a message forum I regularily visit a member was having issues with code being placed in multiple files that he wanted to remove or change without having to edit each and every file manually. For this I created a search and replace function which will recursively search the directory and every file<span id="more-207"></span> for a specific piece of code and will replace with whatever:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p207code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2078"><td class="code" id="p207code8"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;!--</span>?php
<span style="color: #000088;">$stringsearch</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;texttosearchfor&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$stringreplace</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;texttoreplacewith&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;./&quot;</span><span style="color: #339933;">;</span>
SearchandReplace<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">,</span><span style="color: #000088;">$stringsearch</span><span style="color: #339933;">,</span><span style="color: #000088;">$stringreplace</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> SearchandReplace<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">,</span> <span style="color: #000088;">$stringsearch</span><span style="color: #339933;">,</span> <span style="color: #000088;">$stringreplace</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Starting search for <span style="color: #006699; font-weight: bold;">$stringsearch</span> within directory <span style="color: #006699; font-weight: bold;">$dir</span>
&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$listDir</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handler</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/opendir"><span style="color: #990000;">opendir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sub</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/readdir"><span style="color: #990000;">readdir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handler</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$sub</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #000088;">$sub</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;..&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$sub</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;Thumb.db&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_file"><span style="color: #990000;">is_file</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sub</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr_count"><span style="color: #990000;">substr_count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sub</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'.php'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                            <span style="color: #009900;">&#123;</span>
                            <span style="color: #000088;">$getfilecontents</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sub</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr_count"><span style="color: #990000;">substr_count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$getfilecontents</span><span style="color: #339933;">,</span><span style="color: #000088;">$stringsearch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
                            <span style="color: #009900;">&#123;</span>
                            <span style="color: #000088;">$replacer</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$stringsearch</span><span style="color: #339933;">,</span><span style="color: #000088;">$stringreplace</span><span style="color: #339933;">,</span><span style="color: #000088;">$getfilecontents</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                            <span style="color: #666666; font-style: italic;">// Let's make sure the file exists and is writable first.</span>
                              <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_writable"><span style="color: #990000;">is_writable</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sub</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sub</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                       <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Cannot open file (&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sub</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #339933;">;</span>
                                       <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #339933;">;</span>
                                  <span style="color: #009900;">&#125;</span>
                                  <span style="color: #666666; font-style: italic;">// Write $somecontent to our opened file.</span>
                                  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/fwrite"><span style="color: #990000;">fwrite</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span> <span style="color: #000088;">$replacer</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Cannot write to file (&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sub</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #339933;">;</span>
                                      <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #339933;">;</span>
                                  <span style="color: #009900;">&#125;</span>
                                  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Success, removed searched content from:&quot;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sub</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;
&quot;</span><span style="color: #339933;">;</span>
                                  <a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                              <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                                  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;The file &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sub</span><span style="color: #0000ff;">&quot; is not writable
&quot;</span><span style="color: #339933;">;</span>
                              <span style="color: #009900;">&#125;</span>
                            <span style="color: #009900;">&#125;</span>
                            <span style="color: #009900;">&#125;</span>
                        <span style="color: #000088;">$listDir</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$sub</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span><span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_dir"><span style="color: #990000;">is_dir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sub</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                        <span style="color: #000088;">$listDir</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$sub</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> SearchandReplace<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$sub</span><span style="color: #339933;">,</span><span style="color: #000088;">$stringsearch</span><span style="color: #339933;">,</span><span style="color: #000088;">$stringreplace</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            <a href="http://www.php.net/closedir"><span style="color: #990000;">closedir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handler</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$listDir</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
?<span style="color: #339933;">--&gt;</span></pre></td></tr></table></div>

<p>Related posts:<ol>
<li><a href='http://beaver6813.com/2009/10/bash-bad-interpreter/' rel='bookmark' title='Bash, Bad Interpreter'>Bash, Bad Interpreter</a></li>
<li><a href='http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/' rel='bookmark' title='GoDaddy mod_rewrite Hell'>GoDaddy mod_rewrite Hell</a></li>
<li><a href='http://beaver6813.com/2009/10/fetchmp3-com/' rel='bookmark' title='FetchMP3.com'>FetchMP3.com</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://beaver6813.com/2010/04/php-search-and-replace-directory-recursively/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>GoDaddy mod_rewrite Hell</title>
		<link>http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/</link>
		<comments>http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 13:17:58 +0000</pubDate>
		<dc:creator>Beaver6813</dc:creator>
				<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://beaver6813.com/?p=175</guid>
		<description><![CDATA[Whilst trying to install a piece of software on a GoDaddy hosted account I noticed that mod_rewrite variables were simply not being passed to the correct pages. When digging a bit deeper I found that it was effectively ignoring extensions &#8230; <a href="http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://beaver6813.com/2009/11/case-of-the-missinghidden-ie8-developer-tools-window/' rel='bookmark' title='Case of the missing/hidden IE8 Developer Tools window'>Case of the missing/hidden IE8 Developer Tools window</a></li>
<li><a href='http://beaver6813.com/2009/10/about-me/' rel='bookmark' title='About Me'>About Me</a></li>
<li><a href='http://beaver6813.com/2011/06/php-unset-not-freeing-memory-fully-on-objects/' rel='bookmark' title='PHP: unset() not freeing memory fully on objects'>PHP: unset() not freeing memory fully on objects</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Whilst trying to install a piece of software on a GoDaddy hosted account I noticed that mod_rewrite variables were simply not being passed to the correct pages. When digging a bit deeper I found that it was effectively ignoring extensions in URLs and just displaying the file with the extension. i.e. instead of having to enter:<span id="more-175"></span></p>
<p><code><em>www.example.com/advertise.php</em></code></p>
<p>you could instead type</p>
<p><code><em>www.example.com/advertise</em></code></p>
<p>And it would return the same file, which is good if for some unknown reason your file doesn&#8217;t have the correct extension, but its not exactly.. good..</p>
<p>After trawling Google for a while I found a post by <a href="http://www.ericfaerber.com/2007/08/21/godaddy-and-mod_rewrite/">Eric Faerber</a> that solved the problem. The strange redirects were due to Apache MultiViews being enabled, disabling this by entering</p>
<p><code><em>Options -MultiViews</em></code></p>
<p>into the .htaccess file. Solved the problem, the simplest solutions are always the best!</p>
<p>Related posts:<ol>
<li><a href='http://beaver6813.com/2009/11/case-of-the-missinghidden-ie8-developer-tools-window/' rel='bookmark' title='Case of the missing/hidden IE8 Developer Tools window'>Case of the missing/hidden IE8 Developer Tools window</a></li>
<li><a href='http://beaver6813.com/2009/10/about-me/' rel='bookmark' title='About Me'>About Me</a></li>
<li><a href='http://beaver6813.com/2011/06/php-unset-not-freeing-memory-fully-on-objects/' rel='bookmark' title='PHP: unset() not freeing memory fully on objects'>PHP: unset() not freeing memory fully on objects</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Case of the missing/hidden IE8 Developer Tools window</title>
		<link>http://beaver6813.com/2009/11/case-of-the-missinghidden-ie8-developer-tools-window/</link>
		<comments>http://beaver6813.com/2009/11/case-of-the-missinghidden-ie8-developer-tools-window/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 14:14:02 +0000</pubDate>
		<dc:creator>Beaver6813</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[developer tools]]></category>
		<category><![CDATA[hidden]]></category>
		<category><![CDATA[missing]]></category>
		<category><![CDATA[window]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://beaver6813.com/?p=120</guid>
		<description><![CDATA[Whilst working on a current project I was trying to get cross-browser compatability working nicely. However when I came to load up IE&#8217;s Developer Tools I found it was loading up the window but nothing was there! I&#8217;m running Windows &#8230; <a href="http://beaver6813.com/2009/11/case-of-the-missinghidden-ie8-developer-tools-window/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://beaver6813.com/2011/05/selectinvite-all-friends-on-facebook-automatically/' rel='bookmark' title='Select/Invite all friends on Facebook automatically'>Select/Invite all friends on Facebook automatically</a></li>
<li><a href='http://beaver6813.com/2010/07/php-compilation-cannot-find-lltdl/' rel='bookmark' title='PHP Compilation (Cannot find -lltdl)'>PHP Compilation (Cannot find -lltdl)</a></li>
<li><a href='http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/' rel='bookmark' title='GoDaddy mod_rewrite Hell'>GoDaddy mod_rewrite Hell</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Whilst working on a current project I was trying to get cross-browser compatability working nicely. However when I came to load up IE&#8217;s Developer Tools I found it was loading up the window but nothing was there! I&#8217;m running Windows 7 and this seems to be the only<span id="more-120"></span> version of windows the problem is affecting:<br />
<a href="http://beaver6813.com/wp-content/uploads/2009/11/missingdev.png"><img class="size-full wp-image-121 aligncenter" title="Missing/Hidden Developer Tools" src="http://beaver6813.com/wp-content/uploads/2009/11/missingdev.png" alt="Missing/Hidden Developer Tools" width="468" height="263" /></a></p>
<p style="text-align: left;">The solution I found is actually very simple, right click on that hidden window thumbnail and click maximise. If that fails then you could always try a solution outlined on <a href="http://stackoverflow.com/questions/960683/why-isnt-my-ie8-developer-tools-working">StackOverflow</a>. The best solutions are often the most simple!!</p>
<p>Related posts:<ol>
<li><a href='http://beaver6813.com/2011/05/selectinvite-all-friends-on-facebook-automatically/' rel='bookmark' title='Select/Invite all friends on Facebook automatically'>Select/Invite all friends on Facebook automatically</a></li>
<li><a href='http://beaver6813.com/2010/07/php-compilation-cannot-find-lltdl/' rel='bookmark' title='PHP Compilation (Cannot find -lltdl)'>PHP Compilation (Cannot find -lltdl)</a></li>
<li><a href='http://beaver6813.com/2010/03/godaddy-mod_rewrite-hell/' rel='bookmark' title='GoDaddy mod_rewrite Hell'>GoDaddy mod_rewrite Hell</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://beaver6813.com/2009/11/case-of-the-missinghidden-ie8-developer-tools-window/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>[PHP] Get current time in milliseconds</title>
		<link>http://beaver6813.com/2009/10/php-get-current-time-in-milliseconds/</link>
		<comments>http://beaver6813.com/2009/10/php-get-current-time-in-milliseconds/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 17:59:31 +0000</pubDate>
		<dc:creator>Beaver6813</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[milliseconds]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[timer]]></category>

		<guid isPermaLink="false">http://beaver6813.com/?p=100</guid>
		<description><![CDATA[I recently needed to get the current time in milliseconds, of course this can easily be retrieved using microtime() however I needed the entire number in digits, not in decimals with seconds seperately etc. Heres how: View Code PHP1 2 &#8230; <a href="http://beaver6813.com/2009/10/php-get-current-time-in-milliseconds/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://beaver6813.com/2010/04/php-search-and-replace-directory-recursively/' rel='bookmark' title='PHP Search and Replace Directory Recursively'>PHP Search and Replace Directory Recursively</a></li>
<li><a href='http://beaver6813.com/2010/03/jokepants/' rel='bookmark' title='Jokepants'>Jokepants</a></li>
<li><a href='http://beaver6813.com/2010/05/decor-scene/' rel='bookmark' title='Decor Scene'>Decor Scene</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I recently needed to get the current time in milliseconds, of course this can easily be retrieved using microtime() however I needed the entire number in digits, not in decimals with seconds seperately etc. Heres how:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p100code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p10010"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p100code10"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$timeparts</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><a href="http://www.php.net/microtime"><span style="color: #990000;">microtime</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$currenttime</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/bcadd"><span style="color: #990000;">bcadd</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$timeparts</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><a href="http://www.php.net/bcmul"><span style="color: #990000;">bcmul</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$timeparts</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currenttime</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><em>NOTE: PHP5 is required for this function due to the improvements with microtime() and the bc math module is also required (as we&#8217;re dealing with large numbers, you can check if you have the module in phpinfo).</em></p>
<p>Related posts:<ol>
<li><a href='http://beaver6813.com/2010/04/php-search-and-replace-directory-recursively/' rel='bookmark' title='PHP Search and Replace Directory Recursively'>PHP Search and Replace Directory Recursively</a></li>
<li><a href='http://beaver6813.com/2010/03/jokepants/' rel='bookmark' title='Jokepants'>Jokepants</a></li>
<li><a href='http://beaver6813.com/2010/05/decor-scene/' rel='bookmark' title='Decor Scene'>Decor Scene</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://beaver6813.com/2009/10/php-get-current-time-in-milliseconds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash, Bad Interpreter</title>
		<link>http://beaver6813.com/2009/10/bash-bad-interpreter/</link>
		<comments>http://beaver6813.com/2009/10/bash-bad-interpreter/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 15:42:42 +0000</pubDate>
		<dc:creator>Beaver6813</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[bad]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[interpreter]]></category>
		<category><![CDATA[remedy]]></category>

		<guid isPermaLink="false">http://beaver6813.com/?p=84</guid>
		<description><![CDATA[I recently came across: /bin/bash^M: bad interpreter: No such file or directory When trying to run a bash script that someone else had edited. This most commonly happens on UNIX systems if the file has been edited on MS-DOS or &#8230; <a href="http://beaver6813.com/2009/10/bash-bad-interpreter/">Continue reading <span class="meta-nav">&#8594;</span></a>
Related posts:<ol>
<li><a href='http://beaver6813.com/2009/10/fetchmp3-com/' rel='bookmark' title='FetchMP3.com'>FetchMP3.com</a></li>
<li><a href='http://beaver6813.com/2010/03/jokepants/' rel='bookmark' title='Jokepants'>Jokepants</a></li>
<li><a href='http://beaver6813.com/2011/06/php-unset-not-freeing-memory-fully-on-objects/' rel='bookmark' title='PHP: unset() not freeing memory fully on objects'>PHP: unset() not freeing memory fully on objects</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I recently came across:</p>
<p>/bin/bash^M: bad interpreter: No such file or directory</p>
<p>When trying to run a bash script that someone else had edited. This most commonly happens on UNIX systems if the file has been edited on MS-DOS or Mac. The cure for this is to run a simple perl script:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p84code12'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8412"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p84code12"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -pi</span>
s<span style="color: #000000; font-weight: bold;">/</span>\n<span style="color: #000000; font-weight: bold;">/</span>\r\n<span style="color: #000000; font-weight: bold;">/</span>;</pre></td></tr></table></div>

<p>Save as unix2dos.pl, chmod +x unix2dos.pl and then run like:</p>
<p>./unix2dos.pl filetoconvert.txt</p>
<p>Simples!</p>
<p>Related posts:<ol>
<li><a href='http://beaver6813.com/2009/10/fetchmp3-com/' rel='bookmark' title='FetchMP3.com'>FetchMP3.com</a></li>
<li><a href='http://beaver6813.com/2010/03/jokepants/' rel='bookmark' title='Jokepants'>Jokepants</a></li>
<li><a href='http://beaver6813.com/2011/06/php-unset-not-freeing-memory-fully-on-objects/' rel='bookmark' title='PHP: unset() not freeing memory fully on objects'>PHP: unset() not freeing memory fully on objects</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://beaver6813.com/2009/10/bash-bad-interpreter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

