<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>leftcolumn.net</title>
	
	<link>http://www.leftcolumn.net</link>
	<description>Covering Mac OS X, Mac Software, and other stuff</description>
	<lastBuildDate>Fri, 21 Aug 2009 08:15:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/leftcolumn" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Adding an entry to /etc/hosts on OS X</title>
		<link>http://feedproxy.google.com/~r/leftcolumn/~3/jbAjnD5owzM/</link>
		<comments>http://www.leftcolumn.net/2009/07/04/adding-an-entry-to-etchosts-on-os-x/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 23:31:53 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[mac osx]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=216</guid>
		<description><![CDATA[Web Developers, Administrators of Mac Networks, and anyone who likes to noodle with OS X will probably eventually need to add hosts file entries. I use them when I&#8217;m testing a moved and/or changed version of a website at new hosting before I move the DNS.
I used to add hosts file entries manually then wonder [...]]]></description>
			<content:encoded><![CDATA[<p>Web Developers, Administrators of Mac Networks, and anyone who likes to noodle with OS X will probably eventually need to add hosts file entries. I use them when I&#8217;m testing a moved and/or changed version of a website at new hosting before I move the DNS.</p>
<p>I used to add hosts file entries manually then wonder why they didn&#8217;t seem to work. I tried rebooting, logging out, etc with varying success, until I learned this trick. On the Mac you must flush the DNS cache for the changes to take effect. Mac OS X used to have a friendly utility called NetInfo Manager, but that seems to have been removed in Leopard, so we&#8217;re using terminal commands.</p>
<p>Open a terminal sesion and type:<br />
<code>sudo nano /etc/hosts</code></p>
<p>Hit the down arrow until you get to the end of the file, and add your hosts file entry, for example:<br />
<code>192.168.2.33 myintranetserver.mydomain.com</code><br />
&#8230; I put in an extra line break at the end. I don&#8217;t think it&#8217;s really necessary but it&#8217;s a habit from having to use Windows, which would ignore the last line in a hosts file. </p>
<p>then flush the cache:<br />
<code>sudo dscacheutil -flushcache</code></p>
<p>&#8230;the name should now resolve! Test it:<br />
<code>ping myintranetserver.mydomain.com</code></p>
<h3>Other Info</h3>
<p>One thing that Windows, for all its annoyances, did get right is that changes to the hosts file (in &#8216;c:\Windows\system32\drivers\etc&#8217;) are reflected immediately. I&#8217;d like to see Apple do something about this in OS X, perhaps just flushing the cache automatically when /etc/hosts changes.</p>
<p>Another handy use for /etc/hosts is to set up mapping of virtual server addresses. For example, I use MAMP on my development Mac, and create new virtual hosts entries in Apache for each site I&#8217;m working on. Then for each I just add a new entry in the hosts file, e.g.:<br />
<code>127.0.0.1 devclientsite7.leftcolumn.net</code><br />
&#8230; then I just use devclientsite7.leftcolumn.net:8080 in Safari or Firefox to access the development site. It means my development sites don&#8217;t have to be in subdirectories, instead I just make sure the sites use a config file to figure out what their address is, and I make sure that config file is updated when the site is moved to a live system.</p>
<p>On OS X Tiger (10.4) and probably earlier, there was some strange behaviour with hosts file entries. You could add an entry and it would take effect, but if you had no network available, the name would not resolve and could not be used, even if it resolved to 127.0.0.1! So you have the bizarre situation of putting in addresses for virtual hosts as described in the previous paragraph, all of which resolve to 127.0.0.1, but still not being able to use them for testing and development when not connected to the Internet. If anyone can enlighten me as to how this was anything other than a bug in OS X I&#8217;d be interested&#8230;</p>
<p>You can also use hosts file entries to block ads (by resolving common ad server addresses to e.g.: 127.0.0.1). You can download huge lists of ad servers for this purpose. This is a good idea when you&#8217;re stuck using  Internet Explorer on Windows, especially on dial-up.</p>
<img src="http://feeds.feedburner.com/~r/leftcolumn/~4/jbAjnD5owzM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/07/04/adding-an-entry-to-etchosts-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.leftcolumn.net/2009/07/04/adding-an-entry-to-etchosts-on-os-x/</feedburner:origLink></item>
		<item>
		<title>MacBook Pro won’t wake up from sleep</title>
		<link>http://feedproxy.google.com/~r/leftcolumn/~3/SMpM5nSSoVQ/</link>
		<comments>http://www.leftcolumn.net/2009/05/24/macbook-pro-wont-wake-up-from-sleep/#comments</comments>
		<pubDate>Sun, 24 May 2009 00:31:47 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[mac osx]]></category>
		<category><![CDATA[macbook pro]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=205</guid>
		<description><![CDATA[One day my new MacBook Pro 17&#8243; wouldn&#8217;t wake up. When I opened the lid machine was running but the Desktop wouldn&#8217;t load (just a default blue Desktop background colour) and there was no response from the Mouse or Keyboard. I eventually had to hard reset the Mac. 
This annoying issue can apparently be caused [...]]]></description>
			<content:encoded><![CDATA[<p>One day my new MacBook Pro 17&#8243; wouldn&#8217;t wake up. When I opened the lid machine was running but the Desktop wouldn&#8217;t load (just a default blue Desktop background colour) and there was no response from the Mouse or Keyboard. I eventually had to hard reset the Mac. </p>
<p>This annoying issue can apparently be caused a few different ways, but if your Mac is new and has all System Updates applied, chances are that the issue is caused when you close the lid and then move the mac before the contents of RAM are written out. There&#8217;s a feature called Safe Sleep, enabled by default, which can preserve and restore the state of a sleeping Mac even when the battery is removed. This sounds great, but the Safe Sleep procedure can take up to 30 seconds, which is too long for me.</p>
<p>How to fix this annoying problem? Here&#8217;s how I switched it off:</p>
<pre>sudo pmset -a hibernatemode 0
sudo rm /var/vm/sleepimage
</pre>
<p>&#8230;you need to supply the super user password. After making the change, reboot the Mac. The Mac should now Sleep within a couple of seconds. The second line removes the file that Sleep Safe uses to store the contents of RAM. Since you&#8217;ve switched off Safe Sleep, the space can be recovered.</p>
<p>Personally I don&#8217;t see the need for Safe Sleep on a Mac with a non-removable battery, but be aware that if the machine is asleep and runs out of battery power you wil lose your logged in session! I haven&#8217;t tried it, and most OS X apps will deal pretty well with this anyway, but it&#8217;s not wise to let this happen&#8230;</p>
<p>More details:</p>
<p><a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/pmset.1.html">Apple pmset Manual</a><br />
<a href="http://www.macworld.com/article/53471/2006/10/sleepmode.html">Macworld article on setting sleep modes</a></p>
<img src="http://feeds.feedburner.com/~r/leftcolumn/~4/SMpM5nSSoVQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/05/24/macbook-pro-wont-wake-up-from-sleep/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.leftcolumn.net/2009/05/24/macbook-pro-wont-wake-up-from-sleep/</feedburner:origLink></item>
		<item>
		<title>Zend Framework: How to add FCKeditor to a Zend_Form</title>
		<link>http://feedproxy.google.com/~r/leftcolumn/~3/BFq8rI_iF1U/</link>
		<comments>http://www.leftcolumn.net/2009/03/10/zend-framework-how-to-add-fckeditor-to-a-zend_form/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 00:39:18 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[zend framework]]></category>
		<category><![CDATA[fckeditor]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[zend_form]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=157</guid>
		<description><![CDATA[There are around 1,083,367 JavaScript-based Rich-Text Editors out there, and I&#8217;m sure most are pretty good. But I&#8217;ve had good results with FCKeditor so I use it on all my projects.  Here&#8217;s a step-by-step guide to adding the FCKeditor to your Zend Form Elements. 
1 &#8211; The basics
Download FCKeditor and Upload it to your [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>There are around 1,083,367 JavaScript-based Rich-Text Editors out there, and I&#8217;m sure most are pretty good. But I&#8217;ve had good results with FCKeditor so I use it on all my projects.  Here&#8217;s a step-by-step guide to adding the FCKeditor to your Zend Form Elements. </em></strong></p>
<h3>1 &#8211; The basics</h3>
<p><span style="font-weight: normal;"><a href="http://www.fckeditor.net/">Download FCKeditor</a> and Upload it to your Web Server. It needs to be somewhere accessible to the world, for example: <strong>/js/fckeditor/</strong>, which on your server may be a path like <strong>/var/www/html/your_site/js/fckeditor/</strong>.</span></p>
<p><span style="font-weight: normal;"><br />
</span></p>
<h3>2 &#8211; .htaccess</h3>
<p><span style="font-weight: normal;">The .htaccess that sets up your index.php as the bootstrap needs to <em>exclude the files that FCKeditor uses</em>. If your bootstrap code in .htaccess looks like this:</span></p>
<pre>RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php</pre>
<p>you&#8217;ll need to change it. I typically only rewrite to /index.php if the requested file <em>really</em> doesn&#8217;t exist. So .htaccess should be something like this:</p>
<pre>RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1</pre>
<p><span style="font-weight: normal;"><br />
</span></p>
<h3>3 &#8211; Zend_Form Elements</h3>
<p>In the Form code, you need to make sure that you know the id of the Element (In this case the id is &#8216;body&#8217;), and that you are filtering out all tags and attributes that you don&#8217;t want to explicitly allow. Create an allowed_tags list like the one below and ensure that the FormElement has a StripTags filter applied to it:</p>
<pre>$allowed_tags = array(
	'a' =&gt;	array('href', 'title'),
	'strong',
	'img'	=&gt;	array('src', 'alt'),
	'ul',
	'ol',
	'li',
	'em',
	'u',
	'strike');

$body = new Zend_Form_Element_Textarea('body');
$body-&gt;setLabel('Body')
	-&gt;setAttrib('rows', 12)
	-&gt;setAttrib('cols', 40)
	-&gt;setRequired(true)
	-&gt;addFilter('StringTrim')
	-&gt;addFilter('StripTags', $allowed_tags);</pre>
<p><span style="font-weight: normal;"><br />
</span></p>
<h3>4 &#8211; View Script</h3>
<p>Let&#8217;s Assume that you use Layouts, and that you only want to use the FCKeditor on a couple of pages on your site. You don&#8217;t want to include the FCKeditor code on every page because it just adds to the page size, so we do something like this in the View Script <em>(Note: Wordpress is messing with the quote marks in this block, ensure you have single quotes after <strong>src=</strong> and before the last semicolon. The other quotes should be double quotes.)</em>:</p>
<pre>$this-&gt;custom_head .= '&lt;script src="/js/fckeditor/fckeditor.js" type="text/javascript"&gt;&lt;/script&gt;';
$this-&gt;custom_head = "&lt;script language='javascript' type='text/javascript' src='/js/customs.js'&gt;&lt;/script&gt;";
$this-&gt;custom_body = ' onload="setupFCK()"';</pre>
<p><span style="font-weight: normal;"><br />
</span></p>
<h3>5 &#8211; Layout Script</h3>
<p>The Layout Script needs to know about this new variable, so the Layout Script needs to know to refer to $this-&gt;custom_head if it is set. Drop the code below inside the &lt;head&gt; section of your layout script:</p>
<pre>&lt;?php

if ($this-&gt;custom_head) {
	echo $this-&gt;custom_head;
}
?&gt;</pre>
<p>&#8230;and change the html body element to look like this:</p>
<pre>&lt;body&lt;?php if ($this-&gt;custom_body) {
	echo $this-&gt;custom_body;
}?&gt;&gt;</pre>
<h3>6 &#8211; Loading the FCKEditor when the page loads</h3>
<p>Create /js/custom.js and put this in it:</p>
<pre><span style="font-weight: normal;">function setUpFCK() {
	if(document.getElementById('body')) {
        var oFCKeditor = new FCKeditor('body') ;
        oFCKeditor.BasePath = "/js/fckeditor/" ;
        oFCKeditor.Height = 400;
        oFCKeditor.ReplaceTextarea() ;
    }

}</span></pre>
<h3>7 &#8211; FCKeditor changes</h3>
<p>I like to implement FCKeditor as a single row of buttons for basic editing, just to keep it from looking too big and clunky. I use a set of icons like this:</p>
<pre>FCKConfig.ToolbarSets["Default"] = [
	['Bold','Italic','Underline','StrikeThrough','OrderedList','UnorderedList','Blockquote','Link','Unlink','Image', 'SpecialChar','SpellCheck']
] ;</pre>
<p>And I don&#8217;t want to enable any kind of file uploads, so I make sure these configs are all set to false (edited to show the relevant bits):</p>
<pre>FCKConfig.LinkBrowser = false ;
...
FCKConfig.ImageBrowser = false ;
...
FCKConfig.FlashBrowser = false ;
...
FCKConfig.LinkUpload = false ;
...
FCKConfig.ImageUpload = false ;
...
FCKConfig.FlashUpload = false ;</pre>
<p><span style="font-weight: normal;"><br />
</span></p>
<h3>8 &#8211; Anything else?</h3>
<p>Not really! There are no Controller changes, which is good because this stuff all belongs in Views anyway. The Models know about the allowed tags, which is good because that&#8217;s the kind of work that Models should do. So to me this solution fits the MVC pattern and is not too hack-like. Feedback welcome&#8230;</p>
<h3>Update: 25/3/09</h3>
<p>Fixed various problems with the instructions and it should now all work properly.</p>
<h3>Update: 20/3/09</h3>
<p>I&#8217;ve been doing a bit of reading about Ruby on Rails with the intention of moving to it as my primary development platform. I haven&#8217;t quite got my head around the integration of front-end stuff like FCKeditor yet but Rails really does look like it simplifies the creation and maintenance of forms, which is, after all, about 70% of the work in websites. Need an example? Well Rails has a sensible defaults approach to forms where they can be created automatically based on the model. So compare that to Zend Framework, where I create a separate class for the Form that must match the structure of the model (and be updated when the model changes)! For a big site, that is significant: only one class per table/model!</p>
<img src="http://feeds.feedburner.com/~r/leftcolumn/~4/BFq8rI_iF1U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/03/10/zend-framework-how-to-add-fckeditor-to-a-zend_form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.leftcolumn.net/2009/03/10/zend-framework-how-to-add-fckeditor-to-a-zend_form/</feedburner:origLink></item>
		<item>
		<title>Zend Framework one-line platform config: Configure, Don’t Integrate</title>
		<link>http://feedproxy.google.com/~r/leftcolumn/~3/weeDno1uiPM/</link>
		<comments>http://www.leftcolumn.net/2009/02/18/zend-framework-one-line-platform-config-configure-dont-integrate/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 04:06:22 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[zend framework]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=146</guid>
		<description><![CDATA[Separating config from code in Zend Framework is not as simple as it is in say, Ruby on Rails. And when your source code is version-controlled you want to minimise the manual configuration required. So here&#8217;s a nice way to keep it simple. The idea is to keep configuration data for your test and production [...]]]></description>
			<content:encoded><![CDATA[<p>Separating config from code in <a href="http://framework.zend.com/">Zend Framework</a> is not as simple as it is in say, <a href="http://rubyonrails.org/">Ruby on Rails</a>. And when your source code is version-controlled you want to minimise the manual configuration required. So here&#8217;s a nice way to keep it simple. The idea is to keep configuration data for your test and production environments in a single config file that does not change, then switch environments in a dedicated separate one-line config file.</p>
<p>Here&#8217;s a sample platforms.ini:</p>
<pre>
[test]
developer_mode = true
db.adapter = PDO_MYSQL
db.params.host = localhost
db.params.dbname = testdb
db.params.username = lkdf034k3k3b
db.params.password = SJGS43we3sdd

[production]
developer_mode = false
db.adapter = PDO_MYSQL
db.params.host = localhost
db.params.dbname = productiondb
db.params.username = ksjdhfkjjdhf
db.params.password = jfdhkjsdhdjk</pre>
<p>.. .And here&#8217;s active_platform.ini. This is where we define which of test or production is currently active:</p>
<pre>[platform]
setting = test</pre>
<p>&#8230;And here&#8217;s how index.php refers to active_platform.ini to first determine which platform it&#8217;s on, and second load the appropriate config from platforms.ini:</p>
<pre>// which platform mode are we on? i.e.: test or production
$active_platform = new Zend_Config_Ini('application/configs/active_platform.ini','active_platform');

// get the platform config
$config = new Zend_Config_Ini('application/configs/platforms.ini', $active_platform->setting);
Zend_Registry::set('config', $config);

// set up the db
$db = Zend_Db::factory($platform_config->db);
Zend_Db_Table::setDefaultAdapter($db);</pre>
<p>When you want to deploy to production, you change the setting in active_platform.ini to &#8216;production.&#8217; Simple as that.. this may be obvious but I&#8217;ve found it to speed up deployment and make it less error-prone. </p>
<img src="http://feeds.feedburner.com/~r/leftcolumn/~4/weeDno1uiPM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/02/18/zend-framework-one-line-platform-config-configure-dont-integrate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.leftcolumn.net/2009/02/18/zend-framework-one-line-platform-config-configure-dont-integrate/</feedburner:origLink></item>
		<item>
		<title>40 Useful Mac OS X Shell Scripts and Terminal Commands</title>
		<link>http://feedproxy.google.com/~r/leftcolumn/~3/3Fr4pnCo8nU/</link>
		<comments>http://www.leftcolumn.net/2009/02/15/40-useful-mac-os-x-shell-scripts-and-terminal-commands/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 10:51:16 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[mac osx]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=71</guid>
		<description><![CDATA[Here are a bunch of Mac OS X terminal commands sorted into general categories. I have intentionally omitted long bash scripts and AppleScripts and focussed instead on small useful commands that can be plugged into bigger scripts or used on their own&#8230; enjoy!
System
Restart Mac OS X:
shutdown - r now
Shutdown Mac OS X:
shutdown now
Power Management / [...]]]></description>
			<content:encoded><![CDATA[<p>Here are a bunch of Mac OS X terminal commands sorted into general categories. I have intentionally omitted long bash scripts and AppleScripts and focussed instead on small useful commands that can be plugged into bigger scripts or used on their own&#8230; enjoy!</p>
<h3>System</h3>
<p>Restart Mac OS X:</p>
<pre>shutdown - r now</pre>
<p>Shutdown Mac OS X:</p>
<pre>shutdown now</pre>
<h3>Power Management / Energy Saving</h3>
<p>Get overview of current Power Management Settings:</p>
<pre>pmset -g</pre>
<p>Put display to sleep after 15 minutes of inactivity:</p>
<pre>sudo pmset displaysleep 15</pre>
<p>Put Computer to sleep after 30 minutes of inactivity:</p>
<pre>sudo pmset sleep 30</pre>
<p>&#8230;Also see my post about <a href="http://www.leftcolumn.net/2009/05/24/macbook-pro-wont-wake-up-from-sleep/" title="hibernate mode and Safe Sleep on the Mac">hibernate mode and Safe Sleep on the Mac</a></p>
<h3>OS X Look and Feel</h3>
<p><a href="http://www.macosxhints.com/article.php?story=20090105064613347">Permanently disable Dock icon bouncing</a></p>
<p>Disable Dashboard (don&#8217;t forget to drag the Dashboard Dock icon off the Dock too):</p>
<pre>defaults write com.apple.dashboard mcx-disabled -boolean YES
killall Dock</pre>
<p>Enable Dashboard:</p>
<pre>defaults write com.apple.dashboard mcx-disabled -boolean NO
killall Dock</pre>
<p>Force the Finder to show hidden files (very useful for Web Developers who need to edit .htaccess files, for example):</p>
<pre>defaults write com.apple.finder AppleShowAllFiles TRUE</pre>
<p>Force the Finder to hide hidden files (ie: back to the default setting):</p>
<pre>defaults write com.apple.finder AppleShowAllFiles FALSE</pre>
<h3>Networking</h3>
<p>Ping a host to see whether it&#8217;s available:</p>
<pre>ping -o leftcolumn.net</pre>
<p>Troubleshoot routing problems to a host using traceroute:</p>
<pre>traceroute leftcolumn.net</pre>
<p>Check whether a host is running an HTTP server (ie: check that a Web Site is available):</p>
<pre>curl -I www.leftcolumn.net | head -n 1</pre>
<p><a href="http://www.macosxhints.com/article.php?story=20080217065538984">Automatically enable Internet Sharing at startup</a></p>
<p>Manage Windows networks (a drop-in for the NET command on Windows). Too many options to list here, so run this for details:</p>
<pre>man net</pre>
<p>Use dig to discover Domain information:</p>
<pre>dig www.leftcolumn.net A
dig www.leftcolumn.net MX</pre>
<p>Who is logged in to your Mac?</p>
<pre>w</pre>
<p>Show routing table:</p>
<pre>netstat -r</pre>
<p>Show active network connections:</p>
<pre>netstat -an</pre>
<p>Show network statistics:</p>
<pre>netstat -s</pre>
<h3>Troubleshooting</h3>
<p>List all open files (this will take a few seconds to complete on most Macs):</p>
<pre>lsof</pre>
<p>Restart Bonjour &#8211; handy when a Mac &#8216;disappears&#8217; from the Network:</p>
<pre>sudo launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist</pre>
<p>Eject a CD&#8230; it&#8217;s never happened to me but you can eject a stuck cd with the following. Note that it won&#8217;t always be &#8216;disk1&#8242;:</p>
<pre>diskutil eject disk1</pre>
<h3>Text Manipulation commands</h3>
<p><em>Sometimes you need to take some text from the clipboard or a file, transform it somehow and then use it. Here are a bunch of commands that do text manipulation. I&#8217;ve assumed you want to transform text from the clipboard and back again, see the notes at the end of the article for info on how to write to and from files instead.</em></p>
<p>Count number of lines in the text in the Clipboard:</p>
<pre>pbpaste | wc -l</pre>
<p>Count number of words in the text in the Clipboard:</p>
<pre>pbpaste | wc -w</pre>
<p>Sort lines of text in the Clipboard and copy them back to the Clipboard:</p>
<pre>pbpaste | sort | pbcopy</pre>
<p>Reverse each line of text in the Clipboard (ie: make each line appear backwards) and copy them back to the Clipboard:</p>
<pre>pbpaste | rev | pbcopy</pre>
<p>Strip duplicate lines from lines of text in the Clipboard and copy only one instance of each duplicate line back to the Clipboard (output is sorted):</p>
<pre>pbpaste | sort | uniq | pbcopy</pre>
<p>Find duplicate lines from lines of text in the Clipboard and copy only one instance of each duplicate line (stripping non-duplicates) back to the Clipboard (output is sorted):</p>
<pre>pbpaste | sort | uniq -d | pbcopy</pre>
<p>Strip duplicate lines from lines of text in the Clipboard and copy only one instance of each line (stripping duplicates entirely) back to the Clipboard (output is sorted):</p>
<pre>pbpaste | sort | uniq -u | pbcopy</pre>
<p>Tidy up HTML in the Clipboard and copy it back to the Clipboard:</p>
<pre>pbpaste | tidy | pbcopy</pre>
<p>Display the first 5 lines from the Clipboard:</p>
<pre>pbpaste | head -n 5</pre>
<p>Display the last 5 lines from the Clipboard:</p>
<pre>pbpaste | tail -n 5</pre>
<p>Convert tabs to spaces for the lines in the Clipboard:</p>
<pre>pbpaste | expand | pbcopy</pre>
<h3>Other useful commands</h3>
<p>Password protect your web site! Create a CRYPTed user/password for using in a .htpasswd file. Save the <strong>outputted results</strong> of <strong>A</strong> below to a file called .htpasswd in the directory you want to secure. Then save the <strong>contents</strong> of <strong>B</strong> to a file called .htaccess in the same folder.</p>
<h4>A:</h4>
<pre>htpasswd -nb username password</pre>
<h4>B:</h4>
<pre>AuthType Basic
AuthName "restricted area"
AuthUserFile /path/to/your/site/.htpasswd
require valid-user</pre>
<p>Display a history of commands used in the terminal by the current user:</p>
<pre>history</pre>
<p>Convert a file to HTML. Support formats are Text, .RTF, .DOC.</p>
<pre>textutil -convert html file.extension</pre>
<p>Nano is a very easy-to-use text editor for quick changes to text files. It is less powerful than VIM but has the advantage of clearly showing you the common editing commands:</p>
<pre>nano [file_to_edit]</pre>
<p>&#8230;In nano, use ctrl+o to Save and ctrl+x to quit.</p>
<h3>iTunes</h3>
<p>Change iTunes link behaviour to point at local iTunes Library instead of iTunes Store:</p>
<pre>defaults write com.apple.iTunes invertStoreLinks -bool YES</pre>
<p>Change iTunes link behaviour to point at iTunes Store instead of local iTunes Library (ie: back to the default):</p>
<pre>defaults write com.apple.iTunes invertStoreLinks -bool NO</pre>
<h3>Other Mac OS X Terminal Resources</h3>
<p><a href="http://www.kernelthread.com/mac/osx/tools.html">Mac OS X Hacking Tools</a> (old but detailed list for the obsessive only).</p>
<p><a href="http://hayne.net/MacDev/Bash/">Cameron Hayne&#8217;s Bash Scripts</a></p>
<p><a href="http://www.macosxhints.com/">Mac OS X Hints</a></p>
<p><a href="http://discussions.apple.com/">Apple Forums</a></p>
<p>Note: For commands where I&#8217;ve used pbcopy to get the contents of the Clipboard as input, you can use the contents of a file as input instead. Swap <em>pbpaste</em> for:</p>
<pre>cat [/path/to/filename]</pre>
<p>And to put the results into a file on your desktop, just swap <em>| pbcopy</em> for:</p>
<pre>&gt; ~/Desktop/filename.txt</pre>
<p>&#8230; hope you find them useful!</p>
<img src="http://feeds.feedburner.com/~r/leftcolumn/~4/3Fr4pnCo8nU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/02/15/40-useful-mac-os-x-shell-scripts-and-terminal-commands/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.leftcolumn.net/2009/02/15/40-useful-mac-os-x-shell-scripts-and-terminal-commands/</feedburner:origLink></item>
		<item>
		<title>MD5 Tool added to site</title>
		<link>http://feedproxy.google.com/~r/leftcolumn/~3/fbmh31uwzas/</link>
		<comments>http://www.leftcolumn.net/2009/02/12/md5-tool-added-to-site/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 08:39:22 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[site admin]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=115</guid>
		<description><![CDATA[Here&#8217;s a new MD5 Tool for creating salted hashes of passwords. Just added this because I find it useful and it&#8217;s good to share!
]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a new <a title="MD5 tool for creating salted hashes of passwords" href="http://www.leftcolumn.net/md5-tools/">MD5 Tool for creating salted hashes of passwords</a>. Just added this because I find it useful and it&#8217;s good to share!</p>
<img src="http://feeds.feedburner.com/~r/leftcolumn/~4/fbmh31uwzas" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/02/12/md5-tool-added-to-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.leftcolumn.net/2009/02/12/md5-tool-added-to-site/</feedburner:origLink></item>
		<item>
		<title>Changing directions</title>
		<link>http://feedproxy.google.com/~r/leftcolumn/~3/fw4A6pN1S80/</link>
		<comments>http://www.leftcolumn.net/2009/02/12/changing-directions/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 00:12:49 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[site admin]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=97</guid>
		<description><![CDATA[A rare site administration message: I&#8217;m moving the focus of this blog away from Undone. Essentially, Undone was a bit of development I did while figuring out some technology, and it now seems like a rather rough and unready piece of software. I&#8217;m going to leave Undone running as people are still using it, and [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>A rare site administration message:</em></strong> I&#8217;m moving the focus of this blog away from <a href="http://undone.leftcolumn.net">Undone</a>. Essentially, Undone was a bit of development I did while figuring out some technology, and it now seems like a rather rough and unready piece of software. I&#8217;m going to leave Undone running as people are still using it, and you can create new accounts etc if you want too. That said, for serious project management / to do lists etc, I&#8217;d recommend something like TaDa lists or installing Redmine or DotProject.</p>
<p>The new focus for leftcolumn.net will be to cover &#8220;Web Sites and the Macs we make them with.&#8221; This means Web Development, and also Mac OSX Software: both development tools and general apps like iTunes, Safari etc. These are rough plans, and I&#8217;m going to see where it takes me.Â </p>
<p>Cheers!</p>
<img src="http://feeds.feedburner.com/~r/leftcolumn/~4/fw4A6pN1S80" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/02/12/changing-directions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.leftcolumn.net/2009/02/12/changing-directions/</feedburner:origLink></item>
		<item>
		<title>Essential Web Development Software: DigitalColor Meter</title>
		<link>http://feedproxy.google.com/~r/leftcolumn/~3/YBIS-4nma6g/</link>
		<comments>http://www.leftcolumn.net/2009/01/26/essential-web-development-software/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 09:37:24 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[digitalcolor meter]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=48</guid>
		<description><![CDATA[Â 
Installed with every Mac, DigitalColor Meter gives you accurate readings of on-screen colours: you can inspect individual pixels, and copy and paste RGB values. When used with Safari or Firefox and a great text editor, it&#8217;s a lightweight but powerful tool. Here&#8217;s an overview&#8230;
Â 

Find it in /Applications/Utilities/
For using with HTML and CSS, Â set the colour [...]]]></description>
			<content:encoded><![CDATA[<p>Â </p>
<div id="attachment_49" class="wp-caption alignleft" style="width: 236px"><img class="size-full wp-image-49  " title="DigitalColor Meter in use" src="http://www.leftcolumn.net/wp-content/uploads/2009/01/picture-3.png" alt="DigitalColor Meter is handy for sampling on-screen colour " width="226" height="113" /><p class="wp-caption-text">DigitalColor Meter is handy for sampling on-screen colour </p></div>
<p><em><strong>Installed with every Mac, DigitalColor Meter gives you accurate readings of on-screen colours: you can inspect individual pixels, and copy and paste RGB values. When used with Safari or Firefox and a great text editor, it&#8217;s a lightweight but powerful tool. Here&#8217;s an overview&#8230;</strong></em></p>
<p>Â </p>
<ul>
<li>Find it in /Applications/Utilities/</li>
<li>For using with HTML and CSS, Â set the colour type to &#8220;RGB as Hex Value, 8-bit&#8221;</li>
<li>Command+Shift+c to copy the current colour as text &#8211; perfect for pasting straight into a .css file, alternatively, click and drag from the swatch area to copy the current colour as text (switch this on in preferences first)</li>
<li>Command+Shift+h to hold the current colour</li>
<li>Set the magnification factor to maximum and the aperture size to minimum for pixel-perfect sampling. Handy for &#8216;borrowing&#8217; font colours from other sites!</li>
<li>Reduce the magnification factor and increase the aperture size for getting an averaged colour &#8211; say, when you&#8217;re working with gradients or photos</li>
<li>When DigitalColor Meter is the active app, you can use the arrow keys to move the aperture in one-pixel increments</li>
<li>You can also save the current hovered area as a .tiff file, or copy it to the clipboard.Â </li>
<li>Set the window to float and keep it in the bottom right of the screen, so it&#8217;s always there at a glance.Â </li>
</ul>
<p>One last point: on Tiger at least, if you switch users to a user who hasÂ DigitalColor MeterÂ running it will crash. But that&#8217;s an annoyance at worst&#8230;</p>
<img src="http://feeds.feedburner.com/~r/leftcolumn/~4/YBIS-4nma6g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/01/26/essential-web-development-software/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.leftcolumn.net/2009/01/26/essential-web-development-software/</feedburner:origLink></item>
		<item>
		<title>Calling a View Helper from inside another View Helper in Zend Framework</title>
		<link>http://feedproxy.google.com/~r/leftcolumn/~3/6qccMMPgOMQ/</link>
		<comments>http://www.leftcolumn.net/2009/01/15/calling-a-view-helper-from-inside-another-view-helper-in-zend-framework/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 10:02:23 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=35</guid>
		<description><![CDATA[Update 8th April 2009: Apparently as of 1.7.6 $this-&#62;view-&#62;[helperName()] now works with no extra work required so the info in this post is only necessary if you&#8217;re using &#60;= 1.7.5. Thanks to Mike van Lammeren for the heads up, Â see Mike&#8217;s comment below. 
If you&#8217;re relatively new to Zend Framework, some of the little details [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update 8th April 2009: Apparently as of 1.7.6 $this-&gt;view-&gt;[helperName()] now works with no extra work required so the info in this post is only necessary if you&#8217;re using &lt;= 1.7.5. Thanks to Mike van Lammeren for the heads up, Â see Mike&#8217;s comment below. </strong></p>
<p>If you&#8217;re relatively new to Zend Framework, some of the little details can stump you. To call a view helper from within another view helper, you need to give the helper some, er, help. Helpers will try to call a function called setView to set up $_view, so just add it:</p>
<p>Add these lines to the view helper:</p>
<p><code>private $_view;<br />
public function setView($view) {<br />
$this-&gt;_view = $view;<br />
}</code><br />
then to call the View Helper you need, use $this-&gt;_view-&gt;anyHelperYouLike();</p>
<p>Edit: I found this information somewhere on the web, but can&#8217;t remember the source. Any information appreciated!</p>
<img src="http://feeds.feedburner.com/~r/leftcolumn/~4/6qccMMPgOMQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/01/15/calling-a-view-helper-from-inside-another-view-helper-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.leftcolumn.net/2009/01/15/calling-a-view-helper-from-inside-another-view-helper-in-zend-framework/</feedburner:origLink></item>
		<item>
		<title>Retrospect again</title>
		<link>http://feedproxy.google.com/~r/leftcolumn/~3/awYZKEHKa1w/</link>
		<comments>http://www.leftcolumn.net/2007/10/31/retrospect-again/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 10:42:10 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[backup]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[retrospect]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/2007/10/31/retrospect-again/</guid>
		<description><![CDATA[UPDATE 24 March 2009: Retrospect 8 for Mac OS X has been released! 
Just saw this on MacNN: EMC Retrospect 8.0 on chopping block? (ok, it&#8217;s months old), so it looks like version 8 definitely isn&#8217;t coming to the Mac. Is it just me or does this seem like an opportunity for some hungry Mac [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE 24 March 2009</strong>: <a href="http://www.retrospect.com/products/software/retroformac/" title="Retrospect 8 for Mac OS X" >Retrospect 8 for Mac OS X has been released!</a> </p>
<p>Just saw this on MacNN: <a title="EMC Retrospect 8.0 on chopping block?" href="http://www.macnn.com/articles/07/01/22/emc.axes.retrospect.80/" target="_blank">EMC Retrospect 8.0 on chopping block?</a> (ok, it&#8217;s months old), so it looks like version 8 definitely isn&#8217;t coming to the Mac. Is it just me or does this seem like an opportunity for some hungry Mac developers to build a really good backup system that suits Small Office Networks, has provision for offsite backups like Retrospect does, but sports a swish Cocoa interface and is Universal?</p>
<p>Because basically Time Machine covers local backups but doesn&#8217;t serve the same &#8216;Backup Server&#8217; role that Retrospect Workgroup does&#8230;</p>
<p>I know there are some good small backup apps for the Mac out there, but do any backup a network of Macs and provide backup set management?</p>
<img src="http://feeds.feedburner.com/~r/leftcolumn/~4/awYZKEHKa1w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2007/10/31/retrospect-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.leftcolumn.net/2007/10/31/retrospect-again/</feedburner:origLink></item>
	</channel>
</rss>
