<?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>Brandon Wamboldt</title>
	<atom:link href="http://brandonwamboldt.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://brandonwamboldt.ca</link>
	<description>Programmer - Web Developer - Geek</description>
	<lastBuildDate>Thu, 02 May 2013 02:35:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6-beta1</generator>
		<item>
		<title>phpMyAdmin woes</title>
		<link>http://brandonwamboldt.ca/phpmyadmin-woes-1201/</link>
		<comments>http://brandonwamboldt.ca/phpmyadmin-woes-1201/#comments</comments>
		<pubDate>Thu, 02 May 2013 02:35:51 +0000</pubDate>
		<dc:creator>Brandon Wamboldt</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[all]]></category>
		<category><![CDATA[banner]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[woes]]></category>

		<guid isPermaLink="false">http://brandonwamboldt.ca/?p=1201</guid>
		<description><![CDATA[I use phpMyAdmin for managing many of my databases, as it&#8217;s quick and easy to setup, and I don&#8217;t have to enable Internet access to the MySQL server (directly anyways). I use it in both development &#38; production, which brings up an interesting problem. I often have multiple PMA tabs open at one time, and [...]]]></description>
				<content:encoded><![CDATA[<p>I use phpMyAdmin for managing many of my databases, as it&#8217;s quick and easy to setup, and I don&#8217;t have to enable Internet access to the MySQL server (directly anyways). I use it in both development &amp; production, which brings up an interesting problem. I often have multiple PMA tabs open at one time, and sometimes get development/production mixed up and make changes I shouldn&#8217;t. Normally I&#8217;m pretty careful about this, but sometimes your co-worker goes in and drops all of your databases by mistake&#8230;. Tip #1, keep good backups. Luckily I had that tip down pat. Tip #2, don&#8217;t give co-workers drop privileges on your database if they don&#8217;t need it. Lesson learned.  <img src='http://brandonwamboldt.ca/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Both of these tips are great advice, but they don&#8217;t address the issue of mixing up your tabs. Thankfully, I found a solution.</p>
<p><a href="http://brandonwamboldt.ca/wp-content/uploads/2013/05/phpmyadmin-warning.png"><img class="aligncenter size-full wp-image-1202" alt="phpmyadmin-warning" src="http://brandonwamboldt.ca/wp-content/uploads/2013/05/phpmyadmin-warning.png" width="1212" height="723" /></a>This banner shows up on every page within phpMyAdmin, and I didn&#8217;t even have to hack any core files to do it! In your main phpMyAdmin directory, create a file called <code>config.header.inc.php</code> and put the following in it to achieve the same effect:</p>
<pre>&lt;style&gt;
#floating_menubar {
top: 41px!important;
}
&lt;/style&gt;
&lt;div style="height:40px;"&gt;&lt;/div&gt;
&lt;h1 style="position:fixed;top:0;left:0;width:100%;z-index:510000;background:#ffc0cb;margin:0;color:#000;line-height:40px;padding:0 10px;border-bottom: 1px solid #800000;font-weight:normal;"&gt;
Warning! You Are In Production. Proceed With Caution.
&lt;/h1&gt;</pre>
<p>Hopefully this will help to avoid the same mishap in the future!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://brandonwamboldt.ca/phpmyadmin-woes-1201/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GitLab &amp; GitHub</title>
		<link>http://brandonwamboldt.ca/gitlab-github-1194/</link>
		<comments>http://brandonwamboldt.ca/gitlab-github-1194/#comments</comments>
		<pubDate>Tue, 30 Apr 2013 17:51:36 +0000</pubDate>
		<dc:creator>Brandon Wamboldt</dc:creator>
				<category><![CDATA[Ideas/Thoughts]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[gitlab]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://brandonwamboldt.ca/?p=1194</guid>
		<description><![CDATA[For the client I&#8217;m currently doing some consulting for, I recommended that they switch to Git as a version control system as they are currently using Apache Subversion and have regular problems with it. I won&#8217;t go into a history of Git or Subversion, but I normally recommend Git or Mercurial over a centralized system [...]]]></description>
				<content:encoded><![CDATA[<p>For the client I&#8217;m currently doing some consulting for, I recommended that they switch to Git as a version control system as they are currently using Apache Subversion and have regular problems with it. I won&#8217;t go into a history of Git or Subversion, but I normally recommend Git or Mercurial over a centralized system like Subversion. Even when run in a centralized setup, a DCVS is far superior in that it lets you do operations offline. I&#8217;ve also found Git to handle merging far better than Subversion out of the box.</p>
<p>My client was also interested in a web based UI. Web based UIs like <a href="https://enterprise.github.com/">GitHub</a>, <a href="http://gitlab.org/">GitLab</a> and <a href="http://www.atlassian.com/software/fisheye/overview">FishEye</a> make a lot of things easier. Non technical users can go review commits, code reviews, and the code itself among other things. Some packages bundle in issue tracking and tightly integrate it. Most bundle it mechanisms to do code review easily.</p>
<p>I setup two solutions for them. GitHub Enterprise, a virtual appliance provided by GitHub that mirrors their public service quite closely. However, it&#8217;s self hosted, and supports enterprise-y features like LDAP integration. GitLab is essentially a GitHub clone, but less polished and mature, with no enterprise support.</p>
<p>I&#8217;m a huge fan of <a href="https://github.com/brandonwamboldt">GitHub.com</a>, and GitHub enterprise was very familiar to me. The software is very easy to setup, if you already have a virtualization infrastructure (Which my client does). The entire package feels very polished, it&#8217;s extremely user friendly, and it&#8217;s updated frequently.</p>
<p>GitLab is a good alternative if you don&#8217;t have the budget for GitHub enterprise (licenses start at $5000/year) but want the same experience. It&#8217;s not quite as polished, and a few things are harder to use. However, you get most of the same experience, and it&#8217;s open source. It&#8217;s currently under active development, and I plan on making a few pull requests once I get a little more involved in Ruby.</p>
<p><a href="http://brandonwamboldt.ca/wp-content/uploads/2013/04/GitLab.png"><img class="aligncenter size-full wp-image-1199" alt="GitLab" src="http://brandonwamboldt.ca/wp-content/uploads/2013/04/GitLab.png" width="1185" height="1020" /></a></p>
<p>If you&#8217;re considering checking them out, GitHub enterprise has a 45-day free trial and is distributed as an OVF virtual appliance. GitLab is a bit more difficult to setup, but it&#8217;s also worth taking a look at.</p>
]]></content:encoded>
			<wfw:commentRss>http://brandonwamboldt.ca/gitlab-github-1194/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Must-Use Plugins</title>
		<link>http://brandonwamboldt.ca/wordpress-must-use-plugins-1191/</link>
		<comments>http://brandonwamboldt.ca/wordpress-must-use-plugins-1191/#comments</comments>
		<pubDate>Sat, 20 Apr 2013 14:39:45 +0000</pubDate>
		<dc:creator>Brandon Wamboldt</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[must-use]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://brandonwamboldt.ca/?p=1191</guid>
		<description><![CDATA[At this point in time, WordPress remains the easiest-to-use &#8220;CMS&#8221; available to us, so I end up developing quite a few sites with it. Somehow, there is this great feature I&#8217;ve never heard of until a few weeks back, so I thought I&#8217;d share with the class. WordPress has this feature called &#8220;Must Use Plugins&#8220;, [...]]]></description>
				<content:encoded><![CDATA[<p>At this point in time, WordPress remains the easiest-to-use &#8220;CMS&#8221; available to us, so I end up developing quite a few sites with it. Somehow, there is this great feature I&#8217;ve never heard of until a few weeks back, so I thought I&#8217;d share with the class.</p>
<p>WordPress has this feature called &#8220;<a title="Must Use Plugins « WordPress Codex" href="http://codex.wordpress.org/Must_Use_Plugins">Must Use Plugins</a>&#8220;, aka mu-plugins. They go in the directory <code>/wp-content/mu-plugins/</code> which does not exist by default. WordPress will load every .php file in that top level directory, before regular plugins. In my efforts to write less crappy code on WordPress, this directory has proved invaluable. However, rarely do you want a bunch of .php files in that directory. Normally, you&#8217;d want a system more like the regular plugin directory where each plugin can be a file OR a directory.</p>
<p>I wrote up a little proxy loader script that accomplishes this. Just save as <code>/wp-content/mu-plugins/proxy-loader.php</code> or something, and it will load either <code>/wp-content/mu-plugins/&lt;plugin-name&gt;/&lt;plugin-name&gt;.php</code> OR <code>/wp-content/mu-plugins/&lt;plugin-name&gt;/plugin.php</code> if those files exist. The plugin is available via <a title="wp-proxy-loader/proxy-loader.php at master · brandonwamboldt/wp-proxy-loader" href="https://github.com/brandonwamboldt/wp-proxy-loader/blob/master/proxy-loader.php">GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://brandonwamboldt.ca/wordpress-must-use-plugins-1191/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configure Nagios To Use Sendmail</title>
		<link>http://brandonwamboldt.ca/configure-nagios-to-use-sendmail-1188/</link>
		<comments>http://brandonwamboldt.ca/configure-nagios-to-use-sendmail-1188/#comments</comments>
		<pubDate>Fri, 19 Apr 2013 16:29:08 +0000</pubDate>
		<dc:creator>Brandon Wamboldt</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[mailx]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[sendmail]]></category>

		<guid isPermaLink="false">http://brandonwamboldt.ca/?p=1188</guid>
		<description><![CDATA[I&#8217;ve been setting up Nagios for a client of mine, and one of the issues I faced was configuring Nagios to use sendmail to send notifications. It was attempting to use /bin/mail or /usr/bin/mailx to send email, neither of which were present on the CentOS box. There wasn&#8217;t any information when I Google&#8217;d it, so [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been setting up Nagios for a client of mine, and one of the issues I faced was configuring Nagios to use sendmail to send notifications. It was attempting to use <code>/bin/mail</code> or <code>/usr/bin/mailx</code> to send email, neither of which were present on the CentOS box.</p>
<p>There wasn&#8217;t any information when I Google&#8217;d it, so I played around with syntax a bit, got it working, and decided to add it to my blog in-case I forgot about it or anyone else needs it.</p>
<p>The mail command itself is defined in the <code>commands.cfg</code> file, which for me is located at <code>/opt/nagios/etc/objects/commands.cfg</code>, but for you, it&#8217;s probably <code>/etc/nagios/objects/commands.cfg</code>.</p>
<p>At the top, you&#8217;ll see the two relevant command definitions, &#8216;notify-host-by-email&#8217; and &#8216;notify-service-by-email&#8217;. Here&#8217;s my configuration:</p>
<pre># 'notify-host-by-email' command definition
define command{
    command_name notify-host-by-email
    command_line /usr/bin/printf "%b" "Subject: $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$\n\n***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/sbin/sendmail -vt $CONTACTEMAIL$
    }

# 'notify-service-by-email' command definition
define command{
    command_name notify-service-by-email
    command_line /usr/bin/printf "%b" "Subject: $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$\n\n***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/sbin/sendmail -vt $CONTACTEMAIL$
    }</pre>
<p>You&#8217;ll note that I didn&#8217;t simply swap out the sendmail binary path for the previous path. Sendmail takes it&#8217;s arguments slightly differently, so I had to move the subject line inside of the printf statement and tell sendmail to get it&#8217;s mail headers from the input.</p>
]]></content:encoded>
			<wfw:commentRss>http://brandonwamboldt.ca/configure-nagios-to-use-sendmail-1188/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use Layouts &amp; Sub Templates</title>
		<link>http://brandonwamboldt.ca/use-layouts-sub-templates-1178/</link>
		<comments>http://brandonwamboldt.ca/use-layouts-sub-templates-1178/#comments</comments>
		<pubDate>Tue, 16 Apr 2013 11:53:53 +0000</pubDate>
		<dc:creator>Brandon Wamboldt</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[layouts]]></category>
		<category><![CDATA[partials]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://brandonwamboldt.ca/?p=1178</guid>
		<description><![CDATA[For the context of this article, I&#8217;ll be using Zend Framework 1 for usage examples (Why am I using Zend Framework 1 you ask? Because this post is based on an email I sent to my coworkers the other day who use Zend Framework 1). However, all major frameworks support something like this (Symfony2, Zend [...]]]></description>
				<content:encoded><![CDATA[<p>For the context of this article, I&#8217;ll be using <a href="http://framework.zend.com/manual/1.12/en/manual.html">Zend Framework 1</a> for usage examples (Why am I using Zend Framework<strong> 1</strong> you ask? Because this post is based on an email I sent to my coworkers the other day who use Zend Framework 1). However, all major frameworks support something like this (<a href="http://symfony.com/">Symfony2</a>, <a href="http://framework.zend.com/">Zend Framework 2</a>, <a href="http://laravel.com/">Laravel</a>, <a href="http://rubyonrails.org/">Ruby on Rails</a>, <a href="https://www.djangoproject.com/">Django</a>, etc).</p>
<h4><strong>Layouts</strong></h4>
<p>Layouts let you <strong>abstract</strong> the HTML code that is re-used on every page to a single (or several) re-usable template files. Using a layout system allows you to write cleaner, more DRY code. In Zend, layouts are located in the <code>/application/layouts/scripts</code> folder, and use the .phtml extension much like views. Generally, a layout will contain the HTML head/foot, and any parts of the page that may appear in every page (Top navigation for instance). Example of a Zend layout:</p>
<pre>&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;
    &lt;title&gt;Some Title&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
    &lt;?php echo $this-&gt;layout()-&gt;content ?&gt;
&lt;/body&gt;

&lt;/html&gt;</pre>
<p>The part in the body will print out the contents of your regular view. That way, you only need to include the unique parts of a page in the view.</p>
<p>To select a layout in your controller, call the following code:</p>
<pre>$this-&gt;_helper-&gt;layout-&gt;setLayout('admin');</pre>
<p>This will use the layout file <code>/application/layouts/scripts/admin.phtml</code>.</p>
<h4><b>Passing Variables To Your Layout</b></h4>
<p>A common requirement is to pass unique variables to your layout, for example, the page title. This is easily accomplished. In your controller, use the following syntax to assign variables:</p>
<pre>$this-&gt;_helper-&gt;layout-&gt;__set('title', 'My Page Title');</pre>
<p>In your layout template, use the following syntax to access variables:</p>
<pre>&lt;?php echo Zend_Layout::getMvcInstance()-&gt;title ?&gt;</pre>
<h4><b>Rendering Partial Templates</b></h4>
<p>Commonly, you’ll have some code that is re-used in multiple places but is not something you can place in a layout. A great example of this would be a widget that appears on several pages but not all of them. For situations like this, you can use the <code>render()</code> function.</p>
<p><code>render()</code> can be used in layouts or regular views. It will render the contents of a given .phtml template and return it. Here’s an example of its use:</p>
<pre>&lt;?php echo $this-&gt;render('widgets/products.phtml') ?&gt;</pre>
<p>The render() function loads a template relative to <code>/application/views/scripts</code> when used in a regular view, and <code>/application/layouts/scripts</code> when used in a layout.</p>
<p>Variables available in the current template are available in the rendered template as well.</p>
<h4><b>The Partial Function</b></h4>
<p>Also of note is the <code>partial()</code> function. It behaves almost exactly like <code>render()</code>, except you pass it the variables in can use instead of it using the current scope. This is good if you’re iterating over an array (like an array of products) and want to render each one as a template. Example:</p>
<pre>&lt;?php
foreach ($products as $product) {
    echo $this-&gt;partial('partials/product_row.phtml', $product);
}
?&gt;</pre>
<h4><strong>Conclusion</strong></h4>
<p>While the examples used here are specific to Zend Framework 1, the concepts are applicable to most modern frameworks and templating systems (Including Twig).</p>
]]></content:encoded>
			<wfw:commentRss>http://brandonwamboldt.ca/use-layouts-sub-templates-1178/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtualization</title>
		<link>http://brandonwamboldt.ca/virtualization-1186/</link>
		<comments>http://brandonwamboldt.ca/virtualization-1186/#comments</comments>
		<pubDate>Sun, 14 Apr 2013 12:02:50 +0000</pubDate>
		<dc:creator>Brandon Wamboldt</dc:creator>
				<category><![CDATA[Servers]]></category>
		<category><![CDATA[esxi]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[vmware]]></category>
		<category><![CDATA[vsphere]]></category>

		<guid isPermaLink="false">http://brandonwamboldt.ca/?p=1186</guid>
		<description><![CDATA[For the longest time, I read about virtualization but never fully realized the benefits of that approach. Recently I did, and as such my company upgraded to a virtualization server running VMWare ESXi as the hypervisor. I have to say, I love virtualization now, and have no idea how I went without. If you accidentally [...]]]></description>
				<content:encoded><![CDATA[<p>For the longest time, I read about virtualization but never fully realized the benefits of that approach. Recently I did, and as such my company upgraded to a virtualization server running VMWare ESXi as the hypervisor. I have to say, I love virtualization now, and have no idea how I went without.</p>
<p>If you accidentally mess up those iptable rules and lock yourself out of SSH, you no longer have to call the hosting company at 2 in the morning and have them laugh at you (I swear, this never happened to me&#8230;). Instead, you open up the vSphere client and access the VM console directly (much like you would in VMWare Player, VMWare Workstation, or VirtualBox). Since it&#8217;s the same as being physically connected to the machine, it&#8217;s much harder to lock yourself out. You can even reboot into single user mode if need be &#8211; no need for a KVM switch.</p>
<p>You can have separate staging/prod environments easily, with no extra cost. You can create VMs just to test things and discard them when you&#8217;re done (You can do that locally of course). It makes backup &amp; restoration far simpler.</p>
<p>The actual process of setting up and managing VMs couldn&#8217;t be easier either! If you&#8217;ve used VMWare workstation, the process is very similar to that (just with more cool options).</p>
<h4>Licensing</h4>
<p>I will say this though. While the VMWare software is great, their website is not. Licensing terms are very confusing. I&#8217;ll straighten out a few things for those who may be interested.</p>
<p>VMWare ESXi is a bare metal hypervisor that is installed instead of an OS on your server. It supports SSH but only with a small subset of available commands. ESXi is free, but only for servers with up to 32 gb of RAM.</p>
<p>VMWare vSphere is the client you use to connect to your ESXi host and manage it. It&#8217;s akin to VMWare Workstation, but for servers. The vSphere client is free but only for managing 1 server. If you want to manage more from the same host you&#8217;ll need a VMWare vSphere license. To get started, I&#8217;d recommend the <a href="http://store.vmware.com/store/vmware/en_US/DisplayProductDetailsPage/productID.233860600">VMWare vSphere essentials kit</a>. This kit gives you the ability to centrally manage up to 3 servers, and removes the limit of 32 GB of RAM. It also unlocks a few other goodies. The essentials kit is the cheapest available license and starts at $560 USD.</p>
<p>One more note is that if you only have 1 server and go with the free license, you&#8217;ll get a notice about being on a 60 day trial when you first connect to your ESXi host with vSphere. You need to register on the VMWare site and get a free license, and then enter the license key in your vSphere client. Yeah, not very intuitive, I know.</p>
<p>If you have any questions, or if anything here is wrong or has changed, please leave a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://brandonwamboldt.ca/virtualization-1186/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Node.js and NodeFTPD</title>
		<link>http://brandonwamboldt.ca/node-js-and-nodeftpd-1170/</link>
		<comments>http://brandonwamboldt.ca/node-js-and-nodeftpd-1170/#comments</comments>
		<pubDate>Sat, 02 Mar 2013 02:23:35 +0000</pubDate>
		<dc:creator>Brandon Wamboldt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://brandonwamboldt.ca/?p=1170</guid>
		<description><![CDATA[A buddy of mine has been telling me I should learn Node.js for the last few months, but I&#8217;ve been staying away because I haven&#8217;t been the biggest fan of JS in the client (Browser inconsistencies and all that). This week I decided to dive in and see what the hype is all about, and [...]]]></description>
				<content:encoded><![CDATA[<p>A buddy of mine has been telling me I should learn Node.js for the last few months, but I&#8217;ve been staying away because I haven&#8217;t been the biggest fan of JS in the client (Browser inconsistencies and all that). This week I decided to dive in and see what the hype is all about, and I must say: I&#8217;m pretty impressed. I learn best by jumping into &#8220;complex&#8221; problems, and I had a perfect one in mind.</p>
<p>Personally, I think most FTP servers suck. I use ProFTPD, and don&#8217;t like it very much. It&#8217;s annoying to configure, clumsy, and not easy to extend. I decided to write my own FTP server, to learn Node and gain a better understanding of the FTP protocol. So far, it&#8217;s going really well and I think Node.js was an excellent choice. You can actually check out my progress <a href="https://github.com/brandonwamboldt/nodeftpd">over at GitHub</a>, although I&#8217;m still quite early in development. I have the basic functionality implemented in a way I&#8217;m fairly happy with. Next I want to add authentication and improve the command line interface.</p>
<p>I&#8217;m also thinking about implementing a web UI to manage the server and see real time usage information.</p>
<p>If you&#8217;re a web developer and haven&#8217;t checked out Node.js, I&#8217;d highly advise a quick look. It&#8217;s not that bad <img src='http://brandonwamboldt.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://brandonwamboldt.ca/node-js-and-nodeftpd-1170/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Writing nicer console scripts</title>
		<link>http://brandonwamboldt.ca/writing-nicer-console-scripts-1037/</link>
		<comments>http://brandonwamboldt.ca/writing-nicer-console-scripts-1037/#comments</comments>
		<pubDate>Sun, 18 Nov 2012 22:47:19 +0000</pubDate>
		<dc:creator>Brandon Wamboldt</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://brandonwamboldt.ca/?p=1037</guid>
		<description><![CDATA[Recently I working on a web application for a client over at my new company, Spark Creek. The particular component I was building was an import script, runnable via the command line. It was written in PHP, as a bundle for Symfony. At first, I built the script to output progress like &#8220;Matched 50 URLs [...]]]></description>
				<content:encoded><![CDATA[<p>Recently I working on a web application for a client over at my new company, Spark Creek. The particular component I was building was an import script, runnable via the command line. It was written in PHP, as a bundle for Symfony. At first, I built the script to output progress like &#8220;Matched 50 URLs on page: 1&#8243;. It would output a newline for every page. This produced a lot of output for a simple console script, and wasn&#8217;t very nice. What I wanted to do was match certain utilities like wget, which have a progress indicator that changes dynamically. I looked and couldn&#8217;t find how to do it, but with a little research I was able to recreate the effect.</p>
<p>The \x08 hex character code is the ASCII backspace character. If you write it to the console, it deletes a character. With PHP, I kept track of the line length, and every iteration of the loop, I would use str_repeat to send however many backspace characters I needed to erase the current line. Then I would write a new line for the current progress of the loop. This created a very smooth progress indicator.</p>
<p>Here&#8217;s a barebones version as a proof of concept:</p>
<pre>&lt;?php
$lastLineSize = 0;

for ($i = 0; $i &lt;= 50; $i++) {
    echo str_repeat("\x08", $lastLineSize);
    echo "Iteration {$i} of 50";
    $lastLineSize = strlen("Iteration {$i} of 50");
    usleep(100000);
}

echo " - Done\n";</pre>
<p>and the resulting console output after the script is complete looks like this:</p>
<pre>[root@dev /home/brandon] &gt; php test.php
Iteration 50 of 50 - Done
[root@dev /home/brandon] &gt;</pre>
<p>Run the script for yourself to see what it looks like. Basically, the script counts from iteration 0 to 50, all on one line. It makes for very fancy console scripts <img src='http://brandonwamboldt.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://brandonwamboldt.ca/writing-nicer-console-scripts-1037/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customizing Apache config with Plesk</title>
		<link>http://brandonwamboldt.ca/customizing-apache-config-with-plesk-1034/</link>
		<comments>http://brandonwamboldt.ca/customizing-apache-config-with-plesk-1034/#comments</comments>
		<pubDate>Tue, 30 Oct 2012 13:43:48 +0000</pubDate>
		<dc:creator>Brandon Wamboldt</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[conf]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[plesk]]></category>
		<category><![CDATA[vhosts]]></category>

		<guid isPermaLink="false">http://brandonwamboldt.ca/?p=1034</guid>
		<description><![CDATA[Recently, I&#8217;ve had to customize some Apache configuration options on one of my servers running Plesk. I needed to modify PHP&#8217;s open_basedir parameter among other things, and it was a little tricky to figure out how to do it properly. Once I figured it out, I thought I&#8217;d share. FYI, I&#8217;m running Plesk 10.4. Plesk [...]]]></description>
				<content:encoded><![CDATA[<p>Recently, I&#8217;ve had to customize some Apache configuration options on one of my servers running Plesk. I needed to modify PHP&#8217;s open_basedir parameter among other things, and it was a little tricky to figure out how to do it properly. Once I figured it out, I thought I&#8217;d share.</p>
<p>FYI, I&#8217;m running Plesk 10.4.</p>
<p>Plesk allows you to add your own configuration files for each domain, vhost.conf and vhost_ssl.conf. The location of these files varies depending on if you&#8217;re using a regular domain or a subdomain. The locations are:</p>
<pre>/var/www/vhosts/domain.tld/conf/vhost.conf
/var/www/vhosts/domain.tld/subdomains/&lt;somesubdomain&gt;/conf/vhost.conf</pre>
<p>The format of these files should look something like this:</p>
<pre>&lt;Directory /var/www/vhosts/domain.tld/&lt;subdomainlocation&gt;&gt;
  ServerAdmin  "support@domain.tld"
  &lt;IfModule mod_php5.c&gt;
    php_admin_value open_basedir /var/www/vhosts/domain.tld/:/tmp/:/opt/php/lib/php
  &lt;/IfModule&gt;
  &lt;IfModule sapi_apache2.c&gt;
    php_admin_value open_basedir /var/www/vhosts/domain.tld/:/tmp/:/opt/php/lib/php
  &lt;/IfModule&gt;
&lt;/Directory&gt;</pre>
<p>I added a few extra options as an example. If I were modifying my main domain, the config would look like this:</p>
<pre>&lt;Directory /var/www/vhosts/brandonwamboldt.ca/httpdocs&gt;
  ServerAdmin  "support@brandonwamboldt.ca"
  &lt;IfModule mod_php5.c&gt;
    php_admin_value open_basedir /var/www/vhosts/brandonwamboldt.ca/:/tmp/:/opt/php/lib/php
  &lt;/IfModule&gt;
  &lt;IfModule sapi_apache2.c&gt;
    php_admin_value open_basedir /var/www/vhosts/brandonwamboldt.ca/:/tmp/:/opt/php/lib/php
  &lt;/IfModule&gt;
&lt;/Directory&gt;</pre>
<p>Next step is to modify the permissions on your new config files.</p>
<pre>chown root:apache vhost.conf
chmod 640 vhost.conf</pre>
<p>And finally, ask plesk to reconfigure it&#8217;s configuration to include this new config:</p>
<pre>/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain brandonwamboldt.ca</pre>
<p>Note: Even if you&#8217;re adding a config file for a subdomain, you must reconfigure the top level domain</p>
]]></content:encoded>
			<wfw:commentRss>http://brandonwamboldt.ca/customizing-apache-config-with-plesk-1034/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony: Using the current user object with a form</title>
		<link>http://brandonwamboldt.ca/symfony-using-the-current-user-object-with-a-form-998/</link>
		<comments>http://brandonwamboldt.ca/symfony-using-the-current-user-object-with-a-form-998/#comments</comments>
		<pubDate>Wed, 03 Oct 2012 13:15:09 +0000</pubDate>
		<dc:creator>Brandon Wamboldt</dc:creator>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[users]]></category>

		<guid isPermaLink="false">http://brandonwamboldt.ca/?p=998</guid>
		<description><![CDATA[Recently I&#8217;ve been working with Symfony, a powerful and popular PHP framework. I&#8217;ve been running into my fair share of problems with the framework, a lot of which stems from lack of content/documentation for Symfony 2.x, so I&#8217;ve decided to start writing some blog posts about it. For the application I&#8217;ve been developing (For one [...]]]></description>
				<content:encoded><![CDATA[<p>Recently I&#8217;ve been working with Symfony, a powerful and popular PHP framework. I&#8217;ve been running into my fair share of problems with the framework, a lot of which stems from lack of content/documentation for Symfony 2.x, so I&#8217;ve decided to start writing some blog posts about it.</p>
<p>For the application I&#8217;ve been developing (For one of my clients over at Spark Creek), I&#8217;ve had to create an edit profile page. Using Symfony&#8217;s form builder, I created my own form class but wanted to use the current user object instead of creating a dummy model. The problem I was running into was that whenever I tried changing my email address to one already in use, it would show me an error but it would switch by user account to the user with the email address I entered.</p>
<p>After a bit of research, I discovered that the current user object was being re-saved to the session, and since forms bind data to the entity/model even if it&#8217;s invalid, the new email was getting saved. Not to the database, just to the session. A bit more research lead me to a simple fix, if the form validation failed, call refresh() from the Doctrine entity manager. This function restores an entity to it&#8217;s original state (From the database). <span id="more-998"></span>Example below:</p>
<pre class="prettyprint highlight-php"><div class="gutter"><span>1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
<span>6</span>
<span>7</span>
<span>8</span>
<span>9</span>
<span>10</span>
<span>11</span>
<span>12</span>
<span>13</span>
<span>14</span>
<span>15</span>
<span>16</span>
<span>17</span>
<span>18</span>
<span>19</span>
<span>20</span>
<span>21</span>
<span>22</span>
<span>23</span>
<span>24</span>
<span>25</span>
<span>26</span>
<span>27</span>
<span>28</span>
<span>29</span>
<span>30</span>
<span>31</span>
<span>32</span>
<span>33</span>
<span>34</span>
<span>35</span>
<span>36</span>
<span>37</span>
<span>38</span>
<span>39</span>
<span>40</span>
<span>41</span>
<span>42</span>
<span>43</span>
<span>44</span>
<span>45</span>
<span>46</span>
<span>47</span>
<span>48</span>
<span>49</span>
<span>50</span>
<span>51</span>
<span>52</span>
<span>53</span>
<span>54</span>
<span>55</span>
<span>56</span>
<span>57</span>
<span>58</span>
<span>59</span>
<span>60</span>
<span>61</span>
<span>62</span>
<span>63</span>
<span>64</span>
<span>65</span>
<span>66</span>
<span>67</span>
<span>68</span>
<span>69</span></div>&lt;?php

/*
 * This file is part of the ------- application.
 *
 * (c) Brandon Wamboldt &lt;brandon@sparkcreek.ca&gt;
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace App\UserBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use App\UserBundle\Form\Type\EditProfileType;

/**
 * Controller for user profile pages like view profile, edit profile and change
 * password
 *
 * @author Brandon Wamboldt &lt;brandon@sparkcreek.ca&gt;
 */
class ProfileController extends Controller
{
    /**
     * Controller for editing the user's profile page
     *
     * @param  Request $request An HTTP foundation request object
     * @return Response An HTTP foundation response object
     *
     * @access public
     */
    public function editAction(Request $request)
    {
        $user = $this-&gt;get('security.context')-&gt;getToken()-&gt;getUser();

        // Create a new edit profile form
        $form = $this-&gt;createForm(new EditProfileType(), $user, ['user' =&gt; $user]);

        // Was the form submitted?
        if ($request-&gt;getMethod() == 'POST') {
            $form-&gt;bind($request);

            if ($form-&gt;isValid()) {

                // Save the user
                $em = $this-&gt;getDoctrine()-&gt;getManager();
                $em-&gt;persist($user);
                $em-&gt;flush();

                // Redirect the user
                $this-&gt;get('session')-&gt;setFlash('notice', 'Your profile has been updated');
                return new RedirectResponse($this-&gt;generateUrl('my_profile'));
            } else {

                // Reset to default values or else it will get saved to the session
                $em = $this-&gt;getDoctrine()-&gt;getManager();
                $em-&gt;refresh($user);
            }
        }

        return $this-&gt;render(
            'AppUserBundle:Profile:edit.html.twig',
            ['user' =&gt; $user, 'form' =&gt; $form-&gt;createView()]
        );
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://brandonwamboldt.ca/symfony-using-the-current-user-object-with-a-form-998/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
