<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="https://jamesfriend.com.au"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>James Friend - mac</title>
 <link>https://jamesfriend.com.au/tags/mac</link>
 <description></description>
 <language>en</language>
<item>
 <title>Running a Hypercard stack on a modern Mac</title>
 <link>https://jamesfriend.com.au/running-hypercard-stack-2014</link>
 <description>&lt;div class=&quot;field field-name-field-image field-type-image field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;og:image rdfs:seeAlso&quot; resource=&quot;https://jamesfriend.com.au/sites/default/files/styles/full_width/public/field/image/Screen%20Shot%202014-02-12%20at%2010.00.43%20pm_0.png&quot;&gt;&lt;img typeof=&quot;foaf:Image&quot; src=&quot;https://jamesfriend.com.au/sites/default/files/styles/full_width/public/field/image/Screen%20Shot%202014-02-12%20at%2010.00.43%20pm_0.png&quot; width=&quot;870&quot; height=&quot;477&quot; alt=&quot;Hypercard in SheepShaver emulator&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;p&gt;&lt;strong&gt;Updated: now works on Yosemite&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A bunch of people have emailed me about getting Hypercard stacks running under emulation. 
Here is a pretty easy guide to running a Hypercard stack on a recent Mac (eg. running Mavericks, Mountain Lion, etc):&lt;/p&gt;

&lt;p&gt;Place the Hypercard stack you want to access somewhere within your user folder: eg. Documents, or Desktop.&lt;/p&gt;

&lt;p&gt;Download &lt;a href=&quot;/hypercard/hypercard-ca520e219.sheepvm.zip&quot;&gt;this zip file&lt;/a&gt; [95mb] containing the &lt;a href=&quot;http://sheepshaver.cebix.net/&quot;&gt;SheepShaver&lt;/a&gt; classic Mac emulator bundled with Mac OS 9 and Hypercard.&lt;/p&gt;

&lt;p&gt;Extract and open &lt;code&gt;hypercard.sheepvm&lt;/code&gt;. This should boot Mac OS 9.&lt;/p&gt;

&lt;p&gt;On the Mac OS 9 desktop there should be a disk called &quot;Unix&quot;. This is a virtual disk which actually lets you access files on your computer (eg. outside the emulator). Opening it is equivalent to opening your OS X &lt;code&gt;/Users/&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;From there, navigate to your user folder (eg. your OS X username) and then to the folder you placed your Hypercard stack (in the first step).&lt;/p&gt;

&lt;p&gt;Copy your Hypercard stack from the &#039;Unix&#039; disk to somewhere on the OS 9 &#039;Macintosh HD&#039; disk.&lt;/p&gt;

&lt;p&gt;Double-click the Hypercard stack in the location you placed it on the OS 9 &#039;Macintosh HD&#039; disk (or open it from within Hypercard).&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Tags:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/mac&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;mac&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/hypercard&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;hypercard&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/emulation&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;emulation&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Thu, 06 Feb 2014 14:32:17 +0000</pubDate>
 <dc:creator>James</dc:creator>
 <guid isPermaLink="false">11 at https://jamesfriend.com.au</guid>
</item>
<item>
 <title>Why port emulators to the browser?</title>
 <link>https://jamesfriend.com.au/why-port-emulators-browser</link>
 <description>&lt;div class=&quot;field field-name-field-image field-type-image field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;og:image rdfs:seeAlso&quot; resource=&quot;https://jamesfriend.com.au/sites/default/files/styles/full_width/public/field/image/macpaint-woodblock_0.png&quot;&gt;&lt;img typeof=&quot;foaf:Image&quot; src=&quot;https://jamesfriend.com.au/sites/default/files/styles/full_width/public/field/image/macpaint-woodblock_0.png&quot; width=&quot;513&quot; height=&quot;343&quot; alt=&quot;MacPaint Woodblock sample image&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;p&gt;In a discussion on Hacker News about emulators being ported to the browser, I drew attention to my own project, &lt;a href=&quot;/pce-js/&quot;&gt;PCE.js&lt;/a&gt;, which emulates a &lt;a href=&quot;http://en.wikipedia.org/wiki/Macintosh_Plus&quot;&gt;Macintosh Plus&lt;/a&gt; and an &lt;a href=&quot;http://en.wikipedia.org/wiki/IBM_Personal_Computer_XT&quot;&gt;IBM PC/XT&lt;/a&gt;. Some of the questions brought up included why someone would undertake such a project, and also the legal considerations of including the software ROM required to boot the machine.&lt;/p&gt;

