All notes


Shortcut symbols

( ^ ) The caret symbol is the control key.
( ⇧ ) The single arrow up is the shift key.
( ⇪ ) The arrow up with the line under it is the caps lock key.
( ⌘ ) Most people don’t miss the command key since the symbol is on the keyboard.
( ⌥ ) The upper right to lower left slash with the line above it is the alt/option key.

Shortcut list


Lock screen:
  Control+Shift+Eject for Macs with an Eject key
  Control+Shift+Power for Macs without the eject key

Command+Shift+m: me/switch user

  Command+Control+F: Toggle fullscreen.
  Command+m: minimize window.
  Command+`: cycle through active windows in the current application. Much like Command+Tab. wcfNote: this feature is not working in maximised mode! In that case, use shortcuts to change workspaces instead.

  Fn+Left = Home
  Fn+Right = End
  Fn+Up = Pg Up
  Fn+Down = Pg Down

Finder shortcuts
  Command+A	Go to Applications.
  Command+D	Go to Desktop.
  Command+H	Go to Home of current user.
  Command+U	Go to Utilities.

Other good shortcuts

Screenshot ROI: Command+Shift+4
Screenshot Window: Command+Shift+4 then SPC
Screenshot Screen: Command+Shift+3
Screenshot Window to clipboard: Command+Shift+Control+4

Force quit

osxdaily: force quit mac apps.

Firefox shortcuts

I can't live without shortcuts! The useful shortcuts of Firefox in Mac OS IMO are:



wikipedia: Darwin.

Darwin is an open-source Unix operating system released by Apple Inc. in 2000. It is composed of code developed by Apple, as well as code derived from NeXTSTEP, BSD, Mach, and other free software projects.

Darwin forms the core set of components upon which macOS (previously OS X and Mac OS X), iOS, watchOS, and tvOS are based.


wikipedia: BSD.

FreeBSD is a free Unix-like operating system descended from AT&T UNIX via the Berkeley Software Distribution (BSD). Apple Inc.'s Mac OS X, with its Darwin base including a large amount of code derived from FreeBSD.

NetBSD is a freely redistributable, open source version of the Unix-derivative Berkeley Software Distribution (BSD) computer operating system. Due to its portability and quality of design and implementation, it is often used in embedded systems and as a starting point for the porting of other operating systems to new computer architectures.

OpenBSD is a Unix-like computer operating system descended from Berkeley Software Distribution (BSD), a Unix derivative developed at the University of California, Berkeley. It was forked from NetBSD in 1995. OpenBSD includes a number of security features absent or optional in other operating systems.


Type table corner brackets on OS X

Control + Command + Space.

Can't install an iOS app on a device?

UserVoice. Here are a few things to check:


Stackexchange. --alldrivers --esp
mkdir /Volumes/esp
sudo mount -t msdos /dev/disk0s1 /Volumes/esp

Create a bootable USB on Mac OS X

Ubuntu help.

  1. Convert IMG to ISO. hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/ubuntu.iso.
  2. Get the current list of devices: diskutil list.
  3. diskutil unmountDisk /dev/diskN. (replace N with the disk number from the last command; in the previous example, N would be 2).
  4. sudo dd if=/path/to/downloaded.img of=/dev/rdiskN bs=1m.
    • Using /dev/rdisk instead of /dev/disk may be faster.
    • If you see the error dd: Invalid number '1m', you are using GNU dd. Use the same command but replace bs=1m with bs=1M.
    • If you see the error dd: /dev/diskN: Resource busy, make sure the disk is not in use. Start the 'Disk' and unmount (don't eject) the drive.
    • Stackexchange. When dd finishes you may see an error like this:
      		dd: /dev/disk2: short write on character device
      		dd: /dev/disk2: Input/output error
      		3726+1 records in
      		3726+1 records out
      		500107862016 bytes transferred in 14584.393113 secs (34290619 bytes/sec)
      That last error message is actually okay. The last block written was a short block because there wasn't a full 128MB block to copy. No worries.
  5. diskutil eject /dev/diskN.
  6. Restart your Mac and press alt/option key while the Mac is restarting to choose the USB stick.

Startup manager

Apple support. Connect the device, restart, and immediately press and hold the Option key to access Startup Manager.

Copy music from iPoD


--- Disable Syncing
1. Make sure your iPod isn't connected to your Mac.
1. Launch iTunes, located at /Applications/.
1. From the iTunes menu, select Preferences.
1. Click the 'Devices' tab.
1. Place a check mark in the box labeled 'Prevent iPods and iPhones from syncing automatically.'
1. Click 'OK.'

--- Connect Your iPod or iPhone to Your Mac.
1. Quit iTunes, if it is running.
1. Make sure your iPod isn't connected to your Mac.
1. Hold down the option and command keys (Apple/cloverleaf) and plug your iPod into your Mac.
1. iTunes will launch and display a dialog box to inform you that it's running in "safe mode". You can release the option and command keys.
1. Click the 'Quit' button in the dialog box.
1. iTunes will quit. Your iPod will be mounted on your desktop, without any syncing between iTunes and your iPod.

Goto: /Volumes/IPOD/iPod_Control/Music

List open ports

# To see system processes such as apache, use "sudo"
sudo lsof -i:80

# List process who is listening on 11113
lsof -n -i4TCP:11113
# wcf Shortcut
lsof -ni:3000

# -n: inhibits the name conversion.
# -i: selects the listing of files whose Internet address matches in the format [46][protocol][@hostname|hostaddr][:service|port].

Code signing

GNU note. Codesigning requires a certificate. The following procedure explains how to create one:

  1. Start the Keychain Access application (in /Applications/Utilities/Keychain
  2. Select the Keychain Access -> Certificate Assistant -> Create a Certificate... menu
  3. Choose a name for the new certificate (this procedure will use "gdb-cert" as an example)
  4. Set "Identity Type" to "Self Signed Root"
  5. Set "Certificate Type" to "Code Signing"
  6. Activate the "Let me override defaults" option
  7. Click several times on "Continue" until the "Specify a Location For The Certificate" screen appears, then set "Keychain" to "System"
  8. Click on "Continue" until the certificate is created
  9. Finally, in the view, double-click on the new certificate, and set "When using this certificate" to "Always Trust"
  10. Exit the Keychain Access application and restart the computer (this is unfortunately required)
  11. Once a certificate has been created, the debugger can be codesigned as follow. In a Terminal, run the following command...
    codesign -f -s  "gdb-cert"  /path/to/gdb
If you don't want to codesign, then you have to use sudo for gdb.

Command line argument in Xcode

Product -> Edit Scheme... -> Run -> Arguments

The shortcut cmd + <

Global include header

The file "stdafx.h" will not be automatically included by all files. But we could import it in the PCH (mac Pre Compiled Header).

Mac not accept crt from GoDaddy?

Yes, the gd_bundle.crt provided by GoDaddy is not accepted by Mac OS. This page explains this and also provides a solution: replace it with a ca_bundle.crt, which is also issued by GoDaddy.

Keep wifi on when sleeping

Ref. In sleep mode, hardware will slow down or stop to work, so there is no solution for the question. The right workaround is to disable automatic sleep mode, and only sleep manually.

iPhoto images

They are in ~/Pictures/iPhoto Library.photolibrary/Masters/. Use the following to mv all images out to DestPath. Reference.

find . -name "*.JPG" -exec move {} /DestPath \;

Download with no wget?

We don't have wget on OS X, but curl is a good replacement - super fast too:

curl "" -o "outfile"

Copy file paths from Finder selections

The simplest way: Open text editor, ensure it is in plain text mode instead of HTML mode, make a new document, drag the seletec file(s) in Finder to the new document, and you will find the full path on that text.

Here comes the guru way - using applescript. Under Applications/Utilities, you will find the apple script editor. Copy the following codes into a new file, save it and it will be given a .scpt suffix. When you click Compile button in the editor, the scpt file will be replaced by a binary file, which is still openable by the editor.

tell application "Finder"
	set sel to the selection as text
	set the clipboard to POSIX path of sel
end tell

Then launch Automator, create a blank workflow, and then drag the Automator -> Run AppleScript (Utilities -> Run AppleScript in 10.5) action to the work area. Replace the stock AppleScript text with the three-line script you see above, then choose File -> Save as APP. Drag this app to dock.
When you need the path to an item, first select that item, then click on your program’s Dock, sidebar, or toolbar icon. Then switch to your target application and press Command-V to paste the path. See the page for reference.


iOS has no swap, so the RAM is a scarcest resource.

Reference on how Macs handle with memory presure.


Switch between different wifi settings

How to switch between different wifi settings, such as I want to connect to wifi1 with DHCP while wifi2 with manually configured IPs? It is really annoying to manually set IP, Netmask and Routers every time when switching from DHCP.

I first tried with command ifconfig, but it doesn't work well together with the system Network config panel (or even conflicting with it). The recommended way is to set "Locations" in Network setting panel. See the detailed Howto here. To open, go: System Preferences - Network - Location.

Set network settings in command line turning off the automatic proxy configuration setting. stackExchange: how to set proxy config file in command line.

function queryStatus() {
  echo "AutoProxy:"
  networksetup -getautoproxyurl Wi-Fi
  echo "WebProxy:"
  networksetup -getwebproxy Wi-Fi
  echo "SecureWebProxy:"
  networksetup -getsecurewebproxy Wi-Fi

function turnOn() {
  sudo networksetup -setautoproxyurl Wi-Fi "http://proxy:8080"
  # networksetup -setautoproxystate Wi-Fi on

function turnOff() {
  sudo networksetup -setwebproxystate Wi-Fi off
  sudo networksetup -setsecurewebproxystate Wi-Fi off

function turnAllOn() {
  sudo networksetup -setwebproxy Wi-Fi "" 8080
  sudo networksetup -setsecurewebproxy Wi-Fi "" 8080
  # networksetup -setwebproxystate Wi-Fi on
  # networksetup -setsecurewebproxystate Wi-Fi on

function turnAllOff() {
  sudo networksetup -setautoproxystate Wi-Fi off

case "$1" in




  echo "Usage: $0 [command]"
  echo "on: turn on the autoProxy only."
  echo "off: turn off the webProxies only."
  echo "allOn, allOff: turn all the autoProxy and webProxies on/off."


Set Bash as login shell

Superuser: change the login shell on Mac OS X.

  1. Goto Users/Groups settings.
  2. Right click your username, get "Advanced Options".
  3. Set the login shell there.

It just doesn't load .bashrc!

This page says in OS X the terminal you get is a login session, therefore BASH will load ~/.bashrc_profile instead of ~/.bashrc. Thus you and add these lines in ~/.bashrc_profile:

[[ -s "$HOME/.bashrc" ]] && source "$HOME/.bashrc"

after any login-specific initializations.



SO: item2 keyboard shortcut for moving tabs around. working effectively with iterm2.

Move tabs
Left: Cmd+Shift+Left
Right Cmd+Shift+Right

Switch between tabs
Previous tab: Cmd+Shift+[, Cmd + Left
Next tab: Cmd+Shift+], Cmd + Right

Pane navigation
split pane left-right: Cmd + d
split pane top-bottom: Cmd + Shift + d
next pane: Cmd + ]
previous pane: Cmd + [
input to all panes in current tab Cmd + Alt + i

open search bar: Cmd + f
find next: Cmd + g

Clear screen
clear buffer: Cmd + k
clear lines (Bash command): Ctrl + l

Zooming / Font Resize
toggle maximize window: Cmd + Alt + =
toggle full screen: Cmd + Enter


Variables in build settings


Dynamic libraries

Ways to add the dylibs to runtime enviroment

Reference by Mac. Another reference.

To find out which libraries a dynamic library depends on, use the otool -L library command.

If that's impossible, it is possible to edit what path is used using install_name_tool, but there are cases where this doesn't work, such as if the new path is longer than the old path and you didn't link it with -header_pad_max_install_names. Rebuilding with the correct path is preferred.

Dylib precedence


Pragma Region

If you are accustomed to Visual Studio's #pragma region, you have a similar tool in Xcode:

#pragma mark - PublicAPI
#pragma mark - PrivateAPI
	another codes

See the Reference I saw.

Commandline arguments

As of Xcode 4.x I've had to go to the Product menu, select "Edit Scheme", then select the arguments tab and add the arguments there.

Parenthesis highlight

I think the Xcode parenthesis hightlighting is not very good. Instead of moving cursor across the paren (only crossing the latter paren has an effect, but not when crossing the beginning one), I would like to double click one the paren and let show enclosing text.

XCode provides a so-called focus ribbon which locates on the left of the editor window, moving the pointer over it will show a focus window around current code snippet, which is Zehr Gute! See the IOS developer help page for this.

Syntax highlighting broken


  1. Go to Project -- Build Settings -- Header Search Paths
  2. Add "$(SRCROOT)/**"
  3. Close and reload the project
  4. Go to Xcode -- Window -- Organizer -- Projects -- $YourProject -- Delete Derived Data
  5. Wait a moment until XCode rebuild all indicies
To get more information activate verbose logging:
  1. Increase Xcode log level in Terminal app: defaults write IDEIndexingClangInvocationLogLevel 3.
  2. Open Console app. Search for "xcode".
  3. I saw "file not found" errors for header files mentioned in the pch file (therefore the fix above).

Split editor

XCode has no direct "split editor screen" but a main/standard editor and several assisstant editors. Click "View - Assisstant editor" to show it. See Stackoverflow discussion on split screen feature.


LLDB and GDB commands.



# List route table:
netstat -nr

# Remove all routes.
sudo route -n flush

sudo route add -net 192.168.10.*

sudo ifconfig en0 down
sudo ifconfig en0 ether yourMacAddr
sudo ifconfig en0 inet netmask
sudo route add default
sudo ifconfig en0 up



I once tried to install MAMP on Mac OS, but visiting my customized documentRoot directory always gave "403 error", and the apache error log gave "no access to htaccess". I checked that the path hierarchy is executable and the files under the documentRoot directory are readable to all. I also ensured that in httpd.conf the directory configuration has the "Allow from all" line. Seeing the update issue of apache 2.2 to apache 2.4, I also tried to change that line to "Require all granted". No use.
In the end, I found that Mac OS has its own apache and PHP installed, so I quitted MAMP, edited /ect/apache2/httpd.conf (add an alias to my homepage and uncomment the php module line), and went to the command line "sudo apachectl start". Bingo! My homepage appeared!
Conclusion: in Mac OS, the bundled Apache and PHP are enough, and using the 3rd party installation may incur trouble.



LoadModule vhost_alias_module libexec/apache2/
LoadModule userdir_module libexec/apache2/
LoadModule rewrite_module libexec/apache2/
LoadModule php7_module libexec/apache2/
Include /private/etc/apache2/extra/httpd-userdir.conf
Include /private/etc/apache2/extra/httpd-vhosts.conf

Personal web sharing

In System Preferences, from the View menu, select Sharing. In the left column, check Web Sharing. To share files on the web, place them in the Sites folder in your home directory.

How to set up how to set up apache.

mkdir ~/Sites/foo
touch ~/Sites/foo/index.html

cd /etc/apache2/users
sudo nano USERNAME.conf
# <Directory "/Users/username/Sites/">
#   AllowOverride All
#   Options Indexes MultiViews FollowSymLinks
#   Require all granted
# </Directory>
sudo chmod 644 USERNAME.conf

cd /etc/apache2
sudo cp httpd.conf httpd.conf.bak
sudo nano httpd.conf
#-- Listed below are the modules to uncomment/enable:
# LoadModule authz_host_module libexec/apache2/
# LoadModule authz_core_module libexec/apache2/
# LoadModule userdir_module libexec/apache2/
# LoadModule vhost_alias_module libexec/apache2/
# Include /private/etc/apache2/extra/httpd-userdir.conf
# Include /private/etc/apache2/extra/httpd-vhosts.conf

cd /etc/apache2/extra
sudo cp httpd-userdir.conf httpd-userdir.conf.bak
sudo nano httpd-userdir.conf
#-- Uncomment the following line, removing #:
# Include /private/etc/apache2/users/*.conf

sudo apachectl restart
# Navigate to http://localhost/~username


sudo cp /private/etc/php.ini.default /private/etc/php.ini



Install MySQL on MacOSX 10.9


bash <(curl -Ls

Config files


iOS developer


See the iOS APP distribution guide by Mac.

Provisioning profile


Obtaining Signing Cert and Provisioning Profiles in XCode

  1. In the Xcode Preferences window, click Accounts.
  2. Select your team, and click View Details.
  3. Click the Refresh button in the lower-left corner of the view details dialog under the Provisioning Profiles table.
  4. If you are missing a development or distribution certificate, a dialog appears asking whether Xcode should request it on your behalf. A dialog may appear for each type of certificate you are missing.
  5. Click Request for the signing identities you want.

See the manual in Mac.

Mac usual commands


Access the Mac OS X user defaults system.

read domain key
write domain key 'value'
delete domain key

	Prints the names of all domains

Make Xcode to compile in 8 threads: (wcf note: I found in others mac there is no such thing existing as

defaults write PBXNumberOfParallelBuildSubtasks 8
There are also many other ways to speed up a compilation, from precompiled headers to distributed builds. Read Reducing Build Times for more information on this. Reference.


# Print the route info
netstat -nr

# Get the default gateway
route -n get default


# To see CPU info:
system_profiler | grep Processor


Install_name_tool changes the dynamic shared library install names and or adds, changes or deletes the rpaths recorded in a Mach-O binary.



# List all disks with their identifiers, even if unmounted.
diskutil list

# List only locally-mounted filesystems
df -Hl

md5sum, md5

Mac OS X, does not come with md5sum installed by default, but it comes with an equivalent tool that you can use instead - "md5".

# To calculate the 128 bit MD5 hash of a file, run this command:
md5 [file.ext]

# If you need the same output format that md5sum has, use this.
md5 -r [file.ext]

# openssl also has a function to calculate md5 hash.
openssl md5 [file.ext]


Use htop instead:

brew install htop


Copy format in Numbers?

Click Format - Copy style.
Alt+Mac+C: copy style
Alt+Mac+V: Paste style

Greyed out Hide Column command

You have to unmerge all the cells first. StackExchange.

MS Office

pages, keynote, numbers

Create an ics from Outlook

Creating an iCalendar (.ics) file in Outlook (Mac)
1.    Create the calendar event and click Save and Close
2.    Go to the File menu and create a new email.
3.    Click and drag the event from the calendar into a grayed-out area in the message header and it will appear as an .ics attachment. 
1.    Create the calendar event and click Save and Close
2.    Drag the event to your desktop and it will create a .ics file
3.    Create a new email message and attach the file.