Dark Launch

This is a Dark Launch.

OSX Install Pip, Virtualenv & VirtualenvWrapper on Mac

To install pip, virtual environment (virtualenv, virtualenvwrapper) on OS X, do the following on the command line:

Code
sudo easy_install pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
 

To enable the workon tab-completion feature, append the following to your profile file (located at ~/.profile):

Code
source /usr/local/bin/virtualenvwrapper.sh
 

Create a directory to house the virtual environments:

Code
mkdir ~/.virtualenvs
 

Create a new virtual environment for your project:

Code
cd ~/.virtualenvs
virtualenv --no-site-packages myproject
 
  • NOTE: Apple's development tools needs to be installed: Xcode http://itunes.apple.com/us/app/xcode/id448457090
  • The "installer" only downloads the file to Applications -- you still need to install Xcode.
  • Running the installer normally may freeze. If so, right click and choose "Show Package Contents" then look for Xcode.mpkg in /Applications/Install Xcode.app/Contents/Resources/Xcode.mpkg and run that instead.

Bash stdout & write output to file

To display dual output on standard output (stdout) and write or append the output to a file, use tee. For example, do the following:

python ./myscript.py | tee -a output.log

The output from the script is piped to tee and tee prints to stdout and appends to the specified log file.

Django Reset Admin User's Password

Change a user's password from the command line, use the changepassword command. It will prompt you to change the password for the specified user.

Python
./manage.py changepassword admin
Python
django-admin.py changepassword admin

You can also change a password programmatically:

Python
from django.contrib.auth.models import User
admin = User.objects.get(username='admin')
admin.set_password('mynewpassword')
admin.save()