&lt;p&gt;So, why port emulators of outdated computers to the browser? Well, to start with, I feel very strongly about the importance of learning from the past – not making the same mistakes again and again due to a lack of historical perspective. I was really inspired by &lt;a href=&quot;http://worrydream.com/dbx/&quot;&gt;Bret Victor&#039;s talk&lt;/a&gt; at the DBX conference, in which Bret demonstrated a bunch of technologies from the 1970s which attempted to solve problems that we&#039;re still wrestling with today. It&#039;s a great talk, and it precipitates the question; why haven&#039;t we figured this stuff out yet? Why do today&#039;s &#039;solutions&#039; feel lame in comparison to these prototypes from several decades ago? If anything, it seems like we&#039;ve gone backwards. The great past ideas Bret mentions, like Sketchpad, NLS, and Smalltalk, should inspire us to aim higher as we create the future.&lt;/p&gt;

&lt;p&gt;Similarly, lots of great thinking and design can be found in old systems. The original Macintosh, with influence from the &lt;a href=&quot;http://en.wikipedia.org/wiki/Xerox_Alto&quot;&gt;Xerox Alto&lt;/a&gt;, solved lots of user interface issues which people are still failing to think about today. A trivial example is that Mac OS, in 1984, had considered ‘&lt;a href=&quot;http://thomaspark.me/2011/10/making-menus-escapable/&quot;&gt;angle of escape&lt;/a&gt;’ in its drop down menus. That is to say, menus don’t close when the mouse cuts a corner on the way to a submenu. It seems minor, but it’s something which Windows didn’t fix until 2001 (Windows XP), and plenty of web apps still do wrong to this day. The awesome usability and simplicity of the original Mac is something which should be available as a working, interactive demo to the newest generation of designers, makers and creators.&lt;/p&gt;

&lt;p&gt;I also feel that the historical significance of these systems means they should be available to explore with a minimal barrier to entry. Making that happen, though, requires including the system ROM, OS and other software such as applications and games, along with the demo, which goes beyond what’s covered by ‘fair use’ in copyright terms. However I’d go as far as to say that making this stuff accessible has, to a degree, a moral imperative, and that it outweighs the negative of the technical infringement on copyright. Such software is, after all, ‘abandonware&#039;; it hasn’t been sold commercially for a long time, and it’s also just really outdated, not likely to be used to any financial gain.&lt;/p&gt;

&lt;p&gt;Being able to explore and interact with these once-pioneering systems, the Macintosh and the IBM PC, has great historical and educational potential, and that’s why I wanted to make them available in the most accessible way possible; in the browser, without any extra searching, downloading, installing. Batteries included, no assembly required.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Tags:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/pce&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;pce&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/macplus&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;macplus&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/mac&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;mac&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/javascript&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;javascript&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/copyright&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;copyright&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/computer-history&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;computer history&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/emulation&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;emulation&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 18 Oct 2013 06:42:40 +0000</pubDate>
 <dc:creator>James</dc:creator>
 <guid isPermaLink="false">9 at https://jamesfriend.com.au</guid>
</item>
<item>
 <title>PCE.js - Classic Mac OS in the browser</title>
 <link>https://jamesfriend.com.au/pcejs-classic-mac-os-browser</link>
 <description>&lt;div class=&quot;field field-name-field-image field-type-image field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;og:image rdfs:seeAlso&quot; resource=&quot;https://jamesfriend.com.au/sites/default/files/styles/full_width/public/field/image/pcejs.png&quot;&gt;&lt;img typeof=&quot;foaf:Image&quot; src=&quot;https://jamesfriend.com.au/sites/default/files/styles/full_width/public/field/image/pcejs.png&quot; width=&quot;820&quot; height=&quot;656&quot; alt=&quot;PCE.js MacPaint screenshot&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;p&gt;I&#039;ve just completed porting Hampa Hug&#039;s excellent &lt;a href=&quot;http://www.hampa.ch/pce/&quot;&gt;PCE&lt;/a&gt; emulator to run in the browser, using Emscripten. I&#039;ve mainly focused on the pce-macplus build. This is pretty awesome because it means you can run classic Mac OS in the browser. Check it out: &lt;a href=&quot;/pce-js/&quot;&gt;PCE.js - Classic Mac OS in the browser&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I&#039;ve also got the pce-ibmpc build working (emulating an IBM compatible, up to a 286 CPU), and and pce-atarist, an Atari ST emulator also, with browser demos coming soon for each.&lt;/p&gt;

