Thursday, July 31, 2008

Do not display initia screen on emacs

To prevent the default GNU message on emacs
add the following line to your .emacs file.

(modify-frame-parameters nil '((wait-for-wm . nil)))

Friday, July 11, 2008

screen command

to switch off the startup message in the screen command,

sudo emacs -nw /etc/screenrc
and uncomment the line,
startup_message off

to enable scroll mode do Ctrl+A and ESC
Press ESC to return to normal mode.

To reattach a screen that is attached else where do:
screen -d

The following commands can be used for navigation purposes. Reference


h -    Move the cursor left by one character
j -    Move the cursor down by one line
k -    Move the cursor up by one line
l -    Move the cursor right by one character
0 -    Move to the beginning of the current line
$ -    Move to the end of the current line.
G -    Moves to the specified line 
       (defaults to the end of the buffer).
C-u -  Scrolls a half page up.
C-b -  Scrolls a full page up.
C-d -  Scrolls a half page down.
C-f -  Scrolls the full page down.
By writing the following line to .screenrc in $HOME you can change number of lines that are stored in the scrolling buffer.

defscrollback 5000

Enable mouse wheel in Ubuntu VMWare guest

If you are using guest Ubuntu under VMware, mouse scroll does not work.
To fix this, open terminal and type the following:
$ sudo gedit /etc/X11/xorg.conf
Then find "InputDevice" section with Identifier "Configured Mouse"
Change Option "Protocol" "ps/2"
to
Option Option "Protocol" "IMPS/2"
Last restart X using Ctrl + Alt + Backspace

create user/grant permission

login as root by....mysql -u root
create user 'username'@'hostname' identified by 'passwd';
create database mydb;
grant all on mydb.* to 'username'@'hostname';

now login as the new user and create table etc in mydb.
mysql -u username -p
enter password

emacs

TRAMP (opening remote files)
Add the followig to .emacs
(require 'tramp) (setq tramp-default-method "scp")

now you can open a remote file like this
/kin:~/re/test.py

Moving to buffers
Next : Ctrl+X+right arrow key
Previous : Ctrl+X+left arrow key

Word wrapping
To toggle the fill mode
M+x auto-fill-mode
If we are in the fill mode then "fill" will appear in the status bar.
At fill mode, line wrapping causes a new line char to be inserted.
(not good, have to reformat)

To format/wrap
M+q (do this on top of text)

Setting the scroll bar on the right
put the following two lines in the .emacs file
(setq scroll-bar-mode-explicit t)
(set-scroll-bar-mode 'right)

Enable backspace
(global-set-key "\C-h" 'backward-delete-char)

Markup/delete/insert
press Ctrl+space to start mark-up a region.
Now move the curser down/up left/right to mark a rectangle.
press Ctrl+x and then r then t now it will turn to
String-rectangle mode. Type what you want to insert

To delete,
markup the rectangle with Ctrl+space and then
Ctrl+x and r k
k is to kill

emacs fonts

To check all availabe font options run, xfontsel from the command line.
You can try diiferent fonts and their options.

One example would be,

(set-frame-font "-adobe-helvetica-*-r-normal-*-14-*-75-75-*-77-*-u")


Add this line to your .emacs file.
To set the geometry of the window (size) add the following line
to ~/.Xresources

Emacs.geometry:31x48

Then run,
xrdb -merge ~/.Xresources

The next time you start emacs, things will be nice!!!

installing/reinstalling/removal

Ubuntu packages: mysql-client-5.0. mysql-server-5.0
starting mysqld service... sudo /etc/init.d/mysqld start

to completely remove mysql do the following.
sudo apt-get --purge remove mysql-client mysql-server-5.0
you will loose all databases!!!

changing the directory in which mysql databases are stored

By default all databases are saved in /var/lib/mysql
Because this is in the root partition you might quickly use up root
partition if you create large databases. If you want to change this
directory to, for example, /home/mysql do the following.

creating the new datadir
sudo mkdir /home/mysql

stop mysql.
sudo /etc/init.d/mysql stop

edit my.cnf (mysql config file)
sudo emacs -nw /etc/mysql/my.cnf

change datadir under [mysqld] from /var/lib/mysql to /home/mysql

edit apparmour (Ubuntu speciality)
sudo emacs -nw /etc/apparmour.d/usr.sbin.mysqld
change lines that contain /var/lib/mysql/ to /home/mysql/

copy the databases to new directory.
sudo mv /var/lib/mysql/* /home/mysql/.

change file ownership (should be owned by user mysql and group mysql)
sudo chown -R /home/mysql

restart apparmour
sudo /etc/init.d/apparmour restart

start mysql
sudo /etc/init.d/mysql start

Continuously monitor GPU usage

 For nvidia GPUs do the follwing: nvidia-smi -l 1