CartMetrix - Do you know yours?

10/14/2005

Welcome to My Life

A system admin’s life is a sorry one. The only advantage he has over Emergency Room doctors is that malpractice suits are rare. On the other hand, ER doctors never have to deal with patients installing new versions of their own innards!
-Michael O’Brien

Popularity: 13%

Remove CVS and SVN Directories

These two little scripts remove CVS and .svn directories from a full directory tree. I use when preparing a application for release.

remove_cvs.sh

remove_svn.sh

Popularity: 7%

10/13/2005

Play Fetch with Mutt and Maildirs

Mutt defaults to the mbox format. Tell it to use the Maildir format by adding the following to ~/.muttrc

set mbox_type=Maildir

These will set the default folders:

set folder=”~/Maildir/”
set mask=”!^\.[^.]”
set record=”+.Sent”
set postponed=”+.Drafts”

To open a specific Maildir:

mutt -f /full/path/to/Maildir

Popularity: 8%

Nagios and thttpd

Nagios defaults to running check via supplied IP address instead of the hostname. If virtual hosting with thttpd using only the IP address will give 404 because it doesn't make it into the virtual hosting subdirectories. Below is a check command that can be added to the Nagios configuration to correct this.

This should also be good for directly checking the status of Apache virtual hosts instead of just checking the default IP as the Nagios check_http command.

# 'check_vhost' command definition
define command{
command_name check_vhost
command_line $USER1$/check_http -H $HOSTALIAS$
}

Popularity: 12%

10/10/2005

Stop Bandwidth Theives - Lighttpd Style

Previous hotlinking post provided a solution for Apache servers only. Here is one for Lighttpd.

# deny access for all image stealers
$HTTP["referer"] !~ "^($|http://.*\.(domain1\.com|domain2\.com)" {
     url.access-deny = ( ".jpg", ".jpeg", ".png", ".wmv", ".avi", ".mpeg", ".mpg", ".gif" )
}

Replace domain1.com and domain2.com with domains to be allowed as referrers. Modify the list of extension to deny access to.

Popularity: 17%

10/7/2005

Using Subselect Queries in MySQL

As of version 4.1, MySQL supports a more ANSI compliant kit of subqueries. In my case here, allowing a subquery in an IN() clause. MySQL's support for subqueries has historically been non compliant on the SQL standard. Their documentation instead presented ways to reword queries to remove subselects.

In my case, I needed to move hundreds of products in a ZenCart database from one category to another based on common words in the product name. I worked out something like:

UPDATE products_to_categories SET categories_id =CAT_ID_1 WHERE products_id IN (
SELECT d.products_id
FROM products_description d, products_to_categories_temp c
WHERE products_name LIKE  '%<em>SEARCHWORDS</em>%'
AND c.categories_id =CAT_ID_2
)

Where CAT_ID_1 is the category to move the products to, CAT_ID_2 is the category they are currently in and SEARCHWORDS is the common word/phrase in the name of the products to be moved. A creative use of space can help in weeding out unintended selections. Use '% ring%' instead of '%ring%' to prevent selecting a product name with 'bring' in it when what you really are trying to move a bunch or rings (ie. the jewelry type).

Popularity: 32%

« Previous Page Next Page »


damonparker.org is proudly powered by WordPress
Entries (RSS) and Comments (RSS).

copyright © 2002-2008 damonparker.org. all rights reserved.

Close
E-mail It