Pear Code
scp dir / file with spaces

scp user@host:'"/home/user/file with spaces"' .

Python SMTP Debugging Server

python -m smtpd -n -c DebuggingServer localhost:1025

Google chart API (images) doesn’t allow negative values for line chart. Is it a joke?

Adding a startup script in Ubuntu / Debian

Create script in /etc/init.d:

case "$1" in
    start)
        #something here
    ;;
    stop)
        killproc -TERM /usr/local/bin/noip2
    ;;
    *)
        echo "Usage: $0 {start|stop}"
        exit 1
esac
exit 0

Add script to rc.d:

update-rc.d script defaults
Using INSERT IGNORE with MySQL to prevent duplicate key errors

INSERT IGNORE INTO mytable
    (primaryKey, field1, field2)
VALUES
    ('abc', 1, 2),
    ('def', 3, 4),
    ('ghi', 5, 6);

Colorized tail

tailcolor() {
    tail -f -n5000 $1 | perl -pe "s/$2/\e[1;31;43m$&\e[0m/g"
}

Display available memory on Linux / Ubuntu

cat /proc/meminfo

Compare Directories using Diff in Linux

Use this command:

diff -qr --exclude=.svn dir1 dir2|sort

-q = print result only where files are different

-r = recursive

—exclude = use it if something has to be excluded

How to trim non-breaking space in PHP

Use this snippet:

$trim = trim($text, " \xC2\xA0\n\t\r\0\x0B");

\xC2\xA0 is non-breaking space (alt+space in mac os x)

How to create *.tar.gz and *.tar.bz2 files

tar.gz:

$ tar -zcvf archive_name.tar.gz directory_to_compress

tar.bz2:

$ tar -jcvf archive_name.tar.bz2 directory_to_compress