Sunday, September 7, 2008

Adding BTNX

There are two ways to get the repository configured: the GUI way and the command line way. I think the command line way is a little quicker, but I’ll give you both. Remember, if you are not running Hardy, you will need to change all instances of hardy throughout these instructions to feisty or gutsy, whichever you are using. Olli did packages for all three versions. If you don’t know which you’re running, go to System > About Ubuntu and read the window that spawns. Your version will be in there somewhere.

First the command line way.

echo -e "deb http://ppa.launchpad.net/daou/ubuntu hardy main\ndeb-src http://ppa.launchpad.net/daou/ubuntu hardy main" | sudo tee /etc/apt/sources.list.d/btnx.list
sudo apt-get update && sudo apt-get install btnx btnx-config

Then, I’d recommend using btnx-config from Applications > System Tools > btnx to configure the tool. You could also do gksu btnx-config at the command line to bring it up.

Next, the GUI way.

If you already have btnx installed, go to System > Administration > Software Sources. Go to the Third Party Software tab. Click +Add and paste the line for each of the two APT lines: deb http://ppa.launchpad.net/daou/ubuntu hardy main and deb-src http://ppa.launchpad.net/daou/ubuntu hardy main. When you click Close, it will ask if you want to reload the sources. Confirm the reload.

If you do not already have btnx installed, go to System > Administration > Synaptic Package Manager. Go to Settings > Repositories and follow the above instructions. One the list finishes reloading, Search for “btnx” and the two packages will be shown in the main screen. Click each to mark it for installation, then click Apply. When it’s finished, you can access btnx-config through Applications > System Tools > btnx from the top panel.

Friday, September 5, 2008

The Daily Newscaster story Secret Service confiscates books, buttons from Ron Paul delegates should piss you of beyond all comprehension. After reading that story, you should be so livid that you could Hulk out and start flipping tables in a manner that Jesus would appreciate.

It shouldn’t matter if you are a Democrat, a Republican, a Libertarian, a Constitutionalist, a Green, or any other party. It shouldn’t matter if you are a capitalist, socialist, communist, constitutional monarchist, or anarchist.

The sneaky confiscation of materials from any delegate to a party convention—especially a federally recognized and federally funded convention—is an abomination and every single member of the party, and any competing party, should be up-in-arms and condemning of such illicit behavior.

This isn’t the Republican party I for which I signed up, and if you’re reading my blog and you’re a Republican, I’m sure it isn’t the party for which you signed up, either.

If it is, leave the party. Go start your own neo-conservative party based around the principles of censorship, control, and centrist propaganda. Better yet, leave the U.S. and go back to from whence you came. I don’t want you here and you are probably not my friend.

I’m taking my party back, and if there is no one with me, I’m gone.

Monday, September 1, 2008

Performance of my PHP stddev implementation versus PECL

Yesterday, I showed my implentation of Don Knuth’s on-line standard deviation implementation.

Today, I have for you, my interested reader, the results of a quick benchmark on my code versus the PECL stats package.

Here’s the script for the benchmark:


function stddev($array){
//Don Knuth is the $deity of algorithms
//http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#III._On-line_algorithm
$n = 0;
$mean = 0;
$M2 = 0;
foreach($array as $x){
$n++;
$delta = $x - $mean;
$mean = $mean + $delta/$n;
$M2 = $M2 + $delta*($x - $mean);
}
$variance = $M2/$n;
return sqrt($variance);
}

function mt($precision=4){ return round(microtime(true),$precision); }
function echodiff($start,$end){ echo ($end - $start) . " μs to execute\n"; }

//first, let's prepare a set of arrays.
mt_srand();
//four arrays on different orders of magnitude
$array10 = array();
$array100 = array();
$array1000 = array();
$array10000 = array();
$array100000 = array();
$array1000000 = array();

for($i=0;$i<10;$i++) $array10[] = mt_rand(0, 100);
for($i=0;$i<100;$i++) $array100[] = mt_rand(0, 100);
for($i=0;$i<1000;$i++) $array1000[] = mt_rand(0, 100);
for($i=0;$i<10000;$i++) $array10000[] = mt_rand(0, 100);
for($i=0;$i<100000;$i++) $array100000[] = mt_rand(0, 100);
for($i=0;$i<1000000;$i++) $array1000000[] = mt_rand(0, 100);

$ars = array($array10, $array100, $array1000, $array10000, $array100000, $array1000000);
foreach($ars as $ar){
echo "Trial of " . count($ar) . " elements.\n";
$mine_start = mt();
$mine_out = stddev($ar);
$mine_end = mt();
echo "Mine: ";
echodiff($mine_start, $mine_end);
$php_start = mt();
$php_out = stats_standard_deviation($ar);
$php_end = mt();
echo "PHP/PECL: ";
echodiff($php_start, $php_end);
}
?>

These are the results on my machine, an Athlon X2 6000+ with the max memory size in php.ini set to 2048M.

[colin@rahab Source]$ php stddev.php
Trial of 10 elements.
Mine: 9.98973846436E-5 μs to execute
PHP/PECL: 0 μs to execute
Trial of 100 elements.
Mine: 0.000200033187866 μs to execute
PHP/PECL: 0 μs to execute
Trial of 1000 elements.
Mine: 0.0019998550415 μs to execute
PHP/PECL: 0.000200033187866 μs to execute
Trial of 10000 elements.
Mine: 0.0218000411987 μs to execute
PHP/PECL: 0.00450015068054 μs to execute
Trial of 100000 elements.
Mine: 0.216400146484 μs to execute
PHP/PECL: 0.042799949646 μs to execute
Trial of 1000000 elements.
Mine: 1.13669991493 μs to execute
PHP/PECL: 0.213500022888 μs to execute

Approximately .8 μs isn’t much, but it could be higher if the dataset it much higher and the calculation is repeated several hundred times. Regardless, it shows that you should probably take the time to simply install PECL stats and use it instead of trying to roll your own.

Sunday, August 10, 2008

Cleaning my Cooler Master Cosmos S

The side panel of the Cooler Master Cosmos S PC case has a 200 mm fan and a grating which covers the entire side. The grating is hard, and protects the fan from damage. Inside the grating, though is a lighter mesh which prevents dust from being sucked in by the fan.

This design keeps dust out while providing an enormous amount of cooling for the entire motherboard.

However, cleaning it is annoying. One must unscrew the inner mesh and its panel, then pop the panel out of a number of tabs. Once that’s open, one can carefully clean it. It took me approximately 20 minutes to clean it.

Check out the picture for the amount of dust which had accumulated since mid-March when I reviewed it for ThinkComputers.