Outlook autoforward

Here’s a macro I wrote to automatically forward outlook emails sent to my work email address to a personal email address.

Outlook does have an autoforward feature, but that seems to have been disabled at my workplace.

This adds the string “AutoFwd:” to the email title and sends it on to the given email address.  This allows easy deleting.  This method requires leaving outlook running at work which is less than ideal.  It also clutters the ‘sent items’ folder.  It would also be nice to send it “from” the original sender, but I haven’t found a way to do that yet.

Other than that, it seems to work well.

Sub ForwardMail(mail As Outlook.MailItem)
Set FwdMail = item.Forward
FwdMail.Recipients.Add “myname@mydomain.com.au”
FwdMail.Subject = “AutoFwd: ” + item.Subject
FwdMail.Send
End Sub

Changed web hosts

I have recently changed webhosts for the first time. Backing up my admittedly small website and moving to the new host was theoretically as simple as doing a backup on my old host, then restoring to the new host. Things in IT are never that easy, and this was no exception.

The restore seemed to restore all my files, but mail, wordpress and phpgedview didn’t work. I decided I didn’t care about mail – I have local backups, and don’t want to mess up mail I have received since I moved to the new host. I also am happy to rebuild phpgedview, but I did want to restore this wordpress blog.
First off, I couldn’t create a database with the same name as the old host, since my new host forces a different naming convention. I believe I could have modified the database script, but didn’t out of fear. I paid my host to change my user id instead, so the default became the same as the original host.
Next I extracted just the database backup from the gzip archive downloaded from my old host.

Restoring this in its native form didn’t seem to do anything, so I rezipped it then tried a restore. This looked like it worked – presenting all the sql scripts on the browser as it unpacked. However it didn’t achieve anything. Next I tried downloading the pretty much empty MYSQL database I had created on the new host, made a small change, then uploaded it again. The change worked – the subtitle of the wordpress blog had been modified.
Hmmm.
Realistically, changing the name of the old host’s archive to that of the archive just downloaded shouldn’t work – it’s ridiculous to think that the restore of an archive is dependent on the name of the zipped file. But hey, I’m semi desperate. Just a waste of time one would think. Really.

Anyway, I took the extracted MYSQL part of the old hosts backup archive, and zipped it into an archive with the same name as the MYSQL backup that I had just downloaded from the new host, then uploaded it.

It worked. Go figure.

Debugging Intel Fortran from c#

Handy tip.
By default, breakpoints don’t work in an Intel Fortran dll linked to a .net project when using Visual studio.
To fix this, Under the project properties, debug tab, check the ‘Enable unmanaged code degugging’ check box.

On line family tree

I have just set up the PhPGedView family tree package at www.prictor.com.au/PhPGedView.  At present it has very little information in it, but I can create an account for anyone who wishes to add to it.

This has been set up in response to a project Luke had at school, and hopefully will become an extended family tree of both the Prictor and Towle branches of his ancestry.

Failed to give up

One reason I gave up on dynamatrix was the natrual log function failed.  I have fixed this bug.

In Expr.cs

case FXType.Ln: mi = typeof(Math).GetMethod(“Log”));

change to

case FXType.Ln: mi = typeof(Math).GetMethod(“Log”, new Type[]{typeof(double)});

The problem was that the program uses reflection to find the Log function in the math assembly, but there is an override, so two functions are available and an exception is thrown.  The extra code specifies that we want the override that does not specify a new base, that is, use the base e

Reflection is cool.

Given up on dynamatrix

Dynamatrix seems to be a good design, but the implementation is buggy, and I don’t have the inclination to fix and test it.  Perhaps just linking to a fortran library is the best bet.  Primitive types can be passed easily between the two, so that might do.  If I get really enthused, I might write a decent marshalling layer between Fortran and c#. I’ve done it before, but I don’t own the rights to the code.

Searching for a Fortran style Matrix Class in C#

As a quant developer I often work with mathematicians who know and love Fortran.  Personally I hate working with this language except for its beautiful handling of matrices.  I’m currently working on building a Value at Risk system in the electricity industry, and I’ve decided to do the lot in C#, with perhaps some shelling out to Matlab, but I don’t want to unwind my vectors and matrices in order to operate on their elements, rather I want to do operations on the matrices as we do in Fortran.

The following link seems to have what I’m looking for, and to boot, consideration has been given to doing it efficiently:

http://www.codeproject.com/KB/recipes/dynmatrixmath.aspx

The documentation is a bit thin, so I’m just jumping in.  It seems to have this smart way of constructing a tree of operations, then waiting until told to evaluate these all at once.  This has led to some confusion on my part.

Vector q = new Vector(3)
Vector r = new Vector(3)

..after assigning values to q, I wanted r to hold log(q), and tried this:

Expr.Log(q).AssignTo(r);

since the following doesn’t work due to the way the expression evaluator works:

r = Expr.Log(q);

After some mucking around I found that I need to do the following:

Expr.Log(q).AssignTo(r)();

A bit clunky perhaps, but much better than any other method I know.