Friday, December 19, 2008

installing caml on ubuntu

download source from
http://caml.inria.fr/download.en.html
Gzipped file. decompress using tar xzvf
do ./configure
test with make world and make opt
install by
sudo make install

#if you want to install/compile MEGA
edit WITHCLIBS variable in Makefile and set this to /usr/lib/ocaml/3.10.0/caml
(replace with your version of caml)

Monday, November 24, 2008

Microsoft Outlook Web Access

Sometimes you might find that the Navigation pane in Outlook Web Access (OWA) does not get displayed. The reason for this is that, OWA uses panes and you made a bookmark to a frame (probably the frame that shows the inbox) instead to the full page. Delete the bookmark you currently has for OWA and log in again. Now create a new bookmark. Enjoy!

Thursday, October 30, 2008

SAMBA Ubuntu Putty Windows Xp Tunneling Map Drive!

The objective is to access Ubuntu server from Windows Xp over internet using SSH!

To achieve this goal, this post describes the following:

1. How to install/configure SAMBA on Ubuntu (file server)
2. How to install/configure a network adapater on windows (Windows connection)
3. How to install/configure Putty (SSH agent)
4. How to Map a network drive (Mapping a network drive)

Installing SAMBA on Ubuntu
sudo apt-get update
sudo apt-get install samba

sudo emacs -nw /etc/samba/smb.conf [open config file]
set the following line.
browsable = yes
writeable = yes

restart samba
sudo /etc/init.d/samba reload

share a folder.
right click the folder in nautilus and select "share options"...share over windows networks (SMB)

see this video and this site

Install a loopback network adapter

A loopback network adapter is kind of a “virtual network adapter”: it acts as a normal network adapter, but you don’t have to install any physical hardware to use it. It is only usable on the PC it’s installed on (other PCs can’t connect to it).

  1. Go to Control Panel - Add Hardware
  2. Click Next, then wait a while, choose “Yes, I have already connected to the hardware” and Next again.
  3. Choose the last option, “Add a new hardware device”, click Next.
  4. Choose “Install the hardware that I manually select from a list (Advanced)”, click Next.
  5. Choose “Network adapters”, click Next.
  6. Choose Microsoft, “Microsoft Loopback Adapter”, click Next and Next again.
  7. Click Finish.

Configure the Microsoft Loopback Adapter

Since the loopback adapter won’t have a DHCP server to ask for an IP address, we need to configure an IP address manually.

  1. Right click on “My Network Places” (on your desktop or in your Start Menu), click Properties.
  2. Find the network connection that is associated with the “Microsoft Loopback Adapter”. Usually it’s called “Local Area Connection 2″. For clarity, I renamed mine to “Loopback” (what’s in a name?). Right click the connection name, click Rename and change it.
  3. Right click the Loopback connection, click Properties.
  4. On the General tab: disable “Client for Microsoft Networks” and “File and Printer Sharing for Microsoft Networks” (only untick the checkboxes, DO NOT uninstall!).
  5. Click “Internet Protocol (TCP/IP)” and click Properties.
  6. On the General tab: click “Use the following IP address” and pick a private IP address on an unused subnet (I used 192.168.100.100 with subnet mask 255.255.255.0).
  7. Click Advanced.
  8. On the WINS tab: click “Disable NetBIOS over TCP/IP”, then click OK and again OK.
  9. Click Close.

Create or edit the LMHOSTS file

  1. Open the file “C:\WINDOWS\system32\drivers\etc\lmhosts” (create it if it doesn’t exist - note that the file should have no file extension).
  2. Add the following line to the end of the file:
    192.168.100.100 servernamehere
  3. Save and close.

Configure PuTTY

At last, we have to tell PuTTY to create an SSH tunnel from the loopback connection to our home server. I assume you already have a PuTTY saved session to connect to your home server.

  1. Open PuTTY, click your saved session and click Load.
  2. Go to Connection - SSH - Tunnels.
  3. In Source port, type “192.168.100.100:139″ (I know, the field is quite small, but it will accept the value anyway).
  4. In Destination, type “localhost:139″.
  5. Click Add, and do not forget to resave your saved connection!

To confirm that everything is working, connect to your home server with the saved session in PuTTY. Click Start - Run and enter “\\servernamehere\sharenamehere”. Depending on your Samba setup, you may have to enter a username and password. Done!

Background information a.k.a. Frequently Asked Questions

Why do I have to install an extra loopback adapter? Can’t I use the adapter that’s already in my PC?

Yes, in fact you could use the adapter that’s already in your PC. But… you would still have to disable the Client for Microsoft Networks and File and Printer Sharing. That means you won’t be able to use any other shares besides your home shares. Not very practical. An extra adapter allows you to have Microsoft Networking enabled on your normal network connection and use your home shares simultaneously with other (work, school, …) shares.

