Mar 15

Optimize your database!

I was trying to figure out why my website was running slowly, most of all my blog.
Thanks to good-tutorials.com and everyone that like tutorials (I am in the midst of writing another one :-P)
I got as many page views in a month than I got in a whole year!!

At first I thought I had exceeded my bandwidth, but I checked and no I was fine :)
I checked my services, I checked the forums I just couldn’t figure it out!

While I was doing so development for an application at work my boss was looking over the database I was using and he noticed that I had overhead. Now being that I have novice-intermediate experience with development ( I started my Job last year in June) I really didn’t think twice about what that meant.

But I have a lot of it! Apparently when you delete rows and things out of your database regularly, which my spam blocker does everyday, you get an over head… and to get rid of it its like defragging your hard drive.

I had 52Kb of over head total in my DB and that is what was causing my blog to run slowly.

screen_17.jpg
Now I have wp-cache installed and my DB optimized but for those of you who didn’t know
what that was here is how you can remedy that situation and save you the trouble:

If you use PHPMyAdmin:

screen_18.jpg

Click on your database in the left column.
“Check tables that have the over head” and from the drop down menu on the bottom, select optimize table.
Those who want to script it:
<?php
$SQL = "
OPTIMIZE TABLE `table_name` , `table_name2` , `table_name3` ";
mysql_query($SQL);
?>

You can even set up a cron job to run at 12:00AM and clear your overhead.

Hope this helps you all :)

Mar 10

This is the new re-write of the gallery viewer.

I wrote it so if your server has a particular extension installed (GD Library)
will make a thumbnail for the gallery. I also wrote it so that it’s really easy to use and install.

The new version utilizes the Lightbox and the Cycle Plugin. These extensions can be enabled in the config file.
When light box is enabled, your image description will appear under the gallery image.

If your server doesn’t the GD library extension installed or you don’t know what that is, don’t worry.
The gallery is written to operate without it.

The file: Free Gallery Viewer V2

The Demo: Free Gallery Viewer V2 Demo

The Demo Gallery: Free Gallery Viewer Gallery

Installation:

  1. Unzip to a folder of your choice.
  2. Edit your config.php file to your liking (Instructions included in the file).
  3. Upload it to a folder on your server.
  4. Have fun!

Questions or Comments feel free to comment on my blog.

Notes:
This Gallery Viewer uses JQuery so props to my friend John Resig for creating such an amazing JavaScript Library.
This also uses the Cycle plugin that Mike Alsup created to do all transitions or the Lightbox plugin by Leandro Vieira Pinho (depends on what you pick). Image class for GD Library written by me.

Feb 29

Alright I know I haven’t posted in a while. I’ve been working on various projects for clients.
So now that I have completed one of the three projects that I have been working I thought I would
post something.

Free Gallery Viewer.

I was working on a website that needed a gallery and I made this up.
It works free from databases because it uses a serialized array.

Files located in this zip: Gallery Viewer.zip

Demo here: Gallery Viewer Demo

Login:
Username : user
Pass: Password

please no malicious images or I will take it down, thank you.

Installing:

  1. Make sure you have PHP installed on your server.
  2. Unzip the file to a folder on your server you want to have the gallery in.
  3. CHMOD the directory “galleries” to 757. This folder is where your images will be uploaded to.
  4. in the config.php define your user name and password.
  5. go to your your new gallery folder and login.

This Gallery Viewer uses JQuery so props to my friend John Resig for creating such an amazing JavaScript Library.
This also uses the Cycle plugin that Mike Alsup created to do all transitions.

Please feel free to edit this code to your fitting. I created it pretty quickly so I don’t know if it has bugs or not.
Constructive feedback is greatly appreciated.

I release this with no warranty AS IS.

Any questions or comments feel free to comment!

NOTE:

  • I realize that you can only have one person write to the gallery array file at a time, just make sure you don’t have 2 or more users uploading photos.
  • Also I am in the midst of writing a better version that includes GD library functionality so it will resize your photos for you. Currently there is no photo resize available.
  • I am writing a script that will install this for you… but I haven’t yet.
Jan 31

So now I am using php cURL for getting headers and other information for Tech Scraper.
Hopefully it works a little bit better.

I am however experiencing an interesting HTTP 3.01 error through cURL on some pages, so I wrote in some
counters to that and so it still uses file_get_contents($url) if cURL returns an HTTP 3.01 error.

I also split all output into arrays so I could keep track of output and use a statement if I could not return any information.

http://www.x24d.com/tech_scrape/

changes:

$ch = curl_init();
$options = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U;
Windows NT 5.1; en-US; rv:1.8.1.11)
Gecko/20071127 Firefox/2.0.0.11",
CURLOPT_FOLLOWLOCATION => true
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
$AR_info = curl_getinfo($ch);
curl_close($ch);

Jan 29

So I found question on yahoo answers about a page that if you input a url it will come back with the languages and technology it uses.

Instead of looking for the page, I thought, hey that might be an interesting page! I’ll do that.

Thus this mini project was born:
http://www.x24d.com/tech_scrape/

Try it out!

Right now its pretty rough, but it does come up with some good material.
I’ll keep tweaking it and things.

-Ted

Jan 24

So I wrote a quasi-class for a shout box. I say quasi-class mostly because the class is really written for just this application. I have to go back and write it so that it can be expanded a little more. Anyway its free, free to use, free to modify, free to do whatever. Just keep my original creds in the php file?

This shoutbox runs off of PHP 5, if you need a PHP4 version just ask. Also if you have any feedback on what I could make better comment!

config.php file contains some constants that you will need to set to use the application. Try not to move things into different folders. If you do be sure to change the reference directory to the right path.

this is what it looks like:
You can view the admin section
username: admin
password: password

as you can see in the admin section, the e-mail address of the user who commented is visible.


Hope you like it!
I am thinking of writing one with a database connection, because I know if you have 2 people trying to write to the same file at once, it just doesn’t like it.

Resources:
» comment_box.zip