Category: Linux
Colorful grep
grep is a useful little *nix command line utility that makes it easy to search for strings in files. The real beauty comes when you start using it with pipes. One thing that kind of bothered me since I started using it, that it didn’t highlight the string you where searching for in it’s output.
Turns out, this can be accomplished very easily (should really just have reade the man page 😉 ).
Put the following in your shell startup script (/home/flo/.bashrc in my case)
export GREP_OPTIONS='--color=auto'
Now that was simple wasn’t it (though you’ll have to re-log in to make it work or at least spawn another shell process, so the startup file gets sourced) 🙂
But now if you followed my tip and started using pipes like mad, after applying this tip, you’ll quickly encounter that the colors are gone again. To hand over colors to say the often used less program you have to make an alias that hands grep the --color=always option (don’t put this in GREP_OPTIONS it tends to break things!) and call less with the -R option.
Or simpler, just add the following to your shell startup script:
export LESS=-R
alias cgrep='grep --color=always'
Remote controlling computers via Synergy
Yesterday I finally set up my good old iBook as juke box. It now sits on a shelf besides my working table and runs iTunes fullscreen wirelessly connected to the net and the stereo via my AirpotExpress. It’s working perfectly and I am really satisfied with it. The only downside was, that when I wanted to control anything on the iBook I had to reach over there.
I evaluated several different utilities for remote control but wasn’t really satisfied with any of them, then I remembered about Synergy. What it does is best quoted from it’s page:
Synergy lets you easily share a single mouse and keyboard between multiple computers with different operating systems without special hardware. It’s intended for users with multiple computers on their desk since each system uses its own display.
That’s exactly what I was going for and luckily setup was really easy (instructions for Mac OS X).
- Download Synergy from Sourceforge.net
- Unzip the archive and copy the resulting folder wherever you want (“Applications” might be a good idea 😉 )
- Decide on your “Server” (= the computer who’s keyboard and mouse will control all the other machines). On this machine you need to make a file named synergy.conf with the following contents
section: screens
screen1:
screen2:
end
section: links
screen1:
left = screen2
screen2:
right = screen1
end
Substitute screen1 and screen2 with the hostnames of your computers (just punch in hostname in your Terminal and find out). Note that there is no implicit logic in the config file about the placement of the screens. So you have to tell Synergy that screen1 is right of screen2 and the opposite or you won’t be able to leave one of the screens with your mouse.
The provided sample config is pretty well documented so you should be able to figure out the appropriate positioning for your particular set up very easily. - When you’re done with the config, all there’s left to do is start Synergy. Just execute the following in your Terminal.
First on the Server (alter the program path to match your system):
/Applications/Synergy/synergys -c synergy.conf
and then the client(s):
/Applications/Synergy/synergyc screen1
again substitute screen1 with the hostname of your server
If you didn’t make any mistakes in the config file you should be up and running by now and be able to move freely between all of your screens no matter to what machine they are connected.
The best thing about Synergy is that it is cross platform compatible, meaning you can connect Windows, Linux and Mac machines in a similar manner. To know more about the program consult the documentation provided in the installation directory.
UPDATE:
For the lazy, there is even a Mac OS X GUI Programm to do the configuring: SynergyKM 😉
Installing eAccelerator on Debian
This is a quick HowTo for installing the eAccelerator PHP cache/optimizer on a Debian system (should be applicable to other Linux distros as well).
- Download the latest release from SourceForge.net to your server and extract the sources.
- Change to the sources directory and type in the following.
export PHP_PREFIX="/usr"
$PHP_PREFIX/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
This should set up the environment and compile configuration correctly. - Now compile with make and install with make install (as root) afterwards.
- To configure eAccelerator you have to edit your PHP config which resides in /etc/php4/apache2/php.ini on my system.
Add the following lines at the end:extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/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"
The file README in the sources directory gives a pretty good explanation of all those parameters. The only one you should probably alter is the shm.size because 16MB of shared memory might be a little bit too conservative. - Last step is to create the directory where eAccelerator stores the cached scripts which don’t fit into the shared memory.
mkdir /tmp/eaccelerator
chmod 0777 /tmp/eaccelerator
Now you’re done. Further tweaking can be accomplished by altering all the parameters in the php.ini file.