<?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>Marius van Witzenburg &#187; Code</title>
	<atom:link href="http://kitara.nl/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://kitara.nl</link>
	<description>We fight for our survival, we fight!</description>
	<lastBuildDate>Sun, 20 May 2012 15:39:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How to create a patch to update one of your projects its external vendor code.</title>
		<link>http://kitara.nl/2010/04/13/how-to-create-a-patch-to-update-one-of-your-projects-its-external-vendor-code/</link>
		<comments>http://kitara.nl/2010/04/13/how-to-create-a-patch-to-update-one-of-your-projects-its-external-vendor-code/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 10:31:50 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Diff]]></category>
		<category><![CDATA[Patch]]></category>
		<category><![CDATA[Update]]></category>
		<category><![CDATA[Upgrading]]></category>
		<category><![CDATA[Vendor]]></category>

		<guid isPermaLink="false">http://mariusvw.com/?p=1627</guid>
		<description><![CDATA[I use this way to upgrade projects such as DokuWiki and CakePHP. The advantage of this method is you will keep modifications you have made in the code of that vendor. In my description I use FreeBSD and Mac OS X so you might need to adjust the commands for a different Operating System. Create [...]]]></description>
			<content:encoded><![CDATA[<p>I use this way to upgrade projects such as DokuWiki and CakePHP.</p>
<p>The advantage of this method is you will keep modifications you have made in the code of that vendor.<br />
In my description I use FreeBSD and Mac OS X so you might need to adjust the commands for a different Operating System.</p>
<p><strong>Create the patch file</strong></p>
<p>First download the old and the new version code from your vendor site. In this example this is the website of CakePHP.<br />
You need this that you can match the old version to the new version you want to upgrade to.</p>
<p>Create a temp directory to work in.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mkdir myUpgrade
cd myUpgrade</pre></div></div>

<p>Download the two versions of CakePHP, your current and the version you desire to upgrade to</p>
<ul>
<li>http://github.com/cakephp/cakephp1x/tarball/1.3.0-RC3</li>
<li>http://github.com/cakephp/cakephp1x/tarball/1.3.0-RC4</li>
</ul>
<p>Unpack tarballs:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">tar -xzvf cakephp-cakephp1x-348e5f0.tar.gz
tar -xzvf cakephp-cakephp1x-f63ab48.tar.gz</pre></div></div>

<p>Now create the aptch width using the diff utility:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">diff -Naur -x '.svn' -x '._*' cakephp-cakephp1x-348e5f0 cakephp-cakephp1x-f63ab48 &gt; cakephp.diff</pre></div></div>

<p><strong>Applying the patch</strong></p>
<p>To apply the patch file you created in the previous step, change into your real vendor directory and run the patch tool.<br />
You may first want to do a test run to see if any conflicts may happen and what files are affected:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">cd myUpgrade
patch -E -p1 &lt; ../cakephp.diff --dry-run</pre></div></div>

<p>The output should be something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">patching file cake/VERSION.txt
patching file cake/basics.php
patching file cake/config/config.php
*etc*</pre></div></div>

<p>When you're happy, apply the patch:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">patch -E -p1 &lt; ../cakephp.diff</pre></div></div>

<p>Once patch is applied you're done <img src='http://kitara.nl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://kitara.nl/2010/04/13/how-to-create-a-patch-to-update-one-of-your-projects-its-external-vendor-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Test-driven development (TDD)</title>
		<link>http://kitara.nl/2010/03/24/test-driven-development-tdd/</link>
		<comments>http://kitara.nl/2010/03/24/test-driven-development-tdd/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 21:15:44 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flow]]></category>
		<category><![CDATA[Flowchart]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[Test-driven development]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://mariusvw.com/?p=1477</guid>
		<description><![CDATA[When I was googling for development flows I found the following page which almost describes completely how I work in my development projects. A flowchart of how this goes: For more info see: http://en.wikipedia.org/wiki/Test-driven_development]]></description>
			<content:encoded><![CDATA[<p>When I was googling for development flows I found the following page which almost describes completely how I work in my development projects.</p>
<p>A flowchart of how this goes:</p>
<p><a href="http://kitara.nl/wp-content/uploads/2010/03/Test-driven_development.png"><img src="http://kitara.nl/wp-content/uploads/2010/03/Test-driven_development-512x367.png" alt="" title="Test-driven development" width="512" height="367" class="aligncenter size-medium wp-image-1476" /></a></p>
<p>For more info see: <a href="http://en.wikipedia.org/wiki/Test-driven_development">http://en.wikipedia.org/wiki/Test-driven_development</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kitara.nl/2010/03/24/test-driven-development-tdd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shellproxy, an easy tool to run shell commands from PHP or other languages</title>
		<link>http://kitara.nl/2010/03/02/shellproxy-an-easy-tool-to-run-shell-commands-from-php-or-other-languages/</link>
		<comments>http://kitara.nl/2010/03/02/shellproxy-an-easy-tool-to-run-shell-commands-from-php-or-other-languages/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 19:53:02 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Command]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Return]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Value]]></category>

		<guid isPermaLink="false">http://mariusvw.com/?p=1302</guid>
		<description><![CDATA[This is a simple script that runs a shell command from PHP with the function system(). It sometimes happens that a command doesn't close the stdin or stdout, resulting the system() function to halt and wait for it to finish... This causes PHP to reach the 30 second time limit and kill the script. This [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple script that runs a shell command from PHP with the function <strong>system()</strong>.<br />
It sometimes happens that a command doesn't close the <strong>stdin</strong> or <strong>stdout</strong>, resulting the <strong>system()</strong> function to halt and wait for it to finish...<br />
This causes PHP to reach the 30 second time limit and kill the script.</p>
<p>This script runs it in the background and you could make your commands send their output to a log file and still having full control.</p>
<p>Read the code below how to use it.</p>
<p>You can compile it by placing the code into <strong>shellproxy.c</strong> and then compile it with the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #660033;">-o</span> shellproxy shellproxy.c</pre></div></div>

<p>I hope this is something useful for you as it was for me.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio .h&gt;</span>
<span style="color: #339933;">#include &lt;stdlib .h&gt;</span>
<span style="color: #339933;">#include &lt;string .h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">char</span> command<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1024</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">int</span> t<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>argc <span style="color: #339933;">==</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;nShell Proxyn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;By Marius van Witzenburg &lt;http ://kitara.nl&gt;nn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;You will mostly use this program from PHP or any othern&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;webscripting language to background run programsnn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Usage:n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;- CLI:n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;shellproxy &quot;</span><span style="color: #339933;">&lt;</span>cmd<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>arg<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;shellproxy &quot;</span><span style="color: #339933;">&lt;</span>cmd<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>arg<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&gt;</span> redirect.<span style="color: #202020;">txt</span><span style="color: #ff0000;">&quot;n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;- PHP:n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;system('shellproxy &quot;</span><span style="color: #339933;">&lt;</span>cmd<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>arg<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&amp;</span><span style="color: #ff0000;">&quot;');n&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;system('shellproxy &quot;</span><span style="color: #339933;">&lt;</span>cmd<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>arg<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&gt;</span> redirect.<span style="color: #202020;">txt</span><span style="color: #ff0000;">&quot;');nn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    command<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>t <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> t <span style="color: #339933;">&lt;</span> argc<span style="color: #339933;">;</span> t<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        strcat<span style="color: #009900;">&#40;</span>command<span style="color: #339933;">,</span> argv<span style="color: #009900;">&#91;</span>t<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        strcat<span style="color: #009900;">&#40;</span>command<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    fclose<span style="color: #009900;">&#40;</span>stdin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    fclose<span style="color: #009900;">&#40;</span>stdout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    fclose<span style="color: #009900;">&#40;</span>stderr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    system<span style="color: #009900;">&#40;</span>command<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It would be nice if you keep my name mentioned into this code if you use it.</p>
<p>Ps. Donations are welcome... <img src='http://kitara.nl/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://kitara.nl/2010/03/02/shellproxy-an-easy-tool-to-run-shell-commands-from-php-or-other-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

