Skip to content

Instantly share code, notes, and snippets.

View Grinderofl's full-sized avatar

Nero Sule Grinderofl

View GitHub Profile
var listener = new Listener();
var factory = new AutoContextFactory();
DependencyResolver.Bind<IContext>().To(x => factory.Context()).OnActivation(x => x.SavingChanges => (sender, args) => {
foreach (var entry in args.Context.ChangeTracker.Entries().Where(x => x.State == EntityState.Added))
listener.InsertEventListener(entry);
foreach (var entry in args.Context.ChangeTracker.Entries().Where(x => x.State == EntityState.Modified))
listener.UpdateEventListener(entry);
foreach (var entry in args.Context.ChangeTracker.Entries().Where(x => x.State == EntityState.Deleted))
@Grinderofl
Grinderofl / jquery.filtertable.js
Created March 3, 2014 15:16
jQuery extension to allow simple table filtering.
(function($) {
$.fn.filterTable = function (targets, options) {
var settings = $.extend({
className: 'hidden',
matchAll:true
}, options);
var targetTable = $(this);
$(targets).each(function () {
@Grinderofl
Grinderofl / gist:1319117
Created October 27, 2011 09:10
Recursion Limiter
public static object Limit(object o, int level)
{
if (level <= 0)
return null;
PropertyInfo[] properties = o.GetType().GetProperties();
foreach (var property in properties)
{
if (property.PropertyType.IsClass && property.CanWrite && property.PropertyType is IEnumerable)
@Grinderofl
Grinderofl / Security.cs
Created October 27, 2011 09:12
C# .NET: Security functions
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Security.cs" company="">
//
// </copyright>
// <summary>
// Class to manage security functions, such as Base64 encode/decode, SHA encryption, etc.
// Requires the Random String Generator class.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
@Grinderofl
Grinderofl / AllowAnonymousAttribute.cs
Created October 27, 2011 09:13
C# .NET: Allow Anonymous Attribute
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AllowAnonymousAttribute.cs" company="">
// Nero Sule
// </copyright>
// <summary>
// Extra attribute to allow making all methods apart from those tagged "AllowAnonymous" to be requiring authorization
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Web.Filters
@Grinderofl
Grinderofl / LogonAuthorize.cs
Created October 27, 2011 09:15
C# .NET: Logon Authorization Enforcer when no AllowAnonymousAttribute is defined.
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LogonAuthorize.cs" company="">
// Nero Sule
// </copyright>
// <summary>
// Class to enforce authorization on everything that isn't declared with AllowAnonymous Attribute.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Web.Filters
@Grinderofl
Grinderofl / HtmlHelpers.cs
Created October 27, 2011 09:18
C# .NET: ActionLink Helpers for MVC3
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="HtmlHelpers.cs" company="">
// Nero Sule
// </copyright>
// <summary>
// HTML Helpers
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Web.HtmlHelpers
@Grinderofl
Grinderofl / MultiViewController.cs
Created October 27, 2011 09:20
C# .NET: MultiViewController for MVC3
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MultiViewController.cs" company="">
// Nero Sule
// </copyright>
// <summary>
// Defines the MultiViewController type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Web.Infrastructure
@Grinderofl
Grinderofl / NinjectDependencyResolver.cs
Created October 27, 2011 09:22
C# .NET: Ninject Dependency Resolver
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NinjectDependencyResolver.cs" company="">
// Nero Sule
// </copyright>
// <summary>
// Dependency Injection
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Web.Infrastructure
@Grinderofl
Grinderofl / jquery.autohash.js
Created November 16, 2011 06:22
jQuery: Autohash extension
(function ($) {
/**
* jQuery extension to parse hash (#) in url,
* fill in values of input boxes with the specific ID's,
* and automatically update the values on address bar by
* monitoring the change/keyup events.
*/
$.fn.autohash = function () {
// This extension is chainable