Thursday, April 30, 2009

limits.conf: virtual memory limit

I was setting some limits on CentOS 5.2 with 24GB of RAM. I wanted to set a limit to virtual memory for a process of group of users to be no more than 4GB. Normally, you a user can do this for its own bash session usingulimit -v 4000000I wanted to do the same thing but to as a root (i.e. admin of a server) to a group of users. Such limits can normally be set in /etc/security/limits.conf. There are many limits# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open files
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to
# - rtprio - max realtime priority
However, I could not find anything for virtual memory, nor I could find any info about this in the Internet. Therefore, I used the try-and-see approach. Finally, I found that item "as" (i.e. address space limit (kb)) does this! Therefore I made a limit to a group @somegroup hard as 4000000To check it, I logged in to a server using ssh as a user from the "somegroup" and executed[test@w ~]$ ulimit -a | grep virtual
virtual memory (kbytes, -v) 4000000
This is of course a limit per process of a user from this group, and not limit for a user of a group!

Monday, April 27, 2009

Matlab: mex error: expected expression before '/' token

Few days ago I installed Matlab 2008b on CentOS 5.2, and I wanted to move my programs from Matlab 2007a on Mac X to the Matlab 2008b on CentOS 5.2. There were no problems with that, execpt my mex C files. When I wanted to compile my mex files in the new Matlab I was getting literally hundreds of errorsmy_c.c:653: error: expected expression before '/' token
my_c.c:655: error: expected expression before '/' token
my_c.c:686: error: expected expression before '/' token
my_c.c:688: error: expected expression before '/' token
my_c.c:688: error: expected expression before '/' token
The reason was that in my C files I was using "//" for doing comments, rather than "/* */". By default Matlab 2008b uses ansi standard (i.e. -ansi flag in gcc). The -ansi flag represents ISO C90 (equivalent to flag -std=c89) standard. In this standard there are no "//" for comments. Therefore, I could change all comments in my C files, or compile my C files using -std=c99 flag instead of -ansi flag. In c99 one can use "//" for comments. I choose the second option, and therefore I modified my file.This file contains default options and flags to be used when executing mex command in matlab (i.e. compiling C files). In my case this this was in my home directory, i.e. ~/.matlab/R2008b/ So I opened this file and edit parts for my computer. I had CentOS5.2 x64 bits, so I edited part #----------------------------------------------------------------------------
Specifically, I changed CC='gcc'
CFLAGS=' -std=c99'
With this change I had no more errors regarding "//" comments.


To determine which options in your mex compiler is using, one can just make an error or typo in some options and check if mex will crash or not.

Thursday, April 23, 2009

VirtualBox: 3D acceleration for Ubuntu

I have just installed VirtualBox 2.2 on Mac X 10.4. I also installed latest Ubuntu 9.04 as a guest in the VB. To my surprise, 3D acceleration works! I can enjoy compiz effects (3D cubes or wobbling windows) in VirtualBox. There were absolutely no problems to make it work!

Thursday, April 16, 2009

TYPO3: Enable realURL

By default typo3 uses URLs such as this: index.php?id=45. This is not very useful, it does not look good and is not "search engine friendly". Therefore it would be nice to have of typo3, to do this you need to have RealURL extension installed. As I remember I had no problems installing it, or maybe it is installed by default, I'm not sure. Anyway, although installation of RealURL was easy, it was not so easy to make it work. I was creating some simple site using typo3, and I needed the most simple way to translate my address (e.g. from /index.php?id=45 to /contact/). The manual on the RealURL website is not so easy to understand, and it seems to be not updated (RealURL wiki seems to be better). For example in TypoScript configuration section the manual, it is said that we should set the following variable in TypoScript template recordconfig.baseURL = 1Unfortunately doing this results in an error: Unsupported TypoScript property was found in this template: "config.baseURL="1": The current version of typo3, at the moment of writing this, was 4.2.2!. So it seams this manual was not updated for a while. To solve this, in my case I needed to set this variable toconfig.baseURL =

Threfore, it took me a while to make this simple translation work. So what I did?

