Archive for October, 2007

Awstats

Monday, October 29th, 2007

In trying to set up external links tracking in Awstats, I inadvertently learned some things about Awstats:
1. /etc/awstats/awstats.mysite.com.conf
This file contains the ExtraSections area.
2. There is an error in the PDF documentations for this section, use their site documentation instead.
3. The stats it produces are actually pretty good (and LIVE).

Is a number, is not a number

Saturday, October 27th, 2007

SQL for is not a number: SELECT * FROM table WHERE country NOT REGEXP(’[0-9]‘)
PHP for starts with a letter: if (preg_match (”/^([A-Z][a-z]+)$/”, $country)) {
}

Just in case, ya know.

And to round out my week of SQL…dates must be in quotes.

Importing CSV into PHPMyAdmin

Tuesday, October 23rd, 2007

Learned a very valuable lesson today…when importing a CSV into PHPMyAdmin, if the CSV was created on a Mac, “Lines terminated by” is \r.

Sed is fun!

Sunday, October 14th, 2007

Jotting down quick notes from a sed tutorial with Jacob…

Did an ls > ../file.txt first, then replaced all spaces with nothing
(while read f; do newf=`echo $f | sed ’s/ //g’`; mv “$f” “$newf”; done;) < ../file.txt

To test first before doing it, can do:
(while read f; do newf=`echo $f | sed ’s/ //g’`; echo mv “$f” “$newf”; done;) < ../file.txt

Take the contents of a file (in this case a list of images) and add the URL to the beginning of each line:
sed ’s/^/http:\/\/www.little-truck.com\//’ <> file2.txt