Correct cedilla in english keyboard

The layout of my keyboard is “USA Alternative international (former us_intl)”, so it does not has cedilla and other minor differences. Furthermore, even if I set the language to portuguese (br) when I press the combination [acute accent] + [C] it gives me Ć/ć instead of Ç/ç. Since I have to make it every time I format my notebook I automate the file changes using sed, but you can also open and change file using either editor (e.g gedit, kate). The turnaround is showed below:

sudo sed -i 's/wa/wa:en/' /usr/lib/gtk-2.0/2.10.0/immodule-files.d/libgtk2.0-0.immodules
sudo sed -i 's/Ć/Ç/' /usr/share/X11/locale/en_US.UTF-8/Compose
sudo sed -i 's/ć/ç/' /usr/share/X11/locale/en_US.UTF-8/Compose

You should restart gdm after to apply changes.

sudo /etc/init.d/gdm restart

See ya

Advertisements

Building QtOctave 0.8.2 from source

The current version of qtoctave provided by apt-get is 0.8.1. I experience some problems that freeze my qteditor. So I check for a bug and found that there is a newer version, which can have some bug fixes. However, when installing QtOctave I have to turnaround the following issues presented in the QtOctave blog:

1. Include in files below:

sed '1 i #include \' qtoctave_pkg/src/main.cpp
sed '1 i #include \' qtoctave/src/search_dialog.cpp.

2. Change the order of the CMakefileList.txt to:

TARGET_LINK_LIBRARIES(qtjs
${QT_QTUITOOLS_LIBRARY}
${Qt4_LIBRARIES}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTXML_LIBRARY}
#${QT_QTSVG_LIBRARY}
${QT_QTSCRIPT_LIBRARY}

rather than

TARGET_LINK_LIBRARIES(qtjs
${Qt4_LIBRARIES}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTXML_LIBRARY}
#${QT_QTSVG_LIBRARY}
${QT_QTUITOOLS_LIBRARY}
${QT_QTSCRIPT_LIBRARY}

3. Compile cmake in the current directory instead of create a directory build to insteas as is described in readme.

qtoctave-0.8.2$ cmake .
qtoctave-0.8.2$ make
qtoctave-0.8.2$ make install

See ya

Cluster SSH: execute the same command in multiple hosts

The routine of a network administrator include need to apply the same change over multiple hosts, such as install a certain package or setup an application. One alternative is make a script that spread your command in a list of hosts. However, the same command can have different results on different hosts, so it’s useful to follow, in the screen, if it was successful applied. Cluster SSH provide this issue. It can be instaled using apt-get:

sudo apt-get install clusterssh

Following some previews:

See ya

QuickSynergy: share mouse and keyboard among multiple hosts

Hi fellows,

This is a tip that is very useful (grateful to Siqueira!), which seems complicated but is very simple to setup. Synergy provide this issue. Instead of have two monitors plugged on the same video card (what is the first intuition), it considers two (or more) different hosts, in the same network, running different operational system. Basically it configures one as the server, which will has the mouse and keyboard plugged, and others as client. It can be installed by apt-get tools on both sides (client and server):

sudo apt-get install quicksynergy

On client: click on the Share tab, select one of the four location (right, left, above or below) of the client in relation to the server, type the client hostname (not the IP address) and click on Execute.

On server: click on Use tab, type the IP address (the opposite of the server) and click on Execute.

See ya

Versioning with svn, RapidSVN and nautilus context menu

Hi Fellows,

Trying to clean up the mess I test some linux tools to help versioning, instead of renaming files with intuitive names like v1, v2, final-v1 and so. SVN can handle this issue. It maintain the current and historical versions. Despite it be more used to code versioning, it can be applied to any file type. The installation can be made by apt-get tool:

sudo apt-get install subversion

First, let’s introduce some concepts:

  • repository: it manages the version history, saving all states sent (commited) to repository
  • working copy: the current version of the project, a repository copy with some changes

And the basic structure of subversion:

  • trunk: the current version of the working project
  • branchs: used to make a test on the current project without corrupt the current version
  • tags: store the stable versions of the project, such as 1.0, 2.0

So let’s show a simple case study presented in SVN command line Ultimolog blog (portuguese).

