Friday, October 24, 2008

Subclipse error: Svn can't create tunnel. Configuring SVN+SSH connection on Windows Vista

Good morning!

Yesterday I wanted to install the beautiful Eclipse IDE on my new Windows Vista laptop. Everything went fine. I also installed Subclipse, the interface to the "Subversion" Version Control System, in order to access my code in the repositories on the remote machines of my Insitute.
Everything went fine again, but then, when I wanted to set up a SVN+SSH connection to checkout my code from the remote machine, I got this error:

The system cannot find the file specified.
svn: Can't create tunnel: The system cannot find the file specified.

Looking on Internet I found a solution for Windows XP, that I had to modify a little bit. Here the solution.

The problem is that you have to specify the path of your SSH client. You can use the classical PuTTY or Plink, but I prefer to use the TortoisePlink, the modified version of Plink contained in the excellent TortoiseSVN package. Using the TortoisePlink client you will be prompted for your username and password without opening an ugly CMD window (the command line window) every time.

So, let's say you have already installed the SVN client, you have now to modify the config file.
In Windows Vista this file is stored in the hidden folder

C:\Users\[username]\App Data\Roaming\Subversion

There you find the file named config. Open it with an editor (for instance Notepad) and look for the string

[tunnels]

this line must be uncommented (no hash # symbol at the beginning of the line). Then you have to modify the line below, to set the right path to your SSH client

# ssh = $SVN_SSH ssh

Let's say you installed the package TortoiseSVN at C:\Program Files\TortoiseSVN
so you can leave commented the line # ssh = $SVN_SSH ssh and you can add this line just below it:

ssh = C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe

Done!! :-)

Now you should be able to connect to your remote site with SVN through a secure SSH tunnelling connection.

And, as always, let me know if you have some problems! ;-)

Sunday, October 12, 2008

Finalmente risolto il problema di Windows Vista con la connessione di rete wireless

Erano mesi ormai che nella nuova casa avevo questo problema con Windows Vista: ogni tanto, senza ragione apparente, perdeva la connessione wireless. Magari per dieci ore tutto funzionava...poi all'improvviso...PUM! L'iconcina della rete mostrava una bella "X" rossa e non c'era piu' verso di far rivelare a Windows la rete wireless di casa. Cercando di fare il refresh delle reti disponibili, appariva semplicemente la scritta "no wireless networks found in range". Solo un hibernate o un restart del computer risolvevano il problema. La rete poteva "cadere" in un momento qualsiasi, dopo due minuti come dopo 3 ore, senza un motivo apparente.
E il problema non era del router, perche' con Windows XP la rete restava bella visibile e funzionante.

Oggi ho voluto spulciare un po' su Internet, e alla fine ho trovato la soluzione sul blog di un ragazzo norvegese, che qui ringrazio ;-)

http://www.catonett.com/blog/archives/194

Nei commenti al post ho poi scoperto il link alla pagina Microsoft ufficiale:

http://support.microsoft.com/kb/928233

In pratica bisogna modificare (aggiungere) una chiave del registro di sistema per far si che Vista non usi un impostazione di rete relativa al DHCP, il protocollo che assegna gli indirizzi di rete in modo dinamico ai computer che richiedono la connessione al router.

Ora ho provato a seguire la procedura descritta nei due post...vediamo se funziona!

Speriamo di si! ;-)

Friday, June 6, 2008

How to measure memory consumption of a program on Linux

The Linux operating system provide detailed information about memory processes use. You can use the ps or the top tools; or you canread information written on the /proc filesystem.

There you can find detailed information for every jobs running on your machine. You can get a list of the running jobs with:


ps -A

and then look, for example, into the file /proc/5995/status, where 5995 is the Job ID:

cat /proc/5995/status

VmSize: 7660 kB
VmLck: 0 kB
VmRSS: 5408 kB
VmData: 4204 kB
VmStk: 20 kB
VmExe: 576 kB
VmLib: 2032 kB

Thursday, May 15, 2008

Linux Fedora Core: How to set the mailing service of YUM Package Manager

To set the mailing notification system of the YUM Packages Manager on Fedora Core Linux systems (as SLC4) edit the file
/etc/sysconfig/yum-autoupdate

and uncomment and edit this line:
#YUMMAILTO="root"

YUM will send a notification email to root every time it update something. Mail messages sent to "root" are stored in the file /var/mail/root. simply open this file with an editor or with more or cat commands.

If you want to receive a notification email on a real e-mail box, you can add more addresses separated by coma, as for example:
YUMMAILTO=user@domain.com,"root"

