Screen Capture x1 Image Size Under Retina Macs

1. Open “Automator”
2. Select “Service” for “Choose a type for your document”
3. Change “Service receives no input in any application” on top right section of the Automator
4. Drag action “Run Shell Script” from the left pane into the workflow on the right pane
5. Make sure Shell setting is to “/bin/bash”
6. Add the following script to the script section (change the 2nd line setting for SS_PATH to your desktop absolute path) and save:

# the path where screenshots to save
SS_PATH="/Users/vincent/Desktop"
TMP_PATH="/tmp"

# a variable of unix timestamp for screenshot file name
NOW=$(date +%s)

# image format to create, default is png (other options include pdf, jpg, tiff and other formats)
SS_TYPE=png

# name of screenshot
SS_NAME=screenshot$NOW

# full path of screenshot file
SS_1X=$SS_PATH/$SS_NAME.$SS_TYPE
SS_2X=$TMP_PATH/$SS_NAME@2X.$SS_TYPE

# execute screen capture command and save to $SS_2X
screencapture -i -r -t $SS_TYPE $SS_2X

# check if screenshot is existing
if [ -f $SS_2X ]; then

    # get the 50% width of screenshot by sips
    WIDTH=$(($(sips -g pixelWidth $SS_2X | cut -s -d ':' -f 2 | cut -c 2-)/2))

    # scale down by sips
    sips --resampleWidth $WIDTH $SS_2X --out $SS_1X
    
    # copy small one to clipboard by applescript
    # if you hold control key when do capture, causes screen shot 2X to go to clipboard
    osascript -e 'set the clipboard to POSIX file "'$SS_1X'"'
fi

7. Open “System Preferences” > “Keyboard” > “Shortcuts”, find the service you just created and assign hotkey (e.g. Cmd+Shift+5).

OSX Slow Samba Client Fix

This may or may not fully fix the very screwed up implementation of SMB on OSX.

Fix 1 – nsmb.conf

echo "[default]" >> ~/Library/Preferences/nsmb.conf; echo "smb_neg=smb1_only" >> ~/Library/Preferences/nsmb.conf; echo "notify_off=yes" >> ~/Library/Preferences/nsmb.conf;

Fix 2 – net.inet.tcp.delayed_ack
Use Lingon to create a “User Daemon” that runs when loaded by the system to run this (Name doesn’t matter):

sudo sysctl -w net.inet.tcp.delayed_ack=0

After Fix 1 and Fix 2 reboot.

OSX Tools

Prepare the environment

xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Some Brew files

brew update
brew upgrade

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php56 --with-fpm --with-homebrew-openssl --without-snmp
brew install php56-xdebug php56-imagick php56-mcrypt
ln -sfv /usr/local/opt/php56/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

brew install mysql
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

brew install nginx
sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons/
sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
mkdir -p /usr/local/etc/nginx/sites-enabled

brew install dnsmasq
sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
cat << 'EOF' > $(brew --prefix)/etc/dnsmasq.conf
address=/double-click.net/127.0.0.1
address=/dev/127.0.0.1
EOF
sudo mkdir /etc/resolver
sudo tee /etc/resolver/dev >/dev/null <<EOF
nameserver 127.0.0.1
EOF
sudo tee /etc/resolver/lan >/dev/null <<EOF
nameserver 127.0.0.1
EOF

brew install lame git youtube-dl node wget yuicompressor ffmpeg rename

Install Apps from commandline:
http://caskroom.io/

brew install caskroom/cask/brew-cask
brew cask install --appdir=/Applications iterm2
brew cask install --appdir=/Applications dropbox
brew cask install --appdir=/Applications onepassword
brew cask install --appdir=/Applications google-chrome firefox skype simple-comic phpstorm mplayer-osx-extended mplayerx imageoptim blueharvest totalfinder utorrent vlc vmware-fusion xld qlstephen rcdefaultapp

Install zprezto
https://github.com/sorin-ionescu/prezto

zsh
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"

setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
    ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done

chsh -s /bin/zsh

Config backup:
https://github.com/lra/mackup

Reference:
http://lapwinglabs.com/blog/hacker-guide-to-setting-up-your-mac
http://gilmendes.wordpress.com/2014/07/09/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-yosemite/

Jump Terminal Command

First:

mkdir ~/.marks

Then add this to your ~/.zshrc or ~/.bashrc:

export MARKPATH=$HOME/.marks

function jump {
    cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1"
}

function mark {
    mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1
}

function unmark {
    rm -if "$MARKPATH/$1"
}

function marks {
    ls -l $MARKPATH | sed 's/  / /g' | cut -d' ' -f9- | sed 's/ -/ -/g' && echo
}

function _marks {
    reply=($(ls $MARKPATH))
}

compctl -K _marks jump
compctl -K _marks unmark

To use:

Now to remember a directory you type

mark <any_string>

and to jump to that directory you type

jump <any_string>

To list all your shortcuts

marks

Patch ESXi to run OSX guest

1. Download http://www.insanelymac.com/forum/topic/267296-esxi-5-mac-os-x-unlocker/
2. Unzip and save it to datastore
3. SSH into ESXi host
4. Run unlock-all-vXXX/esxi/install.sh in ESXi host’s SSH as root
5. Shut down all appliances
6. Reboot ESXi

More info:
http://techiezone.rottigni.net/2013/11/installing-mavericks-on-esxi-5-1/
http://www.virtuallyghetto.com/2013/09/html5-vm-console-does-not-work-after.html