<?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; Code Snippets</title>
	<atom:link href="http://rag.nu/category/programming/code-snippets/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>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>
	</channel>
</rss>