First, I made sure that mod_rewrite module was installed and working in my Apache (I had ubuntu-server 8.04 LTS and typo3 4.1.2). How exactly? There is plenty of information how to do this in the Internet, so I will not repeat it. Sorry:-).

Second, I enabled .htaccess in the root of your TYPO3-installation directory that comes with typo3 mv _.htaccess .htaccess

Third, I added config.simulateStaticDocuments = 0
config.baseURL =
config.tx_realurl_enable = 1
to in the TypoScript record. This record is in Template menu for root page of your site three, i.e. With this, if everything is ok, your realURL should already work! For me, it translated addresses from

Forth, the manual says that file typo3conf/localconf.php should be edited for definition of translation rules. But for me it was enough to make aliases for each page to have e.g. "contact" instead of number 45:I did not have to edit localconf.php file. Thought, for more advanced translations probably you have to edit it.

Because I'm not sure whether I modified .htaccess I attach it here. localconf.php is also attached here.

CentOS: Tabulator completion for sudo in bash

To enable so-called tab-completion for sudo users, it is enough to add complete -cf sudo
to your local .bashrc file. It also works for Arch linux. En example is below:[w@localhost ~]$ sudo vnc
vncconfig vncpasswd vncserver

SSH: Strange characters in Midnight Commander

If one tries to login into a linux box using SSH and gets strange characters instead of lines in Midnight Commander (MC), one can try to set an environmental variable LC_ALL to C:export LC_ALL=CFor me, it transformed MC from this: to this: Although there are still some strange characters for scrolls, MC looks considerably better.

The above command can be written in your local .bash_profile file, that you don't have to set it manually every time you login.

Command local can be used to check the state your local character encoding variables. For example [w@localhost rpms]$ locale

Wednesday, April 15, 2009

Gnome: Add menu item

To add a gnome application menu item or so-called "Desktop Entry" the following procedure can be used (I did it in CentOS5.2). Lets assume that we want to add menu item for Octave. First, as a root create file octave.desktop in /usr/share/applications/ with the following contents:[Desktop Entry]
Name=Octave 3
Comment=Octave instead of Matlab
octave.png icon can be created manually. Just find some octave logo imagee, convert it to png of size of 48x48 pixels and place it in folder /usr/share/pixmaps/. Of course it is not necessary, if icon does not exist gnome will not display any icon, only Name.The advantage of this procedure is that menu entry created will be available for every user, not only for root.

Thursday, April 09, 2009

Epiphany: Install Adobe Flash Player

Just download the latest flash player from Adobe site. In my case it was: install_flash_player_10_linux.tar.gz. Unpack the filetar xzvf install_flash_player_10_linux.tar.gzCopy contents of install_flash_player_10_linux folder obtained (i.e. files flashplayer-installer and into /usr/lib/epiphany/2.26/plugins. For me it work. I used Arch Linux. Similar procedure can be used for Firefox (plugins folder is /usr/lib/firefox-3.0/plugins).

Sunday, April 05, 2009

Arch linux: changing gnome logo in Floating Feet screenserver to Arch logo

To change default Gnome Floating Feet screenserer from:
to this:
the following procedure can be used.
First, install archlinux-artwork pacman -S archlinux-artworkThis will install wallpapers, logs and icons of Arch in /usr/share/archlinux. Than edit file footlogo-floaters.desktop
in /usr/share/applications/screensavers: vi /usr/share/applications/screensavers/footlogo-floaters.desktop and change the following line Exec=floaters /usr/share/pixmaps/gnome-logo-white.svgto two lines:#Exec=floaters /usr/share/pixmaps/gnome-logo-white.svg
Exec=floaters /usr/share/archlinux/logos/archlinux-vert-light.svg

Saturday, April 04, 2009

Arch linux: Install adobe flash plugin for firefox 3

To enable flash support in firefox 3.0, the following procedure can be used: First, as a root install flashplugin:pacman -S flashpluginThis command will install flash plugin in /usr/lib/mozilla. Second, to make it work in firefox, just copy plugins folder from /usr/lib/mozilla into /usr/lib/firefox-3.0. In my case plugins folder in /usr/lib/firefox-3.0 did not exist until I had coppied it there.