Ramblings from MostlyChris

Tech stuff and a bit more

Browsing Posts published in March, 2010

HTML5

No comments

Today I begin my journey with HTML 5. I don't know how far I'll get until I get bored with it, but since it appears to be what we all might be moving to in the near future I am going to get some of it into my brain starting now.

Along with my megacli post, I need to remember how to check drives/RAID on an HP server so here it is.

hpacucli controller slot=1 ld all show

You'll need to replace the slot with the appropriate one for your configuration.

That should do it.

Suppose you would like to send a copy of an incoming email to another account while the email still goes to the original account. You can do this by modifying the .qmail file of the original recipient and adding an entry that looks like the following:

&user@domain.com

On a Plesk server, a full .qmail file with the above changes looks like this:

| true
&user@domain.com
| /usr/bin/deliverquota ./Maildir

Keep in mind that if you do this on a Plesk server, these changes will be overwritten with mchk or upgrades so you will have to take measures to deal with this. I set the files immutable so they can't be changed by Plesk. This causes its own problems so you will have to decide if it is worth it.

I ran into an issue in which I needed to test whether sqlite and the pdo plugin had support for UTF-8. From the documentation, sqlite3 should be able to handle this and other charsets. Further, the pdo should be charset agnostic. The following script should return UTF-8 because of the 'pound' symbol if indeed both items above are true.

<?php
try {
       $dbh = new PDO("sqlite::memory:", "charset=UTF-8");
} catch(PDOException $e) {
    echo $e->getMessage();
}

$sql = "create table t1 (id int, field1 varchar(255))";

try {
    $dbh->exec($sql);
} catch(PDOException $e) {
    echo $dbh->getMessage();
}

$sql = 'insert into t1 (id, field1) values (1, "A bit of text £")';
try {
    $dbh->exec($sql);
} catch(PDOException $e) {
    echo $dbh->getMessage();
}

$sql = 'select field1 from t1 where id=1';
try {
    foreach ($dbh->query($sql) as $row) {
        print "field1: " . $row['field1'] . "\n";
        print "Encoding: " . mb_detect_encoding($row['field1']) . "\n";
    }
} catch(PDOException $e) {
    echo $dbh->getMessage();
}

?>

Output of the above script should look similar to the following:

[rack@186451-db1 ~]$ php test.php
field1: A bit of text £
Encoding: UTF-8

Notice the UTF-8 output due to the pound sign being used in the text string.