&lt;p&gt;A dump of the source is available &lt;a href=&quot;/pce-js/pcejs20131028.zip&quot;&gt;here&lt;/a&gt; but I&#039;ll try to clean it up and make it available on GitHub when I get the chance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update: source on &lt;a href=&quot;https://github.com/jsdf/pce&quot;&gt;GitHub&lt;/a&gt;, and I&#039;ve added an &lt;a href=&quot;/pce-js/ibmpc-games/&quot;&gt;IBM PC Demo&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Tags:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/pce&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;pce&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/macplus&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;macplus&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/mac&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;mac&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/javascript&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;javascript&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 20 Sep 2013 04:56:44 +0000</pubDate>
 <dc:creator>James</dc:creator>
 <guid isPermaLink="false">8 at https://jamesfriend.com.au</guid>
</item>
<item>
 <title>Installing Pygame on Mac OS 10.8 Mountain Lion</title>
 <link>https://jamesfriend.com.au/installing-pygame-python-mac-os-108-mountain-lion</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;p&gt;I decided to install and play around with Pygame today, mainly as an excuse to write some Python for a minor departure from all the Javascript/Coffeescript I&#039;ve been writing lately. Unfortunately the process wasn&#039;t entirely frictionless, due to Pygame not yet accounting for Apple&#039;s move to XQuartz as the recommended X11 implementation for Mac OS as of 10.8 Mountain Lion. As a result I ran into some compilation errors while Pygame was building it&#039;s native extensions, which fortunately were not too hard to fix as I had some familiarity with changes to X11 on Mountain Lion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; &lt;a href=&quot;https://jamesfriend.com.au/installing-pygame-python-mac-os-108-mountain-lion#node_6_tldr&quot;&gt;you need to set some environment variables before installing Pygame&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;What didn&#039;t work&lt;/h3&gt;

&lt;p&gt;Running &lt;code&gt;pip install pygame&lt;/code&gt; would fail as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-nohighlight&quot;&gt;building &#039;pygame.display&#039; extension
cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -Ddarwin -I/Library/Frameworks/SDL.framework/Versions/Current/Headers -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/display.c -o build/temp.macosx-10.8-x86_64-2.7/src/display.o
In file included from src/display.c:30:
/Library/Frameworks/SDL.framework/Versions/Current/Headers/SDL_syswm.h:58:10: fatal error: &#039;X11/Xlib.h&#039; file not found
#include &amp;lt;X11/Xlib.h&amp;gt;
             ^
1 error generated.
error: command &#039;cc&#039; failed with exit status 1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;While building the native extention &#039;pygame.display&#039;, Xlib.h (a particular X11 header, required by SDL) is not found, as XQuartz&#039;s &lt;code&gt;/opt/X11/include&lt;/code&gt; directory has not been specified to search for headers.&lt;/p&gt;

&lt;p&gt;By setting some environment variables, we can configure the Pygame build process to build correctly. I found these in a few other blog posts, but they specified only &lt;code&gt;-arch i386&lt;/code&gt; for CFLAGS, LDFLAGS and ARCHFLAGS, which allowed the build process to complete, but &lt;code&gt;import pygame&lt;/code&gt; fails (when running 64bit Python):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; import pygame
Traceback (most recent call last):
  File &quot;&amp;lt;stdin&amp;gt;&quot;, line 1, in &amp;lt;module&amp;gt;
  File &quot;/usr/local/lib/python2.7/site-packages/pygame/__init__.py&quot;, line 95, in &amp;lt;module&amp;gt;
    from pygame.base import *
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/pygame/base.so, 2): no suitable image found.  Did find:
/usr/local/lib/python2.7/site-packages/pygame/base.so: mach-o, but wrong architecture
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;&lt;a id=&quot;node_6_tldr&quot;&gt;&lt;/a&gt;What actually got Pygame working&lt;/h3&gt;