Do I really need the LMHOSTS file?

No, you don’t. You could refer to the IP address as well (e.g. connect to “\\192.168.100.100\sharenamehere”). But I wanted the solution to be transparant, whether I’m at home or not. If I use “\\servernamehere\sharenamehere” at home, then I want to use it anywhere else as well (or else I have to remember too many things). That’s what the LMHOSTS file is for.

=============================================

Above post was copied from here just in case the original post get vanished!

To set putty access without passwords, copy your private key (id_dsa) from the remote machine to the local machine. Open puttygen and load this key. Save this key in putty format without a passphrase. In Putty select ssh->auth and specify this file. Also connection->auto-login name and specify the user.


Sunday, October 26, 2008

Double Spacing

To add double-spaced line in Latex, do the following:

\usepackage{setspace}
\doublespacing

Thursday, October 16, 2008

subversion

[QUICK REF]

svn import -m "initial import" module svn+ssh://user@server/home/svn/repos/module/

svn co svn+ssh://user@server/home/svn/repos/module/ module

Refer this article to install subversion on Ubuntu and set up Apache to get web access to the repository. Following is a summary of the commands.
(using aptitude is better than apt-get because the former keeps a track of dependencies during uninstall time, and records a log)

installing subversion
sudo apt-get update
sudo apt-get install subversion

creating the repository
cd /var
sudo mkdir svn
sudo svnadmin create /var/svn/repos

add svn as a user
sudo adduser svn
sudo chown -R svn.svn svn

let a user access svn (add to svn group)
sudo vigr
admin:x:110:user_name
svn:x:1001:user_name

SSH access
sudo apt-get install openssh-server
svn co svn+ssh://username@machinename/var/svn/repos

chmod 0700 .ssh
chmod 0600 .ssh/authorized_keys2

Set up Apache Web Access to the repository
sudo apt-get install libapache2-svn
cd /etc/apache2/sites-enabled
sudo vi 000-default

<Location /svn> 
DAV svn
SVNPath /var/svn/repos
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/passwords
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
<Location\>   
sudo /etc/init.d/apache2 force-reload

Add the following to the Location directive above to secure the repository.
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/passwords
Require valid-user

set up BASIC authentication as follows.
sudo htpasswd -cb /etc/apache2/passwords USERNAME PASSWD

sudo /etc/init.d/apache2 force-reload

To see whats on SVN do a list:
svn list svn+ssh://user@server/home/svn/repos

Tortoise SVN
This tool provides a shell script in Windows explorer so that we can easily
checkout, import, or update a folder with an SVN repository in a remote machine.
I will describe how to use Tortoise with svn+ssh on Windows using Putty.

download and install tortoise from here.
http://tortoisesvn.tigris.org/
Installation is fairly simple. Requires a restart on Xp after installation.
Create a tunnel using putty.
First create a key using putty keygen. You can either convert an existing private
key or create a private/public key pair from the scratch by doodling some random
movements. Now load the private key by double clicking. This should load they key
to putty agent and the agent should appear as an icon in the Windows system tray.
Now open putty and create an SSH connection to the remote server as follows:
Give the HOST name (alternatively the IP), specify a name in the saved sessions box,
in the connection->Data provide your username in the "Auto-login username".
Now save the session, load it and open it. Now right click on any windows explorer
window (in a directory) and in the pop-up menu select TortoiseSVN->Repo-broweser and
type the following the url box:
svn+ssh://username@server/home/svn/repos

This will show you all the modules uploaded to the SVN server.
If you are in Linux, then when you try to use svn+ssh then it will always ask you to
type your password. To avoid doing this add your id_dsa.pub and/or id_rsa.pub public
keys to authorized_keys and authorized_keys2 files by doing
cat id_rsa.pub >> authorized_keys2


Thursday, October 2, 2008

Wednesday, October 1, 2008

SQL

1. To use a database
use

2. To show all tables in the database
show tables from

3. Describe a table
describe

4. print some rows
select * from limit

Saturday, August 16, 2008

ssh keys and permissions

