How to change Caps Lock key to Shift key in Microsoft Windows 7 or disable it

If you want to change the Caps Lock key to a Shift key, use the following registry changes:

 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,2a,00,3a,00,00,00,00,00

 

If you want to completely disable the Caps Lock key, use the following registry changes:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=-

 

After applying the registry change, reboot you’re system for the changes to take effect.

 

Found at : http://www.howtogeek.com/howto/windows-vista/disable-caps-lock-key-in-windows-vista/

Log4net performance test on [Root > Level], [Threshold], [LevelRangeFilter] and [LevelMatchFilter]

In many cases you want to allow only ERROR logging in production for performance reasons.

I did a little experiment on log4net performance, based on different configurations in the App.config, to try and find out what the best settings are for only allowing ERROR logging in production.

 

First some explanation on the log4net settings used

1. The [Root > Level] is used to only allow logging based on the given value and above for all appenders.

2. The threshold setting is used to allow logging for the given value and above for a specific appender.

3. LevelMatchFiler is used to allow only logging for a specified level for a specific appender.

4. LevelRangeFilter is used to allow only logging between the given values for a specific appender.

 

The App.config with all settings

This App.config shows all settings used, it is not a working App.config.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<!-- Allow only ERROR logging for this adapter -->
<threshold value="ERROR"/>
<!-- Allow only ERROR logging for this adapter -->
<filter type="log4net.Filter.LevelMatchFilter">
<acceptOnMatch value="true" />
<levelToMatch  value="ERROR" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
<!-- Allow only DEBUG, INFO, WARN and ERROR logging for this adapter -->
<filter type="log4net.Filter.LevelRangeFilter">
<acceptOnMatch value="true"/>
<levelMin value="DEBUG"/>
<levelMax value="ERROR"/>
</filter>
<file value="Log.txt"/>
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="1"/>
<maximumFileSize value="100MB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level %type.%method - %message%newline"/>
</layout>
</appender>
<appender name="ADONetAppender" type="log4net.Appender.ADONetAppender">
<!-- Allow only ERROR logging for this adapter -->
<threshold value="ERROR"/>
<!-- Allow only ERROR logging for this adapter -->
<filter type="log4net.Filter.LevelMatchFilter">
<acceptOnMatch value="true" />
<levelToMatch  value="ERROR" />
</filter>
<filter type="log4net.Filter.DenyAllFilter" />
<!-- Allow only DEBUG, INFO, WARN and ERROR logging for this adapter -->
<filter type="log4net.Filter.LevelRangeFilter">
<acceptOnMatch value="true"/>
<levelMin value="DEBUG"/>
<levelMax value="ERROR"/>
</filter>
<bufferSize value="1"/>
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)"/>
<connectionString value="Data Source=myserver.dev.nl\dev2008;Initial Catalog=MyDatabase;Integrated Security=SSPI"/>
<parameter>
<parameterName value="@log_date"/>
<dbType value="DateTime"/>
<layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}"/>
</parameter>
<parameter>
<parameterName value="@thread"/>
<dbType value="String"/>
<size value="255"/>
<layout type="log4net.Layout.PatternLayout" value="%thread"/>
</parameter>
<parameter>
<parameterName value="@log_level"/>
<dbType value="String"/>
<size value="50"/>
<layout type="log4net.Layout.PatternLayout" value="%level"/>
</parameter>
<parameter>
<parameterName value="@logger"/>
<dbType value="String"/>
<size value="255"/>
<layout type="log4net.Layout.PatternLayout" value="%type.%method"/>
</parameter>
<parameter>
<parameterName value="@message"/>
<dbType value="String"/>
<size value="4000"/>
<layout type="log4net.Layout.PatternLayout" value="%message"/>
</parameter>
</appender>
<root>
<level value="ERROR" />
<appender-ref ref="RollingLogFileAppender" />
<appender-ref ref="ADONetAppender" />
</root>
</log4net>
</configuration>

 

 

The code

public void TestLog4NetPerformance()
{
// Configure Log4Net based on de App.config settings.
XmlConfigurator.Configure();
// Create a Log4Net logger object.
ILog _logger = LogManager.GetLogger("Testing Log4Net on Performance");
// Capture the start date and time
DateTime startDateTime = DateTime.Now;
// Set max for logging callss.
int max = 100000000;
for (int i = 0; i < max; i++)
{
_logger.Debug("This is a log4net debug log entry.");
}
// Capture the end date and time
DateTime endDateTime = DateTime.Now;
// Calculate the time spent on logging.
TimeSpan duration = endDateTime - startDateTime;
// Output to user
Console.WriteLine(string.Format("Total duration in seconds: [{0}s]", (int)duration.TotalSeconds));
}

