Tuesday, November 10, 2009

WordPress Fast thumbnails

I have an idea on how to make fast WordPress thumbnails. There are two methods used inWordPress. One is to use a special custom field that contains the thumbnail name, this requires filling in that field for every item and also uploading the thumbnails for every item.

The second method is to use an add on program like 'TimThumb' that makes thumbnails from the images and then sends the thumbnails to your computer. Your computer then caches them so after the first time they are instantly there. The problem is that it takes time for the web server to shrink the images down so a cache of images is maintained on the server as well.

I have a third solution that works very fast. When pictures are uploaded to WordPress it sets them up with three sizes, large, medium, and small. They are 600x600 pixels, 300x300 pixels, and 150x150 pixels. They are identified by 600x600, 300x300, or 150x150 being added on to the end of the pictures name. You select the size that you want to use for your article.

Now notice that the 150x150 size is 1/16 the total size of the full 600x600 sized image. Why not just select the 150x150 image, send that as the thumbnail and have your browser shrink it to 100x100 or whatever thumbnail size that you want? The images could then be selected totally automatically and sent with very little work by the web page server. All the work would then be done by the user's computer and that would be very little work they would have to do.

The program would find the image reference in the post, then strip off the last 4 characters (usually '.jpg') then add '-150x150' on the end, then put back the last 4 characters. It sounds simple but it is only about 90% successful so far. The problems are that if the image was smaller than 150x150 to begin with then there is no 150x150 image, so it would have to go back to the original image. The next problem is that if you selected the 300x300 image. In that case the last 7 characters would have to be stripped off before the 150x150 was added onto the end.

Sorry the code listing here on BlogSpot is not turning out well. The code goes in the functions as a replacement for get_the_image that uses timthumb. In live testing this code is about 2 times faster using a database of about 500 items. However about 5 % of the thumbnails did not work, so thumbnails had to be manually created and uploaded to fix that problem. One last change fixed problems where the .JPG was capitalized in the uploaded image but was lower case in the thumbnails.





/* For Getting the Image FASTER */



//GET-POST-IMAGE1 quicker than the script by Tim McDaniels







function get_post_image1 ($post_id=0, $width=0, $height=0, $img_script='') {



global $wpdb;



if($post_id > 0) {



$sql = 'SELECT post_content FROM ' . $wpdb->posts . ' WHERE id = ' . $wpdb->escape($post_id);



$row = $wpdb->get_row($sql);



$the_content = $row->post_content;



if(strlen($the_content)) {



preg_match("//", $the_content, $matches);



if(!$matches) {



preg_match("//U", $the_content, $matches); }



$the_image_ext = substr($matches[2],-4);



if ($the_image_ext == ".JPG") { $the_image_ext = ".jpg"; }



$the_image_num = substr($matches[2],-11,-7);



$the_image_src = substr($matches[2],0,-4);



$the_image_150 = $the_image_src . '-150x150' . $the_image_ext;



$the_image_src = substr($matches[2],0,-12);



$the_image_300 = $the_image_src . '-150x150' . $the_image_ext;



$the_image_raw = $matches[2];



if ($the_image_num=="150x" $the_image_num=="300x" $the_image_num=="600x" ) {



$the_image = '';



} else {



$the_image = '';



}



return $the_image;



}



}



}

Here is the code as a gif, but it is too small to read. If someone knows how to post code on blogspot please tell me how.

Tuesday, November 3, 2009

Digital camera evolution

For many years almost all camcorders used VHS tapes. I remember when they were two devices with a big cable that ran between them. Then they made the small VHS camcorders. In those days I do not think I ever owned a camera myself, but I shot about 6 VHS tapes worth of the kids with cameras that I was working on. Then along came YouTube and I bought my first digital camera to make YouTube videos. It was a Sony TRV-250 that I bought on EBay for $50 because it was dead. I fixed it up and used it for some video's but then I bought a Sony TRV-530 for $100 on EBay because it supported analog as well as digital tapes, it has a microphone jack, and worked at lower light levels. I must have shot 30 or 40 video's using that camera. It is on the left in the picture above.

Next I bought some Sony HDR-HC5's on EBay for $250 each. On one of them the tape door jammed because the white magnetic strip theft deterrent was in the way. Another had a steel anti theft cable attached to it, that was easy to remove. They used the mini-DV tape format, and feature a Full HD 1080i 4 mega pixed image sensor. One of them is in the middle of the picture above.

