/kb

personal knowledgebase

Archive for April, 2008

Allow cgi scripts globally

without comments

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

Written by Håvard Grimelid

April 23rd, 2008 at 12:41 pm

Posted in Server

Tagged with , ,

Pydev in Eclipse on Mac

with one comment

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.

Written by Håvard Grimelid

April 23rd, 2008 at 11:23 am

Posted in Editors

Tagged with , , ,

Join tables in MySQL

without comments

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.

Written by Håvard Grimelid

April 21st, 2008 at 9:45 am

Posted in Server

Tagged with ,

grep through several files

without comments

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.

Written by Håvard Grimelid

April 10th, 2008 at 10:13 am

Posted in Shell

Tagged with , , ,

Simple scp script for copying to SSH enabled accounts

without comments

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.

Written by Håvard Grimelid

April 10th, 2008 at 9:37 am

Posted in Scripts

Tagged with , , , ,