&lt;p&gt;The environment variables (gcc flags) required to allow Pygame to correctly build fat binaries (for both 32bit and 64bit Python) are:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;export CC=&#039;/usr/bin/gcc&#039;
export CFLAGS=&#039;-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -I/opt/X11/include -arch i386 -arch x86_64&#039;
export LDFLAGS=&#039;-arch i386 -arch x86_64&#039;
export ARCHFLAGS=&#039;-arch i386 -arch x86_64&#039;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then &lt;code&gt;pip install pygame&lt;/code&gt; and &lt;code&gt;python -c &#039;import pygame&#039;&lt;/code&gt;. If no error is returned by Python, then you should now have a working installation of Pygame.&lt;/p&gt;

&lt;h3&gt;Additional details&lt;/h3&gt;

&lt;p&gt;I&#039;m using homebrew-installed Python/pip, and I&#039;ve set my $PATH with &lt;code&gt;/usr/local/bin&lt;/code&gt; before the system-installed Python.&lt;/p&gt;

&lt;p&gt;If you haven&#039;t installed Python/pip via homebrew (you&#039;re using the system-installed Python), you would likely need to run &lt;code&gt;sudo pip install pygame&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you&#039;re using another install method, such as easy_install, this fix should still work.&lt;/p&gt;

&lt;p&gt;Before running &lt;code&gt;pip install pygame&lt;/code&gt;, I had also installed &lt;a href=&quot;https://developer.apple.com/downloads/index.action&quot;&gt;Command Line Tools for XCode&lt;/a&gt; (&lt;a href=&quot;http://docwiki.embarcadero.com/RADStudio/XE4/en/Installing_the_Xcode_Command_Line_Tools_on_a_Mac&quot;&gt;walkthrough&lt;/a&gt;), as well as &lt;a href=&quot;http://xquartz.macosforge.org/landing/&quot;&gt;XQuartz&lt;/a&gt;, and the following homebrew packages:
&lt;code&gt;brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If homebrew fails to install &lt;code&gt;smpeg&lt;/code&gt; you might need to do the following:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;brew tap homebrew/headonly
brew install --HEAD smpeg
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Tags:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/python&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;python&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/homebrew&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;homebrew&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/pygame&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;pygame&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/osx&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;osx&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/mac&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;mac&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Wed, 07 Aug 2013 08:34:15 +0000</pubDate>
 <dc:creator>James</dc:creator>
 <guid isPermaLink="false">6 at https://jamesfriend.com.au</guid>
</item>
<item>
 <title>Setting up a new Mac for Node.js and Drupal development</title>
 <link>https://jamesfriend.com.au/content/setting-new-mac-nodejs-and-drupal-development</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; property=&quot;content:encoded&quot;&gt;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; I am now of the opinion that you&#039;re probably better off installing homebrew with a prefix of somewhere inside your user directory, eg. &lt;code&gt;~/.homebrew/&lt;/code&gt;. I mention this below as an alternative, but now this would be my primary recommendation. Some parts, however, such as configuring the Apple-included Apache installation, and the custom DNS resolvers, are system-wide changes, so you might not want to couple them to a particular user account. Perhaps consider &lt;code&gt;brew install&lt;/code&gt;ing a user-local copy of Apache, but use a system level installation of dnsmasq.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Original article text follows:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So you&#039;ve got a fresh, clean Mountain Lion install and you need to get up and running for local development. Recently I spent a day doing just that, so I thought I&#039;d write it all down, to save me from having to look all this stuff up again.&lt;/p&gt;

&lt;h4&gt;Install Xcode Command Line Tools&lt;/h4&gt;

&lt;p&gt;Available from the &lt;a href=&quot;https://developer.apple.com/downloads/index.action&quot;&gt;Apple Developer downloads area&lt;/a&gt;. You&#039;ll need an Apple ID.&lt;/p&gt;

