Find The Size Of Files And Directories In Linux With The du Command

Friday, June 29, 2012 - 10:16

The du (or 'disk usage') command is a Linux command that can print a list of the files within a directory including their sizes and even summarize this information. It is useful if you want to see how large a group of files is and provides more information about directories than the ls command does.


Sequentially Rename All Image Files In A Directory With PHP

Monday, March 2, 2009 - 12:36

The following function will rename all of the image files in a directory to be sequential. The parameters are the path of the directory that the files are in and the name of a function that will be used to sort the array of files through the PHP usort() function.


Force Sorting Of VARCHAR Data In MySQL

Thursday, September 18, 2008 - 10:05

If you find that you are having trouble sorting data in a VARCHAR column in a MySQL database then you can try the following trick.

Lets say that you had the values 1,200,30,4000 and 5 and that you inserted them into the database in that order. When the following query is run on this data:


Randomise JavaScript Array

Friday, July 4, 2008 - 09:43

Randomising a JavaScript array can be done in one or two ways. The easy way is to create a function that returns a random number and then use the sort() function of the Array object to sort the array by a random value.


Array Sorting Algorithms In PHP

Tuesday, April 1, 2008 - 16:04

There are many ways to sort an array in PHP, the easiest being to use the sort() function built into PHP. This sort function is quick but has it's limitations, especially when sorting things like dates as PHP usually guesses which value is higher than the other and can produce odd results. However, there are plenty of sorting algorithms available than can allow you to sort an array in any way you want.

The simplest of these is called the bubble sort. Here is a function that will sort an array of values using the bubble sort algorithm.