Wednesday, September 22, 2010

PHP website performance tricks

Hi All,
The following are few points that I just wanted to share with you all. These points are the basic that should be kept in mind and will increase site performance. HAPPY CODING

1. Don't use .htaccess
2. Lock all ports down
3. Stop ping
4. Cut Apache modules down to bare minimum required for security
5. Do not install all PHP modules
6. Benchmark code, workaround narrow code, cache everything.
7. If a ... COUNT(*) ... GROUP BY ... is killing you, just don't do it! Add some app layer logic to increment some counter in some PRIMARY KEY table instead and have instant access to your stats.
8. Use shared folders in PHP instead of putting files outside web root
9. Enable APC
10. Enable Memcached
11. Use Redis or something for sessions
12. Careful programming, do not use slow or insecure functions and do not use header variables
13. Do not connect to your db directly in your code
14. Be careful with long standing selects and updating in MyISAM in MySQL. Table locking can occur causing all other selects to queue and pile up until eventually you have server downtime.
15. Normalize your DB up to 3NF
16. how about stopping hot linking, caching, protecting files from being leeched, stopping viewing of directories.
17. If you have to use .htaccess it directly into Apache config
18. Use CDN
19. Use jmeter. It's a graphical server performance testing tool, for both static and dynamic resources (files or CGI, Servlets, Perl scripts).

Wednesday, June 30, 2010

Zoom on image in jquery

You can find nice collections of zoom on image in jquery in the given below url

http://www.professorcloud.com/mainsite/cloud-zoom.htm

http://www.tripwiremagazine.com/2010/02/15-jquery-plugins-to-create-stunning-image-zoom-effects.html

http://www.denbagus.net/jquery-image-zoom-and-tutorial/

Thanks

jqzoom conflicts with jquery

Hi All,

I used jqzoom in one of my sites and found the after using jqzoom the binding facility of jquery was not getting executed. So I tried cloud zoom and its working fine. So if anyone trying to use jqzoom keep in mind that it conflicts with jquery.

And for cloud zoom you can find this in the blow ur.

http://www.professorcloud.com/mainsite/cloud-zoom.htm

Thanks

Jawed

Change image color to sepia,grayscale,b/w

You can change the image color to sepia or b/w or grayscale with the use of GD library and PHP. Here is the sample example.

1.Change Color to Greyscale

//to black and white
if(!file_exists(‘dw-bw.png’)) {
$img = imagecreatefrompng(‘dw-manipulate-me.png’);
imagefilter($img,IMG_FILTER_GRAYSCALE);
imagepng($img,’db-bw.png’);
imagedestroy($img);
}

2. Change Color to B/W

//to negative
if(!file_exists(‘dw-negative.png’)) {
$img = imagecreatefrompng(‘dw-manipulate-me.png’);
imagefilter($img,IMG_FILTER_NEGATE);
imagepng($img,’db-negative.png’);
imagedestroy($img);
}

3. Change Color to Sepia

//to black and white, then sepia
if(!file_exists(‘dw-sepia.png’)) {
$img = imagecreatefrompng(‘dw-manipulate-me.png’);
imagefilter($img,IMG_FILTER_GRAYSCALE);
imagefilter($img,IMG_FILTER_COLORIZE,100,50,0);
imagepng($img,’db-sepia.png’);
imagedestroy($img);
}

Thanks.

Sunday, March 28, 2010

count files in a folder/directory

Hi all,

We can count files in a folder using the following function.
It return the no of files in the directory provided as input argument

function count_files ($dir) {
$count = count(glob($_SERVER['DOCUMENT_ROOT'].$dir . "*")) ;
return $count;
}

thanks
Jawed