Skip to content

Instantly share code, notes, and snippets.


Randy Burden randyburden

View GitHub Profile
randyburden / gist:1915136
Created Feb 26, 2012
Enabling Custom Key-Press Logic for an IsReadOnly WPF RichTextBox
View gist:1915136
In your XAML:
PreviewKeyDown="MyRichTextBox_PreviewKeyDown" />
In your C# Code-behind:
randyburden / FluentTableCells.js
Created May 7, 2012
Fluent Table Cells - An easily extendible fluent interface for programmatically creating table cells in JavaScript.
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>';
randyburden / HtmlWithJQueryTemplate.html
Created Nov 15, 2012
HTML webpage template with jQuery and jQuery UI included
View HtmlWithJQueryTemplate.html
<!DOCTYPE html>
<!-- Stylesheets -->
<link type="text/css" href="" >
<style type="text/css">
body { font-family: Arial, Sans-Serif; font-size: 12pt; }
randyburden / NHibernateHelper.cs
Created Nov 28, 2012
NHibernate Helper Class
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
randyburden / NHibernate_Duplicate_Mapping_Solution.cs
Created Nov 28, 2012
NHibernate Duplicate Mapping Problem Solution
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 ).
randyburden / Add_Yourself_As_A_Sql_Server_Express_SysAdmin.txt
Created Nov 28, 2012
Add Yourself as a SQL Server Express SysAdmin
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.
randyburden / ContextStorage.cs
Last active Dec 10, 2015
Abstracts away the application's underlying storage context allowing you to simply call Get() or Store() and it will store the data in the appropriate context. It makes use of reflection too so that there is no need to reference the System.Web assembly if the application doesn't need it. For ASP.NET applications, it will store in the data in the…
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
randyburden / StopwatchHelper.cs
Last active Dec 10, 2015
Simple StopWatcher helper class to give you back a nicely formatted elapsed time.
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>
randyburden / ServiceInterceptorAttribute.cs
Last active Sep 1, 2016
Provides numerous service interceptors/hooks for a WCF service, endpoint, or method all wrapped up in a single attribute. You can derive from the ServiceInterceptorAttribute class to create your own custom interceptor attribute or use it in conjunction with a class that implements IServiceInterceptor. Update: This has graduated to it's own proje…
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>
randyburden / DoubleBracketedTokenHelper.cs
Last active Dec 13, 2015
DoubleBracketedTokenHelper - A template / token helper thingy I put together where each token is wrapped in double brackets a la handlebars.js like. This is definately half-baked and is meant to be more of a "Hey, note to self: next time your coding a template helper, remember to look at this gist to get some ideas about how to go about writing …
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
You can’t perform that action at this time.