Wednesday, May 27, 2009

Setting new nice value for a user's processes

To set a new nice value for all processes of a user the renice command can be used. For example to set a nice to 10:sudo renice 10 -u username.

Tuesday, May 26, 2009

Matlab: generate unique ID number

To generate a unique ID number for e.g. a temporary file or seed for random number generator current date/time in milliseconds can be used. I matlab the only command that gives time in milliseconds is datestr with FFF input e.g. datestr(now,'MMSSFFF')

ans =

5139451
datestr(now,'MMSSFFF')

ans =

5140057

UID=datestr(now,'MMSSFFF')

UID =

5214981

Unfortunatly other commands such as cputime or now don't return time in milliseconds, which is not so good.

Sunday, May 24, 2009

CentOS 5: Set a background wallpaper for fluxbox.

To set a background wallpaper for fluxbox in CentOS 5.2 the following command can be used:
fbsetbg -f /usr/share/backgrounds/images/c5-center-2048x1536.jpg or fbsetbg -f /usr/share/backgrounds/images/default.jpg The above commands in my case was executed in xterm in running fluxbox. The CentOS's wallpapers are in usr/share/backgrounds/.

Friday, May 22, 2009

python: simple start with simplejson

JSON (i.e. JavaScript Object Notation) is a popular way of exchanging data in a string format. It can also be used to provide setup parameters for a program. The second option I used to show very basic JSON usage in python with simplejson package. Lets assume that we have a txt file called data.json with the following JSON code:{
"Name": "W",
"Job": "Programmer",
"Movies": ["Star Wars", "Star Trek", "Terminator"],
"Address" : {
"Street": "Some Streat",
"House": 3,
"City": "Some City"
}
}
The above JSON code can be read into python object using load function as followsIn [7]: import simplejson as json
In [8]: f=open("data.json")
In [9]: data=json.load(f)
In [10]: f.close()
In [11]: data
Out[11]:
{'Address': {'House': 3, 'Street': 'Some Streat', 'City': 'Some City'},
'Job': 'Programmer',
'Movies': ['Star Wars', 'Star Trek', 'Terminator'],
'Name': 'W'}
In [12]: print data['Address']['House']
3
In [13]:
That's it:-)

Wednesday, May 20, 2009

Arch Linux: "Create archive" in gnome context menu

"Create archive" option in context menu is provided by Nautilus extenssion called file-roller. To install it in Arch linux it is enough to write (if sudo was installed previusly) sudo pacman -S file-roller With this extension files and folders can be archived, and archve files can be extracted

Thursday, May 14, 2009

Ubuntu 9.04 CD

I got my version of Ubuntu 9.04 on a CD from Canonical. These are the photos.

Monday, May 04, 2009

Matlab 2008b: Execute matlab from python in CentOS 5.2

I have Matlab 2008b running on CentOS 5.2 server. I wanted to be able to execute Matlab commands from python. After a search I found mlabwrap 1.0.1. I decided to install it. On CentOS 5.2 I have python 2.4.3. I also installed numpy 1.0.4 from epel repository. numpy is required to install mlabwrap. To install mlabwrap I fallowed the instructions. Fortunately, I had no problems with the installation.Note: the appearance of the windows in the image is from Mac X because I X forward them from CentOS server.

Sunday, May 03, 2009

Arch Linux: dual monitor

I use gnome 2.26.1 + compiz-fusion on my Archlinux box. I wanted to add a second monitor to it. I have nVidia GeFore FX 5200 card and the following drivers[W@localhost ~]$ pacman -Q | grep nvidia
nvidia-173xx 173.14.18-2
nvidia-173xx-utils 173.14.18-1
I connected one monitor through DVI cable and the second by the VGA cable. I had no problems setting dual screen using nvidia-settings program (it comes with the above drivers). Below are my settings:I also attach a photo of my compiz 3D cube on dual monitor screen. Later I change the monitors to have two, the same one. It can be noticed, that each monitor "is" on a different site of the 3D cube:-)