Thursday, April 28, 2011

SSAS Error in processing a dimension : HYT00 , Query Timeout Expired

A dimension that was working fine on SQL server analysis server started to give the following error :
OLE DB Error: OLE DB or ODBC error: Query timeout expired; HYT00.


After doing the following the dimension processes just fine now. There is a timeout for external data queries defined in the sql server analysis services properties. You can get to it from ssms - right click the analysis server as shown and select properties:



And then select "Show Advanced (All) Properties" as shown:


Edit the current value of "ExternalCommandTimeout" as shown:

And click Ok.
You can open the Properties / Show Advanced view again to verify that the settings took:

Enjoy!

Wednesday, April 27, 2011

Using XManager to setup a terminal connection to a solaris machine

Xmanager is an awesome piece of software. Here's how to set it up to connect to a solaris machine with Display variable automatically configured so you can use gedit etc.

  • Open up xbrowser 
  • create a new xstart session 
  • fill it as as follows (setting the execution command as xterm solaris):

Enjoy!

Tuesday, April 26, 2011

A lovely feature of Silverlight 5 beta

Just saw this on Mike Taulty's blog. The ability to create your own custom markup extensions. The thing I like the most about this is being able to abreviate the common binding syntax that I seem to be using a lot:

Definition:

public class StandardTwoWayBindingExtension : Binding  
{  
  public StandardTwoWayBindingExtension()  
  {  
    this.ValidatesOnNotifyDataErrors = true;  
    this.NotifyOnValidationError = true;  
    this.Mode = BindingMode.TwoWay;        
  }  
}  


Usage:

<Grid  
  x:Name="LayoutRoot">  
  <Grid.DataContext>  
    <local:DataObject />  
  </Grid.DataContext>  
  <TextBox  
    Text="{local:StandardTwoWayBinding Path=SomeProperty}" />  
</Grid> 


Head on over to the post to see it in action.
Enjoy!

Saturday, April 23, 2011

Things to ask when you get a dedicated hosted server

Here is a list of things that I feel you should ask your dedicated windows server hosting company:

  • Windows Update : should be active 
  • Uptime : obvious
  • Backup : do they have RAID 
  • Specs : Processor / RAM / HDD Space | RPM 
  • Remote Desktop : A GUI helps 
  • Admin Rights : you just might need them
  • Latency : Between you and the server and between the server and the customer
Enjoy!

Friday, April 22, 2011

What great .NET developers ought to know

This is a very old post by scott hanselman : http://www.hanselman.com/blog/WhatGreatNETDevelopersOughtToKnowMoreNETInterviewQuestions.aspx
I was just googling .NET interview questions and it came up.

While searching for some of the answers this came up:
http://jingyeluo.blogspot.com/2005/06/what-great-net-developers-ought-to_03.html

A good read :) Even if you know the answers it is nice to know another developer's opinion.

PS: I did not know about .NET shadowing (actually c# uses the new keyword for it)!  Makes me think I should go through the C# keywords for VS2010 again :) http://msdn.microsoft.com/en-us/library/x53a06bb.aspx

Thursday, April 21, 2011

Singleton in C#

Just went though the implementing singleton in c#.
http://msdn.microsoft.com/en-us/library/ff650316.aspx
In short the ideal code :


using System;

public sealed class Singleton
{
   private static volatile Singleton instance;
   private static object syncRoot = new Object();

   private Singleton() {}

   public static Singleton Instance
   {
      get 
      {
         if (instance == null) 
         {
            lock (syncRoot) 
            {
               if (instance == null) 
                  instance = new Singleton();
            }
         }

         return instance;
      }
   }
}


Things of note:

  • The instance is marked volatile. If its multithreaded it might as well be volatile.
  • This will not work in JAVA since double checking is broken problem in Java :
    http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
  • C# ensures that static variables are initialized BEFORE you can use a property. 
  • Instance is created only when it is requested. This is lazy initialization. 
  • Because of lazy initialization we need another reference type (we use an object) to carry out the lock.
  • We really don't want anybody inheriting our data and messing with it ... so sealed. 


Enjoy!

Wednesday, April 20, 2011

My biggest contribution to Ericsson Pakistan


Recursive Function Design 101

Everyone has his approach to how to start writing a function. For a recursive function as soon as you identify that the problem can be simplified by recursion, heres how you should structure your code :

  • First write for the simplest case and return. This would be the boundary condition on the function call. e.g. for factorial write the code for case when input == 0 || input == 1  
  • Build up from there. 
Basically if you put down the simplest case first and test it so you are sure it is reliable writing the rest of the recursive function becomes super easy. 

Enjoy!

Friday, April 15, 2011

Video Tutorials of Prism and Silverlight

It seems that mike taulty is really interested in the same things that I am ... except sooner :) I used his video tutorials on WCF to learn the tech two years ago and now I just found out that he has a prism + silverlight video series up on channel 9. Here are the links:


·        Part 7: Commands 


      One thing I would like to mention on the subject of modules is that there are actually three major advantages of not being binary linked to each other. One is the obvious reusability. Second is the commonly mentioned testability. And the third not commonly mentioned is the fact that you can have separate teams working on the modules, testing them, and putting them together in the shell. This is possible because the modules are not binary linked to each others functioning implementations.

For a more descriptive / less detailed approach check out this video series:


