Cpanel configuration enables you to receive warning when disk space is low. You can instruct cPanel to handle house-keeping duties such as log rotation but this is not a guarantee disk space will not be filled by other activity logs.

I have used the following bash script for years but as disk space is less of a problem I have not needed it for a while so I am posting it here as a reminder for the next time I need it.

To use it paste into a file called duf.sh and change the permissions to allow it to execute.

#!/bin/bash
echo sample usage: /root/duf.sh /usr/\*
du -sk "$@" | sort -n | while read size fname; do for unit in k M G T P E Z Y; do if [ $size -lt 1024 ]; then echo -e "${size}${unit}\t${fname}"; break; fi; size=$((size/1024)); done; done

Run it like this:-

duf.sh /usr/*

And it would return a listing like this:-
how to list linux directories sorted by their size Finding Disk Usage of Linux Sub Directories Sorted By Size

I have the largest folders at the end of the listing to make them easy to find.

 

swfupload makes uploading multiple files a snap and look good at the same time. It can be downloaded from Google Code with examples and implementation takes just a few minutes.

Firefox has a problem with the addPostParam call used to add post parameters dynamically. In normal use this is not important but if you wish to pass extra information with the files such as the name of a group to be associated with the files extra work is needed.

It appears only the second and subsequent calls work correctly, yet making two calls right away has no effect, so this won’t work:-

  swfu.addPostParam('groups',params);
  swfu.addPostParam('groups',params);

Firefox also fails if you change the visibility or display settings for container divs and yet these work ok in IE, so if you wish to hide the upload button until another HTML control is completed (such as a location selection filed or group name) you must move the button off the visible area (such as -1000px to the left) and return it afer a valid selection has been made.

How to bully swfupload to work in Firefox

The solution, found for me by my son an hero Adam, was to ignore the documentation and examples that come with it and load the swfu object only when needed and not to use window.onload. I have a function called updgroupval() that is called by the onclick event of a series of checkboxes, the first time this is called the swfu object is loaded:-

function updgroupval(ctl,id) {
	if(ctl.checked) {
		ctl.value = id;
	} else {
		ctl.value = '';
	}
	var params='';
        //a2s converts array into a csv string
	params = a2s(document.form1.group);
	var button = document.getElementById('SWFUpload_0');
	if(params != '') {
		if(swfu) {
			if(button.style.position == "absolute") {
				button.style.position = 'relative';
				button.style.left='0px';
			}
			swfu.addPostParam('groups',params);
		}else{
			settings.post_params.groups = params; 
                        //Create object
			swfu = new SWFUpload(settings);        
		}
	} else {
		button.style.position = 'absolute';
		button.style.left='-100000px';
 
	}	
}

By creating the object after the page has loaded Firefox and the object manage to communicate with addPostParam in the way described in their documentation. Whether this is just a freak of the versions I am using or total nonsense I don’t care. Now I can demonstrate smooth and stylish uploads in Firefox and IE and Chrome, all versions.

 

PHPMyadmin no longer adds a new host automatically (at least at 1.03am I could not find it) so here’s how it’s done manually:-

GRANT ALL PRIVILEGES ON *.* 
TO root@10.10.161.114 
IDENTIFIED BY 'secretpassword'
WITH GRANT OPTION

The with grant option is dangerous so only provide if absolutely necessary (the user can grant and deny privileges to other users).

 

beatles now feeding on itunes The Beatles.  Now feeding on iTunes

 

Is it possible to power a vehicle faster than the wind using the wind alone? I would have thought that unlikely but take a look at this:-

For the full story see Downwind Noir: The Record

 

The following PHP code repairs databases that show an overhead. Remove the errorlog function if not required.

<?php
$sql = "SHOW TABLE STATUS";
$result = mysql_query($sql) or errorlog( __LINE__."\n\n".mysql_error()."\n\n$sql");
if($result && mysql_num_rows($result)) {
  while($row = mysql_fetch_assoc($result)) {
    if($row['Data_free'] > 0) {
      $sql = "REPAIR TABLE ".$row['Name'].";";
      $repair = mysql_query($sql) or errorlog( __LINE__."\n\n".mysql_error()."\n\n$sql");		
      if($repair) {
        echo "<br /><em>".$row['Name']." succesfully repaired</em>";
      } else {
        echo "<br /><strong>".$row['Name']." error: ".mysql_error()."</strong>";
      }
    }
  }	
}
 
//Stub
function errorlog($msg) { echo $msg; }
 
?>
 

I got stuck today so grabbed my thesaurus (the old fashioned version with words printed on paper) and started digging around for a few alternatives.

I found what I needed, only I don’t think many people would have heard of it so I performed a blog search to see how common it was.

The word is Peripeteia and it means A sudden change of events or reversal of circumstances, especially in literary work and this is Mike Rowe of Dirty Jobs explaining what it means. He also mentions AnagnorisisThe moment of recognition of discovery

If you have a few minutes take this trip with Mike to a sheep farm and you may experience your own anagnorisis!

 

Zdnet found 10 projects Google should kill after the demise of the Wave beta yesterday.

  1. Google Buzz. What was that anyway?
  2. Orkut.  I honestly never visited the site unless by mistake.
  3. Friend Connect.  Not sure I have heard of this either, what was it or will it be?
  4. Google Desktop.  I install and deinstall this regularly.  I love it, I hate it.  I sleep better without it.
  5. Google Base.  Isn’t that where all the chiefs meet?
  6. Google Checkout.  Ahh, now I know about this one, I developed an API for shopping cart software and their API really does suck.  As a consumer I refuse to use them.
  7. Google Toolbar.  I use it and like the way it allows me to click through keywords in searches, and I use the spelligna chhecker.
  8. Google Lattitude.  Don’t they mean attitude?
  9. Google Pack.  Huh?  What do they pack?
  10. Photo Screensaver.  Not another one, surely this is innovation at its thinnest?

toolbarssuck Its Official: Google Apps Suck, heres Zdnets top 10 list Google should kill

 

Are you still surprised when you discover a friend on a new social network?  The number of useful social media sites is growing.  Specialist sites for our interests help keep us focused as opposed to facebook and twitter.

3736525 s 300x200 Six degrees of seperation rapidly becoming threeYou have to be specific to be terrific, as my mentor used to say.  Facebook and Twitter are great just so long as you have a good tool to agrregate the data (sly reference to PalRelay).

I recently joined SoundCloud and managed to get martynwalker as a username.  A couple of days later I was contacted by an old school buddy.

How valuable is that? A school friend not spoken to since 1974 contacted me and we enjoyed a 36 year catchup that we couldn’t hoped to have done without social media.

He found me as I favourited a musician we both like and my username rang a bell (or should that be a triangle?).

 

wiki’s make it easy to edit through the browser. I like everything about them except for two irritating problems.

  • They all look the same
  • They are not easy to customise

Both problems now solved by wikkawiki.

It remains a wiki without the extensive features of the growing groupware solutions such as tikiwiki which are amazing feats of engineering, but only serve to complicate something that is supposed to be easy.

wikkawiki produces excellent documentation, fast.  Setup accounts for your editors then disable login and you remain in control of who gets to edit.

Styling the wiki can be done through CSS plus a header.php and footer.php file. Click here for an example of one with a modified design.

It includes Geshi by default (for colourised code snippets) and you can wirte PHP directly into a page and it will be evaluated at read time.

see http://wikkawiki.org/HomePage for more details.

© 2011 Martyn Walker | Software Architect | Hiker And Hacker Suffusion theme by Sayontan Sinha