&lt;p&gt;This package includes llvm-gcc, which is a (mostly) compatible replacement for gcc. It will work for most homebrew formulas which build with gcc.&lt;/p&gt;

&lt;h4&gt;Install homebrew&lt;/h4&gt;

&lt;p&gt;&lt;a href=&quot;http://mxcl.github.io/homebrew/&quot;&gt;homebrew&lt;/a&gt; can be conveniently installed with one line in the Terminal. As with all curl-to-sh style install scripts, you should read the script first to make sure it&#039;s not going to do anything bad. Don&#039;t say I didn&#039;t warn you :)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ruby -e &quot;$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The most convenient approach to using homebrew is to make &lt;code&gt;/usr/local&lt;/code&gt; writable to admin group, if you don’t mind a (sort of) security risk. Bear in mind, &lt;code&gt;/Applications&lt;/code&gt; is writable by that group by default anyway, so unless you&#039;ve locked that down also, this won&#039;t really make your system much more insecure than it already is.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo chmod -R g+w /usr/local
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Unfortunately without doing this, homebrew doesn&#039;t work particularly well in its default install location. Alternatively install somewhere user-local like &lt;code&gt;~/homebrew&lt;/code&gt; if you&#039;re really concerned about security and locking down user permissions on your local machine.&lt;/p&gt;

&lt;h4&gt;Install Node.js&lt;/h4&gt;

&lt;p&gt;Node in particular is easier to install from the nodejs.org installer package, not homebrew. Due to some past disagreement between the maintainers of npm and homebrew, the homebrew formula for node doesn’t properly install npm. The official installer, however, works pretty well.&lt;/p&gt;

&lt;p&gt;To get &lt;code&gt;npm install -g&lt;/code&gt; working (without sudo) you may also want to change the global node_modules directory to have a group id of &#039;admin&#039;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo chgrp -R admin /usr/local/lib/node_modules
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You may also need to give g+w permissions to that directory tree, if you installed node after running the chmod command above. This comes with the same caveats as homebrew. If you&#039;re really security conscious, install node and npm somewhere in your user directory, rather than globally in &lt;code&gt;/usr&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;Install Redis &amp;amp; MongoDB (optional)&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;brew install redis
redis-server
brew install mongodb
mongod
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Install MySQL&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;brew install mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then follow the instructions depending on whether you want MySQL to run as your user account or a different one, where data should be stored and whether you want to start the daemon manually or run at login.&lt;/p&gt;

&lt;p&gt;Eg. to set up databases to run as your user account, with data in &lt;code&gt;/usr/local/var/mysql&lt;/code&gt; and running at login:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir=&quot;$(brew --prefix mysql)&quot; --datadir=/usr/local/var/mysql --tmpdir=/tmp
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To have launchd start mysql at login:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then to load mysql now:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Set up the root mysql account. Pick a better password than I have.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/usr/local/opt/mysql/bin/mysqladmin -u root password 123456
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Install PHP 5.4 (optional)&lt;/h4&gt;

&lt;p&gt;PHP is not in the main homebrew packages, so you&#039;ll need to &#039;tap&#039; some extra repos before you can install it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Update LoadModule directive in Apache config file to point to new PHP version&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# /etc/apache2/httpd.conf
# Apple default:
# LoadModule php5_module libexec/apache2/libphp5.so
# This should be equivalent to $(brew --prefix php54)/libexec/apache2/libphp5.so
LoadModule php5_module /usr/local/opt/php54/libexec/apache2/libphp5.so
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Add updated PHP version to the PATH in &lt;code&gt;.bash_profile&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# ~/.bash_profile
export PATH=&quot;$(brew --prefix php54)/bin:$PATH&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;MySQL socket location &amp;amp; PHP PDO extension&lt;/h4&gt;

&lt;p&gt;When first running a PHP application which connects to MySQL, you may run in to errors relating to the socket through which PHP&#039;s PDO extension is attempting to connect to MySQL. This is because PDO is looking for the MySQL socket at &lt;code&gt;/var/mysql/mysql.sock&lt;/code&gt;, but it&#039;s probably at &lt;code&gt;/tmp/mysql.sock&lt;/code&gt; instead.&lt;/p&gt;

