Skip to content

Instantly share code, notes, and snippets.

@maroshii
Forked from zircote/osx-10.9-setup.md
Last active August 29, 2015 14:16
Show Gist options
  • Save maroshii/0ce35f40484ce27b6f4d to your computer and use it in GitHub Desktop.
Save maroshii/0ce35f40484ce27b6f4d to your computer and use it in GitHub Desktop.

Mac from scratch

Install Software

Install from App Store

Install from Third-Party Websites

  • Browsers

    • Chrome (installed via Cask)
    • Firefox
  • Development

  • Utilities

    • 1Password
    • Flowdock (installed via Cask)
    • iTerm 2 (installed via Cask)
  • Virtualization

    • Virtualbox (installed via Cask)
    • boot2docker (installed via cask)

Fonts

Mensch coding font

#Xcode Command Line Tools

Xcode > Preferences > Downloads > Command Line Tools

Folders of interest

mkdir -p ~/{Projects,Virtualenvs}

#Homebrew

Install Homebrew

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

Install Homebrew extension Cask

brew install caskroom/cask/brew-cask

Install applications via Homebrew Cask

for app in atom github google-chrome iterm2 vagrant vagrant-manager virtualbox \
           box-sync dropbox flowdock boot2docker sequel-pro navicat-premium; do
    brew cask install ${app}
done

Install common applications via Homebrew

brew install ack autojump automake colordiff curl git git-flow gnu-sed gnu-which gnu-tar gnutls \
             gnu-getopt hub icoutils imagemagick libmemcached memcached openssl ossp-uuid qt \
             go readline redis tmux wget scala python node

Node / NPM

npm install -g npm@latest

for app in grunt-cli express bower; do
    npm install -g ${app}
done

Python setup and configuration

Add the following to ~/.bash_profile this configuration will require all pip executions to be from a virtual env.

# pip should only run if there is a virtualenv currently activated
export PIP_REQUIRE_VIRTUALENV=true
# global pip access via `gpip`
gpip(){
   PIP_REQUIRE_VIRTUALENV="" pip "$@"
}

######

for pkg in pip setuptools virtualenv virtualenv awscli glances httpie; do
    gpip install --upgrade ${pkg}
done


# install virtualenv wrapper (you want this trust me)
gpip install virtualenvwrapper
echo "export WORKON_HOME=~/Virtualenvs"
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.extra"

# create the rst documentation virtualenv
mkvirtualenv documentation
pip install sphinx markdown

configure aws-cli

aws configure

AWS KeyCHain Util

aws-keychain-util

sudo gem install aws-keychain-util
aws-creds init
aws-creds add
aws-creds ls

Configure GO Environment

mkdir ~/go
echo "export GOROOT=~/go" >> ~/.exports

boot2docker port managment

# vm must be powered off
boot2docker stop
for i in {49000..49900}; do
 VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i";
 VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";
done

# to remove it later:
# vm must be powered off
#boot2docker stop
#for i in {49000..49900}; do
# VBoxManage modifyvm "boot2docker-vm" --natpf1 delete "tcp-port$i";
# VBoxManage modifyvm "boot2docker-vm" --natpf1 delete "udp-port$i";
#done

Shell

Install custom .dotfiles (optional)

cd ~/
git init
git remote add origin git@${git_home_of_dot_files}
git fetch origin
git checkout -b master --track origin/master
. ~/.bash_profile

OS X Preferences

# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 0.02
# Set a shorter Delay until key repeat
defaults write NSGlobalDomain InitialKeyRepeat -int 12
# Show the ~/Library folder
chflags nohidden ~/Library
# Store screenshots in subfolder on desktop
mkdir ~/Desktop/Screenshots
defaults write com.apple.screencapture location ~/Desktop/Screenshots

Git

Setup Github

ssh-keygen -t rsa -C "${my_email_address}"

# Copy ssh key to github.com
ssh-add ~/.ssh/id_rsa.pub

# Test connection
ssh -T git@github.com

# Set git config values
git config --global user.name "${FULL_NAME}"
git config --global user.email "${GIT_EMAIL}"
git config --global github.user ${GITHUB_USERNAME}
git config --global github.token ${your_github_token_here}

git config --global core.editor "vim"
git config --global color.ui true

Server

Docker

# for remote docker servers/shared build/docker env
unset DOCKER_TLS_VERIFY
export DOCKER_HOST=tcp://docker.dev.my-domains.local:2376

#for boot2docker local
boot2docker init
boot2docker up
export DOCKER_CERT_PATH=/Users/`whoami`/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://${address_of_boot2docker_or_remote_docker_instance}

MySQL

brew install mysql
brew pin mysql

MySQL Settings

# Copy launch agent into place
mkdir -p ~/Library/LaunchAgents && cp /usr/local/Cellar/mysql/VERSION/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/

# Edit launch agent and set both keepalive and launch at startup to false
vi ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

# Inject launch agent
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

# Set up databases to run as your user account
unset TMPDIR && mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

# Start mysql
start mysql

# Secure mysql
/usr/local/Cellar/mysql/VERSION/bin/mysql_secure_installation

PostgreSQL

brew install postgres --no-ossp-uuid --with-python
brew pin postgres

PostgreSQL Settings

# Initialize db if none exists already
initdb /usr/local/var/postgres

# Create launchctl script
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/*/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/

# Edit launchctl script (set to not start automatically and keepalive false)
mvim ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

# Inject launchctl script
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

# Start PostgreSQL
start pg

# Create DB
createdb `whoami`

Oracle Dependencies and cx_Oracle virtualenv

Oracle 11g Install Page

mkvirtualenv Oracle-Env
export ORACLE_HOME=~/Virtualenvs/Oracle-Env/lib/oracle
mkdir -p ${ORACLE_HOME} && cd ${ORACLE_HOME}

# go to Oracle and download 64-bit versions of the basic and sdk zip files **see link above**

for i in $(ls ~/Downloads/instantclient-*); do
    unzip ${i} -d ${ORACLE_HOME}
done
mv instantclient_11_2/* ./
rm -rf instantclient_11_2

ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib

pip install cx_Oracle --allow-external cx_Oracle --allow-unverified cx_Oracle

#Add post deactivate hooks to clean environment
echo "unset ORACLE_HOME" >> ${VIRTUAL_ENV}/bin/postdeactivate
echo "unset DYLD_LIBRARY_PATH" >> ${VIRTUAL_ENV}/bin/postdeactivate
echo "unset LD_LIBRARY_PATH" >> ${VIRTUAL_ENV}/bin/postdeactivate

#Add post activate hooks to setup the environment
echo "export ORACLE_HOME=\${VIRTUAL_ENV}/lib/oracle" >> ${VIRTUAL_ENV}/bin/postactivate
echo "export DYLD_LIBRARY_PATH=\${ORACLE_HOME}" >> ${VIRTUAL_ENV}/bin/postactivate
echo "export LD_LIBRARY_PATH=\${ORACLE_HOME}" >> ${VIRTUAL_ENV}/bin/postactivate

for projects that will use oracle in the future you should plan to use the following commands:

cpvirtualenv  Oracle-Env scoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment