Archive for March, 2007|Monthly archive page

document title in title bar of emacs

By default emacs in a graphic environment put in the title bar emacs@computer. It’s not a good things when you use the a graphics environment with more than one instance of emacs and try to search for a specific document (ALT+TAB).

It’s possible to have the document name in the titlebar, just put in your ~/.emacs file

(set 'frame-title-format '(myltiple-frames "%b" ("" "%b")))

apache2, mod_rewrite and Sarge

Enabling mod_rewrite in Debian sarge is quite easy :)

~# cd /etc/apache2/mods-enabled/
/etc/apache2/mods-enabled# ln -s ../mods-available/rewrite.load .
/etc/apache2/mods-enabled# /etc/init.d/apache2 restart

apache2 tuning in Sarge

Originally posted on December 2005 on another blog, here is how I tuned a bit apache2 configuration on Debian Sarge in order to avoid an error message.

If you get this message when apache service starts:

apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

just add to /etc/apache2/apache2.conf file the following declaration

ServerName localhost

restart daemon

nautilus and webdav @ Sarge

Sometimes ago (more or less December 2005) I asked my self how to use webdav via the Nautilus interface. After some searching I moored to davfs.

Actually I’m reporting the experience of two years ago, so something could be changed.

So, this is how I made davfs works on Debian Sarge.

Since 0.2.8 there was debian package for sarge and actually there’s a binary installation that I’ve not tested. If you are using etch (or later) distribution, davfs should come with repositories. So installing should be something simple like

#dpkg -i <pagkage>

or

#aptitude install davfs2

The documentation said (remember I tested it two years ago), that it should be possible to specify and outgoing proxy in ~/.davfs2/davfs2.conf but it didn’t work for me. It seemed that only the /etc/davfs2/davfs2.conf file was ridden.

Inside this last file specify the proxy in the form

proxy proxy.domain.com:port

If you need to specify an authentication you can use the secrets file that must have the permission to 600. In this file you will specify both proxy and webdav authentication.

proxy.domain.com user password
http://davserver/path user password

then in order to mount the remote file system, in /etc/fstab specify

http://davserver/path mountpoint davfs user,noauto,rw 0 0

Now from root it is possible to mount the remote server

#mount <mountpoint>

If you have a pc that is shared by many users, and while the authentication by the configuration in the home directory didn’t work, it is possible to remove them from the secrets file and modify the /etc/fstab as following

http://davserver/path mountpoint davfs user,noauto,rw,askauth 0 0

In this way each person who will mount the remote file system, will be required to input user and password.

In order to allow all allowed user to mount the file system (and not only root), you need to give the 4755 permissions to the /usr/lib/mount.davfs-2.6 file

Server script inside js (javascript) files

I develop web application behind portal architecture. I needed to use some tag libraries provided by the portal, in my case plumtree, inside some functions that are implemented in a .js file.

Inside this type of files, the taglibraries and other kind of server side scripting, wont be interpretated ’cause server will treat these files as simple text files.

The main solution was always the one to include those javascript functions directly inside the jsp file. But I don’t like it.

Search search and search, try try and try, J2EE technology comes in our help.

It’s enough to create a jsp file where inside you’ll define all the needed javascript functions. Actually my file looks like the following

<pt:namespace pt:token="$$TOKEN$$" xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/'/>
function farewell$$TOKEN$$(){
alert("farewell world");
return;
}

The first line is a taglibrary declaration that make every occurency of $$TOKEN$$ to be replaced by the unique indetifier (id) of the running portlet.

The habits to assign the portlet id to the function is given by the needing of avoid function naming collision inside portal pages where there are more than application sharing the same space as they were only a single web page.

Now you need to tell in some way that this jsp file must be seen by the application as a simple js one. Well, let’s go the web.xml file and add a servlet mapping for the just created jsp.

<servlet>
<servlet-name>try</servlet-name>
<display-name>try</display-name>
<jsp-file>/try.jsp</jsp-file>
</servlet>

and tell that it must be seen as javascript file

<servlet-mapping>
<servlet-name>try</servlet-name>
<url-pattern>/js/try.js</url-pattern>
</servlet-mapping>

Then inside the jsp calling the function use the usual javascript to include the js file

<pt:namespace pt:token="$$TOKEN$$" xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/'/>
<script language="javascript" src="js/prova.js"></script>
<a href="javascript: farewell$$TOKEN$$();">click</a>

efax, efax-gtk @ Debian

If you rarely need to send faxes, what is offered by efax and his graphics counter part is enough.

Installation

$sudo aptitude install -P efax efax-gtk
$update-menus

Configuration

These are configuration for the Italian country. Edit the /etc/efax.rc file

and edit the following lines as following

DEV=modem (or your device without /dev/)
FROM="+39 02 123456" (own fax number)
NAME="Name and Surname"
PAGE=a4
TELCVT="sed -e s/+39// -e s/+/00/" (for Italy)
INIT="-iZ -iX3E&D2S7=120 -i&C0" (modem initialization string)
SPKR="-iM1L0"

Now try to send a fax

$echo "fax try" > fax.txt
$fax send -v $FAX_NUMBER fax.txt

efax-gtk configuration

