Too many connections in MySQL

July 10th, 2008

To kill them automatically

$result = mysql_query(”SHOW FULL PROCESSLIST”);
while ($row=mysql_fetch_array($result)) {
$process_id=$row[”Id”];
if ($row[”Time”] > 200 ) {
$sql=”KILL $process_id”;
mysql_query($sql);
}
}

Sharpen Image

June 11th, 2008

1. Duplicate image

2. High Pass Filter (Filters - Other - High Pass)

3. Blend mode - Soft Light

4. Select original layer

5. Filters - Sharpen - Unsharp Mask

Redirect 301 domain on no www to a www or vice versa

May 15th, 2008

To forward mysite.com to www.mysite.com, use the following code:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^mysite\.com [nc]

RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]

To forward www.mysite.com to mysite.com, use the following code:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.mysite\.com [nc]

RewriteRule (.*) http://mysite.com/$1 [R=301,L]

Source:

http://ekstreme.com/webmaster/301-redirection.php

 

 

MYSQL Cheat Sheet

May 6th, 2008

Search in true or false mode, no need to index the column.
//Post search words
$search $_GET[’search’];

// remove any code from the search term
$search strip_tags($search);

//escape all data to prevent mysql injection attacks
$search mysql_real_escape_string($search);

SELECT * FROM product WHERE MATCH(product_name) AGAINST(’$search*’ IN BOOLEAN MODE);

Source: http://www.webguideuk.com/tutorials/php/searching-with-php-and-mysql-beyond-like

Connecting to email account on GoDaddy server

April 15th, 2008

Email setup on GoDaddy Simple Control Panel

Use rsync to backing up/mirroring a directory from one server to another server

February 13th, 2008

http://www.scrounge.org/linux/rsync.html

Smooth Edge / Round Edge

February 11th, 2008

1. Select the shape you want to apply (CRTL+left click on the layer of the shape).
2. Add Layer Mask (the icon under layers window with the rectangular shape and circle in it)
3.  Filter > Blur > Gaussian Blur > 4
4. Show layer mask (Alt+left click on the layer mask)
5. Adjust the level to see the edge smooth and round. Image > Adjustments > Level. Move the left and right slider to adjust.
6. Right click on the layer, and Select Apply layer mask.

Password Protect Your Webserver Pages

February 11th, 2008

1. Configure Apache to Allow Access Authorization

Open the httpd.conf usually it locate some where in /etc/httpd/. You’ll see not the first but the second occurance of this text: AllowOverride None. You will need to change it to read AllowOverride AuthConfig.

2. Go to the directory you want to have password protect, and create the .htaccess file with the code below.

AuthName “Login to the Private Area”
AuthType Basic
AuthUserFile /var/www/html/Private/.htpasswd
Require user andrea

OR

<Limit GET POST>
require valid-user
</Limit>

3. Create the .htpasswd file in the same folder by typing the command below (for individual folder protected) OR put it in the not public folder of the webserver (/var/www/html/not_public) for global protect so easier to add/edit user for all sites.

htpasswd -cmb .htpasswd andrea ann2cute

(c-create file, m-force encryption, b-allow to include user and pass immediately)

4. Add additional user

Edit the .htaccess file and add the next username with the space in between.
Example: Require user andrea bradley
Run the command like below to add password.
htpasswd -mb .htpasswd bradley brad4chad

5. Remove user

Edit the .htaccess file and delete the username in there. Save, and run the command to remove the password.
htpasswd -D bradley

6. Reference

htpasswd [-cmdpsD] passwordfile username
htpasswd -b[cmdpsD] passwordfile username password

htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
-c Create a new file.
-n Don’t update file; display results on stdout.
-m Force MD5 encryption of the password.
-d Force CRYPT encryption of the password (default).
-p Do not encrypt the password (plaintext).
-s Force SHA encryption of the password.
-b Use the password from the command line rather than prompting for it.
-D Delete the specified user.

Source: http://www.reallylinux.com
Link: http://www.reallylinux.com/docs/htaccess.shtml

CSS cheat sheet

February 6th, 2008

GREENCulture color reference

PHP cheat sheet

February 6th, 2008

PHP: Exporting Data to Excel

http://www.the-art-of-web.com/php/dataexport/