Reset /Users/X in MacOSX


if [ ! -n “$1” ]; then
echo $0: user
exit 1

sudo chown -R $1:staff /Users/${1}
sudo chmod -R 700 /Users/${1}
sudo chmod 755 /Users/${1}
sudo chmod -R 755 /Users/${1}/Public /Users/${1}/Sites
sudo chmod -R 733 /Users/${1}/Public/Drop Box
sudo chmod +a “everyone deny delete” /Users/${1} /Users/${1}/Sites /Users/${1}/Public /Users/${1}/Desktop
/Users/${1}/Documents /Users/${1}/Downloads /Users/${1}/Pictures /Users/${1}/Music /Users/${1}/Movies
sudo chmod -R +a “${1} allow readattr,readextattr,readsecurity,list,search,read,execute,file_inherit,directory_inherit,delete,writeextattr,writeattr,write,append,delete_child,add_file,add_subdirectory”
/Users/${1}/Public/Drop Box

Change uid in MacOSX


echo dscl . -change /Users/xxx UniqueID 501 new_uid
echo dscl . -change /Users/xxx PrimaryGroupID 20 new_gid
echo chown -R : /Users/xxx
echo ls -n

how to create sparsebundle image file in Mac OSX


if [ ! -n “$2” ]; then
echo $0: machine_name MACid
exit 1

hdiutil create -size 80G -type SPARSEBUNDLE
-imagekey sparse-band-size=65536
-fs HFS+J
-volname “Backup $1”

Above is to create a sparsebundle file required for Time Machine backup to remote afp


diff -up ./audio_carbon.c.lama ./audio_carbon.c
— ./audio_carbon.c.lama 2004-01-23 17:41:31.000000000 +0800
+++ ./audio_carbon.c 2008-10-01 20:22:00.000000000 +0800
@@ -94,7 +94,7 @@ void callback(SndChannelPtr channel, Snd

-int wait(struct buffer *buffer)
+int delay(struct buffer *buffer)
if (MPWaitOnSemaphore(buffer->semaphore, kDurationForever) != noErr) {
audio_error = _(“MPWaitOnSemaphore() failed”);
@@ -263,7 +263,7 @@ int play(struct audio_play *play)
/* wait for block to finish playing */

if (buffer->pcm_nsamples == 0) {
– if (wait(buffer) == -1)
+ if (delay(buffer) == -1)
return -1;

buffer->pcm_length = 0;


export CFLAGS=”

export CPPFLAGS=”

export LDFLAGS=”


enable subversion server come with Leopard

Mac Leopard actually come with subversion server and client that integrated with its own apache2.

Steps to enable it:

LoadModule dav_svn_module libexec/apache2/
LoadModule authz_svn_module libexec/apache2/

    • enable httpd-ssl.conf by removing the comment from the following line in /etc/apache2/httpd.conf:

    Include /private/etc/apache2/extra/httpd-ssl.conf

    • Add the following line at the end of file /etc/apache2/extra/httpd-ssl.conf but before the </VirtualHost>
    DAV svn
    SVNPath /opt/repos
    AuthType Basic
    AuthName “Authorization Realm”
    AuthUserFile /etc/svn-auth-file
    Require valid-user
    • create the /etc/svn-auth-file using the following command to create user id. It will prompt for password twice

    htpasswd -cm /etc/svn-auth-file

    • restart apache by

    /usr/sbin/apachectl restart

    • mkdir the subversion repository, generate the first repository and change ownership of the folder to match with apache user

    mkdir /opt/repos

    svnadmin create /opt/repos
    chown -R www:www /opt/repos
    • test the access to subversion server using the
    • try with svn co –username