Gert Lombard's Blog     About     Archive     Feed
My passion is code quality, automated testing, software craftsmanship.

Recusively change the owner of files (chown) on Mac OS X

I've just changed my OS X / Mac main user - I've created a new 'coder' user account that I want to use for development instead of my old 'lombard' account. I realized that a lot of my applications I've previously installed via Homebrew now had to be changed to be owned by the new coder user. First I ran 'brew doctor' find see what obvious issues I have:
Gerts-Mac-mini:src coder$ brew doctor
Warning: /usr/local/etc isn't writable.
This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a brew tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/etc
xcode-select: note: no developer tools were found at '/Applications/', requesting install. Choose an option in the dialog to download the command line developer tools.
xcode-select: note: no developer tools were found at '/Applications/', requesting install. Choose an option in the dialog to download the command line developer tools.

Warning: You have an outdated version of /usr/bin/install_name_tool installed.
This will cause binary package installations to fail.
This can happen if you install osx-gcc-installer or RailsInstaller.
To restore it, you must reinstall OS X or restore the binary from
the OS packages.

Warning: Git could not be found in your PATH.
Homebrew uses Git for several internal functions, and some formulae use Git
checkouts instead of stable tarballs. You may want to install Git:
brew install git

Warning: No developer tools installed.
Install the Command Line Tools:
xcode-select --install
xcode-select: note: no developer tools were found at '/Applications/', requesting install. Choose an option in the dialog to download the command line developer tools.
Indeed, several files/directories below '/usr/local' were created by Homebrew as user 'lombard':
Gerts-Mac-mini:src coder$ ls -l /usr/local
total 80
-rw-r--r-- 1 lombard admin 3158 5 Jun 09:16
-rw-r--r-- 1 lombard admin 687 5 Jun 09:16
drwxr-xr-x 4 lombard admin 136 17 Jun 17:11 Cellar
-rw-r--r-- 1 lombard admin 1253 5 Jun 09:16 LICENSE.txt
drwxr-xr-x 9 lombard admin 306 17 Jun 17:11 Library
-rw-r--r-- 1 lombard admin 1858 5 Jun 09:16
-rw-r--r-- 1 lombard admin 23719 5 Jun 09:16
drwxrwxr-x 12 root admin 408 17 Jun 17:11 bin
drwxr-xr-x 3 lombard admin 102 17 Jun 17:11 etc
drwxrwxr-x 5 root admin 170 17 Jun 17:11 lib
drwxr-xr-x 3 root wheel 102 17 Jun 17:11 libexec
drwxrwxr-x 4 root admin 136 17 Jun 17:11 share
I can't just use 'chown -R' because I only want to change the owner of some specific files. To recursively fix/change the owner only of files specifically owned by another user, use the versatile 'find' command:
$ find . -user lombard -exec sudo ch
own coder {} \;
Now I just took care of the other things that brew doctor complained about:
$ xcode-select --install
$ brew update
That's it! Now I'm ready to install more tools using Homebrew using the new user account.

Another Note To Self: Setting up the Mac Mini

Sublime Text 3:

I'm using Sublime Text as my default editor on Mac and Windows (replaced Notepad++ about a year ago as my favourite editor on Windows). One of the things I like about Sublime is that the plugins are written in Python. I haven't tried creating my own plugin but I am trying to use Python more so this is one more thing to keep in mind.


This time I'm not going to install the Xcode Command-Line Tools just to get git.

Two easy alternatives seem to be:
1. Install GitHub for Mac and install the Git command-line from the Preferences menu
2. Use Homebrew to install git.

I've opted for option 1. This installs the git binary to /usr/local/bin/git. You need to add the /usr/local/bin directory to your path.

Next I installed SourceTree.


I want a dark theme for the OSX Terminal and found:

curl -O

In Terminal, import the settings with Command+O and select the Solarized file. This gives me a basic dark theme. Not completely happy with it yet but it's a start.

Note to self: Upgrading to OS X Mavericks

After upgrading to OS X 10.9 (Mavericks) I had to do the following to get Android Studio working again:

  • Update Xcode to the latest version
  • Activate the Xcode Command Line Tools license for example by running on the shell `sudo gcc` and accept the license. Now git should work.
  • Install Java 6 when prompted automatically after trying to launch Android Studio.
  • Need to update VirtualBox for Genymotion to work. Use `Oracle VM VirtualBox Manager` to download the latest VirtualBox.

I need a quiet office

