Web Dev Blog

Exploring web development and related foobar.

MySQL Backup Script

Here is what I use to make a backup library of MySQL daily that will keep backups for 30 days.

Apache Expires Headers with mod_expires

Quick example of how to set default expires headers. This will help prevent browsers from re-downloading the same images more than once and therefore reduce the load on your image server.

2-Way MySQL Replication

Some notes and commands I want to keep handy the next time I setup MySQL replication.

Inner Resize Browser Window

This JavaScript function will resize the inside of a browser window to the dimensions provided.

Image Cache using phpThumb and Mod_Rewrite

Generate thumbs by visiting a URL such as your.com/thumbs/50x50/images/image.jpg. This will create a 50x50px thumbnail of your.com/images/image.jpg.

The thumb will be stored on your server at your.com/thumbs/50x50/images/image.jpg so the next request for the same image will be loaded without loading php for ultra fast image cache.

Remove Array Nulls

Recursively removes array keys with null values.

Deep In Array

Function similar to in_array() but it recursively searches a multi-depth array.

Deep Array Reverse

Recursively reverses a multi-depth array.

Fully Qualified Domain Name and Base Path

This simple snippet will provide you with a HTTP or HTTPS Fully Qualified Domain Name URL and Base Path to your CakePHP installation. I use it for the HTML base tag.

Slideshow with Pause on Hover in jQuery

I searched and I could not find something similar already out there, so here is a simple slideshow that will pause when you mouseover. With JavaScript disabled only the contents of the div inside the slideshow will be displayed.

Multiple slideshows per page are supported.

Popular Searches Block in Drupal

This php code can be used in a drupal block to display the most popular searches on your site.

How to display a View in a Block in Drupal

If you want to use a view to get the power of pagers but you need it to render in a block then follow this guide.

Display Blocks On Specified Node Types in Drupal

This code snippet will allow you to only display a block on the node types you select. Simply paste into the PHP options.

URL Reader

This function will download the contents of any URL and return it as a string that you can save to a file or database.

It will use curl if it is installed. Otherwise it will use fopen/fread.

How to make a simple form module in Drupal

This example module will provide a form where you can enter your name and upon submission will display your name as a message on the following page. It is very basic but will give you a start to making your first module.

Create a WHM/cPanel Account

This snippet will allow you to create a cPanel account using PHP.

Create a cPanel Subdomain

This snippet will allow you to create a cPanel subdomain using PHP.

Create a cPanel FTP Account

This snippet will allow you to create a cPanel FTP account using PHP.

Create a cPanel Database

This snippet will allow you to create a cPanel database using PHP.

Only display TinyMCE on certain node types in Drupal

This example will show you how to choose which node types use the TinyMCE module.