<?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>rag.nu &#187; Programming</title>
	<atom:link href="http://rag.nu/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://rag.nu</link>
	<description>yeah, just my thoughts ladies and gentlemen.</description>
	<lastBuildDate>Thu, 23 Apr 2009 16:36:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Concatenating PDFs with PHP on the fly</title>
		<link>http://rag.nu/2009/04/23/concatenating-pdfs-php-on-the-fly/</link>
		<comments>http://rag.nu/2009/04/23/concatenating-pdfs-php-on-the-fly/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 16:36:40 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[concatenation]]></category>
		<category><![CDATA[exec]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pdftk]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://rag.nu/?p=89</guid>
		<description><![CDATA[One of my projects I was working on required PDFs to be concatenated/built on the fly from a stock set of 20 PDFs. Based on questionnaire answers, any 4 of the 20 + a core PDF would be concatenated together and provided for either email or download. The first solution I saw was just to [...]]]></description>
			<content:encoded><![CDATA[<p>One of my projects I was working on required PDFs to be concatenated/built on the fly from a stock set of 20 PDFs. Based on questionnaire answers, any 4 of the 20 + a core PDF would be concatenated together and provided for either email or download.</p>
<p>The first solution I saw was just to talk to a document creation service about painstaking create every single combination.  This wasn&#8217;t within budget.</p>
<p>After researching, I still did not have any solid solutions.  Apparently, because Adobe can charge so much for Acrobat, everyone thinks they can charge for PDF solutions. Don&#8217;t get me wrong there is a huge business need for PDF tools, but they all seem week and all look like a VB script. Trust me do a search for <a href="http://www.google.com/search?q=PDF+concatenation">PDF concatenation</a> and see what you get.</p>
<p>The solution I came up with was to use <a href="http://www.accesspdf.com/pdftk/">pdftk</a> with PHP&#8217;s <a href="http://php.net/manual/en/function.exec.php">exec</a> function. Since pdftk is a CLI solution, you have to be UBER careful using it with PHP&#8217;s exec with any kind of user input, as tampering could be devistating for your server.</p>
<p>The value in pdftk comes with the varity of platforms that are supported. So the solution will work with Windows, Linux, Mac OS X, FreeBSD, and Solaris.</p>
<p>Get ready for it, here&#8217;s the code.</p>
<p><code>$pdfMerge = exec("pdftk $execString cat output $fileName");</code></p>
<p>Basically, pdftk needs to be passed arguments like:</p>
<p><code>pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf</code></p>
<p>The $execString is the name of all the PDFs that need to be concatenated. I was creating this string with a foreach and used a similar method to generate the output filename.</p>
<p>I don&#8217;t know if this is the best solution for the job, but it&#8217;s the one that worked rather well for me.  I&#8217;d be interested to hear if any of you have better/smarter solutions.</p>
]]></content:encoded>
			<wfw:commentRss>http://rag.nu/2009/04/23/concatenating-pdfs-php-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Code Snippets: Edit hosts file in Mac OS X 10.5 Leopard</title>
		<link>http://rag.nu/2008/07/06/edit-hosts-file-in-mac-os-x-105-leopard/</link>
		<comments>http://rag.nu/2008/07/06/edit-hosts-file-in-mac-os-x-105-leopard/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 14:29:25 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[10.5]]></category>
		<category><![CDATA[dscacheutil]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://rag.nu/?p=67</guid>
		<description><![CDATA[I do a lot of development in Leopard. Typically for most projects there is a sandbox set up to mirror the production server. I&#8217;ve found the easiest way and best practice to work on the sandbox is to change the IP to forward to the production domain. What you do is open Terminal, which is [...]]]></description>
			<content:encoded><![CDATA[<p>I do a lot of development in Leopard.  Typically for most projects there is a sandbox set up to mirror the production server.  I&#8217;ve found the easiest way and best practice to work on the sandbox is to change the IP to forward to the production domain.</p>
<p>What you do is open Terminal, which is found in Applications &gt; Utilities.  Then type the following:</p>
<p><code>sudo nano /etc/hosts</code></p>
<p>Terminal will then ask you for your password, because you have invoked the security privileges of the superuser.  Type your password in.  Nano will then open.  I know you can use VI but for such a simple task, I prefer nano.</p>
<p>Next you will be presented with:<br />
<code>##<br />
# Host Database<br />
#<br />
# localhost is used to configure the loopback interface<br />
# when the system is booting.  Do not change this entry.<br />
##<br />
127.0.0.1       localhost<br />
255.255.255.255 broadcasthost<br />
::1             localhost<br />
fe80::1%lo0     localhost<br />
</code></p>
<p>Just a few things to note.  A hash, #, is a comment.  Don&#8217;t mess with those first 4, unless you know what you are doing.</p>
<p>Move the cursor down in nano using the arrow keys.  Now you can type in an IP address of the staging server and have it appear to be on the production server domain name.   Our theoretical staging server is on IP address 111.111.111.111 and our production server is on IP 11.111.111.112, with the domain www.production.com</p>
<p><code><br />
127.0.0.1       localhost<br />
255.255.255.255 broadcasthost<br />
::1             localhost<br />
fe80::1%lo0     localhost<br />
111.111.111.111       www.production.com<br />
</code></p>
<p>Now save.  This is done by hitting ctrl+o or ^o.  Hit enter to name it hosts, then hit ^x to exit nano.   In order for this to work the cache needs to be flushed.  There is a new command for this in 10.5 Leopard.</p>
<p><code>dscacheutil -flushcache</code></p>
<p>Now you can go to your staging server via your production domain name.  Handy.  Just be careful though.  Don&#8217;t accidentally make edits to production, or think you&#8217;re making edits on production but you&#8217;re making them to staging.</p>
]]></content:encoded>
			<wfw:commentRss>http://rag.nu/2008/07/06/edit-hosts-file-in-mac-os-x-105-leopard/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Code Snippets: Add comma&#8217;s to a string</title>
		<link>http://rag.nu/2008/06/30/commas-to-string/</link>
		<comments>http://rag.nu/2008/06/30/commas-to-string/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 00:17:50 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[comma]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://rag.nu/?p=66</guid>
		<description><![CDATA[Pretty commonly I&#8217;ll need to display a string of text that needs to be comma delineated using PHP.  This is the easiest way I have found to accomplish this. &#60;?php $string = "test test2 test3 test4 test5 "; echo substr(str_replace(" ", ", ", $string), 0, -2); //outputs test, test2, test3, test4, test5 ?&#62; Make sure [...]]]></description>
			<content:encoded><![CDATA[<p>Pretty commonly I&#8217;ll need to display a string of text that needs to be comma delineated using PHP.  This is the easiest way I have found to accomplish this.<br />
<code><br />
&lt;?php<br />
$string = "test test2 test3 test4 test5 ";<br />
echo substr(str_replace(" ", ", ", $string), 0, -2); //outputs test, test2, test3, test4, test5<br />
?&gt;<br />
</code></p>
<p>Make sure that there is a space added after every test or otherwise you&#8217;ll end up with the output test, test2, test3, test4, tes.</p>
<p>This could also be adapted into a function, if you wanted.</p>
]]></content:encoded>
			<wfw:commentRss>http://rag.nu/2008/06/30/commas-to-string/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Happy Halloween</title>
		<link>http://rag.nu/2006/10/31/happy-halloween/</link>
		<comments>http://rag.nu/2006/10/31/happy-halloween/#comments</comments>
		<pubDate>Tue, 31 Oct 2006 15:34:07 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://rag.nu/?p=13</guid>
		<description><![CDATA[I get into work this morning and I&#8217;m greeted by a fancy textmate Halloween easter egg. I upgraded first as I was prompted too. Pretty funny though. In other news Hawk and Ananth drew me into one of their cartoons over at Applegeeks. Its funny and yes I do have a fudgem&#8217;s costume. Basically its [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" alt="easter egg" title="easter egg" src="http://rag.nu/images/textmate_easteregg.jpg" />I get into work this morning and I&#8217;m greeted by a fancy textmate Halloween easter egg.</p>
<p>I upgraded first as I was prompted too.  Pretty funny though.</p>
<p>In other news Hawk and Ananth drew me into one of their cartoons over at <a href="http://www.applegeeks.com/lite/index.php?aglitecomic=2006-10-27">Applegeeks</a>. Its funny and yes I do have a fudgem&#8217;s costume.  Basically its a box&#8230; with faux fur over it.  The fur was EXPENSIVE&#8230; oh well its Halloween, best college holiday.</p>
<p>Edit:Â  I&#8217;ve found another one&#8230; click <a target="_blank" href="http://rag.nu/images/textmate_easteregg_big.jpg">here</a> to check it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://rag.nu/2006/10/31/happy-halloween/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
