Compiling mysql-python on OS X leopard

I’ve just finished trying to install mysql-python on OSX Leopard, and had quite a few problems. This is the procedure that finally ended up working for me. First, download mysql-python from here. Unzip and try to build it : ...

August 18, 2009 · 2 min · Dave Perrett

'Hello World' with Scala and Lift on OSX

Obviously we’re going to need scala before we can do anything useful; the easiest way to install it is via macports . We’re also going to need maven. > sudo port install scala > sudo port install maven2 Scala seems to have moved their repository to github, and the old google code repository no longer works. Assuming you have git installed (if not, there’s an OS X installer here) : ...

August 17, 2009 · 2 min · Dave Perrett

mysql select random row with join

I have a users table and an assets (basically just images) table, and I want to select and display a random asset for each user. I want to show a list of users, with a random thumbnail for each user from their assets. I could do this easily enough in code with multiple queries, but it seemed like a nice challenge to try and find a pure-sql alternative. ...

August 11, 2009 · 2 min · Dave Perrett

Customize the Nginx server header

Unfortunately the only way to change the server header in nginx is to actually recompile it from source. Luckily this is quite easy. First, download the latest version of nginx (0.7.61 at the time of writing) : > wget http://sysoev.ru/nginx/nginx-0.7.61.tar.gz > tar xvzf nginx-0.7.61.tar.gz > cd nginx-0.7.61 ...

August 10, 2009 · 2 min · Dave Perrett

Passing IPs to apache with nginx proxy

When you use nginx to proxy to apache , apache picks up the IP address of your nginx proxy as the client. A consequence of this is that apache log files, and any application running on the apache backend, will all receive the same IP address (for example 127.0.0.1 if apache and nginx are running the same server). Luckily, nginx provides a HTTP X-Forwarded-For header containing the clients real IP address, although apache doesn’t pick it up by default. To allow apache to recognize the original client IP, we need to install the mod_rpaf module. On ubuntu, this is as simple as installing a package : ...

August 10, 2009 · 2 min · Dave Perrett

InnoDB as default MySQL table type

To change the default MySQL table type, edit your my.cnf file (usually /etc/mysql/my.cnf on ubuntu), and add the following line to the [mysqld] section : default-table-type=innodb The resulting config will look something like this : ...

August 9, 2009 · 1 min · Dave Perrett

MySQL table 'is marked as crashed'

I recently had a problem trying to use mysqldump where it was complaining that mysqldump: Got error: 145: Table './recurser/wp_options' is marked as crashed and should be repaired when using LOCK TABLES This corrupted wp_options table actually caused wordpress to think it was a fresh install, and showed the interface to create the admin user to anyone who accessed recurser which is a little scary :) The solution was to go to the actual database directory, and run myisamchk -r on the offending table : ...

June 18, 2009 · 1 min · Dave Perrett

HTTPSHandler error using python 2.5 and GAE on OS X

If you are getting an error complaining that ‘module’ object has no attribute ‘HTTPSHandler’ running python 2.5 on OS X : ...

June 6, 2009 · 1 min · Dave Perrett

Python 2.5 "ImportError: No module named _md5" on OS X

If you are getting an error complaining about missing md5 running python 2.5 on OS X : Traceback (most recent call last): File "<string>", line 1, in <module> File "/Users/dave/Desktop/setuptools-0.6c9-py2.5.egg/setuptools/command/easy_install.py", line 21, in <module> File "/Users/dave/Desktop/setuptools-0.6c9-py2.5.egg/setuptools/package_index.py", line 2, in <module> File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 91, in <module> import hashlib File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/hashlib.py", line 133, in <module> md5 = __get_builtin_constructor('md5') File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/hashlib.py", line 60, in __get_builtin_constructor import _md5 ImportError: No module named _md5 … you need to install py25-hashlib :...

June 6, 2009 · 1 min · Dave Perrett

python 2.5 zipimport.ZipImportError on OS X

If you are getting an error similar to the following trying to run pythin2.5 on OS X : zipimport.ZipImportError: can't decompress data; zlib not available … you need to install py25-zlib : > sudo port install py25-zlib

June 6, 2009 · 1 min · Dave Perrett