Autostart Synergy on Fedora Linux
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 synergy client:
Shell script 1 – startSynergy.sh
#! /bin/sh #Make sure any existing instances are shutdown /usr/bin/killall -9 synergyc sleep 1 #Start synergy - use your own IP /usr/bin/synergyc 192.168.1.13 # 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 – stopSynergy.sh
#! /bin/sh #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):
/path/to/script1/startSynergy.sh
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:
/path/to/script2/stopSynergy.sh
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
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:
/usr/share/pear/data/PhpDocumentor.ini
Find the group [_phpDocumentor_phpfile_exts] and add required suffixes so it looks something like this:
[_phpDocumentor_phpfile_exts] php php3 php4 phtml inc module install
Mount or automount samba share
Works with Fedora 16
From command line:
$ mount -t cifs -o user=lopez,password=mypassword //192.168.1.13/path /mnt/share/mntpoint
If samba folder has a space in the name:
$ mount -t cifs -o user=lopez,password=mypassword //192.168.1.13/"path with spaces" /mnt/share/mntpoint
Automount
edit /etc/fstab and add the following lines:
//192.168.1.13/my\path1 /mnt/share/mountpoint1 cifs user=lopez,password=mypassword,uid=lopez,gid=users 0 0 //192.168.1.13//path\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
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 id_rsa.pub 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 id_rsa.pub will be created in ~/.ssh/
the file id_rsa.pub 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
example:
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:
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
SOLUTION
Increase to 100MB:
Edit mysql config error e.g /etc/my.cfg and add line:
max_allowed_packet=100M
then restart mysql
sudo service mysqld restart
Problem solved!
Rsync examples
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/ remoteuser@remotehost.com:/remote/folder/
Example 2: rsync operation deleting files on the remote side that do not exist on local:
rsync -azv --delete -e ssh /source/path/ remoteuser@remotehost.com:/remote/folder/
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
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
Example:
# .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 fi # User specific aliases and functions alias drush="/home/admin98/drush/drush"
MySql Command line
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
ALTER TABLE `tablename` [MODIFY|ADD] `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
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
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
To revert back:
defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder
OR:
Edit the Finder’s preference file, com.apple.finder.plist , located in your home folder in Users/<YourName>/Library/Preferences/
In plist editor find ’AppleShowAllFiles’ and change the value to TRUE

