<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>preppeller&#039;s dev stuff</title>
	<atom:link href="http://preppeller.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://preppeller.wordpress.com</link>
	<description>Spreading knowledge like a thick layer of Nutella</description>
	<lastBuildDate>Thu, 22 Dec 2011 17:34:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='preppeller.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>preppeller&#039;s dev stuff</title>
		<link>http://preppeller.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://preppeller.wordpress.com/osd.xml" title="preppeller&#039;s dev stuff" />
	<atom:link rel='hub' href='http://preppeller.wordpress.com/?pushpress=hub'/>
		<item>
		<title>[Kind of] Private methods in Objective C</title>
		<link>http://preppeller.wordpress.com/2011/12/22/kind-of-private-methods-in-objective-c/</link>
		<comments>http://preppeller.wordpress.com/2011/12/22/kind-of-private-methods-in-objective-c/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 16:37:00 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://preppeller.com/?p=121</guid>
		<description><![CDATA[Objective C is a very flexible language, but one thing which I have always found missing is a native way to have private methods. I find private methods extremely useful when separating internal logic in a class into reusable methods which are irrelevant outside the scope of that class...<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=preppeller.wordpress.com&amp;blog=1825355&amp;post=121&amp;subd=preppeller&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Objective C is a very flexible language, but one thing which I have always found missing is a native way to have private methods. I find private methods extremely useful when separating internal logic in a class into reusable methods which are irrelevant outside the scope of that class.</p>
<p>Before I continue, it&#8217;s worth noting that due to the nature of Obj C, true private methods aren&#8217;t really possible. Never the less, we can simulate them pretty well.</p>
<p>Here is a very basic class which we will be adding a private method to:</p>
<pre>#import "BasicClass.h"

@implementation BasicClass
@end</pre>
<p>As you (hopefully) already know, Objective C separates the header (.h) files from the implementation (.m) of that class. With Objective C, you can send any message to any class so technically, you could just create a method in the implementation of a class without putting it in the header, and send a message to this object when we need to use it.</p>
<p>Lets add a private method called secretMethod to our class. We simply add it to the implementation file and leave it out of the header file.</p>
<pre>#import "BasicClass.h"

@implementation BasicClass
// a secret method
- (void)secretMethod {
}
@end</pre>
<p>From any other method in the BasicClass, we could now simply send a message to the secret message as follows:</p>
<pre>[self secretMethod];</pre>
<p>This works great, so I guess we are done? No! it gives a compiler warning&#8230; and nobody wants compiler warnings! It also doesn&#8217;t auto-complete within Xcode which also sucks.</p>
<h2>Solution &#8211; Use a Class Extension</h2>
<pre>#import "BasicClass.h"

@interface BasicClass()
- (void)secretMethod;
@end

@implementation BasicClass
// a secret method
- (void)secretMethod {
}
@end</pre>
<p>What we have essentially done here is used a private category to add the secretMethod to BasicClass, but inside the implementation file. This means things now compile without warnings AND auto-complete inside Xcode but without revealing this fact within our header file.</p>
<p>Using a Class Extension instead of an internal named Category e.g. @interface (Private) also gives us the advantage of being warned by the compiler if we don&#8217;t implement the secretMethod.</p>
<p><em>Hope this helps and thanks to those who commented about the Class Extension! I have updated both this blog post and my knowledge!</em></p>
<p>Cheers,<br />
Andrew</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/preppeller.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/preppeller.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/preppeller.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/preppeller.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/preppeller.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/preppeller.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/preppeller.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/preppeller.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/preppeller.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/preppeller.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/preppeller.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/preppeller.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/preppeller.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/preppeller.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=preppeller.wordpress.com&amp;blog=1825355&amp;post=121&amp;subd=preppeller&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://preppeller.wordpress.com/2011/12/22/kind-of-private-methods-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/162c29794213afc8acbcf177a42bae9f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">preppeller</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating an Alfred Extension 101</title>
		<link>http://preppeller.wordpress.com/2011/12/11/creating-an-alfred-extension-101/</link>
		<comments>http://preppeller.wordpress.com/2011/12/11/creating-an-alfred-extension-101/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 21:02:13 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Alfred]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://preppeller.com/?p=96</guid>
		<description><![CDATA[This simple tutorial will help you create your first Alfred "Script Extension" to make your Mac speak. For this tutorial, you will need a Mac with Alfred installed, a Powerpack license and your hands.

The extension will work by showing Alfred and using the keyword 'say' followed by some text...<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=preppeller.wordpress.com&amp;blog=1825355&amp;post=96&amp;subd=preppeller&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This simple tutorial will help you create your first <a title="Alfred App" href="http://www.alfredapp.com/" target="_blank">Alfred</a> &#8220;Script Extension&#8221; to make your Mac speak. For this tutorial, you will need a Mac with Alfred installed, a <a href="http://www.alfredapp.com/powerpack/" target="_blank">Powerpack</a> license and your hands.</p>
<p>The extension will work by showing Alfred and using the keyword &#8216;say&#8217; followed by some text, for example:</p>
<pre>say wow, extending Alfred is really easy!</pre>
<h2>Step 1 &#8211; Create the extension</h2>
<p>Open up Alfred&#8217;s preferences to the Extension tab and click the Shell Script option on the welcome screen. This will begin the process for creating an extension.</p>
<div id="attachment_104" class="wp-caption alignnone" style="width: 550px"><a href="http://preppeller.files.wordpress.com/2011/12/extension-101-create.png"><img class="size-full wp-image-104" title="Extension 101 - create" src="http://preppeller.files.wordpress.com/2011/12/extension-101-create.png?w=540&#038;h=424" alt="Extension 101 - Create the new extension" width="540" height="424" /></a><p class="wp-caption-text">Extension 101 - Create the new extension</p></div>
<p>Alternatively, you can click the + button in the bottom left of the Extensions preferences and select &#8220;Shell Script&#8221; on the popup menu.</p>
<h2>Step 2 &#8211; Give your extension a name</h2>
<p>We need to name our extension so we can recognise it later if we want to edit it. We can also set some metadata so that if we later share this extension, the credit goes to the creator.</p>
<div id="attachment_105" class="wp-caption alignnone" style="width: 550px"><a href="http://preppeller.files.wordpress.com/2011/12/extension-101-name.png"><img class="size-full wp-image-105" title="Extension 101 - name" src="http://preppeller.files.wordpress.com/2011/12/extension-101-name.png?w=540&#038;h=424" alt="Extension 101 - Give the extension a name and icon" width="540" height="424" /></a><p class="wp-caption-text">Extension 101 - Give the extension a name and icon</p></div>
<p>I&#8217;ve called this extension &#8216;wordy&#8217; and filled in my name and a URL. At this point, you can also drag an icon into the little image well to the left hand side of this panel.</p>
<h2>Step 3 &#8211; Fill in the extension details</h2>
<p>Firstly, we want to give the extension a Title and Description. These are the things we will see in Alfred&#8217;s results when typing the extension&#8217;s keyword. The description is shown in small text under the result, much like the file path is shown for a file result in Alfred.</p>
<p>Secondly, we want to give the script a keyword, in this case, &#8216;say&#8217;.</p>
<p>Finally, we want to add some bash script to perform the actual extension. The bash command we are going to use is &#8216;say&#8217; and pass {query} which relates to the query you type into Alfred&#8217;s search box after typing &#8216;say&#8217;.</p>
<div id="attachment_106" class="wp-caption alignnone" style="width: 550px"><a href="http://preppeller.files.wordpress.com/2011/12/extension-101-contents.png"><img class="size-full wp-image-106" title="Extension 101 - contents" src="http://preppeller.files.wordpress.com/2011/12/extension-101-contents.png?w=540&#038;h=424" alt="Extension 101 - Fill in the extension details" width="540" height="424" /></a><p class="wp-caption-text">Extension 101 - Fill in the extension details</p></div>
<p>Note that for the title, we can insert a special {query} phrase which will be replaced out with the query we are typing. This gives good feedback to the users of this extension.</p>
<p>&#8216;Silent&#8217; is ticked by default which doesn&#8217;t mean &#8220;don&#8217;t make any noise&#8221;, it actually means run this command behind the scenes without showing Terminal.app &#8211; this is useful for building extensions which feel more native to the OS X user experience.</p>
<p>In summary, we are using the following:</p>
<pre>      Title: say '{query}'
Description: Get your Mac to Speak 
    Keyword: say
    Command: say "{query}"</pre>
<h2>Step 4 &#8211; Save and Test</h2>
<p>Click the save button and now show Alfred and type:</p>
<pre>say Wow, I've created my first Alfred extension!</pre>
<p>It&#8217;s as easy as that! The only thing now is to right [option] click on Wordy in the list and export this extension for all of your fellow Alfred users, which is exactly what I did&#8230;</p>
<p><a title="Download the Alfred Wordy extension" href="http://media.alfredapp.com/scripts/Wordy.alfredextension">Download the Wordy extension</a> if you would like to have a play with the finished extension.</p>
<p>Cheers,<br />
Andrew</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/preppeller.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/preppeller.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/preppeller.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/preppeller.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/preppeller.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/preppeller.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/preppeller.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/preppeller.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/preppeller.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/preppeller.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/preppeller.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/preppeller.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/preppeller.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/preppeller.wordpress.com/96/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=preppeller.wordpress.com&amp;blog=1825355&amp;post=96&amp;subd=preppeller&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://preppeller.wordpress.com/2011/12/11/creating-an-alfred-extension-101/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/162c29794213afc8acbcf177a42bae9f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">preppeller</media:title>
		</media:content>

		<media:content url="http://preppeller.files.wordpress.com/2011/12/extension-101-create.png" medium="image">
			<media:title type="html">Extension 101 - create</media:title>
		</media:content>

		<media:content url="http://preppeller.files.wordpress.com/2011/12/extension-101-name.png" medium="image">
			<media:title type="html">Extension 101 - name</media:title>
		</media:content>

		<media:content url="http://preppeller.files.wordpress.com/2011/12/extension-101-contents.png" medium="image">
			<media:title type="html">Extension 101 - contents</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple, more flexible Obj C Logging</title>
		<link>http://preppeller.wordpress.com/2011/12/08/simple-more-flexible-objective-c-logging/</link>
		<comments>http://preppeller.wordpress.com/2011/12/08/simple-more-flexible-objective-c-logging/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 12:54:56 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://preppeller.com/?p=43</guid>
		<description><![CDATA[NSLog is a simple way of logging text and values out to Console in your code.

When I first started programming Alfred, I very quickly realised that NSLog didn't provide me with enough granularity to be particularly useful. I wanted to separate out log messages such that in normal use, I only see significant messages, however I still have the option to see ALL logging if I needed...<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=preppeller.wordpress.com&amp;blog=1825355&amp;post=43&amp;subd=preppeller&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>NSLog is a simple way of logging text and values out to Console in your code.</p>
<p>When I first started programming Alfred, I very quickly realised that NSLog didn&#8217;t provide me with enough granularity to be particularly useful. I wanted to separate out log messages such that in normal use, I only see significant messages, however I still have the option to see ALL logging if I needed.</p>
<p>Enter APLog, a utility class offering multiple levels of configurable logging to NSLog.</p>
<h2>Logging Levels and Simple Usage</h2>
<p>APLog supports 5 levels of logging. Tiny, Fine, Info, Warning and Error, These methods output depending on a &#8216;logging&#8217; value set in NSUserDefaults as follows:</p>
<p>0: Only Error is output<br />
1: Error, Warning and Info is output<br />
2: Error, Warning, Info and Fine is output<br />
3: Everything is output</p>
<p>You can decide how these different levels suit you, I generally log things I want to see often to info and scope down from there with tiny messages being very low level things you may never want to see unless something is acting up.</p>
<pre>// error logging
[APLog error:@"Unable to connect to network"];

// warning logging
[APLog warning:@"Clipboard cache contains unexpected info, cleaning up"];

// standard logging
[APLog info:@"Application Started"];

// fine logging
[APLog fine:@"Loaded %d rows from the database", 30]; 

// tiny logging
[APLog tiny:@"Currently processing item %d of %d", 4, 20000];</pre>
<p>The beauty of the logging granularity is that when the logging value isn&#8217;t set in NSUserDefaults, the end user doesn&#8217;t get their console log clogged up with your logging. Subsequently, by default I have my logging level set to 1 which means I only see info, warning and fine messages during development while still logging everything which may be of use later.</p>
<h2>Creating class methods</h2>
<p>We want this logging to be as easy to use as possible, without the need for instantiating a class, however having a more modern Obj C interface. This can easily be accomplished using class methods.</p>
<p>By using a + before a method, this is making that method available without instantiating the class. In the header file, we add the info method as follows:</p>
<pre>// in APLog.h
// info log
+(void) info:(NSString *)format,...;</pre>
<p>The ,&#8230;; allows for open ended arguments like you see in NSLog where you can pass additional parameters in which are formatted into the log string.</p>
<pre>// in APLog.m
// info log
+(void) info:(NSString *)format,... {
  if ([[NSUserDefaults standardUserDefaults] integerForKey:@"logging"] &gt;= 1) {
    va_list args;
    va_start(args, format);
    NSString *str = [[NSString alloc] initWithFormat:format arguments:args];
    [AlfredLog doLog:str level:@"INFO"];
    [str release];
    va_end(args);
  }
}</pre>
<p>First, we check NSUserDefaults to see if this level of logging is required, if so, we split out the argument levels and pass them to a method which actually does the logging. Note that we alloc the string and release it, this means that if APLog is used in a large loop, we won&#8217;t need to wait for the autorelease pool to release the memory for logging, it happens here and now.</p>
<p>The other levels of logging for error, warning, fine and tiny are created in the same way as above but with a different method signature.</p>
<h2>Using a separate method for Logging</h2>
<p>By separating the actual method for logging, it allows us to quickly change the format we want for all of the logging output. In my case, I like</p>
<pre>[level] log message</pre>
<p>&#8230; as this makes things easy to scan for INFO, FINE, TINY &#8211; especially considering they are all 4 fix width characters in size. This also makes ERROR and WARNING stand out when reading your log.</p>
<pre>// do the logging
+(void) doLog:(NSString *)log level:(NSString *)level {
  NSLog(@"[%@] %@", level, log);
}</pre>
<p>The doLog method is a categorised private method, something I will cover in a different blog post.</p>
<h2>Easy use by prefixing in your headers</h2>
<p>One final step is to add APLog.h to your Prefix.pch file which means you won&#8217;t need to import this in every class you want to Log in. Your Prefix.pch will look something like this:</p>
<pre>#ifdef __OBJC__
  #import &lt;Cocoa/Cocoa.h&gt;
  #import "APLog.h"
#endif</pre>
<h2>Download the source</h2>
<p><a href="http://media.alfredapp.com/sourcecode/APLog.zip" target="_blank">Download APLog</a> to use in all of your projects, commercial or otherwise. This code is released under the <a href="http://en.wikipedia.org/wiki/MIT_License" target="_blank">MIT License</a>.</p>
<p><em><small>Note: Don&#8217;t forget to set the &#8216;logging&#8217; value in NSUserDefaults (Alfred has the index of a NSPopupMenu bound to this value in the prefs), or call [[NSUserDefaults standardUserDefaults] setInteger:3 forKey:@&#8221;logging&#8221;]; near the beginning of your code to log all levels.</small></em></p>
<p>I hope this is as useful to you as it is for me. Please leave me any comments or improvements below.</p>
<p>Cheers,<br />
Andrew</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/preppeller.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/preppeller.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/preppeller.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/preppeller.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/preppeller.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/preppeller.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/preppeller.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/preppeller.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/preppeller.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/preppeller.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/preppeller.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/preppeller.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/preppeller.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/preppeller.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=preppeller.wordpress.com&amp;blog=1825355&amp;post=43&amp;subd=preppeller&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://preppeller.wordpress.com/2011/12/08/simple-more-flexible-objective-c-logging/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/162c29794213afc8acbcf177a42bae9f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">preppeller</media:title>
		</media:content>
	</item>
		<item>
		<title>Virtual Hosts on your local OS X Apache</title>
		<link>http://preppeller.wordpress.com/2011/12/04/setting-up-virtual-hosts-on-your-local-os-x-apache/</link>
		<comments>http://preppeller.wordpress.com/2011/12/04/setting-up-virtual-hosts-on-your-local-os-x-apache/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 15:34:42 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://preppeller.com/?p=18</guid>
		<description><![CDATA[If you want to easily mirror multiple live websites locally for super fast and offline development, then read on!

When I reinstall OS X, I very quickly reconfigure Apache to allow for local vhosts. Apache can be a bit of a minefield for configuration and I am by no means an expert, however, these simple steps give a huge amount of benefit as you won't need to edit apache's configuration files every time you want to add a new vhost...<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=preppeller.wordpress.com&amp;blog=1825355&amp;post=18&amp;subd=preppeller&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you want to easily mirror multiple live websites locally for super fast and offline development, then read on!</p>
<p>When I reinstall OS X, I very quickly reconfigure Apache to allow for local vhosts. Apache can be a bit of a minefield for configuration and I am by no means an expert, however, these simple steps give a huge amount of benefit as you won&#8217;t need to edit apache&#8217;s configuration files every time you want to add a new vhost.</p>
<p>One example which I use daily is alfredapp.com which is setup locally as alfredapp.local &#8211; These two sites are exact mirrors of each other both rooted with / can be significant in web development when accessing resources and site links. I can develop and test on the local site, then when I&#8217;m happy, push the changes to my distributed repository and deploy to the live site.</p>
<p><em>Note that the following config changes may mutually exclude any other apache changes you have made&#8230; If that means nothing to you, then this will likely work fine.</em></p>
<h2>Before we start, turn on Web Sharing</h2>
<p>Open up OS X&#8217;s sharing preferences and turn on &#8220;Web Sharing&#8221;, this will start up Apache.</p>
<h2>Step 1 &#8211; Backup the configuration files</h2>
<pre>/etc/apache2/httpd.conf
/etc/apache2/extra/httpd-vhosts.conf
/etc/apache2/users/<span style="color:#999999;">[username]</span>.conf</pre>
<h2>Step 2 &#8211; Import the vhosts config into httpd.conf</h2>
<p><em>Temporarily, we are going to make the httpd.conf writable to make some changes.</em></p>
<p>Open Terminal.app and type:</p>
<pre>sudo chmod u+w /etc/apache2/httpd.conf</pre>
<p>Then open the httpd.conf file and remove the <span style="color:#0000ff;">#</span> off the beginning of the following line:</p>
<pre><span style="color:#0000ff;">#</span>Include /private/etc/apache2/extra/httpd-vhosts.conf</pre>
<p>While you are in here and if you haven&#8217;t done so already, it&#8217;s probably worth also uncommenting PHP too by removing the # from the following line:</p>
<pre><span style="color:#0000ff;">#</span>LoadModule php5_module libexec/apache2/libphp5.so</pre>
<p>Save your changes and make your mac more secure again by making the httpd.conf file unwritable:</p>
<pre>sudo chmod u-w /etc/apache2/httpd.conf</pre>
<h2>Step 3 &#8211; Do some magic in the vhosts config</h2>
<p>Replace the contents of /etc/apache2/extra/httpd-vhosts.conf with the following:</p>
<pre>UseCanonicalName Off
VirtualDocumentRoot /Users/<span style="color:#999999;">[username]</span>/Sites/vhosts/%0
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog /var/log/apache2/access_log vcommon</pre>
<p>Turning off UseCanonicalName makes Apache ignore the ServerName directive and instead use the domain name supplied by the browser to construct the domain (blah blah or something like that). VirtualDocumentRoot sets where Apache looks for the virtual hosts. Replace <strong>[username]</strong> with your case sensitive usename. The last two lines setup the log format adding the virtual host at the beginning using %V.</p>
<h2>Step 4 &#8211; Setup the access for vhosts for your user</h2>
<p>In my case, edit /etc/apache2/users/preppeller.conf and update the directory access:</p>
<pre>&lt;Directory "/Users/[username]/Sites/"&gt;
  Options Indexes MultiViews FollowSymLinks
  AllowOverride All
  Order allow,deny
  Allow from all
&lt;/Directory&gt;</pre>
<p>Naturally change <strong>[username]</strong> with your user case sensitive again. Updating this config file firstly allows apache to access this folder, but also allows for better .htaccess overrides.</p>
<h2>Step 5 &#8211; Restart Apache</h2>
<p>In Terminal type:</p>
<pre>sudo apachectl restart</pre>
<h2>Step 6 &#8211; How to use&#8230; this is the easy part!</h2>
<p>Lets say I want to setup alfredapp.local. Firstly, I create the following folder in Terminal:</p>
<pre>mkdir ~/Sites/vhosts/alfredapp.local</pre>
<p>This will contain the files for the website (I just grab these out of repository). Next, I update hosts file and add alfredapp.local to point to localhost. Edit /etc/hosts (you will need to sudo edit this) and add the following line:</p>
<pre>127.0.0.1 alfredapp.local</pre>
<p>Now visiting http://alfredapp.local in my browser and magically it works. You can just repeat step 6 for every site you want to add!</p>
<h2>Wow, that&#8217;s easy! What next?</h2>
<p>The next obvious step would be to configure your DNS so that *.local resolves to localhost. If you did this, then there is ZERO config to do to setup your local mirrors&#8230; simply create folders, populate them, and visit the domain in your browser! DNS configuration is a WHOLE different ballgame, which is why I&#8217;m not covering it here.</p>
<p>I hope that helps. Let me know if you have any comments if you have found this useful or if you know of better ways of doing this.</p>
<p>Cheers,<br />
Andrew</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/preppeller.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/preppeller.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/preppeller.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/preppeller.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/preppeller.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/preppeller.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/preppeller.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/preppeller.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/preppeller.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/preppeller.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/preppeller.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/preppeller.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/preppeller.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/preppeller.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=preppeller.wordpress.com&amp;blog=1825355&amp;post=18&amp;subd=preppeller&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://preppeller.wordpress.com/2011/12/04/setting-up-virtual-hosts-on-your-local-os-x-apache/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/162c29794213afc8acbcf177a42bae9f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">preppeller</media:title>
		</media:content>
	</item>
		<item>
		<title>Oh no, not another blog!!</title>
		<link>http://preppeller.wordpress.com/2011/12/04/oh-no-not-another-blog/</link>
		<comments>http://preppeller.wordpress.com/2011/12/04/oh-no-not-another-blog/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 12:53:38 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[Ramblings]]></category>

		<guid isPermaLink="false">http://preppeller.wordpress.com/?p=11</guid>
		<description><![CDATA[I've been meaning to start a Mac / development blog for quite some time now... so here goes!

Being a Mac developer working for myself is one of the best life decisions I have ever made. It has been extremely stressful and hard work quite a bit of the time, but it is extremely rewarding once you have some software being used by a large number of happy users, it is one of the best feelings in the world...<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=preppeller.wordpress.com&amp;blog=1825355&amp;post=11&amp;subd=preppeller&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to start a Mac / development blog for quite some time now&#8230; so here goes!</p>
<p>Being a Mac developer working for myself is one of the best life decisions I have ever made. It has been extremely stressful and hard work quite a bit of the time, but it is extremely rewarding once you have some software being used by a large number of happy users, it is one of the best feelings in the world.</p>
<p>After over 15 years of commercial enterprise and user interface development, I&#8217;m hoping I can share some of my experiences and knowledge to help other people to get into Mac development too!</p>
<p>I&#8217;m hoping that over time, this blog will evolve into a really valuable resource for Mac developers of all levels <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers,<br />
Andrew</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/preppeller.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/preppeller.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/preppeller.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/preppeller.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/preppeller.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/preppeller.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/preppeller.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/preppeller.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/preppeller.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/preppeller.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/preppeller.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/preppeller.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/preppeller.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/preppeller.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=preppeller.wordpress.com&amp;blog=1825355&amp;post=11&amp;subd=preppeller&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://preppeller.wordpress.com/2011/12/04/oh-no-not-another-blog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:thumbnail url="http://preppeller.files.wordpress.com/2007/10/pepperrell-desk.jpg?w=150" />
		<media:content url="http://preppeller.files.wordpress.com/2007/10/pepperrell-desk.jpg?w=150" medium="image">
			<media:title type="html">pepperrell-desk</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/162c29794213afc8acbcf177a42bae9f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">preppeller</media:title>
		</media:content>
	</item>
	</channel>
</rss>
