<?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>Rusty Razor Blade</title>
	<atom:link href="http://www.rustyrazorblade.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rustyrazorblade.com</link>
	<description>Tech Thoughts, Mostly on LAMP - by Jon Haddad</description>
	<lastBuildDate>Wed, 21 Jul 2010 20:42:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>UIS PHP53, DOM Parsing, PHPUnit, Puppet Config Solution</title>
		<link>http://www.rustyrazorblade.com/2010/07/uis-php53-dom-parsing-phpunit-puppet-config-solution/</link>
		<comments>http://www.rustyrazorblade.com/2010/07/uis-php53-dom-parsing-phpunit-puppet-config-solution/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 20:42:03 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[puppet]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1126</guid>
		<description><![CDATA[I&#8217;m using PHP53 package from the IUS Community repository.  I&#8217;ve been trying to get phpunit to install, but it gives an error that it needs DOM install.  It took me a little bit to figure this out, but I finally got it working.  What you need is the php53-xml package.  You [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using PHP53 package from the <a href="http://iuscommunity.org/">IUS Community</a> repository.  I&#8217;ve been trying to get phpunit to install, but it gives an error that it needs DOM install.  It took me a little bit to figure this out, but I finally got it working.  What you need is the php53-xml package.  You can install it using </p>
<pre>
yum install php53-xml
</pre>
<p>or if you&#8217;re using puppet</p>
<pre>
package { ["php53-xml"]:
          ensure => present
        }
</pre>
<p>And finally, to get it to install, I used the below.   I had to make it go to multiple lines to fit on the page but I have it all on 1 line in my puppet script:</p>
<pre>
exec { "pear channel-discover pear.phpunit.de;
pear channel-discover pear.symfony-project.com;
pear install --alldeps phpunit/PHPUnit  ":
          creates => "/usr/bin/phpunit"
 }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/07/uis-php53-dom-parsing-phpunit-puppet-config-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging with Erlang</title>
		<link>http://www.rustyrazorblade.com/2010/07/debugging-with-erlang/</link>
		<comments>http://www.rustyrazorblade.com/2010/07/debugging-with-erlang/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 23:58:12 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1110</guid>
		<description><![CDATA[First, make sure you have the compile flag (+debug_info) set when compiling your source, then fire up the debugger:
1> i:im(). 
My Erlang Makefile:

EBIN_DIR := ebin
SRC_DIR := src
EXAMPLES_DIR := examples
INCLUDE_DIR := include
ERLC := erlc
ERLC_FLAGS := +debug_info +native -W -I $(INCLUDE_DIR) -o $(EBIN_DIR)

all:
	@mkdir -p $(EBIN_DIR)
	$(ERLC) $(ERLC_FLAGS) $(SRC_DIR)/*.erl

clean:
	@rm -rf $(EBIN_DIR)/*
	@rm -f erl_crash.dump

Read up on the Erlang docs.
The debugger [...]]]></description>
			<content:encoded><![CDATA[<p>First, make sure you have the compile flag (+debug_info) set when compiling your source, then fire up the debugger:</p>
<pre>1> i:im(). </pre>
<p>My Erlang Makefile:</p>
<pre>
EBIN_DIR := ebin
SRC_DIR := src
EXAMPLES_DIR := examples
INCLUDE_DIR := include
ERLC := erlc
ERLC_FLAGS := +debug_info +native -W -I $(INCLUDE_DIR) -o $(EBIN_DIR)

all:
	@mkdir -p $(EBIN_DIR)
	$(ERLC) $(ERLC_FLAGS) $(SRC_DIR)/*.erl

clean:
	@rm -rf $(EBIN_DIR)/*
	@rm -f erl_crash.dump
</pre>
<p><a href="http://www.erlang.org/doc/apps/debugger/debugger_chapter.html">Read up on the Erlang docs.</a></p>
<p>The debugger can be a bit weird in that it doesn&#8217;t always find your ebin directory (if you&#8217;re compiling to a separate ebin dir)&#8230; it took me a bit to figure out.  Also on the Mac it seems to either crash or not launch timetimes.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/07/debugging-with-erlang/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Headless Virtual Box</title>
		<link>http://www.rustyrazorblade.com/2010/07/headless-virtual-box/</link>
		<comments>http://www.rustyrazorblade.com/2010/07/headless-virtual-box/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 23:07:01 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[virtual box]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1116</guid>
		<description><![CDATA[I like running VirtualBox headless on my Mac.  It doesn&#8217;t show up in the Dock, and feels like it&#8217;s a remote server.
First, figure out which VMs you have on your machine.
haddad-work:~ jhaddad$ VBoxManage list vms
Oracle VM VirtualBox Command Line Management Interface Version 3.2.6
(C) 2005-2010 Oracle Corporation
All rights reserved.

"WebServer" {2c61a180-e098-4926-b09a-27e431791c88}
Then start it using VBoxHeadless
nohup VBoxHeadless [...]]]></description>
			<content:encoded><![CDATA[<p>I like running VirtualBox headless on my Mac.  It doesn&#8217;t show up in the Dock, and feels like it&#8217;s a remote server.</p>
<p>First, figure out which VMs you have on your machine.</p>
<pre>haddad-work:~ jhaddad$ VBoxManage list vms
Oracle VM VirtualBox Command Line Management Interface Version 3.2.6
(C) 2005-2010 Oracle Corporation
All rights reserved.

"WebServer" {2c61a180-e098-4926-b09a-27e431791c88}</pre>
<p>Then start it using VBoxHeadless</p>
<pre>nohup VBoxHeadless -s WebServer -vrdp on  &#038;</pre>
<p>I&#8217;m using <a href="http://cord.sourceforge.net/">Cord</a> for RDP.</p>
<p>Open up Cord.  If you&#8217;re using the default settings, you can just go to quick connect and type &#8220;localhost&#8221;.  You&#8217;ll see your VM booting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/07/headless-virtual-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Erlang Code from the Command Line</title>
		<link>http://www.rustyrazorblade.com/2010/07/running-erlang-code-from-the-command-line/</link>
		<comments>http://www.rustyrazorblade.com/2010/07/running-erlang-code-from-the-command-line/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 18:31:31 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1105</guid>
		<description><![CDATA[This was really useful for me in scripting TextEdit to run my unit tests, as Erlide has been crashing every time I use it.

erl -run mymodule myfunc -run init stop -noshell

http://www.trapexit.org/Running_Erlang_Code_From_The_Command_Line
]]></description>
			<content:encoded><![CDATA[<p>This was really useful for me in scripting TextEdit to run my unit tests, as Erlide has been crashing every time I use it.</p>
<pre>
erl -run mymodule myfunc -run init stop -noshell
</pre>
<p><a href='Running Erlang Code From the Command Line'>http://www.trapexit.org/Running_Erlang_Code_From_The_Command_Line</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/07/running-erlang-code-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with DOM in PHP &#8211; Looking at a PHP HTML Parser</title>
		<link>http://www.rustyrazorblade.com/2010/06/working-with-dom-in-php-looking-at-an-html-parser/</link>
		<comments>http://www.rustyrazorblade.com/2010/06/working-with-dom-in-php-looking-at-an-html-parser/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 19:25:45 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[html]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1095</guid>
		<description><![CDATA[So, lets assume you&#8217;ve got a PHP project where you&#8217;re scraping pages and trying parse fields out of the DOM.  Up till now, I&#8217;ve just used regular expressions because they&#8217;re easy.  I avoided trying to parse html as xml using SimpleXML because there&#8217;s just to many cases where it would fail due to invalid tags.
Well, [...]]]></description>
			<content:encoded><![CDATA[<p>So, lets assume you&#8217;ve got a PHP project where you&#8217;re scraping pages and trying parse fields out of the DOM.  Up till now, I&#8217;ve just used regular expressions because they&#8217;re easy.  I avoided trying to parse html as xml using SimpleXML because there&#8217;s just to many cases where it would fail due to invalid tags.</p>
<p>Well, I feel like an idiot.  It turns out there&#8217;s a great extension built into PHP to do just that, and it&#8217;s the <a href="http://us.php.net/manual/en/book.dom.php">DOM extension</a>.  Using this, parsing HTML with PHP is just as easy as accessing the DOM using <a href="http://jquery.com/">JQuery</a>. (hint: very easy).</p>
<p>Lets say we&#8217;ve got a page our drive already.  For this example, I&#8217;ll use the <a href="http://www.rustyrazorblade.com/">homepage of this blog</a>.  We&#8217;re going to parse out all the links.  I&#8217;ve saved the page as index.html and in the same directory I&#8217;ve created the parser script.</p>
<pre>&lt;?
$dom = new DomDocument;</pre>
<pre>// you can use loadHTML if you already have your string in memory
$dom-&gt;loadHTMLFile( "index.html" );
$dom-&gt;preserveWhiteSpace = false;

// grab all the A tags
// returns a domnodelist
$tags = $dom-&gt;getElementsByTagName( 'a' );

// you can actually iterate over the tags returned - </pre>
<pre>// I'm not sure why they don't say that more explicitly
</pre>
<pre>echo "Total length:"  . count($tags-&gt;length) . "\n";

foreach($tags as $t)
{
	// each of these is a DOMElement object
	// the value is what's inside the tag
	// the attributes can also be accessed
	printf( "%-50s%s   \n", $t-&gt;nodeValue, $t-&gt;getAttribute('href') );

}</pre>
<p>Here&#8217;s a glimpse of the output:</p>
<pre>
vim                 http://www.rustyrazorblade.com/category/vim/  
virtual box         http://www.rustyrazorblade.com/category/virtual-box/   
vmware              http://www.rustyrazorblade.com/category/vmware/
weird               http://www.rustyrazorblade.com/category/weird/   
wikipedia           http://www.rustyrazorblade.com/category/wikipedia/
windows             http://www.rustyrazorblade.com/category/windows/  
xcode               http://www.rustyrazorblade.com/category/xcode/ 
﻿</pre>
</p>
<p><a target="_blank" href="http://www.phpro.org/examples/Parse-HTML-With-PHP-And-DOM.html">Here&#8217;s another great reference</a> I originally used to get started:</p>
<p>You can take this a bit further if you want to use the <a href="http://php.net/manual/en/book.curl.php">php curl extension</a>.  Additionally, if you&#8217;re interested in using the advanced curl_multi_exec functionality, check out my <a href="2008/02/curl_multi_exec/" target="_blank">previous post</a>.</p>
<p><em>Edit: <a href="http://www.reddit.com/user/cynope">cynope</a> on reddit suggested <a href="http://code.google.com/p/phpquery/">phpquery</a>.  I haven&#8217;t used it yet but it looks pretty cool. If I get a chance to try it I&#8217;ll post a followup.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/06/working-with-dom-in-php-looking-at-an-html-parser/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Print all Puppet Config Variables</title>
		<link>http://www.rustyrazorblade.com/2010/05/print-all-puppet-config-variables/</link>
		<comments>http://www.rustyrazorblade.com/2010/05/print-all-puppet-config-variables/#comments</comments>
		<pubDate>Fri, 07 May 2010 21:44:03 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[puppet]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1092</guid>
		<description><![CDATA[For some reason, I haven&#8217;t found this anywhere in the docs.

puppet --configprint all

It&#8217;ll print all your puppet configuration variables.
]]></description>
			<content:encoded><![CDATA[<p>For some reason, I haven&#8217;t found this anywhere in the docs.</p>
<pre>
puppet --configprint all
</pre>
<p>It&#8217;ll print all your puppet configuration variables.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/05/print-all-puppet-config-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VirtualBox Guest Additions &#8211; Redhat / CentOS</title>
		<link>http://www.rustyrazorblade.com/2010/04/virtualbox-guest-additions-redhat-centos/</link>
		<comments>http://www.rustyrazorblade.com/2010/04/virtualbox-guest-additions-redhat-centos/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 21:49:24 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[virtual box]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1089</guid>
		<description><![CDATA[Mount VirtualBox Additions disk through the VirtualBox UI.

yum install -y gcc kernel-devel-`uname -r`
mkdir /mnt/cdrom
mount -o ro -t iso9660 /dev/cdrom /mnt/cdrom
sh /mnt/cdrom/VBoxLinuxAdditions-amd64.run

Info found on tuxtraining.com
]]></description>
			<content:encoded><![CDATA[<p>Mount VirtualBox Additions disk through the VirtualBox UI.</p>
<pre>
yum install -y gcc kernel-devel-`uname -r`
mkdir /mnt/cdrom
mount -o ro -t iso9660 /dev/cdrom /mnt/cdrom
sh /mnt/cdrom/VBoxLinuxAdditions-amd64.run
</pre>
<p>Info found on <a href="http://tuxtraining.com/2009/01/06/install-guest-additions-in-centos-through-virtualbox">tuxtraining.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/04/virtualbox-guest-additions-redhat-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove File From Git History</title>
		<link>http://www.rustyrazorblade.com/2010/04/remove-file-from-git-history/</link>
		<comments>http://www.rustyrazorblade.com/2010/04/remove-file-from-git-history/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 20:55:43 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1084</guid>
		<description><![CDATA[Useful stuff.  

git filter-branch -f --index-filter 'git update-index --remove filename' HEAD
git push --force --verbose --dry-run
git push --force

Slight better version.  Only rewrites history from the first commit the file existed.
git filter-branch -f --index-filter 'git update-index --remove filename' ..HEAD
git push --force --verbose --dry-run
git push --force
Found on github.
]]></description>
			<content:encoded><![CDATA[<p>Useful stuff.  </p>
<pre>
git filter-branch -f --index-filter 'git update-index --remove filename' HEAD
git push --force --verbose --dry-run
git push --force
</pre>
<p>Slight better version.  Only rewrites history from the first commit the file existed.</p>
<pre>git filter-branch -f --index-filter 'git update-index --remove filename' <introduction-revision-sha1>..HEAD
git push --force --verbose --dry-run
git push --force</pre>
<p>Found on <a href="http://github.com/guides/completely-remove-a-file-from-all-revisions">github.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/04/remove-file-from-git-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Puppet Stand Alone &#8211; Templates, Configs</title>
		<link>http://www.rustyrazorblade.com/2010/04/puppet-stand-alone-templates-configs/</link>
		<comments>http://www.rustyrazorblade.com/2010/04/puppet-stand-alone-templates-configs/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 01:12:42 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[puppet]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1081</guid>
		<description><![CDATA[I&#8217;m working on getting all our servers standardized with puppet to minimize installation and maintenance hassle.  Pretty exciting.
I&#8217;m setting all this up with puppet standalone.  I don&#8217;t think we really gain anything by using the daemons, so it&#8217;s just a simple call to 
puppet site.pp -v
And the changes are applied.
I ran into a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on getting all our servers standardized with puppet to minimize installation and maintenance hassle.  Pretty exciting.</p>
<p>I&#8217;m setting all this up with puppet standalone.  I don&#8217;t think we really gain anything by using the daemons, so it&#8217;s just a simple call to </p>
<pre>puppet site.pp -v</pre>
<p>And the changes are applied.</p>
<p>I ran into a snag today trying to get templates working.  I kept getting the below error when trying to update my test system:</p>
<blockquote><p>Could not find template &#8216;push.erb&#8217; at /etc/puppet/manifests/site.pp:32 on node somename.myserver.local</p></blockquote>
<p>Using strace:</p>
<pre>
[root@somename manifests]# strace -o ~/trace.txt -e trace=file puppet site.pp
Could not find template 'push.erb' at /etc/puppet/manifests/site.pp:32 on
node somename.myserver.local
[root@somename manifests]# tail -n 1 ~/trace.txt
stat("/var/puppet/templates", 0x7fffb7073a30) = -1 ENOENT (No such file or directory)
</pre>
<p>Fortunately there&#8217;s also config tool to check this stuff:</p>
<pre>
[root@somename manifests]# puppet --configprint templatedir
/var/puppet/templates
</pre>
<p>I have everything under /etc/puppet, NOT /var/puppet.  I want the templates directory to reside in there too.  I had a /etc/puppet/puppetd.conf file, and I set the <em>templatedir</em> variable in there under [puppetd] and [puppetmasterd] and [puppet] (I really had no idea which it needed) &#8211; and when that still didn&#8217;t work I tried renaming the config to <strong>puppet.conf</strong>.  These are the lines I needed:</p>
<pre>[puppet]
templatedir=/etc/puppet/templates
</pre>
<p>Thanks to the guys in #puppet on freenode for helping me sort this out.</p>
<p>See the <a target="_blank" href="http://www.puppetlabs.com/">puppet site</a> and <a target="_blank" href="http://docs.puppetlabs.com/">documentation</a> for more info.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/04/puppet-stand-alone-templates-configs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mount afp share over command line</title>
		<link>http://www.rustyrazorblade.com/2010/04/mount-afp-share-over-command-line/</link>
		<comments>http://www.rustyrazorblade.com/2010/04/mount-afp-share-over-command-line/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 20:15:50 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1079</guid>
		<description><![CDATA[This is so useful to me that I have to repost it here, just in case it disappears.

# create a folder for the mount point
sudo mkdir /Volumes/music

# mount the disk
mount -t afp afp:/// /Volumes/music/

#refresh the finder for when you get back
disktool -r

# when you're done
sudo umount /Volumes/music

Found on macosxhints
]]></description>
			<content:encoded><![CDATA[<p>This is so useful to me that I have to repost it here, just in case it disappears.</p>
<pre>
# create a folder for the mount point
sudo mkdir /Volumes/music

# mount the disk
mount -t afp afp://<ip address>/<share name> /Volumes/music/

#refresh the finder for when you get back
disktool -r

# when you're done
sudo umount /Volumes/music
</pre>
<p>Found on <a href="http://www.macosxhints.com/article.php?story=2001120201020569">macosxhints</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/04/mount-afp-share-over-command-line/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
