Handy Hints

Enable CORS on windows

Often i recognize that the PUT and DELETE http methods are not allowed and in these days of REST Apis this can be a problem. Often is enough to enable the support for CORS (Cross-origin resource sharing).

To do this you could add to the Global.asax the following Application_BeginRequest implementation.

public class WebApiApplication : System.Web.HttpApplication
{
    protected void Application_BeginRequest(object sender, EventArgs e)
    {
        var context = HttpContext.Current;
        var response = context.Response;

        // enable CORS
        response.AddHeader(
            "Access-Control-Allow-Origin", 
            "*");
            
        response.AddHeader(
            "X-Frame-Options", 
            "ALLOW-FROM *");

        if (context.Request.HttpMethod == "OPTIONS")
        {
            response.AddHeader(
                "Access-Control-Allow-Methods", 
                "GET, POST, PUT, DELETE");
            response.AddHeader(
                "Access-Control-Allow-Headers", 
                "Content-Type, Accept");
            response.AddHeader(
                "Access-Control-Max-Age", 
                "1728000");
            response.End();
            return;
        }
        
        //Here goes the other initializations
    }
}

Disable Java Update

[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Update\Policy] 
    "EnableAutoUpdateCheck"=dword:00000000

Another approach would be to delete the following key blocking the scheduler for Java updates

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\
 CurrentVersion\Run\SunJavaUpdateSched

Reset File Associations Windows 7/8

Restart Ms Download Manager

Simply run...

    %windir%\Downloaded Program Files\TransferMgr.exe

Show hide tabs and spaces VS2010-VS2012

The shortcut to toggle them is

CTR+R, CTRL+W

Castle Windsor-Component is not a typed factory

Facing an exception like...

System.ArgumentException: 
    Component MyPackaged.IMyTypedFactory is not a typed factory. 
    TypedFactoryInterceptor only works with typed factories.

Probably you have to force the order of registrations. You should register the Castle TypedFactoryFacility BEFORE registering the IMyTypedFactory.

Suppose your bootstrap works like the following

    var container = new WindsorContainer();
    container.Install(FromAssembly.This());

With two installers like the following

public class MyServicesInstaller : IWindsorInstaller
{
    public void Install(IWindsorContainer container, IConfigurationStore store)
    {
        container.Register(
            Component.For<IMyTypedFactory>()
            .ImplementedBy<MyTypedFactory>()
            .LifeStyle.Singleton);
    }
}
    
public class MyWindsorInstaller : IWindsorInstaller
{
    public void Install(IWindsorContainer container, IConfigurationStore store)
    {
        container.AddFacility<TypedFactoryFacility>();
    }
}

To ensure the correct order of initialization you should create a new Castle InstallerFactory. This will take all the types founded and will reorder them. In our specific situation the first to install will be the MyWindsorInstaller!

public class MyCustomInstallerFactory : InstallerFactory
{
    public override IEnumerable<Type> Select(IEnumerable<Type> installerTypes)
    {
        var firstInstaller = installerTypes.FirstOrDefault(it => it == typeof(MyWindsorInstaller));

        var retVal = new List<Type>();
        retVal.Add(firstInstaller);
        retVal.AddRange(installerTypes
            .Where(it => 
                typeof(IWindsorInstaller).IsAssignableFrom(it) &&
                !retVal.Contains(it)
                ));

        return retVal;
    }
}

The bootstrapper would be then changed to:

    var myInstallerFactory = new MyCustomInstallerFactory();
    var container = new WindsorContainer();
    container.Install(FromAssembly.This(myInstallerFactory));

SQLServer Take Db Offline

This means force disconnection and take offline

ALTER DATABASE MyDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE MyDB SET OFFLINE WITH ROLLBACK IMMEDIATE

Download Metro Apps

New Way To Download Metro App In Win 8 And Install For Each computer

Prerequisites

Installation

Download

Sideload Apps in windows 8

Procedure

Windows 8 needs to be prepared before you can sideload apps. The first thing you need to do is enable "Allow all trusted applications to install" in the Group Policy. Keep in mind that the Group Policy is only available in Windows 8 Pro and Enterprise, and not Windows 8 or Windows 8 RT. Users on those systems can change a Registry setting instead.

In case of errors

After entering Windows Store Just click on the Repair button Then close the Windows Store Try running the game or program

Installing Sqitch on windows

If there are unknown errors, like "Verify script 'my script.sql' failed" probably you would need to add the binaries directory for your database to the machine path.


Last modified on: January 11, 2017