Created
August 4, 2013 21:18
-
-
Save 0xqd/6151997 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=========================================================== | |
PATHS | |
=========================================================== | |
# Make sure /usr/local/bin is at top | |
sudo nano /etc/paths | |
/usr/local/bin | |
/usr/bin | |
/bin | |
/usr/sbin | |
/sbin | |
=========================================================== | |
XCODE | |
=========================================================== | |
https://itunes.apple.com/us/app/xcode/id497799835?mt=12 | |
=========================================================== | |
HOMEBREW | |
=========================================================== | |
http://mxcl.github.com/homebrew/ | |
# Install | |
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" | |
# Troubleshoot | |
brew doctor | |
# Update | |
brew update | |
=========================================================== | |
MYSQL | |
=========================================================== | |
# Install | |
brew install mysql | |
# Post install | |
unset TMPDIR | |
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp | |
# Start at login | |
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents | |
# Start now | |
mysql.server start | |
-or- | |
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist | |
# Clean up for production (changes root pw, etc.) | |
/usr/local/opt/mysql/bin/mysql_secure_installation | |
# Log in as root (no password) | |
mysql -u root -p | |
# Add user (do it as root!) | |
CREATE USER '[user]'@'localhost' IDENTIFIED BY '[password]'; | |
FLUSH PRIVILEGES; | |
GRANT SELECT ON * . * TO '[user]'@'localhost'; | |
# Create database (do it as root!) | |
CREATE DATABASE [database]; | |
GRANT ALL PRIVILEGES ON `[database]` . * TO '[user]'@'localhost'; | |
FLUSH PRIVILEGES; | |
# Quit | |
QUIT; | |
# Load database | |
mysql -u [user] -p [database] < [~/Dropbox/Apps/MyUploader2873711277/richardcornish_r-20130316].sql | |
# Dump database | |
mysqldump -u [user] -p [database] > [file].sql | |
# Log in | |
mysql -u [user] -p | |
# List databases | |
SHOW DATABASES; | |
# Use database | |
USE [database]; | |
# Show tables | |
SHOW TABLES; | |
# Delete user | |
DROP USER '[user]'@'localhost'; | |
# Stop server | |
mysql.server stop | |
=========================================================== | |
POSTGRESQL | |
=========================================================== | |
# Install | |
brew install postgresql | |
# Info | |
brew info postgres | |
# Load at login (once) | |
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents | |
# Load now | |
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
-or- | |
launchctl load /usr/local/opt/postgresql/homebrew.mxcl.postgresql.plist | |
# Create database system (once) | |
initdb /usr/local/var/postgres -E utf8 | |
# If starting over | |
# rm -rf /usr/local/var/postgres | |
# Start/stop database system | |
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start | |
pg_ctl -D /usr/local/var/postgres stop -s -m fast | |
# Mountain Lion bug | |
sudo mkdir /var/pgsql_socket/ | |
sudo chown $USER /var/pgsql_socket/ | |
nano /usr/local/var/postgres/postgresql.conf | |
unix_socket_directory = '/var/pgsql_socket' | |
sudo ln -sfv /var/pgsql_socket/.s.PGSQL.5432 /tmp/.s.PGSQL.5432 | |
# stop | |
# start | |
-or- | |
# Show memory settings | |
sysctl kern.sysv.shmmax # kern.sysv.shmmax: 4194304 | |
sysctl kern.sysv.shmall # kern.sysv.shmall: 1024 | |
# Edit memory this time | |
sudo sysctl -w kern.sysv.shmmax=33554432 # 33554432 = 4194304 * 8 | |
sudo sysctl -w kern.sysv.shmall=33554432 | |
# Edit memory for all times | |
sudo nano /etc/sysctl.conf | |
kern.sysv.shmmax=33554432 | |
kern.sysv.shmall=33554432 | |
# Use default database | |
psql postgres | |
# Create user | |
CREATE USER [user] WITH PASSWORD '[password]'; | |
# Create database | |
CREATE DATABASE [database] OWNER [user]; | |
# Grant privileges to user | |
GRANT ALL PRIVILEGES ON DATABASE [database] TO [user]; | |
# Quit database | |
\q | |
# Load database | |
psql [aornfoxvalley] [webmaster] < [~/Dropbox/Apps/MyUploader2873711277/aornfoxvalley-20130317].sql | |
# Login as other user | |
psql -U [user] [database] | |
# Show databases | |
\l | |
# Show tables | |
\d | |
# Show columns | |
\d [django_flatpage] | |
# Drop database | |
dropdb [database] | |
# Find postgres process | |
ps aux | grep postgres | |
# Kill rogue process | |
sudo kill -9 [10368] | |
# More help | |
# https://gist.github.com/vlado/1877457 | |
# http://www.brentmc79.com/posts/psql-could-not-connect-oh-fuck-you | |
=========================================================== | |
GIT | |
=========================================================== | |
# Install | |
brew install git | |
brew link git | |
brew link --overwrite git | |
# Setup | |
git config --global user.name "Your name" | |
git config --global user.email "email@domain.com" | |
=========================================================== | |
PYTHON | |
=========================================================== | |
# Install | |
brew install python | |
brew install pil | |
brew link --overwrite pil | |
# Global python packages | |
pip install mysql-python # mysql database | |
pip install psycopg2 # postgresql database | |
pip install pytz | |
pip install python-memcached | |
pip install virtualenv | |
pip install virtualenvwrapper | |
# First time virtualenvs | |
source /usr/local/share/python/virtualenvwrapper.sh | |
# For future virtualenvs | |
nano ~/.bash_profile | |
PATH=/usr/local/share/python:$PATH | |
export PATH | |
export WORKON_HOME=$HOME/.virtualenvs | |
export PROJECT_HOME=$HOME/Rich/Web | |
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--system-site-packages' | |
source /usr/local/share/python/virtualenvwrapper.sh | |
source ~/.bash_profile | |
# Basic virtualenv (don't use much) | |
virtualenv [projectname] | |
cd [projectname] | |
source bin/activate | |
=========================================================== | |
DJANGO | |
=========================================================== | |
# Virtualenvwrapper | |
# Create + use | |
mkvirtualenv myproject | |
# If you didn't add extra bash export above + | |
# You forgot to add --system-site-packages, | |
# cdvirtualenv | |
# rm lib/python2.7/no-global-site-packages.txt | |
# Install packages | |
pip install django | |
pip install -e git+git://github.com/django/django-localflavor-us.git#egg=django-localflavor-us --src ~/lib/python2.7/ | |
pip install -e git+git://github.com/richardcornish/django_compressor.git#egg=compressor --src ~/lib/python2.7/ | |
(to update: pip install -e git+git://github.com/richardcornish/django_compressor.git#egg=compressor --src ~/lib/python2.7/ -U) | |
pip install south | |
pip install django-robots | |
pip install markdown | |
pip install typogrify | |
pip install twitter | |
pip install instagram | |
pip install sorl-thumbnail | |
# Start Django project | |
django-admin.py startproject myproject | |
# Unset DSM if getting an error | |
# unset DJANGO_SETTINGS_MODULE | |
# Add Django project/other packages to path | |
# You must be outside the project directory to add! | |
add2virtualenv myproject | |
add2virtualenv ~/Rich/GitHub/django-adminplus/ | |
# Edit add2virtualenv additions | |
cdsitepackages | |
nano _virtualenv_path_extensions.pth | |
# Export settings module for future | |
cdvirtualenv | |
cd bin | |
nano postactivate | |
export DJANGO_SETTINGS_MODULE=myproject.settings | |
chmod 755 bin/postactivate | |
nano postdeactivate | |
unset DJANGO_SETTINGS_MODULE | |
chmod 755 bin/postactivate | |
# Run server | |
django-admin.py runserver | |
# Add Django project to Git | |
cd myproject | |
nano .gitignore | |
.DS_Store | |
*.pyc | |
git init | |
git add . | |
git commit -m "First commit" | |
# git remote add origin ... | |
# git push -u origin master | |
django-admin.py startapp myapp | |
# Stop | |
deactivate | |
# List | |
workon | |
# Use existing | |
workon myproject | |
# Delete | |
rmvirtualenv myproject | |
# Helpful virtualenvwrapper commands | |
mkvirtualenv (creates a new virtualenv) | |
rmvirtualenv (removes an existing virtualenv) | |
workon (change the current virtualenv) | |
add2virtualenv (add external packages in a .pth file to current virtualenv) | |
cdsitepackages (cd into the site-packages directory of current virtualenv) | |
cdvirtualenv (cd into the root of the current virtualenv) | |
deactivate (deactivate virtualenv, which calls several hooks) | |
lssitepackages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment