31 December 2008

PHP bcompiler extension

Install necessary prerequisites and PECL extension (replace apt-get with package manager - on suse/fedora use YUM, on gentoo use emerge)

sudo apt-get install php5-dev
sudo apt-get install libbz2-dev
pecl install bcompiler


Add “extension=bcompiler.so” to /etc/php5/apache2/php.ini to activate the extension.

This is how to encode .php files:

<?php
$fh = fopen(“example.phb”, “w”);
bcompiler_write_header($fh);
bcompiler_write_file($fh, “example.php”);
bcompiler_write_footer($fh);
fclose($fh);
?>


Then in your code, update the include to include the .phb file instead.

Installing php eAccelerator

Download and install the latest version of eaccelerator:

wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
tar xjf eaccel*.tar.bz2
cd eaccel*
phpize
./configure
make
make install
cp control.php /var/www/eaccelerator.php

Edit control.php to change the $user and $pw settings.

in your php.ini file, add this:

zend_extension="/usr/lib/php5/20060613+lfs/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/var/cache/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
eaccelerator.allowed_admin_path="/var/www/eaccelerator.php"


Create cache directory:

mkdir /var/cache/eaccelerator
chown www-data:www-data /var/cache/eaccelerator
chmod u=rwx,g=rwx,o= /var/cache/eaccelerator

Restart apache:
/etc/init.d/httpd restart

17 December 2008

Flash and other audio players

If you want to get sound to work simultaneously on flash (in firefox) and other video/audio players (like totem), all you need to do is install the "libflashsupport" package and restart firefox - that's it. I'm sooo happy I found this one - helps so much. After all, even gmail uses flash and ties in the audio so no other media player works properly after that ...

13 November 2008

ALSA record output to file

In ~/.asoundrc


pcm.!default {
type file
slave.pcm {
type plug
slave.pcm {
type hw
card 0
device 0
subdevice -1
}
}
file /dev/shm/audio.raw
format raw
}


Note the file it's been recorded to is in RAM to make things faster.
You can convert the raw audio to mp3 file with the following:

ffmpeg -ac 2 -f s16le -i /dev/shm/audio.raw -acodec mp3 -ab 192k output.mp3

11 November 2008

~/.bashrc

Edit ~/.bashrc

alias l="ls -l"

sudo

Add full permissions to a selected group and set it so it doesn't ask for confirming password.

in /etc/sudoers:


%wheel ALL=(ALL) ALL
%wheel ALL=NOPASSWD: ALL

Log Watch

After installing logwatch, edit the configuration file to set the email to send reports to.

On most standard installs, check
/etc/cron.daily/00-logwatch

And also
/etc/log.d/logwatch.conf


Optionally also install an SMTP replacement to send emails, using an external mail server if sendmail isn't doing the work for you.