Screen cast 1 of 4 - Creating a shell and modules
Screen cast 2 of 4 - Visual Composition
Screen cast 3 of 4 - Implementing views and services
Screen cast 4 of 4 - Decoupled Communication

      There is a cool mention of Regions:TabControlRegionAdapter.ItemContainerStyle in video 3 so be sure to check it out. Also nicely mentioned in video 4 is why the subscribe delegate for EventAggregator needs to be public ( it is to allow the View model to be garbage collected. If the delegate is public you can keep a weak reference to it )


Enjoy! 

Monday, April 11, 2011

Reference Types inside a Value Type

Everybody should be clear that it is a bad idea. This is because we no longer get the "Copy Allocates new memory and therefore new values that are completely separate from the original" principal. 

However if you use an immutable reference type you can get away with it. But you should never do so simply because there really isn't any benefit from it and you might at sometime forget that it is actually a struct you are dealing with and mistakenly add a mutable reference type. 

Here is some weird sample code to show what happens when you add a reference type to a value type: 

public class MutableClass
    {
        public int SomeProperty { get; set; }
        public override string ToString()
        {
            return SomeProperty.ToString();
        }
    }
    public struct BadStruct
    {
        public string SomeProperty { get; set; }
    }
    public struct BadBadStruct
    {
        public MutableClass SomeProperty { get; set; }
    }


    class Program
    {
        static void Main(string[] args)
        {
            //BAD STRUCT
            var badStruct = new BadStruct();
            badStruct.SomeProperty = "10";
            var badStructCopy = badStruct;
            //This will actually assign a new string because they are immutable.
            badStructCopy.SomeProperty = "20"; 
            Console.WriteLine("ORIGINAL:" + badStruct.SomeProperty) ; 
            Console.WriteLine("COPY:" + badStructCopy.SomeProperty) ; 

            //BAD BAD STRUCT
            var badBadStruct = new BadBadStruct();
            badBadStruct.SomeProperty = new MutableClass() { SomeProperty = 10 };
            var badBadStructCopy = badBadStruct;
            //This will acually modify the original. 
            //Therefore the BadBadStruct no longer behaves like a value type 
            badBadStructCopy.SomeProperty.SomeProperty = 20;
            Console.WriteLine("ORIGINAL: "+badBadStruct.SomeProperty.ToString());
            Console.WriteLine("COPY: " + badBadStructCopy.SomeProperty.ToString());

        }
    }

And the output : 


Sunday, April 10, 2011

Visual Studio LightSwitch Videos on Channel 9

You can check out LightSwitch videos at channel 9 from intro to advanced customizations :

http://channel9.msdn.com/blogs/dan/jay-schmelzer-introducing-visual-studio-lightswitch
http://channel9.msdn.com/blogs/funkyonex/visual-studio-lightswitch-beyond-the-basics

It is built on silverlight, mvvm, ria and basically code generation awesomeness. 

Rx (Reactive Extensions) Video Tutorials

Rx is meant to provide simpler asynchronous application design. These are the video tutorials I could find on Channel 9. I am more interested in the silverlight / WPF usage of this framework:

Writing your first Rx Application : a taste of Rx
DevCamp 2010 Keynote - Rx: Curing your asynchronous programming blues : the best intro
Kim Hamilton and Wes Dyer: Inside .NET Rx and IObservable/IObserver in the BCL (VS 2010)
Wes Dyer and Jeffrey Van Gogh: Rx Virtual Time

Rx Update :  Async Support


From Silverlight.net: 
Asynchronous programming with Rx : by jesse liberty (nice to get a taste of it)


Incomplete:
Reactive Extensions API in depth: intro

Sunday, April 3, 2011

Expression design: Pen Tool

There are great video tutorials provided by microsoft over here:
http://expression.microsoft.com/en-us/cc197142.aspx

Here are some of my footnotes:

Pen Tool
From video:
http://expression.microsoft.com/en-us/cc188984.aspx

Pen tool (P)
Select fill and stroke
Start by clicking at the point of origin.
Click and hold to make two curve handles at the next point.
Click the last point added to delete the forward handle (a point without a forward handle is called a cusp point).
Press alt while on a handle to edit the two handles separately.
Click while on an anchor point to delete an anchor point (or use the - key to activate the tool).
Click while on a line to add a new anchor point (or use the + key to active the tool)
Shift+C  to use the convert anchor point tool which will allow you to add handles to existing anchor points


Pen is the heart of expression design. Learn to use it well. 

Friday, April 1, 2011

How WCF will deal will dynamic

Yes. WCF can serialize dynamic as long as the underlying type passed as dynamic supports serialization.

This is soo cool.

So I made a test WCF project will the following Operation Contract in the Service Contract :

[OperationContract]
        dynamic AcceptDynamic(dynamic cool);
And the following service implementation: 
public dynamic AcceptDynamic(dynamic cool)
        {
            if (cool is string)
                return cool + " DAMN COOL";
            if (cool is int)
                return cool + 10;
            return "";
        }

After I import this at the client I get the following method signature: 
public object AcceptDynamic(object cool) {
            return base.Channel.AcceptDynamic(cool);
        }

Notice the dynamic has been changed to object. Means I pass in anything I want. It get stored in object. Serialized to server. Deserialized into dynamic. And used as necessary. In retrospect its obvious. But the repercussions for potentional dynamic service design are enormous. More on that latter (basically it could have been something that inherits from DynamicObject and implements INotifyPropertyChanged/IErrorInfo and been a kickass dynamic data model). 

Sample client:

static void Main(string[] args)
        {
            ServiceReference1.Service1Client svc = new ServiceReference1.Service1Client();
            Console.WriteLine(svc.AcceptDynamic("asdf"));
            Console.WriteLine(svc.AcceptDynamic(10));
        }

And the output: 
Enjoy!