Deprecated: Assigning the return value of new by reference is deprecated in /home/parspro/public_html/StoppingTime/wp-includes/cache.php on line 99

Deprecated: Assigning the return value of new by reference is deprecated in /home/parspro/public_html/StoppingTime/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/parspro/public_html/StoppingTime/wp-includes/theme.php on line 576
Stopping Time

Refactoring and Branches in Subversion

December 6th, 2010

To quote from the subversion documentation. “A common desire is to refactor source code, especially in Java-based software projects.” This might be one of your concerns too.

One problem I encountered using a branch from a refactored project was the following error when merging from the trunk:


$ pwd
myProjectBranch
$ svn merge http://myServer/svn/stijn/myProject/trunk
Cannot replace a directory from within.

To illustrate the problem we assume the following:

  • myProject was created at revision 50
  • myProject was refactored at revision 100
  • myProjectBranch was copied from the trunk at revision 150
  • myProjectBranch is now at revision 200 and we try to merge from the trunk

If you refactored enough the problem above will show up when doing:


$ pwd
myProjectBranch
$ svn merge http://myServer/svn/stijn/myProject/trunk
Cannot replace a directory from within.


The reason is that the merge operation tries to apply all diffs between revisions 0 and 200 to the branch. As there are files or directories that have disappeared or have been moved the problem arises when trying to apply these diffs to the branch.

The problem is to tell Subversion to ignore all diffs between 0 an the moment the copy was made (revision 150) as these were already applied when the branch was created. To do this one could manually edit all svn propedit svn:mergeinfo subversion properties. A better way to do this is using the following


$ svn merge http://myServer/svn/stijn/myProject/trunk -r1:150 --record-only
$ svn commit -m "Tricked subversion into ignoring all diffs between \\
  1 and 150 (creation of branch) when merging"

An even better way is to directly do this after creation of the branch.

Subversion ignore list and patching

October 14th, 2010

When using subversion you can keep versioned files together with unversioned files (data, objects,…). You typically want subversion to ignore all these files in your subversion work flow (e.g. using svn status. To achieve this we use the propedit command,


$ svn propedit svn:ignore .


This open your favorite editor and allows you add a list of files and directories to ignore. Wildcards can also be used. A typical file looks like this,


changeLog.txt
Doc
*kdev*


Where in my case the first is my change log file, the next is the Doxygen directory and the last uses * wildcards to ignore anything used by KDevelop. The same is possible for any subdirectory,


$ svn propedit svn:ignore subdir

To see which properties are attached to a directory use,


$ svn proplist .

or

$ svn proplist -v

where the -v option shows the content of each property in the list.

It can be useful to keep track of what you change in a log file. To commit later using this file (which I conveniently added to the ignore list) we use,


$ svn commit -F changeLog.txt

Another useful feature is the use of diff for patching files using the patch program. This is possible since diff outputs unified diff format. For instance to examine the changes made to file between the last committed version (HEAD) and the version just before this file was last changed (PREV) we use,

$ svn diff -r HEAD:PREV myFile.txt

if we now write the output to a patchfile,

$ svn diff -r HEAD:PREV hritProcessing.cpp > patchMyFile.patch

we can examine and modify the patch and then apply it using, (-i works from an input file),

$ patch -i myFile.txt

as usual after this check if the patch worked using you usual tools.

SMTP Server on the Road

September 6th, 2010

If you have no access to an smtp server (for instance at a conference) sending email using an email client can be a pain. However, there is an easy fix for this. Mac OS X (at least form 10.6 up) has postfix installed. To start it you use:


sudo postfix start

Then set your mail client to use,


localhost

or 127.0.0.1 as SMTP server to send email.

To stop the SMTP server (to avoid any malicious use) type,


sudo postfix stop

CLOC, Count Lines of Code

July 1st, 2010

To analyze your code CLOC is a very neat tool. Just download it form http://cloc.sourceforge.net/. And put it somewhere in your path (or not).

For ease of use I put an alias in my .bashrc file:


alias cloc="/SomePath/cloc-1.51.pl"

running CLOC on my current project yields:


$ cloc myProject
       9 text files.
       9 unique files.
      41 files ignored.

http://cloc.sourceforge.net v 1.51  T=0.5 s (16.0 files/s, 9016.0 lines/s)
------------------------------------------------------------------
Language        files          blank        comment           code
------------------------------------------------------------------
C++                 3            614            772           1801
C/C++ Header        2            211            281            592
make                1             28             28             82
C                   2             30             14             55
------------------------------------------------------------------
SUM:                8            883           1095           2530

How about that huge amount of documentation (seen as comments). ;-)

