Blog

  • Changing the USB polling rate

    As standard, Windows will poll USB devices once every 1ms. However, this can cause the issue of laptops unable to enter the C3 processor power-saving state. By increasing the USB polling interval from 1ms to 5ms the processor can enter a C3 power-saving state during its inactivity.

    There are also suggestions that decreasing the polling rate will also save energy generally. I’m not sure.

    But, anyway, until I hear that all of this is some kind of urban myth, I’m willing to give it a try.

    Here’s a couple of scripts (save them with .reg extensions and run them as required) that I rattled off to activate the “idle” (5ms) and also to return to “normal” (1ms)…

    Activate Idle Polling Interval…

    REGEDIT4 
    
    [HKEY_LOCAL_MACHINESystemCurrentControlSetControlClass 
    {36FC9E60-C465-11CF-8056-444553540000}000] 
    "IdleEnable"=dword:00000001

    Deactivate Idle Polling Interval…

    REGEDIT4 
    
    [HKEY_LOCAL_MACHINESystemCurrentControlSetControlClass 
    {36FC9E60-C465-11CF-8056-444553540000}000]
    "IdleEnable"=-

    Or download them from here.

  • Optimize and Backup your MySQL databases

    At the moment I’m juggling 3 MySQL databases. It could very easily be more.

    I usually use phpMyAdmin for backing them up but restrictions on port forwarding has meant I can’t do this whilst at work (and I have a tendency to forget if I leave it until the evening at home). So, I wrote myself a script to do this. And optimize the tables as well.

    An extract of the script is below… mine allows me to choose the database and compression type and then populates the appropriate database fields (username, password, etc) but for generic usage purposes, the script below should be fine for other people to use and build upon.

    if ($compression=="None") {$comp_cmd=""; $comp_ext="sql";}
    if ($compression=="Gzip") {$comp_cmd=" | gzip"; $comp_ext="gzip";}
    if ($compression=="Zip") {$comp_cmd=" | zip"; $comp_ext="zip";}
    
    mysql_connect($host,$user,$password);
    mysql_select_db($database);
    $query="SHOW TABLE STATUS FROM ".$database;
    $result=mysql_query($query);
    $num=mysql_numrows($result);
    $compressed=0;
    $i=0;
    while ($i < $num) {
       $table=mysql_result($result,$i,"Name");
       $gain=mysql_result($result,$i,"Data_free");
       if ($gain!=0) {
           if ($compressed==0) {echo "<br/>Compressing tables...<br/><br/>n";}
           echo "Table ".$table." - ".$gain." bytes gained<br>n";
           $query="OPTIMIZE TABLE ".$table;
           $optimise=mysql_query($query);
           $compressed=$compressed+$gain;
       }
       $i++;
    }
    if ($compressed!=0) {
       echo "<br/>".$compressed." bytes gained in total<br/>";
    } else {
       echo "<br/>No tables were optimised.<br/>";
    }
    $backupFile = "backup/".$name."_".date("Ymd").'.'.$comp_ext;
    $command = "mysqldump --opt --extended-insert --complete-insert --hex-blob
    --host=".$host." --user=".$user." --password='".$password."' ".$database.
    $comp_cmd." > $backupFile";
    exec($command, $ret_arr, $ret_code);
    if ($ret_code==0) {
       echo "<br/>Database backed up: <a href="".$backupFile."">download</a>.n";
    } else {
       echo "<br/>The database could not be backed up - the return code was ".
    $ret_code.".n";
    };

    Before running the above, you need to populate the following fields…

    $database – your MySQL database
    $user – your MySQL username
    $password – your MySQL password
    $host – your MySQL host name
    $name – used to name your backup
    $compression – this is the type of compression you wish to apply and should be either None, Zip or Gzip.

    When run any tables that require optimizing will be, well, optimized and the details output. Finally a backup is made of the database and a link displayed so that you can download it.

    Downloads are placed in a folder named /download, so make sure you add write permissions for this folder. The filename will be xxx_yymmdd, where xxx is the name you specified in $name and yymmdd is the date. Obviously the extension will be based on the type of compression you requested.

    Whilst trying to write this code I came across various scripts and resources which did something similar but often didn’t work (grrr) for one reason or another. In particular, often the backup files are create empty if you have the MySQLdump parameters wrong. One thing you might spot that I’ve worked around – and here’s my tip for the day – is that I’ve placed single quotes around the password. This was because one of my passwords had an ampersand in it and, well, MySQLdump doesn’t like it.

    Enjoy, play and let me know how you get on!

  • Getting Help for my WordPress Plugins

    Since I’ve started writing WordPress plugins, I’ve had a few questions about them.

    These I don’t mind at all and I’m very happy to answer them. However, I’m often limited as to how much help I can give by what details I’m actually sent.

    So, to help out, I’ve immediately implemented an attachment feature on the contact page so that you can send me examples of you code – this attachment feature only allows limited size files and only certain extensions. For code, none of these should cause an issue.

    Let’s assume you’ve tried one of my plugins and it’s not working properly. In that case I’d need the following…

    1. What’s actually happening when you try it? Is any output appearing? Are there any error messages?
    2. Please send me a copy of the file in which you’ve added my code. In most cases this will be sidebar.php.
    3. Lastly, let me know the URL of the page where it’s going wrong, assuming you’ve not turned off the plugin or removed the offending code.

    Send me this and there’s a good chance the return email from myself will have the answer in it!

  • Changing Windows Wallpaper

    On my main PC and at work I use the excellent John’s Background Switcher to randomise my wallpaper and, in the case, of work display different ones across my multi-monitor setup. It works well and, due to the amount of time I’m usually on them, changes regularly throughout the day.

    For my Netbook, however, it’s different. Due to its short bursts of use, changing regularly isn’t so important and, at the same time, I need a program that’s compact and uses as few resources as possible.

    Step forward Craig’s Random Wallpaper Changer. This has no options, no GUI interface. Nothing. You simply drop it into the folder that your wallpapers are stored in and then create a shortcut to it in your Startup folder. It will then randomise your desktop background on startup. And that’s it. It then finishes and uses no more resources.

    It’s a superb idea and I highly recommend it.

  • Useful Netbook Software

    With short battery lives and small resolution screens Netbooks, unlike many other computers on the market, could so with some specific software for their use.

    Now, not all of those I’ve found are specifically designed for Netbooks, but all are relevant. And they’re designed for Windows XP.

    Battery Display

    If your Netbook didn’t come with model-specific battery display then you’ll be left with the rather weak XP default. My favourite options is BatteryBar, although there is also Power Meter Plus.

    CPU Accelerator

    Mz Cpu Accelerator does a simple thing, but it does it well. It increases the priority of the current application that is in use. If, like me, you normally just view one application at a time, such as Firefox, then this work brilliantly.

    Display Improvement

    F.lux is a rather curious utility that makes the colour of your computer’s display adapt to the time of day – warm at night and like sunlight during the day. Obviously this is neither specific to Netbooks nor Laptops in general, but due to the nature of Netbook being used anywhere and everywhere, often on a lap and up-close.

    I run it on my Acer and don’t notice it. But that’s a good thing – tell it to return to normal and you will notice the difference. But otherwise it remains discreet and just does what it says it will.

    Drive Image

    If your hard drive is made by Maxtor or Seagate, then you can download the free DiscWizard software from their site. This is a re-badged version of the, usually chargeable, Acronis True Image software.

    If you have a Maxtor hard drive then they sell the rather more obviously badged Acronis True Image WD Edition.

    USB Boot Disks

    With a lack of CD drives in Netbooks, the ability to boot from USB keys is essential in the case of any problems. UNetbootin will download one of a number of OS’ and install them onto a USB key ready to be booted from. Not only can you choice from their rather long list, but you can also add your own options.

    Performance Booster

    Ahh, if only XP could have the ReadyBoost technology that they use in Vista and Windows 7, where a USB key can be used to increase performance. But you can! eBoostr is an XP equivalent of ReadyBoost. I’ve not tried it myself, but there is a trial to download and it then costs from £13 depending on your requirements.

    Power Management

    Including a battery meter, Notebook Hardware Control allows you to control and modify CPU and battery information on your system. What functionality is available is pretty dependant on your system, but it’s worth giving it a try. But watch out for that huge EULA during installation…

    HotKeyz (added 15/07/2009)

    A wonderfully discrete and compact piece of software, HotKeyz allows you to create shortcut keys for running applications.

    Update: Read more Netbook software recommendations