Mac

From Shiftyjelly

Jump to: navigation, search

Contents

Apple Links

Apple Australia
Apple Store
Apple US
Downloads
Apple Discussions
Developer Connection
Concise Mac Intro
OSX Hints
Cool Mac Freeware

Snow Leopard Compatibility

Dev Programs That Work Fine

Netbeans, Eclipse, Xcode, Simply DB, Ardzip, Viscosity (32 bit kernel mode only)

Installing Java 1.5

http://daveyshafik.com/archives/721-fixing-zde-5-5-in-snow-leopard.html

Fixing MySQL

The MySQL that was installed for Leopard does not function under Snow Leopard. Here is how to update it:
grab the latest version of macports (if you already have macports, then just run selfupdate):

svn co http://svn.macports.org/repository/macports/trunk/base/ macports

build it

cd macports
./configure
make
sudo make install
sudo /opt/local/bin/port -v selfupdate

Install Mysql5:

sudo port install mysql5
sudo port install mysql5-server
--if this is a fresh install and you need to configure the DB
sudo -u mysql mysql_install_db5

Copy your old MySQL data:

sudo bash
cd /opt/local/var/db/mysql5
rm -rf *
cp -r /usr/local/mysql-5.0.67-osx10.5-x86/data/* .
chown -R _mysql *

Start Mysql5:

cd /opt/local ; sudo /opt/local/lib/mysql5/bin/mysqld_safe &

Set MySQL to launch at system startup:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

Fix MySQL Query Browser and Admin Tool, these both work fine, but need to be told where the new .sock file is (expand the advanced arrow):

/opt/local/var/run/mysql5/mysqld.sock

Fixing Stunnel

The latest openssl and stunnel from macports seems to be a bit broken on snow leopard. You can grab the older version by copying over these files:

openssl, stunnel in /opt/local/bin

libssl.* in /opt/local/lib/
libcrypto.* in /opt/local/lib/

once you've done that if you do an stunnel -version it should have reverted to a previous version

Bugs and Fixes

Get Spotlight to index Thunderbird mail

http://www.dennis.ca/weblog/2007/04/17/howto-make-spotlight-and-google-desktop-index-thunderbird-messages/

Get Spotlight to not index the virtual machines applications and files

System Preferences -> Spotlight -> Privacy -> "Add the virtual machine folders"

Show/Hide Hidden Items In Finder

To show and hide hidden items in Finder, run the following commands in Terminal: To show hidden items:

To hide them again:

Automatically get rid of the Print Queue when printing is finished

Symptom: You issue a print job and the print queue for the printer keeps hanging around on your dock
Solution: Right click the print queue and enable "Auto Quit"

Pointers for People Switching From Windows

Terminal Tips

alias ll="ls -la"

export MAVEN_HOME=/Applications/maven-1.0.2
export M2_HOME=/Applications/maven-2.0.4
export M2_REPO=~/.m2/repository
export ANT_HOME=/Applications/apache-ant-1.7.0
export PATH=/Applications/TextEdit.app/Contents/MacOS/:$MAVEN_HOME/bin:$M2_HOME/bin:$JAVA_HOME/bin:$ANT_HOME/bin:/usr/local/bin:/usr/local/mysql/bin:$P
ATH
export GWT_HOME=/Applications/gwt-mac-1.4
export GWT_EXTERNAL_BROWSER=firefox
export CATALINA_HOME=/Applications/apache-tomcat-5.5.23
export AXIS_CLASSPATH=/Applications/axis-1_4/lib/axis.jar:/Applications/axis-1_4/lib/commons-discovery-0.2.jar:/Applications/axis-1_4/lib/commons-loggi
ng-1.0.4.jar:/Applications/axis-1_4/lib/jaxrpc.jar:/Applications/axis-1_4/lib/saaj.jar:/Applications/axis-1_4/lib/log4j-1.2.8.jar
test -r /sw/bin/init.sh && . /sw/bin/init.sh
Just java files in current directory and subdirectories:
grep -r --include="*\.java" "Test" .
sudo ipfw add fwd localhost,3306 tcp from any to any 3305 via lo0
open .
mate .
open test.pdf
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'

How to slow your internet speed for testing

slowNet.sh

#!/bin/sh

/sbin/ipfw add 100 pipe 1 ip from any 3000 to any out
/sbin/ipfw add 200 pipe 2 ip from any 3000 to any in
/sbin/ipfw pipe 1 config bw 128Kbit/s queue 64Kbytes delay 250ms
/sbin/ipfw pipe 2 config bw 128Kbit/s queue 64Kbytes delay 250ms

normalNet.sh

#!/bin/sh

/sbin/ipfw delete 100
/sbin/ipfw delete 200

Keyboard Shortcuts

Applications

TextMate - Text editor/IDE (esp. useful, but not limited to, Ruby on Rails)

Apple Script - "AppleScript is an English-like language used to write script files that automate the actions of the computer and the applications that run on it."

Butler - Butler's purpose is to make it easier for you to perform different — potentially recurring — tasks.

Chax - iChat plugin for tabs and other features.

Namely - Mini application launcher. To start hit Option + Esc

Quicksilver - More in depth application launcher and command linker. To start hit Control + Space

Adium - Chat client that links to MSN, AIM, Google ...

Tips

hdiutil resize -size 10g

10g = 10 Gigabytes, but you can specify whatever size you want

alias l='ls -lG'
alias ll='ls -alG'

File Sharing

Screen Sharing

defaults write com.apple.ScreenSharing 'NSToolbar Configuration ControlToolbar' -dict-add 
'TB Item Identifiers' '(Scale,Control,Share,Curtain,Capture,FullScreen,GetClipboard,SendClipboard,Quality)'

Developing For The Mac

General

Java

-Dapple.laf.useScreenMenuBar=true
<key>CFBundleDocumentTypes</key>
<array>
	<dict>
		<key>CFBundleTypeExtensions</key>
		<array>
			<string>*</string>
		</array>
		<key>CFBundleTypeName</key>
		<string>Generic Document</string>
		<key>CFBundleTypeOSTypes</key>
		<array>
			<string>****</string>
		</array>
		<key>CFBundleTypeRole</key>
		<string>Viewer</string>
	</dict>
</array>
public static boolean isOSX(){
    return System.getProperty("os.name").toUpperCase().indexOf("OS X") >=0;
}
<key>JVMArchs</key>
<string>x86_64</string>
System.out.println("Locale="+Locale.getDefault());

You must ensure you select your Language correctly:

Automation

Ruby OSA

RubyOSA is a ruby library that lets you access AppleScript functionality on your mac. This comes in handy when you want to automate systems tasks or interact with applications in a friendly object orientated way, instead of in the weird pseudo code language that is AppleScript.
It's as simple as:

sudo gem install rubyosa

And then you can do things like:

require 'rbosa'
itunes = OSA.app('iTunes')

track = itunes.current_track
p track                     # <OSA::Itunes::FileTrack:0x1495e20>
p track.name                # "Over The Rainbow" 
p track.artist              # "Keith Jarrett" 
p track.duration            # 362.368988037109 
p track.date_added.to_s     # "2006-06-30" 
p track.enabled?            # true

# Play the selected track.
itunes.play                    

# Fade the volume.
100.times { |i| itunes.sound_volume = i; sleep 0.1 }  

# Set iChat's status message to the current track.
OSA.app('iChat').status_message = "Playing: #{track.name}"

To find out what functions a given application has available:

rdoc-osa --name "iTunes" --op DirectoryToStoreDocIn

or for system level things:

rdoc-osa --name "System Events" --op DirectoryToStoreDocIn
Personal tools
Namespaces
Variants
Actions
Reference
Navigation
Toolbox