The Results

1. [Root > Level value=”ERROR”] – 100.000.000 – Total duration in seconds: [17s]

2. [threshold value=”ERROR”] – 100.000.000 – Total duration in seconds: [656s]

3. [LevelMatchFilter levelToMatch=”ERROR”] – 100.000.000 – Total duration in seconds: [716s]

4. [LevelRangeFilter levelMin=”ERROR” levelMax = ERROR] – 100.000.000 – Total duration in seconds: [715s]

 

When a setting was used, all other settings where removed from the app.config.

 

So the winner is: Root > Level!!!!!!

How to collapse / expand a specific row group in a tablix in Microsoft Reporting Services 2008 / Report Builder 3.0

Let’s say you want to show costs on a parent child hierarchy in a Microsoft SQL Server Reporting Service 2008 R2 report and you want only to expand the children of parent "John":

 

image

 

Follow the steps below, to create this report:

 

Table design

image

 

Table contents

image

 

Add new report

Start Microsoft SQL Server 2008 R2 Report Builder 3.0 > New Report > Blank Report

image

 

Add a new data source to the report

Add a data source [Right click Data Sources > Add Data Source…]

image

 

The [Add Data Source Wizard]:

image

 

Add a new dataset to the report

Add a dataset [Right click Datasets > Add Dataset…]

image

 

The [Add Dataset Wizard]:

image

 

Add a tablix to the report

Add a tablix [Click in the ribbon on Insert > Table > Table Wizard…]

image

 

The [Add Table Wizard]

image

Add Parent and Child to Row groups and Cost to Values

image

Choose [Stepped subtotals above]

image

 

image

 

Row visibility

Right click on the row header of the [Child] row > Row Visibility…

image

Show or hide based on an expression: = IIF(Fields!Parent.Value = "John", False, True)

image

 

Group visibility

Make sure this expression is forwarded to the group visibility > right click on the row header of the [Child] row > Row Group > Group Properties…

image

image

 

InitialToggleState

Select row header of the [Parent] row > Properties > InitialToggleState > <Expression…>

=IIf(Fields!Parent.Value = "John", True, False)

image

 

image

 

Run the report

image

Press tab in a Windows command line console window to loop files in a folder.

When you use cmd.exe and change directory to lets say: "C:\Windows\Microsoft.NET\Framework64\v4.0.30319" and want to loop through all the files in the folder, just press tab to forward loop all files, press shift tab to reverse the loop.

You can also start typing the first part of the filename and then press tab.

 

So if you want to find aspnet_regiis.exe, you can type aspnet and the press tab to start looping the files, starting with first file that starts with "aspnet" in this case: Aspnet.config.

 

Yes, yes, I know this is probably the oldest shortcut in the DOS / Windows book, but I keep on forgetting it Winking smile

How to set the connectionstring at runtime of a dbcontext in Entity Framework 4.2

If you want to set the connectionstring for a dbcontext, when using EntityFramework 4.2, just create a partial class for the specific dbcontext and add a constructor that call’s de dbcontext constructor with connectionstring. Now you can instantiate MyDatabaseEntities with a connectionstring.

 

public partial class MyDatabaseEntities
{
public MyDatabaseEntities(string connection)
: base(connection)
{
}
}

The generated partial class looks something like:

 

public partial class MyDatabaseEntities : DbContext
{
public MyDatabaseEntities()
: base("name=MyDatabaseEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public DbSet<Products> Products { get; set; }
}

Create table in T-SQL with named primary key and foreign key

Just a simple example of creating a table by using T-SQL:

if not exists(select 1 from sys.objects where object_id = object_id(‘Product’))

begin

  create table [dbo].[Product]

  (

    [Id] [int] not null identity (1, 1),

    [Code] [nvarchar] (max) not null,

    [ManufacturerId] [int] not null,

    constraint [PK_Product_Id] primary key (Id),

    constraint [FK_Manufacturer_ManufacturerId] foreign key ([ManufacturerId]) references [dbo].[Manufacturer] ([Id])

  ) on [primary]

end

Solving: CSC: Assembly generation — Referenced assembly ‘mscorlib.dll’ targets a different processor in MSBUILD

I was getting the warning / error in the MSBUILD output

CSC: Assembly generation — Referenced assembly ‘mscorlib.dll’ targets a different processor in MSBUILD

 

After setting the [MSBuild Platform] to [X86] in the build definition, the warnings / errors were resolved.

 

image