Skip to content

Instantly share code, notes, and snippets.

View dealproc's full-sized avatar

Richard Bennett dealproc

View GitHub Profile
/// <reference path="./jquery-1.10.2-vsdoc.js" />
/// <reference path="./jquery-ui-1.10.3.js" />
/// <reference path="./jquery.jqGrid.src.js" />
window.jqGridSettings = {};
function bindConfiguration(key, options) {
var p = window.jqGridSettings[options.idPrefix];
@dealproc
dealproc / jquery.dataTables.bootstrapInit.js
Created September 24, 2013 01:35
jQuery Data Tables - Bootstrap UI with OData Parsing for reading/loading Data.
/* Default class modification */
$.extend($.fn.dataTableExt.oStdClasses, {
"sWrapper": "dataTables_wrapper form-inline"
});
/* API method to get paging information */
$.fn.dataTableExt.oApi.fnPagingInfo = function (oSettings) {
return {
"iStart": oSettings._iDisplayStart,
/// <reference path="../../Scripts/jquery-2.0.3.intellisense.js" />
/// <reference path="../../Scripts/jquery-2.0.3.js" />
///
define(["jquery", "knockout"],
function ($, ko) {
return function () {
var get = function (params) {
var resource = this.resource;
@dealproc
dealproc / create.html
Created October 26, 2013 00:06
Durandal.JS example for running modals.
<div class="messageBox wideMessageBox">
<div class="modal-header">
<h3 data-bind="text: title"></h3>
</div>
<div class="modal-body">
<!-- Whatever you want here to display in your modal -->
</div>
<div class="modal-footer">
<!-- only because i have save/cancel bindings on my module above. -->
<button class="btn btn-default" data-bind="click: cancel">Cancel</button>
@dealproc
dealproc / DateTimeOffsetConvention.cs
Last active March 1, 2016 14:05
Uses DateTimeOffset to Timestamp with Timezone in Postgres from Npgsql
namespace Your.Namespace.Here {
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.AcceptanceCriteria;
using FluentNHibernate.Conventions.Inspections;
using FluentNHibernate.Conventions.Instances;
using System;
class DateTimeOffsetConvention : IPropertyConvention, IPropertyConventionAcceptance {
public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria) {
criteria.Expect(x => x.Type == typeof(DateTimeOffset));
@dealproc
dealproc / gist:5dfb780eb8f9dd109924
Created June 25, 2014 19:10
Resolve registered types that implement a given generic interface for Autofac
var connectionTypes = _LifetimeScope
.ComponentRegistry
.Registrations
.Where(reg =>
reg.Activator
.LimitType
.GetInterfaces()
.Any(iface =>
iface.IsGenericType && iface.GetGenericTypeDefinition() == typeof(IConnectionEditorViewModel<>)
)
@dealproc
dealproc / AuthorizationProvider.js
Created July 17, 2014 15:56
The way we sent the headers to the api backend from DurandalJS
define(['amplify'], function () {
return {
BeginAuthorization: function () {
var authorizationUrl = SystemState.AuthorizationUrl,
client_id = SystemState.ClientID,
scope = SystemState.AuthScope,
response_type = "token",
redirect_uri = SystemState.AuthRedirectURI,
@dealproc
dealproc / DataGridAutomaticEditingBehavior.cs
Created July 18, 2014 15:38
WPF Datagrid - Edit on focus
namespace {Your.Namespace.Here}.Behaviors {
using System.Windows.Controls;
using System.Windows.Interactivity;
// Pulled from: http://codermonkey65.blogspot.com/2012/12/making-wpf-datagrid-keyboard-friendly.html
public class DataGridAutomaticEditingBehavior : Behavior<DataGrid> {
protected override void OnAttached() {
AssociatedObject.GotFocus += AssociatedObject_GotFocus;
base.OnAttached();
}
@dealproc
dealproc / BaseSyncTask.cs
Last active August 29, 2015 14:04
Healing SignalR Connection
namespace {YourNamespace}.ServiceBus.Tasks {
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
public abstract class BaseSyncTask : ISyncTask {
protected NLog.Logger Log = NLog.LogManager.GetCurrentClassLogger();
public abstract int Priority { get; }
@dealproc
dealproc / ParameterModelsModelBinder.cs
Last active August 29, 2015 14:04
Binding to a generic type through reflection.
namespace Adapt.SSRV.Web.Models {
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Web.Http.Controllers;
using System.Web.Http.ModelBinding;
public class ParameterModelsModelBinder : IModelBinder {
public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext) {
if (bindingContext.ModelType != typeof(ParameterModels)) {
return false;