Monday, November 22, 2010

Google TTS engine

Now you can make Google to speak

http://translate.google.com/translate_tts?tl=hy&q=%D5%A2%D5%A1%D6%80%D6%87%20%D5%A1%D5%BA%D5%A5

tl=<language>
q=<text to talk>


Download

Wednesday, February 3, 2010

Saving changes is not permitted (SQL Server 2008)

On clean installed SQL Server 2008 instance if you change the Table you may see this message:


This dialog states: "Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created."

This can be fixed by changing settings for SQL Server Management Studio.
Open: Tools > Options


Do uncheck "Prevent saving changes that require table re-creation".
Once you do that save will work.

I think Microsoft should made it unchecked by default.

Wednesday, January 6, 2010

Implementation of thread safe Singleton in C#

Lazy initialization

public sealed class Singleton
{
    static Singleton instance=null;
    static readonly object instancelock = new object();

    Singleton()
    {
    }

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

Thread-safe without locks
public sealed class Singleton
{
    static readonly Singleton instance=new Singleton();

    static Singleton()
    {
    }

    Singleton()
    {
    }

    public static Singleton Instance
    {
        get
        {
            return instance;
        }
    }
}

Wednesday, December 9, 2009

How to add .NET control to a Win32 window

using System.Runtime.InteropServices;

[DllImport("user32.dll")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

Then when you want attach control on window call
SetParent(control.Handle, parentHWND);
control.BringToFront();