Food in Barcelona

June 1st, 2010

Barcelona is amongst my favorite places to be and the food is a great help in this. So hereby a list containing a few addresses that particularly pleased me:

matamala
Rambla Catalunya 13
08007 Barcelona

A nice modern style tapas bar / restaurant. One of my favorite places in Barcelona.

ELJ APO NES & BAR LOBO
Pintor Fortuny 3
08001 Barcelona

Another nice modern style tapas bar (BAR LOBO) with a nice terras located very close to the ramblas. If I am in Barcelona I for a longer period I go there more than once. Nice to start having a few wines at the terras and letting it flow into dinner or lunch.

On the top floor is ELJ APO NES which is a tapas/japanese fusion restauant. Extremly nice.

this last one also exists at a second place,

ELJ APO NES
Pasaje de la Concepcion 2
08008 Barcelona

CARMELITAS
Doctor Dou, 1 / Carme, 42
08001 Barcelona

Nice place with cheap lunch.

Flamant
C Enric Granados, 23
08007 Barcelona

A very nice catalan/french style restaurant. Very nice and not too expensive. We had our first wedding anniversary there. Take a look at the cava they offer.

Cargol Treu Banya
Plaza Dr. Letamendi, 27
08031 Barcelona

Extremely nice to go eat caracoles but (maybe go check it out and write me an email) closed.

As a last tip (the delicatessen shop where I got it ice cold is listed below) is to fetch a bottle of Duran Cava and drink it in nice company in one of the parks in Barcelona.

Colmado Quilez
Rambla Catalunya, 63
08007 Barcelona

ssh and public/private key authentication

February 5th, 2010

When login in via ssh it can become a nuisance to type in your passphrase and if you want to automate some process over ssh it is necessary to be able to login without passphrase. To achieve this feat we use authentication via a public/private key pair. The public key is then put on the remote machine and the private one on the local machine.

In essence, the public key is like a personal locked backdoor on the remote machine and the private key is the key to open the lock. In this example the remote machine is called remotehost and the local machine localhost.

First we generate a key pair. For this we use,


user@localhost$ ssh-keygen -t dsa -b 1024 -f ~/.ssh/identity

this generates a 1024-bit DSA key pair called identity and identity.pub in the .ssh directory. This should be sufficiently safe for everyone (I once figured out why but forgot to write it down ;-). If you want no passphrase just leave it empty.

Now we put the public key on the remote machine,


user@localhost$ scp ~/.ssh/identity.pub user@remotehost:

Now login to the remote machine,


user@localhost$ ssh user@remotehost:

and add it to the authorized_keys list,


user@remotehost$ cat ~/identity.pub >> ~/.ssh/authorized_keys
user@remotehost$ rm ~/identity.pub

Voila, you can now login to the remote host without password.

  • Note 1: the above works fine if you use Mac OS X. The description for most UNIX like systems is fairly analogue. One of my linux systems you have to rename identity to id_dsa or id_rsa.
  • Note 2: you might want to $ chmod 600 identity for safety
  • Note 3: the remote host might not accept public key authentication. Mot of the time it is out your hands then and you will need to ask the sysadmin. If you are the sysadmin, then the procedure is along the following lines. Log in as root and change,
    
    /etc/ssh/sshd_config
    

    by adding following lines:

    
    RSAAuthentication yes
    PubkeyAuthentication yes
    

    Then reload your configuration,

    
    # /etc/init.d/ssh reload
    

For ease of use we can add shortcuts to ~/.ssh/config.


Host remotehost
 hostname remotehost
 user remoteuser
 Port 10001

A Visual Guide to Version Control

