learnmac

Sunday, April 22, 2007

Mac os start up sequence for MacTel

Press C during startup Start up from a bootable CD or DVD, such as the Mac OS X Install disc that came with the computer.
Press D during startup Start up in Apple Hardware Test (AHT), if the Install DVD 1 is in the computer.
Press Option-Command-P-R until you hear two beeps. Reset NVRAM
Press Option during startup Starts into Startup Manager, where you can select a Mac OS X volume to start from. Note: Press N to make the the first bootable Network volume appear as well.
Press Eject, F12, or hold the mouse button Ejects any removable media, such as an optical disc.
Press N during startup Attempt to start up from a compatible network server (NetBoot).
Press T during startup Start up in FireWire Target Disk mode.
Press Shift during startup Start up in Safe Boot mode and temporarily disable login items.
Press Command-V during startup Start up in Verbose mode.
Press Command-S during startup Start up in Single-User mode.
Press Option-N during startup Start from a NetBoot server using the default boot image.

Thursday, January 25, 2007

Creating a subshell with user nobody

This is a useful command as nobody is a really strange user

sudo /usr/libexec/StartupItemContext /usr/bin/sudo -u nobody -s

Monday, December 18, 2006

Bash shortcuts - cool things

These work on mac as well

Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
Ctrl + W Delete the word before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor
Ctrl + F Find previous executed commands
Tab Auto-complete files and folder names

Thursday, August 17, 2006

Simple way to Get the current locale on Mac OS

To get the currently selected locale:
defaults read NSGlobalDomain AppleLocale

To get the array of preferred languages 
defaults read NSGlobalDomain AppleLanguages

Friday, June 30, 2006

Working with Disk images 

Creating/attaching/unmounting/ejecting through command-line

use hdiutil / diskutil


Skip disk image checksum verification:

defaults write com.apple.frameworks.diskimages skip-verify true

Other preference keys as well as their defaults are in /System/Library/PrivateFrameworks/DiskImages.framework/Resources/defaults.plist 

Wednesday, March 22, 2006

Explaining prebinding in simple terms

Under Mac OS X, a mechanism called prebinding is used to accelerate the launching of applications. Applications on Mac OS X, like applications on every other modern operating system, are composed of more than just a single file that is executed by the computer. Applications are built on top of libraries full of functionality. Some of the libraries are provided by the operating system vendor -- Apple provides more than 150 libraries in the default installation of OS X. Everything from Cocoa to Carbon to the Web Services API to the libraries used by iPhoto to talk to your mac.com account are implemented in libraries.

Instead of including the contents of the library into an application directly (a process known as static linking), a developer will cause their application to dynamically link the needed libraries. This has two very distinct advantages.

First, if five applications are currently running that all use the Cocoa framework (a framework is simply a mechanism that contains a dynamic library and all resources associated with the library in a single directory), the shared memory mechanism kicks in and all five applications share the same chunk of memory to hold a copy of the Cocoa dynamic library. Not only does this save memory, but applications that use the Cocoa framework that are launched after at least one app that uses the Cocoa framework has been launched will not have to load the Cocoa framework and, as such, will launch faster.

Secondly, when Apple ships a system update that upgrades the frameworks shipped with the system, applications that dynamically link against that framework (or library) will automatically take advantage of the new features or bug fixes provided in the new version of the framework or dynamically linked library.

Back to prebinding...

A dynamic library is just a big collection of functionality that the application can use to implement whatever features it needs. When an application dynamically loads a library, it has to find all of the chunks of functionality before it can use them. Each bit of functionality-- each function, class, constant, global variable, or whatever-- is represented by a symbol.

As the application loads, it looks up each symbol that it needs from all the dynamic libraries that it uses and binds that symbol into itself. Once a symbol is bound, the application can then use that symbol-- that function, class, constant, global, etc.. -- as a part of its implementation.

The process of binding each symbol is quite time consuming. There may be thousands, if not tens of thousands, of symbols that have to be bound. Not only does the application have to bind all of the symbols from the libraries that it uses, but each library has to also bind all of the symbols that the library uses from other libraries.

Obviously, eliminating this manual binding process would improve applciation launch times.

Prebinding is a means by which application launch times are improved on OS X by eliminating the manual binding process. When an application or dynamic library is prebound, it means that the application or dynamic library contains a cache of all of the symbols it needs in an already bound state. When the application is launched, it automatically uses this information cache such that all symbols are bound without having to go through the arduous task of binding each symbol individually.

Every time a new version of a library is built, all of the locations of the symbols within that library change. When this happens, all prebinding information that was built against the previous version of the library is no longer valid. When an application is launched, OS X automatically detects this situation and falls back to the manual binding process.

Under 10.2, the system automatically updates prebinding information any time an application is launched that lacks complete prebinding information. This happens automatically and in the background.

Friday, December 09, 2005

Cocoa tip

How to create a Cocoa application that does not have a main menu but behaves like Cocoa App ?

Add LSUIElement in the Info.plist with a value of 1. That will make the application run without a menu bar.
Note : that if you have a close button on the window and you close it your app is still running and has no interface
to allow it to quit. Best is either have be it a window without close button or have it quit on close by implementing
-(BOOL) applicationShouldTerminateAfterLastWindowClosed: (NSApplication *)theApplication