I really struggle to concentrate / focus (i.e. to "get into the zone") when trying to develop or read something technical while people are talking around me in the office. Perhaps the open plan layout works for some people, but I find it very distracting. (And I'm very guilty myself of causing distraction for others as well!)

I think ideally some of the office space should be divided into a few smaller work areas to be used by small teams that prefer to have privacy.  For example, I'm currently working with a small team (3-5 developers) and we occasionally need to communicate with a remote office via Skype and a webcam. Ideally we shouldn't have to go to a meeting room every time we want to have a chat with the remote team members.

At a very least, I wish we had several small 1-person private guest offices for us to use when we need privacy. That way I can keep my desk in the open office, but get away for 3-4 hours a day for productive work.

The only way I can fight the distraction, is to listen to music while I work. But this only works for certain type of tasks (like unit testing). When I really need to focus (like learning/reading or designing/writing code), I want no distractions. A single sentence on the other side of the office can bring me out of the "zone".

If you Google search for "open plan office productivity" you'll immediately see lots of evidence that Open Plan doesn't work for everyone. (It seems like younger people like open offices more, presumably because it feels more social).

A systematic survey of research upon the effects of open plan offices found frequent negative effects in some traditional workplaces: high levels of noise, stress, conflict, high blood pressure and a high staff turnover.[7] The noise level greatly reduces the productivity, which drops to one third relative to what it would be in quiet rooms ... A balance between the office types may be found by employees having an open setting with part-time access to a quiet workspace.
Or from
a growing body of evidence suggests that the open office undermines the very things that it was designed to achieve. ...  In laboratory settings, noise has been repeatedly tied to reduced cognitive performance.
More links:

How to flash Samsung Galaxy Nexus with the latest factory image

I was running CyanogenMod on a Google/Samsung Nexus Galaxy and decided to go back to the stock Google image from the Factory Images for Nexus Devices page. The latest factory image for the Galaxy Nexus is 4.3 (JWR66Y).

Make sure to download the correct image for your Nexus phone. In my case it's "yakju" for the Galaxy Nexus "maguro" (yakju-jwr66y-factory-09207065.tgz).

I downloaded the yakju archive and extracted the .tgz with 7za:

cd \temp
curl -k -O
7za x yakju-jwr66y-factory-09207065.tgz
7za x yakju-jwr66y-factory-09207065.tar
cd yakju-jwr66y

I wanted to see if I had the Samsung driver installed on my Windows 8.1 laptop:  Go to Device Manager:

So, no clearly I didn't have the driver for the phone yet: Device Manager shows the Nexus phone as "Unknown USB Device (Device Descriptor Request Failed)".

At this point, I decided to put the phone into fastboot anyway and see if I could flash the factory image without the Samsung driver (hint: no, it didn't work):

To use adb.exe and fastboot.exe, I just used the Android SDK in my Android Studio installation. I added the sdk/platform-tools folder to my PATH and put the device into fastboot mode:

set PATH=%PATH%;D:\Android\android-studio\sdk\platform-tools
adb reboot bootloader

Now the phone is in fastboot mode (while in "fastboot mode" you can "flash" the Android firmware, i.e. modify the system image / operating system):

However, as I feared, fastboot.exe couldn't see the phone, because the Samsung driver wasn't installed, i.e. when I ran  "fastboot devices" no devices were listed. While in fastboot mode, Device Manager now shows the phone as "Other Devices" -> "Android 1.0":

I downloaded Samsung_USB_Driver_for_Mobile_Phones_v1.5.14.0.exe from Samsung's website. 

During the process of installing the Samsung USB driver I had to reboot my Windows 8.1 a few times (and I also had to take the battery out of the phone once to get it out of fastboot mode because the phone seemed to hang).

I right-clicked on the "Android 1.0" device and clicked "Update Driver Software...". Then I selected "Let me pick from a list of device drivers on my computer" and then selected the "SAMSUNG Android Phone" from the list:

And on the next screen I selected "SAMSUNG Electronics Co., Ltd." ->  "SAMSUNG Android ADB Interface":

Windows confirms that the Samsung driver is installed OK:

After updating the "Android 1.0" device's driver to "Samsung Android ADB Interface", Fastboot now shows the device:

C:\temp\yakju-jwr66y> fastboot devices
0356B9BB0201A005        fastboot

Now run flash-all.bat from the downloaded factory image folder. That's it! That batch file runs fastboot.exe a few times to install the new factory image. Now Android 4.3 is installed successfully on the Nexus phone.