Archive for April, 2008
Allow cgi scripts globally
I run Apache on my Macbook and want to be able to run my cgi scripts from everywhere. All directories I want to access are symlinked from the DocumentRoot (/Library/WebServer/Documents) and the only thing necessary is to add the following directive for this section in httpd.conf:
Options ExecCGI
Pydev in Eclipse on Mac
You will be asked to specify the where Python interpreter is located:
Please configure a Python or Jython interpreter in Window -> Preferences -> PyDev
before creating a new Pydev project
- Press Apple key and , (Preferences) and browse to the Python Interpreters submenu
- Choose New in the upper right and browse to /usr/bin/python
- Eclipse will then take care of the rest for you – ie. updating the $PYTHONPATH
NOTE: I use Eclipse 3.3.2 on Mac OS 10.5.2.
Reference: On Using Pydev on a Mac.
Join tables in MySQL
Join three tables (shows, bands, locations) in MySQL:
select * from shows left join (bands, locations) ON (bands.id = shows.band_id and locations.id = shows.location_id);
For further information see MySQL Reference manual 12.2.7.1. JOIN Syntax.
grep through several files
By adding option -H to the grep command, the filename will be output together with the matching line:
grep -i -H TEXT_TO_SEARCH_FOR
-i turns on ignore case.
Simple scp script for copying to SSH enabled accounts
I frequently use scp to copy files to shell accounts. It’s quite annoying to type the full account info each time, so by writing a very small and very simple shell script some typing can be saved:
#!/bin/bash scp -r "$1" login@server.domain.com:$2
The script copies file $1 to the destination $2 on the server. With -r option directories are copied as well. The “” are for taking care of file/directory names with spaces in.