<?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>David Janes&#039; Code Weblog &#187; macintosh</title>
	<atom:link href="http://code.davidjanes.com/blog/category/macintosh/feed/" rel="self" type="application/rss+xml" />
	<link>http://code.davidjanes.com/blog</link>
	<description></description>
	<lastBuildDate>Fri, 03 Feb 2012 00:49:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Installing Drupal on a Macbook Air</title>
		<link>http://code.davidjanes.com/blog/2010/12/22/installing-drupal-on-a-macbook-air/</link>
		<comments>http://code.davidjanes.com/blog/2010/12/22/installing-drupal-on-a-macbook-air/#comments</comments>
		<pubDate>Wed, 22 Dec 2010 18:58:37 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[drupal]]></category>
		<category><![CDATA[macintosh]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=694</guid>
		<description><![CDATA[This documents how I installed Drupal on a brand new Macbook Air running Snow Leopard 10.6.5. Web/Desktop/Shell: Install MySQL Go here (&#8220;Mysql Community Server&#8221;) and download the 64 bit version Double click on the DMG and Install Drag the .PREF file in the DMG to the System Preferences Note &#8211; I&#8217;m still having trouble starting [...]]]></description>
			<content:encoded><![CDATA[<p>This documents how I installed Drupal on a brand new Macbook Air running Snow Leopard 10.6.5.</p>
<h4>Web/Desktop/Shell: Install MySQL</h4>
<ul>
<li>Go <a href="http://dev.mysql.com/downloads/mysql/">here</a> (&#8220;Mysql Community Server&#8221;) and download the 64 bit version</li>
<li>Double click on the DMG and Install</li>
<li>Drag the .PREF file in the DMG to the System Preferences</li>
</ul>
<p>Note &#8211; I&#8217;m still having trouble starting MySQL from the command line. Right now I&#8217;m doing:</p>
<ul>
<li><code>cd /usr/local/mysql/bin</code></li>
<li><code>nohup ./mysqld_safe &amp;</code></li>
<li><code>disown %1</code></li>
</ul>
<p>If you have advice, I&#8217;d appreciate it.</p>
<h4>Web/Shell: Install Drupal</h4>
<ul>
<li><a href="http://drupal.org/drupal-6.20">Download Drupal</a></li>
<li>Untar Drupal in <code>~/Sites/</code></li>
<li>In Apple &gt; System Preferences &gt; Sharing, select Web Sharing</li>
<li>In your browser go to <code>http://localhost/~USERNAME/drupal-6.20/</code></li>
</ul>
<p>In case it&#8217;s not clear what happened here:</p>
<ul>
<li>Snow Leopard has an Apache Server built in</li>
<li>each user account gets it&#8217;s HTTP files in <code>~/Sites/</code></li>
<li>you turn on Apache by turning on Web Sharing</li>
<li>you browse by going to <code>~USERNAME/</code></li>
</ul>
<p>You&#8217;ll notice at this stage we&#8217;re just seeing a directory listing, or if you&#8217;re a little more ambitious and click on &#8220;index.php&#8221;, PHP code. If you&#8217;re actually seeing a Drupal setup page, skip the next section.</p>
<h4>Shell: Setup PHP</h4>
<p>This is just following the excellent instructions from <a href="http://maestric.com/doc/mac/apache_php_mysql_snow_leopard">here</a>.</p>
<ul>
<li><code>sudo vim /etc/apache2/httpd.conf</code></li>
<li>uncomment <code>LoadModule php5_module</code></li>
<li><code>bash</code> (to start a subshell)</li>
<li><code>cd /etc</code></li>
<li><code>sudo cp php.ini.default php.ini</code></li>
<li><code>sudo chmod 666 php.ini</code></li>
<li><code>sudo vi /etc/php.ini</code></li>
<li>search for <code>;date.timezone</code></li>
<li>uncomment and change to:<br />
<code>date.timezone=America/Toronto</code></li>
<li>restart apache: <code>sudo apachectl restart</code></li>
<li>end the subshell: <code>exit</code></li>
</ul>
<p>Note &#8211; if you see the error &#8220;<code>/usr/sbin/apachectl: line 82: ulimit: open files: cannot modify limit: Invalid argument</code>&#8220;, follow the instructions <a href="http://excid3.com/blog/2010/12/usrsbinapachectl-line-82-ulimit-open-files-cannot-modify-limit-invalid-argument/">here</a>:</p>
<ul>
<li>sudo vim /usr/sbin/apachectl</li>
<li>comment out ULIMIT_MAX_FILES at line 64</li>
</ul>
<h4>Local Web/Shell: Set up Drupal</h4>
<ul>
<li>go to the webpage<code> install.php</code> (on the URL figured out way above)</li>
<li>click on <strong>Install Drupal in English</strong></li>
<li>if you get an error message about <code>default.settings.php</code>
<ul>
<li><code>cd ~/Sites/drupal-6.20/sites/default</code></li>
<li><code>cp default.settings.php settings.php</code></li>
<li><code>chmod a+w settings.php</code></li>
</ul>
</li>
<li>if you get an error message about <code>sites/defaults/files</code>
<ul>
<li><code>cd ~/Sites/drupal-6.20/sites/default</code></li>
<li><code>mkdir files</code></li>
<li><code>chmod 777 files</code></li>
</ul>
</li>
</ul>
<p>At this point you should be brought to a &#8220;Database Configuration Page&#8221; and we have to leave the browser and go back to the command line.</p>
<h4>Shell: MySQL Database Configuration</h4>
<p>These instructions create a MySQL database called &#8220;<strong>drupal_db</strong>&#8221; with access by &#8220;<strong>drupal_user</strong>&#8221; using the password &#8220;<strong>drupal_password</strong>&#8220;.</p>
<ul>
<li><code>/usr/local/mysql/bin/mysql -u root</code>
<ul>
<li><code>create database drupal_db;</code></li>
<li><code>grant all privileges ON drupal_db.* TO "drupal_user"@"localhost" identified by "drupal_password";</code></li>
<li><code>grant all privileges ON drupal_db.* TO "drupal_user"@"127.0.0.1" identified by "drupal_password";</code></li>
<li><code>flush privileges;</code></li>
<li><code>exit;</code></li>
</ul>
</li>
</ul>
<h4>Local Web: Enter MySQL information into Drupal</h4>
<p>Back in the browser you should be on the Drupal <strong>Database Configuration</strong> page. Enter <strong>drupal_db</strong>, <strong>drupal_user</strong> and <strong>drupal_password</strong> (the values you created in the previous step)</p>
<p>Submit the form. If you get the following error message:</p>
<blockquote><p>Failed to connect to your MySQL database server. MySQL reports the following message: No such file or directory.</p></blockquote>
<p>Make sure you typed everything correctly. If necessary, click on <strong>Advanced Options</strong> and change the hostname from <strong>localhost</strong> to <strong>127.0.0.1</strong>.</p>
<h4>Local Web: Configure Site page for Drupal</h4>
<ul>
<li> Site Information:
<ul>
<li>Site Name: <code>localhost</code> (why not)</li>
<li>Site e-mail address: <code>your@email.com</code></li>
</ul>
</li>
<li> Administrator account:
<ul>
<li>Username: <code>admin</code> (why not)</li>
<li>E-mail address: <code>your@email.com</code></li>
<li>Password:/Confirm password: <code>your-favorite-password</code></li>
</ul>
</li>
</ul>
<h4>Local Web: Drupal installation complete</h4>
<p>After you hit submit, you should be finished installing Drupal, except for the next little cleanup step.</p>
<h4>Shell: Clean up files</h4>
<p>Drupal doesn&#8217;t like you leaving <code>settings.php</code> alterable by the web server around:</p>
<ul>
<li><code>cd ~/Sites/drupal-6.20/sites/default</code></li>
<li><code>chmod go-w settings.php</code></li>
</ul>
<p>The directory <code>files</code> must be left writable.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2010/12/22/installing-drupal-on-a-macbook-air/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to use XCode for Android Projects</title>
		<link>http://code.davidjanes.com/blog/2009/11/20/how-to-use-xcode-for-android-projects/</link>
		<comments>http://code.davidjanes.com/blog/2009/11/20/how-to-use-xcode-for-android-projects/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 23:07:39 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[code fragments]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[macintosh]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=625</guid>
		<description><![CDATA[Let&#8217;s assume you already have an Android project on your Mac. Create the XCode Project start XCode select File &#62; New Project&#8230; select External Build System go to the parent directory of your Android Project in the Save As: field, enter the directory name of your Android Project select the scarily-misnamed Replace option [not in [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s assume you already have an Android project on your Mac.</p>
<h4>Create the XCode Project</h4>
<ul>
<li>start XCode</li>
<li>select <strong>File &gt; New Project&#8230;</strong></li>
<li>select <strong>External Build System</strong></li>
<li>go to the parent directory of your Android Project</li>
<li>in the <strong>Save As:</strong> field, enter the directory name of your Android Project</li>
<li><del>select the scarily-misnamed <strong>Replace</strong> option</del> [<a title="See Comments" href="http://code.davidjanes.com/blog/2009/11/20/how-to-use-xcode-for-android-projects/#comment-895">not in XCode 4</a> -- thanks Jusin]</li>
</ul>
<h4>Add Files</h4>
<p>In your new XCode project:</p>
<ul>
<li>select first item in the left hand column, which is the name of your project</li>
<li>right-click, select <strong>Add &gt; Existing Files&#8230;</strong></li>
<li>select add files (don&#8217;t select the <strong>Copy</strong> option)</li>
<li>organize as desired (I like to do a lot of grouping). You should be probably adding at least your Java files and your Layout resources.</li>
</ul>
<h4>Configure your Build Target</h4>
<p>In your new XCode project:</p>
<ul>
<li>look for Targets</li>
<li>inside will be a target for your project&#8217;s name</li>
<li>double click on it
<ul>
<li>change <strong>Build Tool</strong> to <code>ant</code></li>
<li>change <strong>Arguments</strong> to <code>install</code></li>
</ul>
</li>
</ul>
<p>Clicking <strong>⌘B</strong> should now compile your project.</p>
<p><em>Note: if you figure out how to have a Build vs. Build &amp; Install (e.g. <strong>⌘ENTER</strong>) please let me know!.</em></p>
<h4>Getting XCode to Recognize Java errors</h4>
<ul>
<li>Reconfigure the Build Target, changing <code>ant</code> to <code>./xant</code></li>
<li>Make a file <code>xant</code> in the project&#8217;s home directory, using the code below</li>
<li>do (from a Terminal) <code>chmod a+x xant</code></li>
</ul>
<pre>#!/usr/bin/env python

import sys
import re
import subprocess

av = list(sys.argv)
av[0] = "ant"

p = subprocess.Popen(av, stdout = subprocess.PIPE)

javac_rex = re.compile(" +[[]javac[]] +")
line_rex = re.compile("[.]java:[\d]+:")

pending = ""
while True:
    d = p.stdout.read(128)
    if not d:
        break

    d = pending + d

    nx = d.rfind('\n')
    if nx == -1:
        pending = d
        continue
    else:
        d, pending = d[:nx + 1], d[nx + 1:]

        d = javac_rex.sub("", d)
        d = line_rex.sub(r"\g error: ", d)
        sys.stdout.write(d)
        sys.stdout.flush()

sys.stdout.write(pending)
p.wait()
sys.exit(p.returncode)</pre>
<p><em>Note: this code has been updated from the original post. It now reads little chunks and outputs them immediately rather than post-processing the ant output.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2009/11/20/how-to-use-xcode-for-android-projects/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>PIL, libjpeg, jpeg and Mac OS/X Snow Leopard</title>
		<link>http://code.davidjanes.com/blog/2009/11/16/pil-libjpeg-jpeg-and-mac-osx-snow-leopard/</link>
		<comments>http://code.davidjanes.com/blog/2009/11/16/pil-libjpeg-jpeg-and-mac-osx-snow-leopard/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 12:47:50 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[macintosh]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=620</guid>
		<description><![CDATA[If you want to the use the Python Imaging Library on Mac OS/X Snow Leopard, these instructions appear to be the best way to to get libjpeg installed: 1. Download the source from http://libjpeg.sourceforge.net/ 2. Extract, configure, make: tar zxvf jpegsrc.v6b.tar.gz cd jpeg-6b cp /usr/share/libtool/config/config.sub . cp /usr/share/libtool/config/config.guess . ./configure --enable-shared --enable-static make 3. You [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to the use the <a href="http://www.pythonware.com/products/pil/">Python Imaging Library</a> on Mac OS/X Snow Leopard, <a href="http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/">these instructions</a> appear to be the best way to to get <code>libjpeg</code> installed:</p>
<blockquote><p>1. Download the source from <a href="http://libjpeg.sourceforge.net/">http://libjpeg.sourceforge.net/</a></p>
<p>2. Extract, configure, make:<br />
<code><br />
tar zxvf jpegsrc.v6b.tar.gz<br />
cd jpeg-6b<br />
cp /usr/share/libtool/config/config.sub .<br />
cp /usr/share/libtool/config/config.guess .<br />
./configure --enable-shared --enable-static<br />
make<br />
</code></p>
<p>3. You may need to create the following directories:<br />
<code><br />
sudo mkdir -p /usr/local/include<br />
sudo mkdir -p /usr/local/lib<br />
sudo mkdir -p /usr/local/man/man1<br />
</code></p>
<p>4. Now you can install it as usual.<br />
<code><br />
sudo make install</code></p></blockquote>
<p>I used to use <a href="http://www.finkproject.org/">Fink</a> on Leopard, but it didn&#8217;t seem to work to well this time. If you&#8217;ve previously made an attempt at installing PIL, make sure to <code>rm -rf build</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2009/11/16/pil-libjpeg-jpeg-and-mac-osx-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Interact with applications from the command line on the Mac</title>
		<link>http://code.davidjanes.com/blog/2008/12/23/interact-with-applications-from-the-command-line-on-the-mac/</link>
		<comments>http://code.davidjanes.com/blog/2008/12/23/interact-with-applications-from-the-command-line-on-the-mac/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 11:50:38 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[macintosh]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=396</guid>
		<description><![CDATA[I&#8217;m a command line guy &#8211; I spend 90% of my non-blog reading day in Terminal, working on Python apps on my Mac or SSHed into work and working on Java and Javascript applications. I do realize the benefit of &#8220;real&#8221; applications, for image editing, for advanced text processing and so forth. On the Mac [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://code.davidjanes.com/resources/Terminal%20Replacement%20Icons/Terminal%20Replacement_128x128.png" style="margin: 0 0 10px 10px; float: right;  position: relative; top: -15px;" />I&#8217;m a command line guy &#8211; I spend 90% of my non-blog reading day in Terminal, working on Python apps on my Mac or SSHed into work and working on Java and Javascript applications. I do realize the benefit of &#8220;real&#8221; applications, for image editing, for advanced text processing and so forth. On the Mac you can send files to the default application easily:</p>
<pre style="clear: both">
open "Madeline Doll House.jpg"
</pre>
<p>(Don&#8217;t ask). If the Mac doesn&#8217;t know how to deal with the file type, or you want to specify a particular app, that&#8217;s cool too:</p>
<pre>
open -a smultron index.jd
</pre>
<p>Note that it doesn&#8217;t matter that I&#8217;m SSHed into a work computer &#8211; <a href="http://code.davidjanes.com/blog/2008/12/11/mount-ntfs-and-remote-filesystems-using-macfuse/">we got around that issue last week using MacFUSE</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2008/12/23/interact-with-applications-from-the-command-line-on-the-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mount NTFS and remote filesystems using MacFUSE</title>
		<link>http://code.davidjanes.com/blog/2008/12/11/mount-ntfs-and-remote-filesystems-using-macfuse/</link>
		<comments>http://code.davidjanes.com/blog/2008/12/11/mount-ntfs-and-remote-filesystems-using-macfuse/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 16:56:24 +0000</pubDate>
		<dc:creator>David Janes</dc:creator>
				<category><![CDATA[macintosh]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://code.davidjanes.com/blog/?p=331</guid>
		<description><![CDATA[Earlier this week I bought a LaCie 500Gb USB drive so I could bring VMWare images between work and home. When I went to copy the image, the copy failed with no meaningful error message (Error 0, I believe). Trying the copy on the command line was a little more informative: as it turns out, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://code.davidjanes.com/examples/2008-12-13/macfuse-icon.png" alt="MacFUSE" style="border: 0 0 10px 10px; float: right;" />Earlier this week I bought a LaCie 500Gb USB drive so I could bring VMWare images between work and home. When I went to copy the image, the copy failed with no meaningful error message (Error 0, I believe). Trying the copy on the command line was a little more informative: as it turns out, the LaCie drive ships with a FAT-32 file system which can only handle files up to 4Gb in size. As the image I was trying to copy had a 8Gb file in it, this was a no go.</p>
<p>My initial thought was to use the UNIX commands <code>tar</code> and <code>split</code> to break the files into individual smaller chunks, but this is hardly a satisfactory answer. If I formatted the drive to the Mac filesystem, the Windows machines would not be able to read it at all. If I formatted the drive the &#8220;new&#8221; NTFS filesystem, Windows can read and write just fine but the Macintosh wouldn&#8217;t be able to write to it.</p>
<p>Fortunately, there&#8217;s an excellent install for the Mac called <a href="http://code.google.com/p/macfuse/">MacFUSE</a> that allows access to all sorts of filesystem types not natively supported by the Macintosh, include NTFS. Here&#8217;s how I set up MacFUSE.</p>
<h4>MacFUSE Installation</h4>
<ul>
<li>go to <a href="http://code.google.com/p/macfuse/">http://code.google.com/p/macfuse/</a></li>
<li>download the latest version</li>
<li>install</li>
<li>reboot</li>
</ul>
<p>Installation by itself does nothing except set you up for the next stage: installing drivers for particular file systems.</p>
<h4>NTFS</h4>
<p>You have to search through the documentation for a bit to figure out where to get NTFS to with Windows filesystems. It actually turns out to be rather easy:</p>
<ul>
<li>go to <a href="http://macntfs-3g.blogspot.com/">http://macntfs-3g.blogspot.com/</a></li>
<li>look for the latest NTFS-3G [stable] release</li>
<li>click on the link, download and install the package</li>
<li>reboot</li>
</ul>
<p>You can now write to NTFS drives. It&#8217;s a little slow &#8211; it&#8217;s taking me about 2 hours to copy 8Gb to the La Cie drive, but that&#8217;s better than not being able to do it at all. You wouldn&#8217;t want to work live off the drive however, and it may be worth investigating commercial NTFS compatibility applications if you need to do this.</p>
<p>To reformat your La Cie drive plotline, use Applications &gt; Disk Utility to erase and install an empty NTFS file system.</p>
<h4>SSHFS</h4>
<p>SSHFS lets you see remote filesystems through <a href="http://en.wikipedia.org/wiki/Ssh">SSH</a>.</p>
<ul>
<li>go to <a href="http://code.google.com/p/macfuse/wiki/MACFUSE_FS_SSHFS">http://code.google.com/p/macfuse/wiki/MACFUSE_FS_SSHFS</a></li>
<li>download the version appropriate to your Mac; you can store this in your home directory or if you&#8217;re a little more organized about your path, a directory link <code>~/bin</code></li>
<li>make a mount point &#8211; this is just a directory on your Mac that is needed by MacFUSE; it can be hidden as Mac OS will show you the mounted drive on your desktop and in <code>/Volumes</code>. For example, on the command line run <code>mkdir -p ~/.Volumes/Remote</code>.</li>
<li>run the mount command; you&#8217;ll be prompted for your remote system password</li>
</ul>
<p>You&#8217;ll see the drive appearing on your desktop. I&#8217;ve actually created a shell alias to do the mounting for me called &#8220;mount-xxx&#8221;. If you don&#8217;t know how to do this, it&#8217;s probably too much to go into right now.</p>
<p>The nice thing about SSHFS is that I could see being able to run an entire Mac desktop development shop with all the backend computing running Linux, all being accessed nicely through SSHFS.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.davidjanes.com/blog/2008/12/11/mount-ntfs-and-remote-filesystems-using-macfuse/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