create ssh keys in your local machine (if you don't have any yet)
ssh-keygen -t rsa

This will create two keys id_rsa and id_rsa.pub

In the remote machine, create a .ssh directory in your home directory
set permission to 700 by, chmod 700 .ssh

create an authorized_keys file in the .ssh directory by
touch authorized_keys

copy the public key into this file by,
cat id_rsa.pub >> authorized_keys

set the permission of authorized_keys to 640
Now you can access the remote machine without passwords!

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

GNUPLOT

To plot CSV files do the following,
set datafile separator ","

to print to eps:
set terminal postscript eps enhanced "Times-Roman" 18
set size 1.0, 1.0
set output 'histo.eps'

Here, size is relative to the box

to generate histograms:
(actually gnuplot cannot cumulate the data for you.
use a program to do that. gnuplot only draws the bar chart)

set style fill solid 1.00 border -1
set style data histograms
set style histogram clustered gap 1
set xtics border in scale 1,1 nomirror rotate by -45 offset character 0, 0, 0

set xlabel "xxx"
set ylabel "yyy"
set yrange [0.00:1.00] noreverse nowriteback
set nokey #off the legend
plot 'datafile' using 2:xticlabels(1) #column one contains labels
pause -1 #wait until enter is pressed

Setting up WinShell and dviout with pLatex

Install pLatex using the installer at;
http://www.ms.u-tokyo.ac.jp/~abenori/mycreate/

install ghost script, ghost view and dviout

install winshell
http://www.winshell.org/modules/ws_download/

configuration in winshell
options->program calls
1. Latex
C:\pTex\bin\platex.exe
cmdline: -src-specials -interaction=nonstopmode "%s.tex"
[-src "%s.tex" worked for me]

2. bibtex
C:\pTex\bin\jbibtex.exe
cmdline: "%s"

3. dviview
C:\pTex\dviout\dviout.exe
cmdline:-1 %s.dvi "# %l '%c.tex'"

4. dvips
C:\pTex\bin\dvipsk.exe
cmdline:-D600 "%s.dvi"

set font; ms gothic size 14 script Japanese encoding sjis

set colors in syntax-colors

In dviout set the following settings;
option->set up parameters->common
src: C:\Program Files\WinShell\WinShell.exe^s-c "%s" -l %d

This will jump to the position in winsell editior when you double click on a word in the dvi file

check, options->continuous review
to stop opening dviout window everytime you run dviout from winsell.
Moreover, it will instantly show any changes that you have made to tex file when you compile it.

LaTex PDF Generation from DVI

To create a USLetter size pdf from dvi do,
dvipdfm -p letter mypaper.dvi

Write XML from Python

from xml.sax import saxutils
then use saxutils.escape("raw_string")
will give all exceptions escaped!

Thursday, July 10, 2008

HTML tooltip texts

<HTML>
<HEAD>
<STYLE>
.popup
{
COLOR: #9F14A;
}
</STYLE>
<TITLE>Test Page</TITLE>
</HEAD>
<BODY>
<SPAN title="popup text" class="popup">display</SPAN>
</BODY>
</HTML>

Python CGI programming

apache configuration
/etc/httpd/conf/httpd.conf is the configuration file. Open this as root (sudo emacs -nw httpd.conf)
To enable cgis
ScriptAlias /cgi-bin/ "/var/www/cgi-bin"
<Directory "/var/www/cgi-bin">
Allow Override None
Options FollowSymLinks ExecCGI
Order allow, deny
Allow from all
<Directory>

It is also possible to set per-user cgi-bin, html folders but this reveals the users in a machine.
public_httml settings are not good for this reason

/var/www/html html folder
/var/www/cgi-bin/ cgi-bin
Must have write permissions (root or su)

AddHandler cgi-script .cgi .pl .py
Now save and start httpd by,
sudo /etc/init.d/httpd restart

File permissions
cgi-bin should be 755 (4=read, 2=write, 1=exec)
scripts should be 705 (if this needs to write to a folder then set to 707)
chmod 705 my.py

#!/usr/bin/python
import cgi
import cgitb; cgitb.enable()

print "Content-Type: text/html \n"
print "<HTML> \n"
print "<HEAD> <TITLE> Results </TITLE> </HEAD> \n\n\n"

(At least two lines should be there after the header. If not we get Internal Server Error 500)

Python float string formatting

z='%.15f' % x
gives a 15 decimal precision float converted to a string.
It is possible to get more than 15 decimals using %.20f and
%.80g etc. But the decimals after 15th are not reliable.

****incrementing integers in python
i+=1
i*=5
i-=1
i/=2
all works. Note i**2 means i to the power 2
***********************
Python have private class and module methods. To make a method private
to a class or a module use __before the name.
Ex;
def __privateMethod():
If you try to call this method outside the module or outside the class
declaration, python will generate a 'method not found' exception.
Python 万歳!!!

suppress the log-in message

create a file on the remote machine by,
touch .hushlogin

Symbolic links

ln -s /data/dvd5 dvd5
If dvd5 is a directory then we must create a soft link using -s option.
Do not use a trailing back slash after the directory name

firefox remote

to open firefox on a remote machine, in that local machine do;

firefox -no-remote&
If there is already a firefox opened in the remote machine then you
will have to first close it.
find the pid of the currently running instance of firefox by,
ps -ax|grep 'firefox'
and kill it by
kill -9 pid

Logitec Keyboard

The scroll bar makes a clicking noise during use. To turn the noise off/on, hold the 'FN' key and hit the 'pics' button next to it.
To turn the bar off altogether, since it is very sensitive, hold the 'FN' key and hit the 'X' next to it. To turn it back on, hold the 'FN' key and hit the flip-3d key next to it.

ssh X11 Forwarding not working!

In Ubuntu edit /etc/ssh/ssh_config file and set
ForwardX11 yes
do the same for secure tunneling X11 and agent forwarding.

Now delete all Xauthority file locks by
sudo rm .Xauthority*

Now log in again.

Adding another hard drive

http://wiki.linuxquestions.org/wiki/Add_a_new_hard_drive

Compressing/Uncompressing

to uncompress tar.bz2 files do:
tar jxvf filename

Add users set passwords and home directory

sudo useradd -d /home/usrname -m usrname
sudo passwd usrname
change the password

installing vmware tools on fetsity

install build tools first, they are not installed by default
sudo apt-get update
sudo apt-get install build-essential
howto

Terminal title

export PS1="[\u@\h \w]$ "
will print
username@first_level_host last_dir]$
as the prompt