December 22nd, 2009

I just had to post this really good introduction to version control:

Visual Guide to Version Control

It uses Subversion for the examples.

TrueCrypt + USB stick + rsync = Backups Everywhere

November 30th, 2009

Step 1: Open Disk Utility (can be found in /Applications/Utilities/) and create partitions on your USB stick. I chose for one partition in FAT32 to transport data and a second one to make backups. Note: the backups partition will be encrypted.

Step 2: Download TrueCrypt

Step 3: Open TrueCrypt and go trough the following steps:

  • Create Volume
  • Create a volume within a partition/drive
  • Standard TrueCrypt volume
  • Select device -> Choose the right volume
  • Set a volume password
  • Format Options -> Mac OS Extended
  • Only mount on Mac OS X
  • Create volume (this takes a while)
  • Done

Step 3: Open TrueCrypt (unless it was already open).

  • Select Device -> Choose the right volume
  • Mount

Step 4: Now our volume has name “untitled” and Mac OS X extended formatting. We want to give it a name and Mac OS extended, case sensitive,

  • Open Disk Utility (can be found in /Applications/Utilities/ )
  • Select your volume (it will be under volume.dmg as untitled)
  • Go to “Erase”
  • Give a name (say “TC”) and a formatting type
  • Click the “Erase…” button

Step 5: We now have an encrypted volume “TC”.

Step 6: You can mount and dismount the volume “TC” with TrueCrypt.

Step 7: I then use a script like this to do my backups:


#!/bin/bash

echo "execute: chmod 777 /Volumes/TC/.Trashes"

chmod 777 /Volumes/Rhea/.Trashes

echo "starting synchronization of all files in "\
"/Users/stijn/ to /Volumes/TC"

wait

rsync -av --delete --progress --exclude 'Library/Caches' \
--exclude 'Library/PubSub' /Users/stijn/ /Volumes/TC

wait

touch /Volumes/TC/.Trashes

echo "synchronisation done"

MPlayer om Mac OS X

November 28th, 2009

MPlayer is probably the only video player one needs in life. However the guys from mplayer have not been updating since 2006. If you want a new version you have two options:

- Get MPlayer OSX Extended which is really great and provides easily the best GUI. However, for some reason the command-line version embedded in it seems not to work. And since the GUI lacks subtitle controls beyond ordinary loading (delay,scaling,…) I needed the command-line version.
- This guy provides Unoffical MPlayer OS X SVN Builds which is very nice AND the command line version of this works!

To use the command line tool we first add a symbolic link to /usr/local/bin/:


$ sudo ln -s /Applications/MPlayer\ OSX.app/\
Contents/Resources/External_Binaries/\
mplayer.app/Contents/MacOS/mplayer\
 /usr/local/bin/

now you can test if it works:


$ mplayer movie.avi

Now if you want subtitles using a command like:


$ mplayer -sub sub.srt movie.avi

this does not work since it cannot find the appropriate font ~/.mplayer/subfont.ttf. The solution is straightforward. First go to /Library/Fonts/ pick an appropriate font (I took Trebuchet MS Bold which seems ok) and drop it in ~/.mplayer/ and rename it to subfont.ttf .

This should now work using appropriate scaling:


$ mplayer -subfont-text-scale 3 -sub sub.srt movie.avi

Optional, add this line to your ~/.bashrc:


alias mplayer='mplayer -subfont-text-scale 3'

Now to use delays we hit:


$ mplayer -sub mov.srt mov.avi -subdelay 1

The Concepts and Practice of Mathematical Finance

November 28th, 2009

When i started writing this post (some time ago) I just finished reading (from cover to cover) The Concepts and Practice of Mathematical Finance by Mark Joshi.

As I am already familliar with a huge part of the field I have no idea on how good an introduction it is. But in my opinion it is probably not the best “first” book on mathematical finance but absolutely worth reading for someone starting in this field.

For me it consolidated and deepened my knowledge in a few ways:
- It gave me some extra intuition on a lot of the material covered.
- It allowed me to rethink and test my understanding of some topics
- It also lead to some interesting discussions with other people in our quant unit.