For this application I preferred to set some paramters in the /etc/efax-gtkrc file and the each user can custom the behaviours via the graphical interface.

Edit the /etc/efax-gtkrc file and use these lines

NAME: Name and Surname (I've used the computer name)
NUMBER: +39 02 1234 5678 (fax number)
DEVICE: modem
PAGE: a4
INIT: Z X3E&D2S7=120 &C0 M1L0

Once the parameters are setted it should be possible to send fax with the graphical interface. Just select the file to send (only accept postscript file), input the phone number and use the send fax button.

If you need to customize your settings, you can do it with the File->Settings menu.

It’s possible to get off the switchboard. If for example the “key to exit” is 0, and the number to dial is 02123456 then the number to pass to efax will be 0,02123456.

More informations are availble (italian) on the appunti and it.tldp

Websphere cell variables

It happened to me the needing of retrieving via java, in a Websphere 5.1 server, a string variable defined at a “cell level”.

After some research, I found that the variable have to be defined in the following path (Websphere admin console): admin console -> environment -> naming -> name space bindings and then it can be retrieved by the following java code

String s = (new InitialContext()).lookup("thisNode/cell/legacyRoot/variablename");

What I thought the first time: define the variable in admin console -> environment -> manage websphere variables, is not working because the variables here defined, are only for administrative purpose and can’t be seen by the jvm.

Another way to make a variable available for all the applications is to define it directly on the jvm command line and then retrieve it by the System.getProperty(). But if you have more than one server, it’s too expensive to maintain, because you will have to define it for each server.

Apache and PHP on Sarge

Originally posted on December 1st, 2005 on another blog, here is how I installed apache and php on a Debian Sarge.

#aptitude install libapache2-mod-php4 apache2-doc

first of all let’s fix the apache2 documentation. Go to the /var/www directory and link to the documentation

#cd /var/www
#ln -s /usr/share/doc/apache2-doc/manual .

Let’s now configure the ports and who can access the service. If you want to enable only lo interface (localhost) to access the apache services just edit the /etc/apache2/ports.conf file make it looks something similar to

Listen 127.0.0.1:80

If you want to leave free access to everybody, just put a line like the following

Listen 80

or desired port.

Let’s restart the service

#/etc/init.d/apache2 restart

If you want to remove the auto startup of the daemon, so

#update-rc.d -f apache2 remove

easy as drinking a glass of water :)

Cadaver and Sitecopy on Cygwin

On job I’m forced to use windows as operating system, but I can’t give up to the bash power, so I always install cygwin.

Now I need to use both cadaver and sitecopy. I tried the binary version of the first one but it didn’t work on my bash, so I compiled both of them from scratch. Here is how.

Install the make, gcc-g++ and gettext package from the cygwin installer.

Cadaver

Download the latest sources and expand the archive in /usr/local/src (create the directory if not exists). Then execute

./configure && make && make install

Configuration

The only configuration I used for cadaver is the proxy settings for the company in which I’m working.

Edit the ~/.cadaverrc file (create if not exists) and insert the lines

set proxy proxy.company.com
set proxy-port 3128

Sitecopy

Download the latest sources and expand the archive in /usr/local/src, then execute

./configure && make && make install

Configuration

The sitecopy configuration is a bit complex but not too much I used something like the following

site YOURSITE
server YOUR.HOSTNAME.COM
protocol http
#uncomment if needed http noexpect
username YOURUSERNAME
password YOURPASSWORD
remote /davhome
local "/path/to/your/site/directory/"
permissions ignore
symlinks ignore
exclude *.bak
exclude *~
exclude "#*#"
exclude hs~*.html
exclude hs~*.php
exclude *.jbf
exclude *.swp
ascii *.php
ascii *.php3
ascii *.inc
ascii *.html
ascii *.htm
ascii *.pl
ascii *.js
proxy-server proxy.company.com
proxy-port 3128

Emacs, Windows and Ispell

While installing emacs for windows is easy (just unzip the archive and add the bin path to %PATH%), installing ispell is a bit tricky.

Before proceeding remember to add the HOME environment variable for your user. In this way emacs will search for .emacs, dictionaries and other files in there. In my case I used the C:\Documents and Settings\myuser as home. Otherwise it will search for files in C:\.

Now assuming you have emacs up and running, let’s install ispell.

Following what I’ve found in the Learning GNU Emacs book, let’s download the windows binary of ispell. Unzip the archive.

Move ispell.exe into the emacs’ bin directory and move english.hash into your %HOME%. Also copy this file as american.hash.

Now run emacs, open a buffer in text mode, type something in correct english and something not, and try ispell by M-x ispell-buffer. You should get ispell asking you what to do.

If everything is fine, let’s install the Italian dictionary. Obviously if you wont type anything in Italian, you wont need this feature.

Download the Italian dictionary, and extract the archive. Now download another version of ispell for windows and extract the zip.

Now copy the italian.words and italian.aff from the italian dictionary directory into the bin directory of the last ispell downloaded. Now from that directory give the command

C:\...\bin>BUILDHAS.EXE italian.words italian.aff italian.hash

and copy the italian.hash created file into your %HOME%.

For toggling automatically ispell into italian, see my .emacs file.

Next Page »