# create repository
/tmp# mkdir repository
/tmp# cd repository/ 
/tmp/repository# svnadmin create HelloWorld 
/tmp/repository# ls -lh
/tmp/repository# ls -lh HelloWorld

# create a project directory with the standard directory structure:
/tmp/repository# cd .. 
/tmp# mkdir HelloWord 
/tmp# cd HelloWord 
/tmp/HelloWorld# mkdir trunk 
/tmp/HelloWorld# mkdir branchs 
/tmp/HelloWorld# mkdir tags 
/tmp/HelloWorld# ls -lh 

# write a file on trunk directory:
/tmp/HelloWorld# cd trunk 
/tmp/HelloWorld/trunk# echo ""  > index.php 
/tmp/HelloWorld/trunk# cat index.php 
/tmp/HelloWorld/trunk# ls -lh

# import your working project directory to svn (carefull with the three slashes):
/tmp/HelloWorld/trunk# cd ..
/tmp/HelloWorld# svn import . file:///tmp/repository/HelloWorld/ -m "Importacao Inicial"
/tmp/HelloWorld# ls -lh /tmp/repository/HelloWord/ 

# delete your working project and checkout a working copy from the repository
/tmp/HelloWorld# rm * -r 
/tmp/HelloWorld# svn  checkout  file:///tmp/repository/HelloWorld/trunk   . 
/tmp/HelloWorld# ls -lh

# add a line to file in your working copy, check out the svn status and make a commit 
/tmp/HelloWorld# echo "" >> index.php
/tmp/HelloWorld# cat index.php
/tmp/HelloWorld# svn status
/tmp/HelloWorld# svn commit -m "index.php modificado"

# create a directory, write a file on it, add it to svn and commit:
/tmp/HelloWorld# mkdir cpanel
/tmp/HelloWorld/cpanel# cd cpanel
/tmp/HelloWorld/cpanel# echo "" > cpanel.php
/tmp/HelloWorld/cpanel# cd ..
/tmp/HelloWorld# svn status
/tmp/HelloWorld# svn add cpanel/ 
/tmp/HelloWorld# svn commit -m "+ Diretorio cpanel"

# add a file to this new directory,  check svn status, add the file to svn and commit:
/tmp/HelloWorld# echo "" > cpanel/user.php
/tmp/HelloWorld# svn status
/tmp/HelloWorld# svn add cpanel/user.php
/tmp/HelloWorld# svn commit -m "+ modulo usuario"

# remove "accidentally" a file and check the svn status:
/tmp/HelloWorld# rm cpanel/user.php 
/tmp/HelloWorld# svn status

# update to the previous svn commited version (it will bring user.php back):
/tmp/HelloWorld# svn update

# delete the file user.php on the repository:
/tmp/HelloWorld# svn delete cpanel/user.php
/tmp/HelloWorld# ls cpanel -lh
/tmp/HelloWorld# svn commit -m "- user.php"

# roll back to the repository revision 4:
/tmp/HelloWorld# svn update -r4
/tmp/HelloWorld# ls cpanel -lh

# came back to the current repository revistion (#5):
/tmp/HelloWorld# svn update
/tmp/HelloWorld# ls cpanel/ -lh

# copy file from repository revistion 4 to current version (doesn't work here.. not found error, but I'll follow with the case study):
/tmp/HelloWorld# svn copy -r4 file:///tmp/repository/HelloWorld/trunk/cpanel/user.php cpanel
/tmp/HelloWorld# ls cpanel/ -lh
/tmp/HelloWorld# svn status
/tmp/HelloWorld# svn commit -m "user.php recovered"

# list the content of the tag and trunk repository directory 
/tmp/HelloWorld# svn list file:///tmp/repositorios/HelloWord/tags/
/tmp/HelloWorld# svn list file:///tmp/repositorios/HelloWord/trunk/

# launches the first version (1.0) and list tag repository directory again:
/tmp/HelloWorld# svn copy file:///tmp/repositorios/HelloWord/trunk/ file:///tmp/repositorios/HelloWord/tags/versao1.0 -m "Launch version 1.0"
/tmp/HelloWorld# svn list file:///tmp/repositorios/HelloWord/tags/