check version

uname -a (gives the kernel)
cat /etc/redhat-release (gives redhat version)

System Bell

system->preference->sounds->system bell Disable

bashrc vs bash_profile

bash_profile is callled when a non-interactive log-in shell
is invoked (e.g., starting terminal in Gnome or emacs shell)

bashrc is called when an interactive log-in shell is invoked
(e.g., ssh shells)

Add the following to .bash_profile and write all things that
you need to do in .bashrc so that even when a non-interactive
log-in shell is invoked, still .bashrc will get invoked.

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

IE maximizing new windows

open IE and right click on a link and open it in a new window.
Now resize the new window (do not use maximize button) by dragging the edges to your
preference. Now close the first window by File->Exit
and do the same for the new window.
This works for IE7

Ubuntu Japanese IME/Emacs

set the root password by
sudo passwd root
Give a new root password

specify japanese ubuntu ring,
system->software sources->third-party software
Add the following two locations for feisty (7.04)

deb http://archive.ubuntulinux.jp/ubuntu-ja feisty/
deb http://archive.ubuntulinux.jp/ubuntu-ja feisty-ja/

close->reread
This will give an error because of public key mismatch, but
do not worry.
Install ubuntu-japanases-ring package

system->admin->synaptic package manager
ubuntu-ja-keyring
Apply->ok
This will download japanese packages and install.

To set up IME, first install Japanese language support by,
admin->language package

Now restart (logout X) and log in again, try
Ctrl+Space

If this does not trigger scim, then you need to add the following
to Xsession.d,

sudo touch /etc/X11/Xsession.d/74custom-scim_startup
sudo chmod 646 /etc/X11/Xsession.d/74custom-scim_startup
echo 'export XMODIFIERS="@im=SCIM"' >> /etc/X11/Xsession.d/74custom-scim_startup
echo 'export GTK_IM_MODULE="scim"' >> /etc/X11/Xsession.d/74custom-scim_startup
echo 'export XIM_PROGRAM="scim -d"' >> /etc/X11/Xsession.d/74custom-scim_startup
echo 'export QT_IM_MODULE="scim"' >> /etc/X11/Xsession.d/74custom-scim_startup
sudo chmod 644 /etc/X11/Xsession.d/74custom-scim_startup

You need to re-log-in to make the changes effective.
Now you can inset Japanese.

subversion control (SVN)

SVN is much easier to work with when compared to CVS.
Some useful commands are:
When you have first created SVN and want to submit the initial version of a project use import command.
1. svn import hmm http://ppp.berlin.ghost.de/svn/

2.To check out for the first time, do
svn co http://pp.berlin.ghost.de/svn/hmm newhmm
Files will be downloaded and saved as newhmm
If http fails, use svn://...

3. After changing a file, if you want upload the changes, do commit.
svn commit
(Remember to go out to the appropriate parent directory. Otherwise, you
may get a 'work directory not found' kind of an error.

4. Once you have checked out, but want the latest version, do, update.
svn update (alternatively, svn up)

if svn breaks down, do
svnadmin recover /home/svn
chmod -R g+w /home/svn

file permission and groups

u=owner
g=group
o=others

r=read w=write x=execute
+ add permissions
- remove permissions
= set permissions absolutely

Ex:
chmod go+rx mydir

separate multiple settings by a comma
chmod a=rx,u+w myhome
will set myhome to drwxr_xr_x

Continuously monitor GPU usage

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