Skip to content

Instantly share code, notes, and snippets.

View pradeepn's full-sized avatar

Pradeep Nagendiran pradeepn

  • Chennai, IN
View GitHub Profile
@pradeepn
pradeepn / Specification.cs
Created September 25, 2018 20:27
LINQ Specification Pattern
using System;
using System.Linq;
using System.Linq.Expressions;
namespace Logic.Movies
{
internal sealed class IdentitySpecification<T> : Specification<T>
{
public override Expression<Func<T, bool>> ToExpression()
{
@pradeepn
pradeepn / index.html
Last active September 16, 2018 18:00
HTML5 Bootstrap4 Boilerplate Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
@pradeepn
pradeepn / NgRouteRessolveCss.js
Last active March 9, 2017 09:05
Inject CSS in ngroute resolve method to lazy load css
// Routing setup
.config(function ($routeProvider) {
$routeProvider
.when('/home', {
controller: 'homeCtrl',
templateUrl: 'home.tpl.html'
}).when('/users', {
controller: 'usersCtrl',
controllerAs: 'vm',
templateUrl: 'users.tpl.html',
@pradeepn
pradeepn / ngbootstrap.js
Created March 8, 2017 10:47
Angular - Manual Bootstrapping
<script>
angular.module('config', []);
angular.module('myApp', ['config']);
window.onload = function(){
// get injector object
var initInjector = angular.injector(['ng']);
// extract necessary angular services
var $http = initInjector.get('$http');
var $timeout = initInjector.get('$timeout');
@pradeepn
pradeepn / AsyncMediatorPipeline.cs
Created January 3, 2017 11:05
AsyncMediatorPipeline and Autofac Registration
public class AsyncMediatorPipeline<TRequest, TResponse> : IAsyncRequestHandler<TRequest, TResponse> where TRequest : IAsyncRequest<TResponse>
{
private readonly IAsyncRequestHandler<TRequest, TResponse> inner;
private readonly IAsyncPreRequestHandler<TRequest>[] preRequestHandlers;
private readonly IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers;
public AsyncMediatorPipeline(IAsyncRequestHandler<TRequest, TResponse> inner, IAsyncPreRequestHandler<TRequest>[] preRequestHandlers, IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers)
{
this.inner = inner;
@pradeepn
pradeepn / gist:639bfe6f690956998a0140ecb33027e9
Created January 3, 2017 10:51
MediatR MediatorPipeline
public class MediatRInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store) {
container.Register(Classes.FromAssemblyContaining<IMediator>().Pick().WithServiceAllInterfaces());
container.Kernel.AddHandlersFilter(new ContravariantFilter());
container.Register(Classes.FromThisAssembly().BasedOn(typeof (IRequestHandler<,>)).WithService.AllInterfaces().LifestyleTransient());
container.Register(Classes.FromThisAssembly().BasedOn(typeof (IPreRequestHandler<>)).WithService.AllInterfaces().LifestyleTransient());
container.Register(Classes.FromThisAssembly().BasedOn(typeof (IPostRequestHandler<,>)).WithService.AllInterfaces().LifestyleTransient());
container.Register(Classes.FromThisAssembly().BasedOn(typeof (INotificationHandler<>)).WithService.AllInterfaces().LifestyleTransient());
@pradeepn
pradeepn / AngularSignalRHub.js
Created December 23, 2016 14:56
Angular Factory For SignalR Hubs
'use strict';
app.factory('signalRHubProxy', ['$rootScope', 'signalRServer',
function ($rootScope, signalRServer) {
function signalRHubProxyFactory(serverUrl, hubName, startOptions) {
var connection = $.hubConnection(signalRServer);
var proxy = connection.createHubProxy(hubName);
connection.start(startOptions).done(function () { });
return {
@pradeepn
pradeepn / CustomPrinciple.cs
Created December 21, 2016 11:58
IPrinciple Implementation
//Create the interface
interface ICustomPrincipal : IPrincipal
{
int Id { get; set; }
string FirstName { get; set; }
string LastName { get; set; }
}
//CustomPrincipal
public class CustomPrincipal : ICustomPrincipal
{
@pradeepn
pradeepn / usb-credit-card-reader.js
Created December 16, 2016 07:32 — forked from stracqan/usb-credit-card-reader.js
Very simple jQuery implementation that reads card data from a USB Magnetic Strip Credit Card Reader.
/**
*
* Simple jQuery Script to parse credit card data
* that was collected via a USB Magnetic Stripe
* Credit Card Reader.
*
* To get this to work, focus your cursor (either
* programmatically or via a click, it's your choice) on an input field #credit-card-number
* and then with the card reader plugged in, swipe
* the card and it will take over from there