Installing Django on OS X Leopard

Posted by Trey on February 26, 2008

If you haven’t already, stick your Leopard disk in and install Xcode 3.0.

Make a home for Django:

sudo mkdir /usr/local/django
cd /usr/local/django

Get the Django trunk from Subversion:

sudo svn co http://code.djangoproject.com/svn/django/trunk/

The Django trunk should now be in /usr/local/django/trunk/, and if you ever want to check out another branch, you have a nice spot to put it next to the trunk.


I’ve you’ve previously install Python yourself, pay attention here

Find out if you’re using the right version of Python:

which python

If you don’t see:

/usr/bin/python

then delete whatever version you have sitting in your path, such as one in /usr/local/:

sudo rm /usr/local/bin/python

Once “which python” gives you “/usr/bin/python“, make sure your Python site-packages is in the right place. Running this command:

python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

should give you:

/Library/Python/2.5/site-packages

End of previous Python caveat


Now make sure Python knows where to find Django:

ln -s /usr/local/django/trunk/django /Library/Python/2.5/site-packages/django

Put the django-admin.py script on your system path:

sudo ln -s /usr/local/django/trunk/django/bin/django-admin.py /usr/local/bin

Now you should have Django installed and ready to go. Run:

django-admin.py startproject project_name

and see.

If it works, cd into the folder it creates and try:

python manage.py runserver

Then go to localhost:8000 in your browser.

Django + MySQL:

If you want to use MySQL with Django, there’s a bit more to do. If you have MySQL ready to go, continue. Otherwise, go talk with Dan for a bit and come back here when you’re done.

Download the MySQLdb package. Stick in in /usr/local/src if you’re cool. Open it and edit site.cfg.

Change line ~ 13 from:

#mysql_config = /usr/local/bin/mysql_config

To:

mysql_config = /usr/local/mysql/bin/mysql_config

In _mysql.c:

Remove these lines (~ 37-39):

#ifndef uint 
#define uint unsigned int 
#endif

Go to the folder on the command line, then:

sudo python setup.py build
sudo python setup.py install

You might have to run the build command more than once. Don’t ask me why–I’m a copy and paster just like you.

That should do it. Try editing your settings.py file in your Django project and entering information for a MySQL database and see if it works.

If you experience something different than this or have any problems, please let me know directly or leave a comment.

Sources

Installing Git on OS X Leopard

Posted by Trey on February 25, 2008

It’s apparently best to install Git using both MacPorts and from source. That way you’ll get all the dependencies that are a pain in the ass to get set up, and you’ll also get the newest version of Git.

Install Git + Dependencies from MacPorts

Install the MacPorts “Leopard (Universal)” disk image from here.

If after the installation, running “which port” doesn’t show “/opt/local/bin/port“, try adding the following lines above any other path rules you have in your .bash_login file:

# MacPorts
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
# / MacPorts

Make sure MacPorts is up-to-date:

sudo port -v selfupdate

Install Git:

sudo port install git-core

Install Git from Source

Go to git.or.cz and download the newest package.

Stick the file where you want it (I prefer /usr/local/src/).

Open the file and cd into its folder. Then:

sudo make prefix=/usr/local all

(You won’t need the sudo on the last command unless you’ve got your source in /usr/local/src/, which is owned by root)

Then:

sudo make prefix=/usr/local install

If everything goes as planned, you should be able to type “which git” and see exactly this:

/usr/local/bin/git

If instead you see /opt/local/… you’re using the MacPorts version and you need to move those path rules above the other rules in your .bash_login.

Enjoy.


Bonus: TextMate Integration

To use TextMate to edit your commit messages, put the following in your ~/.bash_login:

export GIT_EDITOR="mate -w"

Install the TextMate Bundle:

mkdir -p /Library/Application\ Support/TextMate/Bundles
cd !$
git clone git://gitorious.org/git-tmbundle/mainline.git Git.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'

Since Git is installed in /usr/local/bin, you’ll need to make a link to where the bundle expects it:

sudo ln -s /usr/local/bin/git /usr/bin/git

Sources:

Using SSH Keys for Password-Free Logins from OS X

Posted by Trey on January 11, 2008

If your remote username is different from your OS X username, edit your ~/.ssh/config file like so:

Host whathaveyou.com
    User remote_username

Generating your keys

On your OS X machine, enter this command:

ssh-keygen -t dsa

Enter a password or don’t (I didn’t).

This creates a public (~/.ssh/id_dsa.pub) and private key (~/.ssh/id_dsa).

Copying the public key to the remote server

Log in to the server with ssh (with your password–for the last time).

However you want to do it, open the file ~/.ssh/authorized_keys on the remote server and paste in the contents of id_dsa.pub. Alternately, you could use scp like so:

scp ~/.ssh/id_rsa.pub remote_username@whathaveyou.com:~/.ssh/authorized_keys

(Naturally, if the file and/or folder aren’t there, you’ll have to create them first.)

Now change the permissions:

chmod 700 ~/.ssh/
chmod 600 ~/.ssh/authorized_keys

All done. The next time you want to ssh to the server, it won’t prompt you for a password.

Sources:

Restoring keychain passwords (including Transmit) from a hard drive backup

Posted by Trey on May 05, 2007

This worked for me:

  • Rename the file ~/Library/Keychains/login.keychain (to keep it safe just in case)
  • Drag your backup copy of login.keychain to the same location
  • Make sure your admin account on your new system (or install of OS X) has the same password as the old one, or (according to JTJ) it won’t automatically open it when you log in.

Source: Originally tweeted.

Creating a Web Archive of a Writeboard in Yojimbo

Posted by Trey on December 26, 2006

  1. Share the Writeboard with yourself
  2. Get the password out of the email you receive
  3. Archive the item in Yojimbo
  4. In the password prompt inside of the archive in Yojimbo, put the password from the email
  5. Submit the form
  6. Delete the web archive
  7. Archive the Writeboard again

Delete photos inside an album in iPhoto

Posted by Trey on December 06, 2006

If you want to move photos to the trash that are inside of an album (smart or otherwise), you can’t just drag them to the trash icon (?!). You have to hit cmd-option-delete.

Now you know.