Wednesday, May 7, 2008

list of file with full path with 'ls' in a shell

if you want a list of file with the full path, ready to be pasted in a txt file to be processed by a script, for example, you have to add $PWD to the path in 'ls';
e.g.:

ls -1 $PWD/*.root

will show you the list of all the files ending with .root with their full path.

Wednesday, January 23, 2008

VI editor: Search and Replace text

IMPORTANT! Before start changing your text file, please remember the commands to UNDO and REDO:


:u or :undo[n]
:red or :redo[n]

where "n" is the number of changes. The default value is "n=1".


With the command (in ESC mode):

:%s/foo/bar/gc

the active file will be searched for the pattern "foo" and replaced with "bar". For every replacement you'll be asked for a confirmation.

With

:%s/foo/bar/g

you won't be asked for a confirmation.

:%s/foo/bar/gi is case-insensitive
:%s/foo/bar/gI is case-sensitive

With ESC or "q" you terminate the searching.

Note that above we used the % symbol. This is a shortcut that means "from the first line to the end of file".

The "substitute" (:s) command accepts, before of itself, a range of lines, e.g.:


:28s/text1/text2/ only on line 28
:.s/text1/text2/ only on the current line
:.,20s/text1/text2/ from current to line 20
:1,$s/text1/text2/ from line 1 to the end of file
:%s/text1/text2/ over the whole file. Like 1,$


Morevore please notice that if you want to use special characters like [ you have to escape them, like:


:.,$s/lego/\[lego/gc


this command substitutes all the occurrences of "lego" with "[lego", from the current line to the end of file, asking for confirmation before each substitution.

IMPORTANT. Please notice that you have to escape symbols ONLY within the substituting text, not in the text you look for. E.g.:

:.,$s/(ciao)/\[\(ciao)\)\]/gc

substitutes "(ciao)" with "[(ciao)]".

Saturday, January 12, 2008

History Brush on Photoshop CS3: Make a Black&White Image with coloured areas

Open an image in Photoshop CS3.



Edit the image as necessary. Open the Image->Adjustements->Black&White in order to get a nice b&w image.



Click on "History" and click on the little square on the left of a status of the image just before the black&white conversion. This status will be taken as "Source" for the "History Brush".



Now come back to the image clicking on the last status. Select the "History Brush" and "paint" an area of your image.


You'll see the area coming back to its original colour!

Friday, January 11, 2008

Rename files

Thanks to Stephan [my room-mate :-) ] I discovered the command "rename"!

N.B. The following works on Debian:

Let's say I want to rename a file callled "test11.txt" to "test12.txt"; the command which does the job is:

rename 's/11/12/' test11.txt

where 's/11/12/' is a perl-style Regular Expression (RE), where 's' stands for "string".

If you are not sure about your RE you can test it with the "-n" option, as:

rename -n 's/11/12/' test11.txt

it just shows to you the result of the operation without actually doing it.

If you have many files in a folder and you want to rename all of them you can use the "*" wildcard:

rename 's/11/12/' *

the command above renames all files containing a string "11" in the name, changing it to "12".

N.B. And the following works on SLC4 (and I guess on Fedora Core then)

the command:

rename .htm .html *.html

changes all the files ending with .htm into .html

P.S.
And if you want, for example, to rename or to add a suffix to a list of files in a directory you can use these commands:

for FILE in * ; do mv $FILE $FILE.txt ; done

where we add the suffix .txt to all files in the directory.
(Note for physicists: Useful to rename AOD or DPD data files to .root files ;-) )

Wednesday, January 9, 2008

VI editor: comment a whole line or N lines

If you want to comment N lines of a Bash script (for example) with the VI (or VIM) editor you have to type in ESC- mode (type ESC before typing the command):


:.,25s/^/# /

where ".,25s" stands for "from the current line to line number 25" and the sequence added to comment a line is "# " (hash plus a white space).
For a single line:

:11s/^/# /

for the 11th line or

:.s/^/# /

for the current line pointed by the cursor.



To uncomment:

:1,$s/^# //

where "$" stands for "last line", i.e. "from line 1 to the end of file".

Print the Copiright Sign in Python

To print the Copiright Sign with Python we need to use the Unicode string literal format.

A quoted string with a "u" or a "U" just before the leading quote is an Unicode string.
The escape sequence "\N{name}" prints the character specified by "name", where "name" is a standard Unicode name, a s listed in www.unicode.org/charts/

Example:

print u'\N{Copyright Sign}'

prints the Copyright sign.