Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Exova.LIMS.Contract.Entities">
<class name="Client, Exova.LIMS.Contract" writeTable="" replicationTable="[Sales].[Client]" table="[Sales].[Client_View]">
</class>
</hibernate-mapping>
@kstenson
kstenson / gist:796724
Created January 26, 2011 14:03
extjs grid override getCellEditor
var store = new Ext.data.SimpleStore({
data: [
['Value 1', 'text', 'text'],
['Value 2', 'number', 1],
['Value 3', 'date', new Date()]
],
fields: ['name', 'type', 'value']
});
var comboStore = new Ext.data.SimpleStore({
id: 0,
@kstenson
kstenson / gist:3040235
Created July 3, 2012 14:55
Log4Net interceptor
public class LoggingInterceptor: IInterceptor
{
private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public void Intercept(IInvocation invocation)
{
try
{
StringBuilder sb = null;
@kstenson
kstenson / gist:3040253
Created July 3, 2012 14:58
Using modules with autofac
builder.RegisterModule(new DataModule()
{
AssemblyMapper = typeof(AcquireConfig).Assembly,
BuildSchema = true,
ConnectionString = Properties.Settings.Default.DataAcquisitionStoreConnection,
Web = false
});
public class DataModule : Module
{
@kstenson
kstenson / gist:3047511
Created July 4, 2012 14:03
Autofac intercepter setup
//this class registers the two interceptors in the container with a name for each
public class InterceptorsModule: Module
{
protected override void Load(ContainerBuilder builder)
{
builder.Register(x => new LoggingInterceptor()).Named<IInterceptor>("Logger");
builder.Register(x => new TimingInterceptor()).Named<IInterceptor>("Timing");
}
}
@kstenson
kstenson / HealthMonitor
Created July 26, 2012 09:17
Clients is null
namespace MC.Bureau.Adaptation.Service
{
public class HealthMonitor :IWantToRunAtStartup
{
private string url = "http://localhost:8081/";
private Server _server;
private HealthMonitorHub _healthMonitor;
public ITransport Transport { get; set; }
@kstenson
kstenson / delete.sql
Created September 3, 2012 15:15
clear all tables in db
-- disable all constraints
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
-- delete data in all tables
EXEC sp_MSForEachTable "DELETE FROM ?"
-- enable all constraints
exec sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
@kstenson
kstenson / gist:6216952
Created August 13, 2013 01:16
Log all events fired in a page on the console
$(document).on("click mousedown mouseup focus blur keydown change",function(e){
console.log(e);
});
public class MvcApplication : NinjectHttpApplication
{
protected void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new
@kstenson
kstenson / ObjectDiff.cs
Last active August 29, 2015 14:05
A Naive Object diff extension method
public static class ObjectExtensions
{
public static IEnumerable<Change> Diff<T>(this T obj1, T obj2)
{
PropertyInfo[] properties = typeof(T).GetProperties();
List<Change> changes = new List<Change>();
foreach (PropertyInfo pi in properties)
{
object value1 = typeof(T).GetProperty(pi.Name).GetValue(obj1, null);