Chris McMichael

Terminal-config

by Chris

A while back, I found a bash framework called Bash-it. I extend it's functionality and created a simple installer wizard. I've added a few of my personal scripts in as well. Basically, I wanted a quick and easy way to install my personal home directory configurations. It's a continual work in progress. Check it out or Forkit @ My Github

Bike to Work Day 2012

by Chris

Today I took a road-trip on my bike for a total of 40 miles to and from work. The photo below shows where I tried to take a shortcut through the trails running next to NASA, only to find that they dead-end. Boo! Backtracking cost me 5 miles of extra biking.

Django Base

by Chris

I created a nice commandline utility a while back for automating the process of creating a Django project template. Since doing so, Django 1.4 arrived which added similar functionality but my script takes project creation a step further.

What is so cool about my script:

  • A commandline wizard with pretty colors!
  • Bash autocomplete command called mkdjango (like mkdir but for Django)
  • Pick from the 4 of the most common server setups which will auto generate the configuration files needed.
  • Use your own project template (if mine isn't good enough!)

Installation:

pip install Django-base

Check it out or fork-it @ Github

Coachella 2012

by Chris

Last weekend, I took my very first trip to SoCAL to attend Coachella; the most amazing music festival of them all.

Here is a list of musical artists I saw this year:

50 Cent, Andrew Bird, AVICII, The Black Keys, Bon Iver, BoomBoomBoomBand (RedBull Speakeasy), Calvin Harris, DJ Shadow, Dr Dre, Eminem, Florence and the Machine, Flying Lotus, Frank Ocean, Girl Talk, Godspeed, Gotye, The Hives, Justice, Kendrick Lamar, M83, Miike Snow, Radiohead, SBTRKT, Snoop Dogg, Swedish House Mafia, Tupoc hologram, Warren G, Wiz Khalifa, & a few others that I can't recall.

Pro Tips for next year:

  • Get a campground for drinking, eating, and hanging out. Who wants to pay $10-14 for beer and food inside?!!
  • Rent a condo b/c if you sweat like all of the other smelly campers you will want to take a shower (at least I hope you would). Also it's nice to sleep in a real bed and not a blowup bed or worse, the ground. Glad we made the choice of getting a condo this year.
  • Bring your own TP (if you go the route of camping). Does this point really require detail?
  • Buy some walking shoes with tons of padding. You will be walking around for 6-12 hours at a time. I made the mistake of walking around in my Vibrams sock shoes which has zero padding. Don't make that mistake or you will regret it, like I did.

Check out my Gallery: Coachella 2012 Gallery

Django on Mac OS X Lion

by Chris

Django on Mac OS X (10.7+) is completely easy right? I decided to put together this tutorial since sometimes it can be a pain to get things like MySQL, mysql-python, and python PIL imaging library installed properly.

1. Install Xcode which can be found on the Mac App Store.

This step might take a while so be prepared Xcode is 1GB+.

2. Install a database of your choice:

MySQL Server

MySQL can be downloaded HERE

Be prepared to click through layers of links and community registration nag. Very Lame MySQL! Also take note that MySQL will be a pain to setup and should be avoided at all cost!

First issue: MySQL's installer is so ghetto that it does not SymLink it's own executable to /usr/bin/ for commandline usage. Gee thanks MySQL installer! So here is the command to do this manually:

sudo ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
sudo ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin

PostgresSQL Server

You can download postgres HERE (no link trickery or registration nag).

Also check out postgresapp HERE. Start, stop, and launch postgres as a standalone app.

PostgresSQL comes with an awesome installer and will even install PostGIS if needed.

Wait... that's it? Yep, it just works. Moving on..

3. Install Python libraries.

First lets start with python's imaging library but before we can install it, we'll need to download, build, and install a couple prerequisites.

JPEG Library

curl -O http://www.ijg.org/files/jpegsrc.v8c.tar.gz
tar -xvzf jpegsrc.v8c.tar.gz
cd jpeg-8c
./confgure
make
sudo make install

FreeType Library

curl -O http://ftp.igh.cnrs.fr/pub/nongnu/freetype/freetype-2.4.5.tar.gz
tar -xvzf freetype-2.4.5.tar.gz
cd freetype-2.4.5
./configure
make
sudo make install

PIP

Next lets install PIP, a Python package management tool.

sudo python easy_install pip

VirtualEnv

Lets also install VirtualEnv, a dependency manager for python related projects.

pip install pil virtualenv

Python Imaging (PIL) and Django

pip install pil django

Note: This might also be a good time to consider using virtualenv so that project specific libraries will be isolated within the project directory and not globally installed.

MySQL-Python

Since you chose to use Postgres, you can clearly skip this part!

Before starting, we must first set an environment variable or this library will fail!

export DYLD_LIBRARY_PATH='$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/'

In some cases it my be helpful to place the mysql bin directory on your path

export PATH=/usr/local/bin:/usr/local/mysql/bin/:$PATH

Now you can install via pip install

pip install mysql-python

Still having problems? Lets try to install from source HERE

Download and unpack mysql-python:

tar -xvzf MySQL-python-x.x.x.tar.gz
cd MySQL-python-x.x.x

Make sure to change the mysql_config variable under site.cfg to point to:

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

If the above path does not work try a path like this:

mysql_config=/usr/local/mysql-5.6.10-osx10.7-x86/bin/mysql_config

Now lets try to install

python setup.py install

Lastly, check that mysql-python did in fact install correctly.

python -c "import MySQLdb"

Install psycopg2

pip install psycopg2

Wait... that's all I need to do for postgres? Glad you chose to switch?

Note: If experiencing any password or permission denied errors when connecting to Postgres, ensure that the lines below exist in your pg_hba.conf (obviously you would want to make this a little more secure in a production environment)

/Library/PostgreSQL/x.x/data/pg_hba.conf

# "local" is for Unix domain socket connections only
local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
# IPv6 local connections:</code>
host    all         all         ::1/128               trust

And that is it. enjoy!