&lt;p&gt;Some options you have include setting up a php.ini file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo cp /etc/php.ini.default /etc/php.ini
sudo vi /etc/php.ini
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and setting &lt;code&gt;pdo_mysql.default_socket=/tmp/mysql.sock&lt;/code&gt; therein. If you go for the php.ini approach it might also be worth setting &lt;code&gt;display_errors = On&lt;/code&gt; while you&#039;re there.&lt;/p&gt;

&lt;p&gt;Or you could use a symbolic link to make PHP happy:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I&#039;m not really sure which solution is best, but both seem to do the job.&lt;/p&gt;

&lt;h4&gt;Set up .dev TLD for local development using dnsmasq&lt;/h4&gt;

&lt;p&gt;No one likes having to go and edit your hosts file, or something similarly tedious, every single time they create a new local project. By setting up a special TLD and dynamic vhosts, we can avoid ever having to waste time with this stuff again.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;brew install dnsmasq
mkdir -pv $(brew --prefix)/etc/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Configure dnsmasq&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;echo &#039;address=/.dev/127.0.0.1&#039; &amp;gt; $(brew --prefix)/etc/dnsmasq.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Create LaunchDaemon so dnsmasq runs at startup&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Set up a custom resolver to delegate resolution for .dev domains to dnsmasq&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo mkdir -v /etc/resolver
sudo bash -c &#039;echo &quot;nameserver 127.0.0.1&quot; &amp;gt; /etc/resolver/dev&#039;
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Set up dynamically configured mass virtual hosting in Apache&lt;/h4&gt;

&lt;p&gt;Ideally, all you should need to do to spool up a new site for development is create a directory under &lt;code&gt;/srv/www&lt;/code&gt;.
This Apache config should let you do just that.
Create /etc/apache2/other/mass-vhost.conf:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;Directory /srv/www&amp;gt;
  Order Deny,Allow
  Allow from all
  AllowOverride All
&amp;lt;/Directory&amp;gt;

NameVirtualHost *:80
&amp;lt;VirtualHost *:80&amp;gt;
  # get the server name from the Host: header
  UseCanonicalName Off
  # include the server name in the filenames used to satisfy requests
  VirtualDocumentRoot /srv/www/%1
&amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Create your sites directory&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;sudo mkdir -p /srv/www
sudo chown -R _www:_www /srv/www
sudo chmod -R g+w /srv/www
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Add your user account to the _www group so you can write to &lt;code&gt;/srv/www&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo dseditgroup -o edit -a `whoami` -t user _www
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Start Apache (and configure it to start automatically at startup)&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;sudo apachectl start
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Install Drush&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;brew install drush
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Set up a test Drupal site&lt;/h4&gt;

&lt;p&gt;Create a database in MySQL&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd /srv/www
drush dl drupal
mv drupal-* dtest
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Create a Drupal settings.php file and fill it out with your database credentials.&lt;/p&gt;

&lt;p&gt;In the site .htaccess file uncomment the directive:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# RewriteBase /
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Navigate to &lt;a href=&quot;http://dtest.dev/install.php&quot;&gt;http://dtest.dev/install.php&lt;/a&gt;
Once installed, you should also be able to enable Clean URLs.&lt;/p&gt;

&lt;p&gt;And you&#039;re done!&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-tags field-type-taxonomy-term-reference field-label-above&quot;&gt;&lt;div class=&quot;field-label&quot;&gt;Tags:&amp;nbsp;&lt;/div&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/mac&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;mac&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/osx&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;osx&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/nodejs&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;nodejs&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/drupal&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;drupal&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/dnsmasq&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;dnsmasq&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item odd&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/php&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;php&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;field-item even&quot; rel=&quot;dc:subject&quot;&gt;&lt;a href=&quot;/tags/apache&quot; typeof=&quot;skos:Concept&quot; property=&quot;rdfs:label skos:prefLabel&quot; datatype=&quot;&quot;&gt;apache&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 26 Mar 2013 14:00:01 +0000</pubDate>
 <dc:creator>James</dc:creator>
 <guid isPermaLink="false">3 at https://jamesfriend.com.au</guid>
</item>
</channel>
</rss>
