Thursday, 28 February 2013

Removing stack trace from Microsoft Dynamics CRM 2011 log files.

If you've ever had to do any serious troubleshooting with MS Dynamics CRM, you know how annoying the log files can get with all the stack trace information that 99% of the times tells you nothing of use.

You can use the following PowerShell commands to remove them. Note that Exception Stack traces will still be there, use \s instead of \t if your really want to get rid of them.
Get-Content CrmTraceFile.log | Select-String "^[\t]" -NotMatch  | Out-File -Width 256 newlogfile.log
You could do it for all files in the trace directory like this, which should be used as a script:
$files = ls
foreach ($file in $files){  
$name = [string]::Format("p_{0}",$file.Name)
 $filepath = [string]::Format("{0}\{1}", $file.DirectoryName,$file.Name)
 get-content -Path $filepath | select-string "^[\t]" -notmatch | out-file $name -width 256 

Monday, 25 February 2013

How to hire experts in a field of which you know nothing about

I went to another interview a few days back, the position that I was interview for was of MS Dynamics CRM developer. The company had decided, god knows why, that their perfectly good .NET system wasn't up to scratch anymore and so they were going to move it to MS Dynamics CRM 2011. It looks as if the head developer might have done some of the Dynamics CRM 2011 certifications, but it doesn't look as if anything else related to Dynamics CRM 2011 might have been done by anybody, other than install it on the dev server.

I was asked three technical questions:
  1. Write a complex SQL query (I was given some tables and asked to write a query to extract the average of some column with some filtering and joining)
  2. Explain how locking works for SQL Server Databases. In particular what was the behaviour of  selects and update statements, see this for details.
  3. How would I debug a WCF service? I don't know, run it from Visual Studio or use a remote debugger.
It is possible that they decided that they did not want me and were looking for a way of closing the interview quickly, but I think that they just didn't know what would prove my knowledge of, or lack thereof,  Dynamics CRM 2011 so they asked me about stuff that they knew about as some sort of knowledge proxy.

I must admit that I've never been in a position to make a decision about hiring anybody, I have looked over many CVs, but never actually interviewed anybody, but I simply cannot see how this is a good way of establishing potential performance on a person on any given subject. It is a good way of establishing whether they know about something that you know, but that's not really relevant when you are hiring for something that you don't know, is it?

Granted that these were not random questions but it's hard to see how they enable to make a reasonable guess at anybody's competency on another somewhat related field. How related these are is a matter of opinion.

The salient point is that use knowledge proxies is a bad idea.

At the same time, I must admit that I don't know of a good way of establishing degrees of competency on a particular subject, if you know very little about the subject.

If somebody were to bullshit me about the intricacies of STP or VPNs, I simply wouldn't know because I know very little about those areas, certainly not enough to establish somebody else's competence on the field.

Recruitment agencies could do some of this job, but all they seem to do is look at CVs and ask really bland questions, e.g. so you are comfortable writing plug-ins and custom workflows?. I guess somebody may answer: actually, I haven't got a clue what you are talking about, but it's unlikely. 

At the end of the day they are recruitment people not techies, so they would have to charge more for their services if they had techies to evaluate other techies on competency, but how would these judges of competency by judged themselves and I guess therein lies the problem.

Wednesday, 20 February 2013

Triggering Workflows in Ms Dynamics CRM 2011

Yesterday I was looking at an issue where we were getting two accounts created for each of our callbacks (a custom entity) under certain circumstances.

It turns out that if you have a dialog, workflow or plugin that updates a field, even if the update is to set the field to the same value that it had before, this will trigger any workflows that are watching that field.

The solution is simple, only make the update if it's needed, i.e. check the value before you do the update, but it's perhaps a little bit counter-intuitive as the field has not actually changed.

If you have auditing enabled, you'll be able to see how a change is registered from value to value [sic].

Sunday, 17 February 2013

God Mode {ED7BA470-8E54-465E-825C-99712043E01C} in Windows 7/8

I came across this yesterday, I've only tried it for Windows 7 so far but it's really good, you essentially get everything in control panel in one screen (Why can't this be the default?).

Incidentally, all that is needed is the guid as an extension to a new folder, this would work too:

Friday, 15 February 2013

Acer V273HLObmid Review

A few weeks back I finally bought a new monitor, an Acer V273HL, or Acer V273HLObmid if you believe the ebuyer website.

I was surprised by how thick it actually, this is not thin monitor. I don't have a caliper but I'd say that at its thickest is a good 9 cm, which is a lot better than a CRT, but not thin.

It comes with DVI and VGA cable, EU and UK power supply cable and a 3.5 mm headphone cable., though sadly not with an HDMI cable, which is a bit annoying.

I have full 5.1 surround sound which I only switch on when watching movies, see this, the fact that the monitor has some speakers, however puny, is a really good feature.

I have only one complain about the monitor and that is clear type does not seem to work too well, this could be because I'm a lot closer that I should to a 27" monitor or something worse, but it is not very good, however as I hardly ever use for anything other than watching videos is not a major issue. Funnily enough, I've started to notice a lot more the effects or lack thereof, of Clear Type, even on my laptop, which did not seem to bother me at all before.

The only objective measurements that I can take are related to power usage, for which I have used a Brennenstuhl PM 230 Power and Energy Monitor.

I must say I was positively surprised by the monitor's power usage, not on standby mind you.

Mode Black background (W) White background (W)
Standby 9.5 9.5
Minimum Brigthness 28.5 26.8
Eco 31.3 28.9
Standard 38.3 36.7
Movie 36 33.2

Sunday, 10 February 2013

Managed vs Unmanaged solution dependencies in MS Dynamics CRM 2011

A few days back I was trying to merge a couple of solutions together and when I tried to import the second solution, I was greeted with with this error:

It turns out that dependencies need to be satisfied by components that are part of the same type of solution, i.e. managed components cannot depend on unmanaged components.

I know I had read about it somewhere, but I had completely forgotten about it.

Thursday, 7 February 2013

Setting up a VPN server (PPTP) on Amazon Linux AMI

I finally decided to give Amazon EC2 a go a few days ago, thinking to myself that it would be a nice way of keeping my Linux skills afresh, long term followers of this blog (hello mum), would have noticed the recent dearth of Linux posts in this blog.

Amazon Linux AMI is based on RHEL, so the instructions below work for RHEL 6 ( I didn't realize that RHEL images were not included in the free tier, D'Oh), so without further ado this what you need to do:

I'm assuming that you have already launched an AMI instance.
  1. Get the PPTP deamon from sourceforge and Install it
  2. wget
    sudo yum -y install pptpd-1.3.4-2.el6.x86_64.rpm
  3. Set Server IP address and Client IP Address ranges by editing /etc/pptpd.conf
  4. localip
  5. Add allowed users by editing /etc/ppp/chap-secrets
  6. myuser pptpd myuserpassword *
  7. Add DNS servers (I've used Google DNS servers) by editing /etc/ppp/options.pptpd
  8. ms-dns
  9. Set up port forwarding (to allow connections to escape the server)
  10. sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    sudo service iptables save
  11. Allow system to forward packets. Edit /etc/sysctl.conf
  12. net.ipv4.ip_forward=1 
  13. Start VPN service
  14. sudo service pptpd start
  15. Set VPN service to start with the system.
  16. sudo chkconfig pptpd on
The firewall configuration was completely empty, relying on the Amazon EC2 firewall instead. If you don't really trust Amazon, it's probably worthwhile setting up appropriate rules to drop all traffic apart from port 22 (SSH) and 1723 (PPTD). I've simply decided to use the amazon firewall or security groups as amazon calls it.

Do note that protocol ID 47 also needs to be open, probably something like this is needed (not tested)
iptables -A INPUT -p 47 -j ACCEPT
The main problem with using amazon is that the IP address changes with every reboot, which means that you either look it up every time or you use some sort of DDNS.

There are free DDNS services but I've not used them and obviously looking it up is a bit of pain, I'm going to investigate whether this information can be obtained programmatically from the console and the VPN connection edited programmatically, so watch this space.

Alternatively, an elastic IP address could be used, which is free while the instance is powered on.

Monday, 4 February 2013

Multiple installations of Joomla in single server.

This has been asked multiple times, How do I host multiple installs of Joomla in a single server? in this post, actually only once, but I thought I would answer it properly here.

I am going to assume that you have followed my guide to install Joomla, here, which means that you already have a working instance of Joomla.

Note that while the original post was for CentOS 6.x, it also works fine for Amazon Linux AMI as long as you remember to sudo most commands and indeed RHEL 6. I've left sudo out of the commands to keep it more general.
  1. Extract downloaded package again:
  2. Create New Joomla directory
  3. mkdir /var/www/html/secondjoomla
  4. Move all files to home web directory:
    mv /joomla/* /var/www/html/secondjoomla
  5. Create second Joomla User (note that these are two separate commands):
    mysql -u root -p
    CREATE USER 'SecondJoomlaUser'@'localhost' IDENTIFIED BY 'mypass';
  6. Create second Joomla Database:
    mysqladmin -u root -p create SecondJoomla
  7. Provide appropriate privileges to the second Joomla User user  (note that these are two separate commands):
    mysql -u root -p
                    TO SecondJoomlaUser@localhost IDENTIFIED BY 'mypass';
            'SecondJoomla' is the name of your database
            'SecondJoomlaUser@localhost' is the userid of your webserver MySQL account
            'mypass' is the password required to log in as the MySQL user
  8. Apply privileges and exit:
    flush privileges; \q
  9. Create empty configuration.php file and set permissions:
    touch /var/www/html/secondjoomla/configuration.php
    chmod 666 /var/www/html/secondjoomla/configuration.php
  10. Set up Virtual Hosts in Apache. You will need to edit /etc/httpd/conf/httpd.conf. You can find a sample below. Ensure that the first directive has been uncommented.
  11. NameVirtualHost *:80 
    <VirtualHost *:80>
     DocumentRoot /var/www/html
     ErrorLog logs/
     CustomLog logs/ common
    <VirtualHost *:80>
     DocumentRoot /var/www/html/secondjoomla
     ErrorLog logs/
     CustomLog logs/ common
  12. Ensure config syntax is ok and restart Apache.
  13. apachectl -S
    apachectl restart
  14. You can now start the Second Joomla install proper by navigating to:
  15. On step 4 use the following settings:
  16. Ensure that you remove the installation directory
    rm -rf /var/www/html/secondjoomla/installation/
  17. You can now go and administer your second site or view the sample sites if you chose to install the sample data. Enjoy!
Please note that in order to test this setup (two Joomla websites), the machine browsing to the joomla websites must be able to resolve and, or whatever domain names are being used.
Ordinarily this is done by a DNS server, but the above entries can be added to the hosts file. It is imperative that all devices accessing the website are able to resolve those names, otherwise the first website (example1) will be displayed.

Friday, 1 February 2013

Somebody needs to improve their knowledge of regular expressions (case sensitivity)

UK post codes are quite hard to pin down. This is the official regex, from here:

(GIR 0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) [0-9][A-Z-[CIKMOV]]{2})

There is no excuse for making them Upper Case only though (I know the regex above is case sensitive), just add (?i) to the start of the regex.