Monday, April 26, 2010

Find ubuntu release and version on the command line


lsb_release

or 

cat /etc/lsb-release

Thursday, April 22, 2010

Configure git colors and output format


# Add color
git config color.ui auto

# Format for log, whatschanged
git log --pretty=

Monday, April 19, 2010

Installing OSQA

While installing OSQA, an opensource clone of StackExchange (Stackoverflow) written in Python (Django), I encountered a few gotchas

Installation instructions:
http://wiki.osqa.net/display/docs/OSQA+Installation+and+Upgrade+Guides
http://wiki.osqa.net/display/docs/Setting+Up+OSQA+for+Apache
http://wiki.osqa.net/display/docs/Ubuntu+9+with+MySQL

Gotchas:

1. Install mod-wsgi for Apache2

sudo apt-get install libapache2-mod-wsgi
2. Commented code in Apache.conf

The following commented code seems to screw up restarting of apache

WSGISocketPrefix /path/to/socket/sock #must be readable and writable by apache
WSGIPythonHome /usr/local #must be readable by apache
WSGIPythonEggs /var/python/eggs #must be readable and writable by apache
Just get rid of them.

3. WSGI script in documentation

As documented in http://wiki.osqa.net/display/docs/Setting+Up+OSQA+for+Apache

os.environ['DJANGO_SETTINGS_MODULE'|'DJANGO_SETTINGS_MODULE'] = 'osqa.settings'
That pipe screws things up. I'm not exactly familar with python so maybe it's deprecated in Python 2.6? Anyways just get rid of it.

os.environ['DJANGO_SETTINGS_MODULE'] = 'osqa.settings'
4. Table migration

Apparently if you followed the recommendation to use South for migration you'll soon find that it FAILS. Yikes! Search their Q&A (meta) provides an answer.

http://meta.osqa.net/question/111/installation-programmingerror-forum_keyvalue-doesnt-exist

Just do

./manage.py syncdb --all
./manage.py migrate --fake
Hmm...

Sunday, April 11, 2010

Recover deleted branches in Git

Accidentally deleted a branch? No problem. Git reflog to the rescue.

git checkout -b recover_lost_commits

git reflog

e9c17db... HEAD@{0}: checkout: moving from stable to master
e9c17db... HEAD@{1}: checkout: moving from stable to e9c17dbfffd79f2bf30530e144c43c0f47322826^0
318c0f2... HEAD@{2}: checkout: moving from master to stable
e9c17db... HEAD@{3}: commit: Forgot to add images to CSS and adjusted positions.
3baab51... HEAD@{4}: commit: Added new buttons.

git merge e9c17db
Awesomeness.

Wednesday, April 7, 2010

Using minitest for speedier unit tests

sudo gem install minitest # Install MiniTest
sudo gem install minitest_tu_shim # Install Test::Unit shim
sudo use_minitest yes

GOTCHA

If you've freezed rails into a project then trying to script/server will throw the following error.

.../vendor/rails/activesupport/lib/active_support/dependencies.rb:445:in `load_missing_constant': uninitialized constant Test (NameError)