# now suppose that this repository is hosted on a server you could make a checkout from other host:
/home/user/temp# mkdir HelloWord
/home/user/temp# cd HelloWord/
/home/user/temp# svn checkout file:///tmp/repositorios/HelloWord/trunk .

This case study explains most of the svn concepts. I’m not sure if it is possible to make a commit without add each directory manually, which could least some time. The RapidSVN could handle this issue. It consists of a front end tool to manage subversion, which allows to commit an entire directory:

Follows a preview of RapidSVN:

Its usage is very simple, you should create a repository manually (svn create on command line), create a working project directory (mkdir projectname), import it to svn (svn import on command line) and after it you could import both repository and working copy to your RapidSVN.

Almost finishing this post I found an interesting tutorial of Department of Electronic System of Denmark, which presents a very simple way to interact with SVN with nautilus context menu on Ubuntu. Follow the provided instructions to install and configure it:

sudo apt-get install nautilus-script-collection-svn
cp -r /usr/share/nautilus-scripts/Subversion ~/.gnome2/nautilus-scripts/

Follow a preview of how it is embedded on Ubuntu:

See more:
1. Portuguese tutorial: http://www.ultimolog.com/2007/05/29/controle-de-versao-com-subversion-svn-rapido-e-pratico/
2. SVN Project: http://subversion.tigris.org
3. Rapid SVN Wiki: http://rapidsvn.com/index.php/OnlineHelp:Contents
4. Graphical SVN: http://doc.es.aau.dk/it_services/30/manage_project_files_using_subversion/graphical_svn_in_ubuntu/

See ya

Create a shared directory in local network using autofs + NFS

Hi fellows,

Use a shared directory is a very useful feature when working on network not only to share files between hosts but also, when executing a distributed program (such as a crawler or a parallel program), to gather all data into a single directory in a given machine. NFS
can handle this issue. It can be installed through apt-get tools:

sudo apt-get install nfs-kernel-server

It creates the file /etc/exports that specifies which filesystems should be exported. Create a directory, add it to exports file and restart nfs server:

hostA# sudo mkdir /share
hostA# sudo echo "/share *(rw,sync)" >> /etc/exports 
hostA# sudo /etc/init.d/nfs-kernel-server restart

To test if it is working you can use mount command with nfs filesystem. So, login on a remote host and mount it manually:

hostB# mkdir /share
hostB# sudo mount -t nfs hostA:/share /share

To avoid need to mount it every time NFS server restart, you can setup NFS client host to mount it “automagically”. One alternative is add it to /etc/fstab to be mounted on startup. Another option, recommeded for secure reasons, is use autofs tool with guest mode (only mount when accessed), which not requires mounting all hosts in /etc/fstab. It also can be installed through apt-get tools:

hostB# sudo apt-get install autofs

The autofs settings are performed by /etc/auto.* files, in the client side. So create a file, for instance, /etc/auto.share, put the base directory to be used to mount all network hosts, add this file to file /etc/auto.master and reload autofs:

hostB# sudo echo "*  -fstype=nfs   &:/share/&" > /etc/auto.share
hostB# sudo echo "/share /etc/auto.share --timeout=30" >> /etc/auto.master
hostB# sudo /etc/init.d/autofs reload

Let’s change the /etc/exports file, in NFS server side, to it export not the base directory but the host directory:

hostA# sudo sed -i "s/share/share\/hostA/" /etc/exports

Now if you change the directory to /share/hostA, in NFS client side, it will try to mount it through NFS on hostB, however it will give a “Permission denied error”. I’m not sure, but I suppose it is due that the /share/hostA is under autofs directory, so the turnaround to it was create a ext3 partition, instead of a directory in / partition (not covered here, some alternatives to manage partitions are fdisk and gparted). And don’t forget to mount it explicitly (regards to logytech support!).

See ya

Meld: diff and merge files

Diff tools are very useful to identify changes in file versions (CVS, subversion). There are some command line tools such as diff and diff3 that compare two or three files, line per line, returning those that present differences. However, in some cases, a visual tool that highlight the differences could be more effective. Meld aims to handle this issue. It can be used not only to compare files but also to compare folders, to find files that exists in one and doesn’t in other. It can be installed through apt-get tools:

sudo apt-get install meld

Take a look on some previews provided by Meld Project:

See ya