Category: Programming

Code Snippet: Photo Randomiser

by John Email

This was something I quickly threw together to randomise a folder of photos. Basically you put all your photos in one folder, it then randomly copies them to an output folder with a new file name. This was used for randomising photos for a photo DVD at… more »

Code Snippet: Misc array counting function

by John Email

A friend wanted some simple code to count the number of times each email address in a list used the same domain. more »

Code Snippet: Get a random image from a directory.

by John Email

This can be useful for banner ads. function getRandomImage( ) { $path = ""; // Replace with your path $img_list = array(); $dir = opendir( $path ); // Get all the files in the directory while( $img = readdir($dir) ) { if… more »

Code Snippet: Display PHP settings

by John Email

Code Snippet: Want to see all your PHP settings? Place the following code in an empty .php file on your server Be sure to not leave this on your server once you are done with it as it could show potential security holes. more »

Code Snippet: Make sure a url starts with http://

by John Email

if( strpos($url, 'http://') === false ) $url = 'http://' . $url; Or if you are a fan of single line functions $url = ( strpos($url, 'http://') === false ) ? 'http://' . $url : $url; more »

Install NuSphere PHPED on Ubuntu

by John Email

Download the Linux installer from the NuSphere website ( www.nusphere.com ) $ chmod a+x ./NuSphere-phped-3.3.3evl-Linux.sh $ ./NuSphere-phped-3.3.3evl-Linux.sh If you get an error similar to the following ERROR: The installer was unable to find… more »