Archive for the 'Apple' Category

Setting up aliases in Snow Leopard

Thursday, 25th February, 2010

Having trouble with Terminal not remembering your aliases? A lot of documentation on the web talks about configuring tcsh or csh in Mac OS X. I was scratching my head for a while wondering why my ~/.tcshrc file wasn’t defining my aliases on login (or my ~/.login file for that matter, that the system created!).

I started to wonder, how do I tell what shell I’m running under? You can find this out by checking in System Preferences » Accounts » Advanced Options (instructions).

Turns out I was running bash – I’ve not changed shell since installing Snow Leopard, so this must be the default. I can’t say I ever set up aliases in Leopard so I’m not sure if this was the default in previous OS X versions.

Create ~/.profile (I chmod 600 mine, read & write for my user only) and add aliases in the following format.

alias sshq="ssh -o 'StrictHostKeyChecking=no' -q"

Quit Terminal and when you open it again your aliases will be set up.

Intel X25-M First Impressions

Friday, 19th February, 2010

Two weeks ago I swapped out my Seagate Momentus 7200.2 160GB HDD for an Intel X25-M 80GB. I didn’t want to post my impressions prematurely so held out a couple of weeks.

I took the opportunity to upgrade to Snow Leopard at the same time – as I was performing a clean install of OS X anyway. First thing I did was move my user directory on to my second hard drive (a Seagate 7200.4 320GB), to redirect writes away from my SSD.

Intel X25-M SSD

So what to make of Intel’s SSD; well boot times have come down to a tidy 20 seconds, Skype starts a whole lot faster. Simultaneous reads are noticeably quicker (think concurrent application launches – particularly common at boot time). My Seagate drive was hovering around the 90 second mark with files (images) on the desktop (Mac OS X creates thumbnail previews). Overall though, and I don’t think I’m a particularly IO heavy user, so it’s a fairly subtle difference once booted.

I’ve 4GBs RAM in my Macbook Pro so I doubt I hit the swap file often. The biggest IO waits I experience are loading eclipse, loading Open Office, loading photoshop and performing multi-file searches in eclipse (~45,000 file project). The latter runs off my magnetic drive, so this contributes to a dulled performance increase.

I got this drive as birthday present, and although I’ve been drooling over SSDs since October, I’d have to say they’re still too expensive. If I had to buy this myself, I’d have held out for another price drop. Intel’s roadmap doesn’t show additions to their consumer SSD line until Q4 2010.

Ultimately, once manufacturers overcome the performance penalty of long term SSD write usage then I’d consider solid state disks all round, instead of a hybrid set up. For now, hold on to your wallet.

A real UK keyboard layout for Mac OS X 10.6 “Snow Leopard”

Wednesday, 17th February, 2010

Thanks to this blogger who made real UK keyboard layouts that work under Snow Leopard. I couldn’t get alternative community created UK layouts, that previously worked in Leopard, to work under Snow Leopard. They would never appear as a selectable layout in ‘Language & Text’ » ‘Input Sources’. Maybe because I tried to installed them under /Library/Keyboard Layouts instead of my user specific directory (~/Library/Keyboard Layouts). The author of the post admits he encountered the same problem.

I’m just relieved to have # ~ ” \ back in their rightful places. As a developer ALT+3 for # is like pulling teeth (thank god I don’t do much Perl programming!).

What’s that? Switch back to Windows? Never! :)

Changing User home directory under Mac OS X Leopard and beyond

Sunday, 31st January, 2010

Yesterday I finally got around to removing my flakey superdrive from my Macbook Pro and replaced it with an optical bay hard disk (OBHC) caddy (Google NewModeUS). This meant I was able to add another 320GB drive where my superdrive once lived (much needed as I was at 92% disk usage on my system drive). I also have an Intel X25-M 80GB to install but I’ll save that for a weekend when I have more time.

In preparation to moving to SSD, I’m looking to divert as many writes as possible, to prolong the performance of the drive (no TRIM support in OS X at present – no, not in Snow Leopard either). One of the best ways to do this is to migrate my user directory to my second (magnetic) hard drive. You might argue I’m losing the performance I paid for getting an SSD but boot times and applications launches should still benefit as the OS and apps reside on my X25-M.

<notice>Before proceeding with these instructions it’s vital you have a backup of your user directory and any other data on your Mac that you want to keep.</notice>

One of the top search results in Google for how to move / change your user directory in Mac OS X recommends using a symlink. There is however a cleaner method documented back in 2002 by Dan Frakes.

First, make sure that on the new volume, the “Ignore ownership on this volume” setting—in the volume’s Get Info window—is not checked

Open Terminal and enter:

$ sudo ditto -rsrc "/Users/greg" "/Volumes/newvolume/Users/greg"
$ sudo niutil -createprop / "/users/greg" home "/Volumes/newvolume/Users/greg"

The problem being that niutil no longer exists in OS X 10.5 (Leopard) and later.

$ niutil
-bash: niutil: command not found

In Leopard and later the NetInfo Manager has been replaced the Directory Services client (dscl). Since Mac OS X 10.4 ditto also has the -rsrc arguments enabled by default.

The commands you’re looking for under Leopard (and Snow Leopard) are (substitute your own username instead of ‘greg’, and here I’m moving my user directory to my second hdd/volume ‘Data’):

$ sudo ditto "/Users/greg" "/Volumes/Data/Users/greg"
Password: (enter password)
$ dscl
Entering interactive mode... (type "help" for commands)
 > cd /Local/Default/Users/
 > ls
 > change greg dsAttrTypeNative:home /Users/greg /Volumes/Data/Users/greg
 > exit

Logout and login again, verify your home directory has moved by opening Terminal and checking the public working directory:

$ pwd
/Volumes/Data/Users/greg

Now rename your old user directory to be sure, before removing it (or leaving it if you can afford the space):

$ cd /Volumes/OSX/Users/
$ mv greg greg.old

I rebooted after this to check my machine started up without any issues. Then removed my old user directory (sudo rm -rf greg.old).

Congratulations you’ve moved your user directory.

Update: When starting Eclipse, it could not locate my workspace but I only had to browse to my new user directory (/Volumes/Data/Users/greg). VirtualBox automatically updated the path to my images created with their wizard (presumably because they use a system variable for the path). The VDIs I had manually selected required my assistance to update their location in the Virtual Media Manager.

Safari 4 bug?

Friday, 11th September, 2009

This might not strictly be a bug – more a choice by Apple / Web kit over compliance, anyway…

I noticed this issue in Safari, my primary browser, (Firefox doesn’t exhibit the same problem) while downloading a file from a system I wrote. The system uses content disposition. When you click to download the file, Safari retreives the file and saves it to disk with the correct name. If you right click and ‘Download Linked File As …’, it seems to ignore the suggested filename and uses the end part of the URL, excluding the query string (everything after and including ‘?…’).

This is not the first time Safari has stumbled. An internal indexing system at work uses prototype to submit forms (so we can chain event handlers on submit). The forms themselves (maybe incorrectly?) do not specify action or onSubmit attributes. Safari can’t submit these forms, Firefox doesn’t have a problem and works. </grumble>

You are currently browsing greg's weblog – the more I learn, the less I know archives in the Apple category.

Categories

xhtml 1.1 compliant   xhtml 1.1 compliant