Autostart Synergy on Fedora Linux

Category: Note to Self

Synergy is a really useful piece of open source software that lets me share a single keyboard and mouse between multiple computers on my desk.

In my work environment my  Mac acts as ‘server’ (because this machine is rarely switched off) which shares its keyboard and mouse with my Linux development machine. Getting the synergy client to start automatically on the Linux box took me a while to work out, this is how I finally got it to work.

This works for me with Fedora 16 & KDE Desktop and is based on the info found here

I use 2 shell scripts to handle starting and stopping of the synergy client:

Shell script 1 –

#Make sure any existing instances are shutdown
/usr/bin/killall -9 synergyc
sleep 1
#Start synergy - use your own IP
# This fixes a bug with synergy that causes @ to display as omega symbol
xmodmap -e "keycode 24 = q Q at at at at"

Shell script 2 –

#Stop synergy
/usr/bin/killall -9 synergyc

1. To have synergy startup after system boot, edit file /etc/gdm/Init/Default and add the line near bottom (before exit):


2. After logging in, we should kill the current instance of synergy because it as running as root – to do this, edit (or create) file /etc/gdm/PostLogin/Default and add the line:


3. To start synergy after user has logged in place script 1 (or a symlink to it) in folder ~/.kde/Autostart

4. To have synergy stop once the user has logged out of a KDE session, place script 2 (or a symlink to it) in folder ~/.kde/shutdown

How to make phpdocumentor recognise non-php file extensions

Category: Note to Self, PHP

(Update 17 Dec 2012: This post relates to PhpDocumentor version 1. Version 2 is now out and allows configuration on a per-project basis, see comments below)

I use  phpdocumentor to generate documentation for my custom PHP projects, but by default it will only process files with the standard file extensions (.php, .phtml .inc etc). However Drupal makes use of  non-standard extensions .install and .module. Phpdocumentor needs to be told this.

To do that, edit  phpDocumentor.ini. On my Fedora system it is located:


Find  the group [_phpDocumentor_phpfile_exts] and add required suffixes so it looks something like this:


Mount or automount samba share

Category: Note to Self

Works with Fedora 16

From command line:

$ mount -t cifs -o user=lopez,password=mypassword  // /mnt/share/mntpoint

If samba folder has a space in the name:

$ mount -t cifs -o user=lopez,password=mypassword  //"path with spaces" /mnt/share/mntpoint


edit /etc/fstab and add the following lines:

//\path1 /mnt/share/mountpoint1  cifs  user=lopez,password=mypassword,uid=lopez,gid=users 0 0
//\040space /mnt/share/mountpoint2  cifs  user=lopez,password=mypassword,uid=lopez,gid=users 0 0

(note use of \040 to escape space in fstab, rather than surrounding quotes used in command line)

Generate SSH key

Category: Note to Self

To allow SSH login without password need to generate keys.

To login in via SSH to a remote server

1. On local machine check for a folder  ~/.ssh and check if files id_rsa and exist

if files do exist  then go to step 3

2. Generate public and private keys if required:

ssh-keygen -t rsa
 (no passkey)

two files –  id_rsa and will be created in ~/.ssh/

the file contains is your public key.

3.  Log on to Remote server  and locate/create folder  ~/.ssh
if necessary create a file in this folder called authorized_keys and copy the contents of the public key  (from local machine) into it.

You should now be able to log in to remote machine without a password


perform rsync operation from local machine  to remote server  soyuz

rsync -avz -e ssh /source/path/  remote_user@soyuz:/remote/folder/

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away:

Category: Note to Self

This error started to happen on a Drupal site I was developing on my development  machine (Fedora)

It’s apparently a problem with the ‘maximum allowed packets’ size in the Mysql configuration

To check the default value:

mysqladmin variables

Look at the value of max_allowed_packet, on my system the default is 1MB


Increase to 100MB:

Edit mysql config error e.g  /etc/my.cfg and add  line:


then restart mysql

sudo service mysqld restart

Problem solved!

Rsync examples

Category: Note to Self

To rsync between 2 hosts you should have a public key to allow password-free login

Example 1: Copy all files to remote folder

rsync -avz -e ssh /source/path/

Example 2:  rsync operation deleting files on the remote side that do not exist on local:

rsync -azv --delete -e ssh /source/path/

Example 3:  exclude specified files from operation

rsync -azv --delete -e --exclude 'Thumbs.db' --exclude '.DS_Store' /source/path/ /destination/folder/

Drush – Getting remote sessions to work

Category: Note to Self

Getting Drush remote sessions working between development machine and hosting

By default aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set:

On remotely hosted server (Staging Server)

 edit ~.bashrc


# .bashrc
# aliases not usually expanded in non interactive shells, so fix this:
shopt -s expand_aliases
# Source global definitions
if [ -f /etc/bashrc ]; then
  . /etc/bashrc
# User specific aliases and functions
alias drush="/home/admin98/drush/drush"

MySql Command line

Category: Note to Self

To import database file into a blank mysql database:

mysql -u[Username] -p [dbname] < dbname.sql

backup your db as dbname.sql in your current directory.

mysqldump [options] db_name [tables] > db_name.sql
mysqldump [options] --databases DB1 [DB2 DB3...] > db_name.sql
mysqldump [options] --all-databases > db_name.sql

If you don’t name any tables or use the –databases or –all-databases option, entire databases will be dumped.

Connecting to the database

mysql -u [username] -p [databasename]

MySql Snippets

Perform global search and replace of partial text

 UPDATE `tablename` SET `column` = REPLACE( COLUMN, 'searchstring', 'replacestring' );

Set timestamp to current and update on db update


Query for next and previous records in table

e.g return the id of the next record, sorted by title

SELECT id, title FROM my_table WHERE title > (SELECT title FROM my_table WHERE id = my_id) ORDER BY title ASC LIMIT 1

and previous record:

SELECT id , title FROM my_table WHERE title < (SELECT my_table FROM my_table WHERE id  = my_id)  ORDER BY title DESC LIMIT 1

Show Hidden Files in OSX finder

Category: Note to Self
defaults write AppleShowAllFiles TRUE
killall Finder

To revert back:

defaults write AppleShowAllFiles FALSE
killall Finder


Edit the Finder’s preference file, , located in your home folder in Users/<YourName>/Library/Preferences/

In plist editor find  ‘AppleShowAllFiles’ and change the value to TRUE