Now I have made another leap forward in camcorder technology, I have bought a Hard drive based Camcorder. It is a Sony DCR-SR82 that I bought on EBay for just under $250. It is on the right in the picture above. I picked this model out because it has the boot for adding a boom microphone, a 1 mega pixel picture, and forward facing built in microphones. Many of the hard drive based models do not have the boot and the built in microphone faces up!

Tuesday, October 27, 2009

5 KV Soda Can Crusher

The 5 KV power supply got a big boost when I won a complete power supply on eBay for $100 including a 5 KV transformer, 100 uf Capacitor and a contactor. There were a lot more parts in there but I did not need them. I rebuilt it and almost split a soda can in half on the first test run. The video is on YouTube under bobdavis321 but I cannot get the link to copy right now. Then I tried to use it again but discovered that the power transformer was shorted and the diode was blown to bits. The problem was that there was no resistor to limit the kickback current.
http://www.youtube.com/watch?v=DocVqsdDQG8
So I rebuilt the power supply using the schematic of the other 5 KV supply. This time I used a resistor to limit the charge current and to protect the diodes during discharge. The schematic is shown below.

To test out the rebuilt power supply I used an apple and then a pumpkin. The apple was soft and mushy but it blew to pieces at 5 KV. The pumpkin did not blow up at all. So I filled it with water and tried again. There was a big bang but the pumpkin survived. After several tries it did split wide open as is seen in the picture below. The video is also on YouTube.
http://www.youtube.com/watch?v=RSYTqCBXRmE

Sunday, October 4, 2009

Gateway T6836 upgrade from Vista to XP

At work we have some almost brand new Gateway T6836 laptops. People tried in vain to use them but because they had Vista on them they were extremely slow, generally useless and quickly virus-ed to death. They told me they could not convert them to XP but that did not stop me! I managed to upgrade them from Vista to XP.To pull this off you will need a USB floppy drive and driver files from Intel or Gateway. During boot up press F10 for boot selection, select the CD ROM, press enter. Then press enter when is says press any key to boot from the CD. Next press F6 when the option to load SCSI drivers comes up.

Here is a step by step sequence;

Download D20258-001-001.exe from Gateway.

Extract it to a folder, then copy it to a floppy disk.

Attach a USB floppy drive to laptop, put an XP CD into the DVD drive.

During the boot process press F10 to select a boot device.

Select the DVD drive from the list and press enter.

When it says 'press any key to boot from CD' press enter again.

Press F6 when Windows XP starts loading to ‘load SCSI drivers'.

When the load the drivers screen comes up press ‘S’ Select the SATA drier from the list (may require trying every driver) The actual driver needed for the T-6836 is called ‘82801HEM/HBM'

Then proceed to install Windows XP as you normally would.

Next you need to find the drivers and put them on a CD or memory sick to install them on the laptop. Below is a picture of my CD with the drivers for the T6836. The first three were not needed. The wireless network and Video driver (The fourth and the seventh files) were from Intel.com. The graphics chip set is 945G. The sound driver was from RealTech I think.




Monday, September 21, 2009

Internet Security

Internet Security - what an oxymoron! I have a favorite quote about the Internet;

Surfing the Internet used to be like going to a library and looking at books, now it is like walking through a minefield.

Something needs to be done about it. If not there will be a backlash as people are scared away from the Internet just as they were scared away from email by all of the garbage that they received.

Here are some of my proposed solutions;

1. Ban Java. Java gives someone the right to download something unto your computer and run it. I do not know how many times have I had to delete all the java files on a computer in order to get someones computer to work again.

2. Close down ISP's that encourage bad sites. Actually they have done this once and hopefully that will slow the pace of all of this garbage.

3. Demand that Microsoft fix its bugs. Putting a computer running Microsoft software on the Internet is asking for it. Servers are totally out of the question. If you must use Microsoft software then at least get a hardware firewall (That is running Linux)! IPCop is a great solution, I wrote about that years ago on my website. Netgear firewall routers are a nice solution too.

Sunday, September 13, 2009

Dell X300 Laptop power problems

As you might know I am a fan of Dell laptop computers. In my experience they hold up the best in the long term. Here is another Dell laptop repair explained. The symptoms were that the laptop would shut off on its own and that it would not charge the battery. After some tinkering it was determined that the problem was in the power jack. So it was disassembled and the motherboard was removed. The power jack is in the back right corner in the picture below.
The power jack has 2 arms that extend back behind the jack. As you can see in the picture below they had become unsoldered from the motherboard. They were re soldered on the top and the bottom side of the motherboard. Then the computer was reassembled and sure enough the battery recharged and the laptop did not shut off on its own anymore.