Thursday, August 30, 2012

Reducing CPU frequency in UBUNTU

Seems that when installing UBUNTU in some machines. The setting for the CPU will be set for maximum performance. This tends to overheat the machine. One fix for this:

$ sudo [gvim or any text editor] /etc/rc.local

This will open the file and accept modifications to it:

#############################################
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0″ on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
for cpu in /sys/devices/system/cpu/cpu?/cpufreq/scaling_governor; do
echo -n powersave > $ cpu
done

exit 0

#############################################

Add the 3 shaded lines and then reboot.

Friday, August 17, 2012

How to avoid typing a password for the default keyring for wireless after booting Ubuntu every time

After booting an Ubuntu machine, you are asked to unlock the default keyring for some wireless connection, the simple solution to avoid this:

1. Edit the wireless connection (Right-click the "Network Manager" icon on the panel at the top-right corner of the screen and click "Edit Connections.", Click the "Wireless" tab at the top of the Network Connections window, Select the wireless connection by clicking its name in the list, Click the "Edit" button)
2. Click the "Available To All Users" checkbox at the bottom of the connection window.

Unfortunately I didn't find an equally effective solution using the shell commpand prompt. 

(This recipe was found in this web-page: http://thanhsiang.org/faqing/node/117#comment-797) 

Friday, July 20, 2012

Fix X11 Freeze

Sometimes it happens that my UBUNTU Box freezes. Especially after extensive usage of the media. Here are two methods to handle this issue:

1- Going to a different virtual console.

Alt+Ctr+F1 (or F2, .... , F6)

After logging, you can restart the X server using:
$sudo service lightdm restart




P.S: This assumes that your display manager is lightdm (True for ubuntu 12.04). You can check your agent using /etc/X11/default-display-manager


2- If you cannot change to another virtual console, b/c the X server took control of the keyboard. You can try taking the control away from the X server using Sysrq.

Alt+SysRq+r

then try Ctr+Alt+F1.  You can also try Alt+SysRq+k, which kills all programs on the current console.

Finding The Display Manager in UBUNTU

Ubuntu has many display managers. In order to see which one is currently used check the file:

/etc/X11/default-display-manager

Sunday, May 27, 2012

ROOT to skip few columns with TGraph

I often use TGraph and TGraphErrors to make plots from text files with columns of data. Example below:

////////////////////////////////////
TGraphErrors *ProfNch09ATLAS = new TGraphErrors("Data/Profile_Nch_pT_09TeV_Data_ATLAS.dat", "%lg %lg %lg");
/////////////////////////////////

Which reads from the .dat file that has 3 columns of data. the x-value, the y-value, and the error in y-valye. If you need to add a 4th columns, the error in the x-value or the bin size, you can add it to be the 3rd column in your text file and the next file can be read using:

/////////////////////////////////
TGraphErrors("Data/Profile_Nch_pT_09TeV_Data_ATLAS.dat", "%lg %lg %lg %lg");
////////////////////////////////

but what id you had another plot that needs the original file? that is plotting on the the first two columns alongside the fourth. This time you can use the option *

///////////////////////////////
 TGraphErrors("Data/Profile_Nch_pT_09TeV_Data_ATLAS.dat", "%lg %lg %*lg %lg");
///////////////////////////////

For files with a dilemeter different than '/t' and ' ' the 'option' argument need to be used. see http://root.cern.ch/root/html/TGraph.html

Wednesday, February 1, 2012

ROOT to perform a shell command in a macro

You can make a ROOT macro execute another root macro or a shell command using the following line:

gROOT->ProcessLine("!shell_command");
or
gROOT->ProcceLine("ThisRootMacro()");

Don't forget that the macro needs to be uploaded first:
gROOT->LoadMaco(ThisRootMacro.C);

Tuesday, January 10, 2012

Running two separate verions of firefox on linux

In many cases of active web and software usage you might need to run an older version of a web browser. In this case I needed a to run Firefox 8 and I didn't want to remove my current version. here is what to do:

1- Create a separate directory and move to it:
$ mkdir /home/mzakaria/opt/firefox8
$ cd ~/opt/firefox8/

2- go to Mozilla FTP server at ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/. and look up the release you want

3- get the folder using wget:
$ wget ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/8.0/linux-i686/en-US/firefox-8.0.tar.bz2 (I got the one with i686 b/c I am using a 32bit machine, you can check that with the command uname -m; it will give you i686 if it was a 32bit)

4- untar the package:
$ tar xvjf firefox-8.0.tar.bz2

5-  move the unpacked folder to a folder with the name you chose (in case you are bringing more than one release)
$ mv firefox firefox8

6- Each version needs a separate user profile — otherwise, it won’t be possible to run them simultaneously, and worse, it might break the default profile which is used by the system version. For our version:
$ firefox -no-remote -CreateProfile firefox8

7- That's it! change to the folder again and run it:
$ cd firefox8/
$ ./firefox -no-remote -P firefox8

Notice that this will create a completely separate browser, you might want to move some bookmarks or certificates.