Instantly share code, notes, and snippets.

View gist:1915136
In your XAML:
PreviewKeyDown="MyRichTextBox_PreviewKeyDown" />
In your C# Code-behind:
View FluentTableCells.js
* Fluent Table Cells - An easily extendible fluent interface for programmatically creating table cells in JavaScript.
* Author: Randy Burden
* Open Source Url:
* Example usage:
var row = '<tr>';
View HtmlWithJQueryTemplate.html
<!DOCTYPE html>
<!-- Stylesheets -->
<link type="text/css" href="" >
<style type="text/css">
body { font-family: Arial, Sans-Serif; font-size: 12pt; }
View NHibernateHelper.cs
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
/// <summary>
/// NHibernate Helper
/// </summary>
/// <remarks>
/// Because the SessionFactory creation is lazy-loaded, you technically never need to bootstrap NHibernate
View NHibernate_Duplicate_Mapping_Solution.cs
NHibernate now has the BeforeBindMapping event which gives you access to the object representation of the HBM XML files at runtime.
Use the BeforeBindMapping event to gain access to the object representation of the .HBM XML files.
This event allows you to modify any properties at runtime before the NHibernate Session Factory is created. This also makes the FluentNHibernate-equivalent convention unnecessary. Unfortunately there is currently no official documentation around this really great feature.
Here's a global solution to duplicate mapping problems ( Just remember that all HQL queries will now need to use Fully Qualified Type names instead of just the class names ).
View Add_Yourself_As_A_Sql_Server_Express_SysAdmin.txt
Adding Yourself as SQL Server Express SysAdmin
The help desk installs SQL Server on our developer machines under their own user accounts meaning you aren't a
sysadmin on your own SQL Server Express instance which in turn means you can't create a new database.
View ContextStorage.cs
/// <summary>
/// Provides a means of getting/storing data in the host application's
/// appropriate context.
/// </summary>
/// <remarks>
/// For ASP.NET applications, it will store in the data in the current HTTPContext.
/// For all other applications, it will store the data in the logical call context.
/// </remarks>
public static class ContextStorage
View StopwatchHelper.cs
using System;
using System.Diagnostics;
namespace PDFMerger.Helpers
public static class StopwatchHelper
/// <summary>
/// Returns the elapsed time of the stopwatch in a formatted string.
/// </summary>
View ServiceInterceptorAttribute.cs
using System;
using System.Collections.ObjectModel;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace Utilities.Wcf.Interceptors
/// <summary>
View DoubleBracketedTokenHelper.cs
public class DoubleBracketedTokenHelper
public Dictionary<string, string> TokensAndValues = new Dictionary<string, string>();
/// <summary>
/// Tokens to ignore.
/// </summary>
public List<string> IgnoredTokens = new List<string> { "{{cr}}" };
// This finds any characters in between open and closing double brackets